summaryrefslogtreecommitdiffstats
path: root/src/plugins/android/src/wrappers/jni/androidcamera.cpp
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@theqtcompany.com>2015-11-10 15:34:22 +0100
committerYoann Lopes <yoann.lopes@theqtcompany.com>2015-12-03 09:40:16 +0000
commitb7880782b92e214d98bb957fb2ff6f7d5fffd104 (patch)
treea4ea6095e332e499122c7eb9e54c362cd77d5fb2 /src/plugins/android/src/wrappers/jni/androidcamera.cpp
parent3b322323d036ae2fc9f685bfc74d1ebcd5532159 (diff)
Android: check for exceptions in some camera operations.
Not all camera operations are documented to raise exceptions, but they actually might do so depending on the hardware/drivers. Check for exceptions in all functions that could porentially fail and react appropriately. Task-number: QTBUG-49134 Change-Id: I633ca7f2e3aeb6532e1c445735e62135f52cf25f Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com>
Diffstat (limited to 'src/plugins/android/src/wrappers/jni/androidcamera.cpp')
-rw-r--r--src/plugins/android/src/wrappers/jni/androidcamera.cpp30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/plugins/android/src/wrappers/jni/androidcamera.cpp b/src/plugins/android/src/wrappers/jni/androidcamera.cpp
index a4acbd8f9..7d8e4532d 100644
--- a/src/plugins/android/src/wrappers/jni/androidcamera.cpp
+++ b/src/plugins/android/src/wrappers/jni/androidcamera.cpp
@@ -224,12 +224,15 @@ public:
Q_SIGNALS:
void previewSizeChanged();
void previewStarted();
+ void previewFailedToStart();
void previewStopped();
void autoFocusStarted();
void whiteBalanceChanged();
+ void takePictureFailed();
+
void lastPreviewFrameFetched(const QByteArray &preview, int width, int height);
};
@@ -245,9 +248,11 @@ AndroidCamera::AndroidCamera(AndroidCameraPrivate *d, QThread *worker)
connect(d, &AndroidCameraPrivate::previewSizeChanged, this, &AndroidCamera::previewSizeChanged);
connect(d, &AndroidCameraPrivate::previewStarted, this, &AndroidCamera::previewStarted);
+ connect(d, &AndroidCameraPrivate::previewFailedToStart, this, &AndroidCamera::previewFailedToStart);
connect(d, &AndroidCameraPrivate::previewStopped, this, &AndroidCamera::previewStopped);
connect(d, &AndroidCameraPrivate::autoFocusStarted, this, &AndroidCamera::autoFocusStarted);
connect(d, &AndroidCameraPrivate::whiteBalanceChanged, this, &AndroidCamera::whiteBalanceChanged);
+ connect(d, &AndroidCameraPrivate::takePictureFailed, this, &AndroidCamera::takePictureFailed);
connect(d, &AndroidCameraPrivate::lastPreviewFrameFetched, this, &AndroidCamera::lastPreviewFrameFetched);
}
@@ -1057,15 +1062,21 @@ void AndroidCameraPrivate::setFocusAreas(const QList<QRect> &areas)
void AndroidCameraPrivate::autoFocus()
{
+ QJNIEnvironmentPrivate env;
+
m_camera.callMethod<void>("autoFocus",
"(Landroid/hardware/Camera$AutoFocusCallback;)V",
m_cameraListener.object());
- emit autoFocusStarted();
+
+ if (!exceptionCheckAndClear(env))
+ emit autoFocusStarted();
}
void AndroidCameraPrivate::cancelAutoFocus()
{
+ QJNIEnvironmentPrivate env;
m_camera.callMethod<void>("cancelAutoFocus");
+ exceptionCheckAndClear(env);
}
bool AndroidCameraPrivate::isAutoExposureLockSupported()
@@ -1314,25 +1325,40 @@ void AndroidCameraPrivate::setJpegQuality(int quality)
void AndroidCameraPrivate::startPreview()
{
+ QJNIEnvironmentPrivate env;
+
setupPreviewFrameCallback();
m_camera.callMethod<void>("startPreview");
- emit previewStarted();
+
+ if (exceptionCheckAndClear(env))
+ emit previewFailedToStart();
+ else
+ emit previewStarted();
}
void AndroidCameraPrivate::stopPreview()
{
+ QJNIEnvironmentPrivate env;
+
m_camera.callMethod<void>("stopPreview");
+
+ exceptionCheckAndClear(env);
emit previewStopped();
}
void AndroidCameraPrivate::takePicture()
{
+ QJNIEnvironmentPrivate env;
+
m_camera.callMethod<void>("takePicture", "(Landroid/hardware/Camera$ShutterCallback;"
"Landroid/hardware/Camera$PictureCallback;"
"Landroid/hardware/Camera$PictureCallback;)V",
m_cameraListener.object(),
jobject(0),
m_cameraListener.object());
+
+ if (exceptionCheckAndClear(env))
+ emit takePictureFailed();
}
void AndroidCameraPrivate::setupPreviewFrameCallback()