summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSanthosh Kumar H E <skhara@codeaurora.org>2015-09-22 13:11:43 +0530
committerDaniel Hillenbrand <codeworkx@cyanogenmod.org>2016-01-08 22:49:56 -0800
commit8ceb088bf9cf14ff1f5288744dfdd07cd32b5432 (patch)
tree6a0c9374eef086efc7d88ec26865569e10c840d9
parent090c538862c6c4204ebf7789bf0d6146893dc6d9 (diff)
downloadandroid_packages_apps_Snap-8ceb088bf9cf14ff1f5288744dfdd07cd32b5432.tar.gz
android_packages_apps_Snap-8ceb088bf9cf14ff1f5288744dfdd07cd32b5432.tar.bz2
android_packages_apps_Snap-8ceb088bf9cf14ff1f5288744dfdd07cd32b5432.zip
Update camera state immediately after start preview.
When user delete all the images in gallery to come back to camera, surface view gets created, destroyed and recreated. Since camera state is updated over handler message after start preview, by the time handler thread updates the state background thread would have stopped the preview. So during surface recreation, state variable is read wrong and it doesn't allow start preview. This change makes sure state variable is updated immediately after start preview and only UI updation is moved to main thread through handler message. Change-Id: I289814821d5c3652b06301d1d4a854e9e40670b6
-rw-r--r--src/com/android/camera/PhotoModule.java23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index 8a3000651..13802c031 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -144,6 +144,7 @@ public class PhotoModule
private static final int SET_PHOTO_UI_PARAMS = 11;
private static final int SWITCH_TO_GCAM_MODULE = 12;
private static final int ON_PREVIEW_STARTED = 13;
+ private static final int UPDATE_GESTURES_UI = 14;
// The subset of parameters we need to update in setCameraParameters().
private static final int UPDATE_PARAM_INITIALIZE = 1;
@@ -473,6 +474,11 @@ public class PhotoModule
onPreviewStarted();
break;
}
+
+ case UPDATE_GESTURES_UI: {
+ updateGesturesUI();
+ break;
+ }
}
}
}
@@ -529,7 +535,6 @@ public class PhotoModule
if (mCameraState == SNAPSHOT_IN_PROGRESS) {
return;
}
- setCameraState(IDLE);
mFocusManager.onPreviewStarted();
startFaceDetection();
locationFirstRun();
@@ -1490,7 +1495,20 @@ public class PhotoModule
private void setCameraState(int state) {
mCameraState = state;
- switch (state) {
+ /*
+ * If the current thread is UI thread, update gestures UI directly.
+ * If the current thread is background thread, post a handler message
+ * to update gestures UI.
+ */
+ if (Looper.getMainLooper().getThread() == Thread.currentThread()) {
+ updateGesturesUI();
+ } else {
+ mHandler.sendEmptyMessage(UPDATE_GESTURES_UI);
+ }
+ }
+
+ private void updateGesturesUI(){
+ switch (mCameraState) {
case PhotoController.PREVIEW_STOPPED:
case PhotoController.SNAPSHOT_IN_PROGRESS:
case PhotoController.LONGSHOT:
@@ -2696,6 +2714,7 @@ public class PhotoModule
setCameraParameters(UPDATE_PARAM_ALL);
mCameraDevice.startPreview();
+ setCameraState(IDLE);
mCameraDevice.setOneShotPreviewCallback(mHandler,
new CameraManager.CameraPreviewDataCallback() {
@Override