diff options
author | Yoann Lopes <yoann.lopes@digia.com> | 2013-11-27 16:05:19 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-30 17:58:40 +0100 |
commit | fd3efc0163d9963c91e24ece43b774c70ec57640 (patch) | |
tree | fc6331226d75c72437466adc86dc17fd1b51a05e | |
parent | 041e75d1c099a937a16759ad40aee4d83e2316f6 (diff) |
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 <christian.stromme@digia.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
-rw-r--r-- | src/plugins/android/src/wrappers/jsurfacetexture.cpp | 24 |
1 files 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<jclass>(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<jclass>(env->NewGlobalRef(clazz)); + if (env->RegisterNatives(g_qtSurfaceTextureClass, + methods, + sizeof(methods) / sizeof(methods[0])) < 0) { + return false; + } } } |