From fd3efc0163d9963c91e24ece43b774c70ec57640 Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Wed, 27 Nov 2013 16:05:19 +0100 Subject: Android: print a warning when using SurfaceTexture on Android 2.3. SurfaceTexture is available since Android 3.0, print a warning when camera preview or video playback is used on an older Android version. Task-number: QTBUG-35075 Change-Id: Ie04c62df99048a25e8fd971e0708157d0d32c503 Reviewed-by: Christian Stromme Reviewed-by: Lars Knoll --- .../android/src/wrappers/jsurfacetexture.cpp | 24 +++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/plugins/android/src/wrappers/jsurfacetexture.cpp b/src/plugins/android/src/wrappers/jsurfacetexture.cpp index 1505443a8..47487f104 100644 --- a/src/plugins/android/src/wrappers/jsurfacetexture.cpp +++ b/src/plugins/android/src/wrappers/jsurfacetexture.cpp @@ -62,6 +62,8 @@ JSurfaceTexture::JSurfaceTexture(unsigned int texName) { if (isValid()) g_objectMap.insert(int(texName), this); + else // If the class is not available, it means the Android version is < 3.0 + qWarning("Camera preview and video playback require Android 3.0 (API level 11) or later."); } JSurfaceTexture::~JSurfaceTexture() @@ -94,16 +96,24 @@ static JNINativeMethod methods[] = { bool JSurfaceTexture::initJNI(JNIEnv *env) { - jclass clazz = env->FindClass("org/qtproject/qt5/android/multimedia/QtSurfaceTexture"); + // SurfaceTexture is available since API 11, try to find it first before loading + // our custom class + jclass surfaceTextureClass = env->FindClass("android/graphics/SurfaceTexture"); if (env->ExceptionCheck()) env->ExceptionClear(); - if (clazz) { - g_qtSurfaceTextureClass = static_cast(env->NewGlobalRef(clazz)); - if (env->RegisterNatives(g_qtSurfaceTextureClass, - methods, - sizeof(methods) / sizeof(methods[0])) < 0) { - return false; + if (surfaceTextureClass) { + jclass clazz = env->FindClass("org/qtproject/qt5/android/multimedia/QtSurfaceTexture"); + if (env->ExceptionCheck()) + env->ExceptionClear(); + + if (clazz) { + g_qtSurfaceTextureClass = static_cast(env->NewGlobalRef(clazz)); + if (env->RegisterNatives(g_qtSurfaceTextureClass, + methods, + sizeof(methods) / sizeof(methods[0])) < 0) { + return false; + } } } -- cgit v1.2.1