summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Mount <mount@google.com>2013-01-14 17:44:41 -0800
committerGeorge Mount <mount@google.com>2013-01-14 18:17:09 -0800
commita489e380036b047daba972115b6a2fd872098b5f (patch)
tree3336edd4ba3f60062d09181c60e5149b6f60b1ed
parentf95aae25a6ba450b534a196f86c91c82b48a2d17 (diff)
downloadCamera-a489e380036b047daba972115b6a2fd872098b5f.tar.gz
Fixed ANR in VideoModule.
Bug 7990250 Any intent that launched the VideoModule before the PhotoModule was causing the VideoModule to deadlock. The VideoModule can now complete its own initialization. Likewise, when resuming, it no longer starts the preview on the UI thread, causing a deadlock. Change-Id: I91ce1a437e57379f83dd48ffc96a0c49bf2dc5b7
-rw-r--r--src/com/android/camera/VideoModule.java43
1 files changed, 22 insertions, 21 deletions
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index cdfdff10..0fecca63 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -462,14 +462,13 @@ public class VideoModule implements CameraModule,
// ignore
}
- Thread startPreviewThread = new Thread(new Runnable() {
+ readVideoPreferences();
+ new Thread(new Runnable() {
@Override
public void run() {
- readVideoPreferences();
startPreview();
}
- });
- startPreviewThread.start();
+ }).start();
initializeControlByIntent();
initializeOverlay();
@@ -481,20 +480,6 @@ public class VideoModule implements CameraModule,
setOrientationIndicator(0, false);
setDisplayOrientation();
- // Make sure preview is started.
- try {
- startPreviewThread.join();
- if (mActivity.mOpenCameraFail) {
- Util.showErrorAndFinish(mActivity, R.string.cannot_connect_camera);
- return;
- } else if (mActivity.mCameraDisabled) {
- Util.showErrorAndFinish(mActivity, R.string.camera_disabled);
- return;
- }
- } catch (InterruptedException ex) {
- // ignore
- }
-
showTimeLapseUI(mCaptureTimeLapse);
initializeVideoSnapshot();
resizeForPreviewAspectRatio();
@@ -844,7 +829,12 @@ public class VideoModule implements CameraModule,
}
readVideoPreferences();
resizeForPreviewAspectRatio();
- startPreview();
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ startPreview();
+ }
+ }).start();
}
// Initializing it here after the preview is started.
@@ -892,6 +882,8 @@ public class VideoModule implements CameraModule,
}
}
+ mPreviewing = true;
+
setDisplayOrientation();
mActivity.mCameraDevice.setDisplayOrientation(mCameraDisplayOrientation);
setCameraParameters();
@@ -912,9 +904,18 @@ public class VideoModule implements CameraModule,
} catch (Throwable ex) {
closeCamera();
throw new RuntimeException("startPreview failed", ex);
+ } finally {
+ mActivity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ if (mActivity.mOpenCameraFail) {
+ Util.showErrorAndFinish(mActivity, R.string.cannot_connect_camera);
+ } else if (mActivity.mCameraDisabled) {
+ Util.showErrorAndFinish(mActivity, R.string.camera_disabled);
+ }
+ }
+ });
}
-
- mPreviewing = true;
}
private void stopPreview() {