From ee5d17ff56388a99a8216a984ccca2eaa4fc6662 Mon Sep 17 00:00:00 2001 From: mingwax Date: Tue, 16 Aug 2016 10:27:36 +0800 Subject: SnapdragonCamera: Fix camera flash blink after unlock device RootCause: when lock the screen and unlock the screen quickly,the system could show the last recent app when the lockscreen is not ready.when the lockscreen is ready now,system could dismiss the last recent app.When camera show,run onResume method,flash could be opened.And when camera run onPause method,flash could be closed,it caused flash blink. Add delay time avoid when camera be opened and closed quickly caused flash blink Change-Id: Id32eaf5186020edd1c835315efa9a2671db9f952 CRs-Fixed: 1034366 --- src/com/android/camera/VideoModule.java | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) mode change 100755 => 100644 src/com/android/camera/VideoModule.java (limited to 'src/com/android/camera/VideoModule.java') diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java old mode 100755 new mode 100644 index a93cff611..dcee0c743 --- a/src/com/android/camera/VideoModule.java +++ b/src/com/android/camera/VideoModule.java @@ -98,6 +98,7 @@ public class VideoModule implements CameraModule, private static final int SHOW_TAP_TO_SNAPSHOT_TOAST = 7; private static final int SWITCH_CAMERA = 8; private static final int SWITCH_CAMERA_START_ANIMATION = 9; + private static final int HANDLE_FLASH_TORCH_DELAY = 10; private static final int SCREEN_DELAY = 2 * 60 * 1000; @@ -415,6 +416,11 @@ public class VideoModule implements CameraModule, break; } + case HANDLE_FLASH_TORCH_DELAY: { + forceFlashOff(!mPreviewFocused); + break; + } + default: Log.v(TAG, "Unhandled message: " + msg.what); break; @@ -1218,7 +1224,7 @@ public class VideoModule implements CameraModule, setDisplayOrientation(); mCameraDevice.setDisplayOrientation(mCameraDisplayOrientation); - setCameraParameters(); + setCameraParameters(true); try { mCameraDevice.setPreviewDisplay(sh); @@ -1313,6 +1319,7 @@ public class VideoModule implements CameraModule, mHandler.removeMessages(CHECK_DISPLAY_ROTATION); mHandler.removeMessages(SWITCH_CAMERA); mHandler.removeMessages(SWITCH_CAMERA_START_ANIMATION); + mHandler.removeMessages(HANDLE_FLASH_TORCH_DELAY); mPendingSwitchCameraId = -1; mSwitchingCamera = false; mPreferenceRead = false; @@ -2589,7 +2596,7 @@ public class VideoModule implements CameraModule, } @SuppressWarnings("deprecation") - private void setCameraParameters() { + private void setCameraParameters(boolean isFlashDelay) { Log.d(TAG,"Preview dimension in App->"+mDesiredPreviewWidth+"X"+mDesiredPreviewHeight); mParameters.setPreviewSize(mDesiredPreviewWidth, mDesiredPreviewHeight); mParameters.set("video-size", mProfile.videoFrameWidth+"x"+mProfile.videoFrameHeight); @@ -2602,7 +2609,11 @@ public class VideoModule implements CameraModule, mParameters.setPreviewFrameRate(mProfile.videoFrameRate); } - forceFlashOffIfSupported(!mPreviewFocused); + if (isFlashDelay) { + mHandler.sendEmptyMessageDelayed(HANDLE_FLASH_TORCH_DELAY, 800); + } else { + forceFlashOffIfSupported(!mPreviewFocused); + } videoWidth = mProfile.videoFrameWidth; videoHeight = mProfile.videoFrameHeight; @@ -2777,7 +2788,7 @@ public class VideoModule implements CameraModule, resizeForPreviewAspectRatio(); startPreview(); // Parameters will be set in startPreview(). } else { - setCameraParameters(); + setCameraParameters(false); } mRestartPreview = false; mUI.updateOnScreenIndicators(mParameters, mPreferences); @@ -2906,7 +2917,7 @@ public class VideoModule implements CameraModule, @Override public void onPreviewFocusChanged(boolean previewFocused) { mUI.onPreviewFocusChanged(previewFocused); - forceFlashOff(!previewFocused); + mHandler.sendEmptyMessageDelayed(HANDLE_FLASH_TORCH_DELAY, 800); mPreviewFocused = previewFocused; } -- cgit v1.2.3