diff options
author | Gabriel Nava <gnava@google.com> | 2015-05-29 02:23:12 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-05-29 02:23:12 +0000 |
commit | 93882a227d38a260885f4e123124a791e31bc07f (patch) | |
tree | eb5ae657a7db1394dadb6ce93f30ade752116e41 | |
parent | 9c8512c1b5129755efb91a6af36b1b7bec049548 (diff) | |
parent | 3d908f59f7640d2d352bb35476338d1ac52f2806 (diff) | |
download | android_packages_apps_Camera2-93882a227d38a260885f4e123124a791e31bc07f.tar.gz android_packages_apps_Camera2-93882a227d38a260885f4e123124a791e31bc07f.tar.bz2 android_packages_apps_Camera2-93882a227d38a260885f4e123124a791e31bc07f.zip |
am 3d908f59: am e6b00bf3: Fix for unusable camera after quick pause/resume and HDR+ switch (camera-Haleakala)
* commit '3d908f59f7640d2d352bb35476338d1ac52f2806':
Fix for unusable camera after quick pause/resume and HDR+ switch (camera-Haleakala)
-rw-r--r-- | src/com/android/camera/CaptureModule.java | 23 | ||||
-rw-r--r-- | src/com/android/camera/one/v2/initialization/GenericOneCameraImpl.java | 2 |
2 files changed, 13 insertions, 12 deletions
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java index 79dfe09d7..a3f728c9d 100644 --- a/src/com/android/camera/CaptureModule.java +++ b/src/com/android/camera/CaptureModule.java @@ -24,6 +24,7 @@ import android.graphics.SurfaceTexture; import android.location.Location; import android.media.MediaActionSound; import android.net.Uri; +import android.os.AsyncTask; import android.os.Handler; import android.os.HandlerThread; import android.os.SystemClock; @@ -148,8 +149,8 @@ public class CaptureModule extends CameraModule implements private OneCamera mCamera; /** The selected picture size. */ private Size mPictureSize; - /** Held when opening or closing the camera. */ - private final Semaphore mCameraOpenCloseLock = new Semaphore(1); + /** Fair semaphore held when opening or closing the camera. */ + private final Semaphore mCameraOpenCloseLock = new Semaphore(1, true); /** The direction the currently opened camera is facing to. */ private Facing mCameraFacing; /** Whether HDR Scene mode is currently enabled. */ @@ -644,8 +645,15 @@ public class CaptureModule extends CameraModule implements if (mPaused) { return; } - closeCamera(); - openCameraAndStartPreview(); + AsyncTask.THREAD_POOL_EXECUTOR.execute(new Runnable() { + @Override + public void run() { + closeCamera(); + if(!mAppController.isPaused()) { + openCameraAndStartPreview(); + } + } + }); } private SurfaceTexture getPreviewSurfaceTexture() { @@ -694,13 +702,6 @@ public class CaptureModule extends CameraModule implements mHdrSceneEnabled = !mStickyGcamCamera && mAppController.getSettingsManager().getBoolean( SettingsManager.SCOPE_GLOBAL, Keys.KEY_CAMERA_HDR); - // The lock only exists for HDR and causes trouble for non-HDR - // OneCameras. - // TODO: Fix for removing the locks completely is tracked at b/17985028 - if (!mHdrPlusEnabled) { - mCameraOpenCloseLock.release(); - } - // This means we are resuming with an existing preview texture. This // means we will never get the onSurfaceTextureAvailable call. So we // have to open the camera and start the preview here. diff --git a/src/com/android/camera/one/v2/initialization/GenericOneCameraImpl.java b/src/com/android/camera/one/v2/initialization/GenericOneCameraImpl.java index 458cb5a8c..f966bfd53 100644 --- a/src/com/android/camera/one/v2/initialization/GenericOneCameraImpl.java +++ b/src/com/android/camera/one/v2/initialization/GenericOneCameraImpl.java @@ -159,7 +159,7 @@ class GenericOneCameraImpl implements OneCamera { public void onFailure(@Nonnull Throwable throwable) { listener.onSetupFailed(); } - }, mMainExecutor); + }); } @Override |