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>
This commit is contained in:
committed by
The Qt Project
parent
041e75d1c0
commit
fd3efc0163
@@ -62,6 +62,8 @@ JSurfaceTexture::JSurfaceTexture(unsigned int texName)
|
|||||||
{
|
{
|
||||||
if (isValid())
|
if (isValid())
|
||||||
g_objectMap.insert(int(texName), this);
|
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()
|
JSurfaceTexture::~JSurfaceTexture()
|
||||||
@@ -94,16 +96,24 @@ static JNINativeMethod methods[] = {
|
|||||||
|
|
||||||
bool JSurfaceTexture::initJNI(JNIEnv *env)
|
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())
|
if (env->ExceptionCheck())
|
||||||
env->ExceptionClear();
|
env->ExceptionClear();
|
||||||
|
|
||||||
if (clazz) {
|
if (surfaceTextureClass) {
|
||||||
g_qtSurfaceTextureClass = static_cast<jclass>(env->NewGlobalRef(clazz));
|
jclass clazz = env->FindClass("org/qtproject/qt5/android/multimedia/QtSurfaceTexture");
|
||||||
if (env->RegisterNatives(g_qtSurfaceTextureClass,
|
if (env->ExceptionCheck())
|
||||||
methods,
|
env->ExceptionClear();
|
||||||
sizeof(methods) / sizeof(methods[0])) < 0) {
|
|
||||||
return false;
|
if (clazz) {
|
||||||
|
g_qtSurfaceTextureClass = static_cast<jclass>(env->NewGlobalRef(clazz));
|
||||||
|
if (env->RegisterNatives(g_qtSurfaceTextureClass,
|
||||||
|
methods,
|
||||||
|
sizeof(methods) / sizeof(methods[0])) < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user