diff options
author | Gabriel Nava <gnava@google.com> | 2015-05-29 00:07:42 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-05-29 00:07:42 +0000 |
commit | 3d908f59f7640d2d352bb35476338d1ac52f2806 (patch) | |
tree | 3b356197a8ce188f782af8ec5bcb70fea349acfb | |
parent | 3609a80b8671b38a282f59795301fd9885b401ff (diff) | |
parent | e6b00bf3c0319cba17ce23161402568c8e3c3547 (diff) | |
download | android_packages_apps_Camera2-3d908f59f7640d2d352bb35476338d1ac52f2806.tar.gz android_packages_apps_Camera2-3d908f59f7640d2d352bb35476338d1ac52f2806.tar.bz2 android_packages_apps_Camera2-3d908f59f7640d2d352bb35476338d1ac52f2806.zip |
am e6b00bf3: Fix for unusable camera after quick pause/resume and HDR+ switch (camera-Haleakala)
* commit 'e6b00bf3c0319cba17ce23161402568c8e3c3547':
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 |