diff options
author | Jay Wang <jaywang@codeaurora.org> | 2016-11-03 13:27:10 -0700 |
---|---|---|
committer | Daniel Hillenbrand <daniel.hillenbrand@codeworkx.de> | 2017-05-30 18:11:15 +0000 |
commit | f68cddc15c628574322d56d02653983dad2bc62e (patch) | |
tree | ba45409a2ddab5ca308891daf09175963646bf7b | |
parent | c737df520a87207f83c864c2876685e190c1113e (diff) | |
download | android_packages_apps_Snap-f68cddc15c628574322d56d02653983dad2bc62e.tar.gz android_packages_apps_Snap-f68cddc15c628574322d56d02653983dad2bc62e.tar.bz2 android_packages_apps_Snap-f68cddc15c628574322d56d02653983dad2bc62e.zip |
SnapdragonCamera: Fix torch mode with continuous shot
Flash torch mode sometime doesn't work because the flash mode
is overwritten by repeating preview request. To resolve the
issue, re-configure the preview request with new flash mode.
CRs-Fixed: 1077543
Change-Id: I614bac704562925cc843a9b8db2852c71368f4e5
-rwxr-xr-x | src/com/android/camera/CaptureModule.java | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java index 7a9f67261..2e6a127ba 100755 --- a/src/com/android/camera/CaptureModule.java +++ b/src/com/android/camera/CaptureModule.java @@ -540,6 +540,7 @@ public class CaptureModule extends BaseModule<CaptureUI> implements PhotoControl Integer afState = result.get(CaptureResult.CONTROL_AF_STATE); Integer aeState = result.get(CaptureResult.CONTROL_AE_STATE); Log.d(TAG, "STATE_WAITING_AF_LOCK id: " + id + " afState:" + afState + " aeState:" + aeState); + // AF_PASSIVE is added for continous auto focus mode if (CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED == afState || CaptureResult.CONTROL_AF_STATE_NOT_FOCUSED_LOCKED == afState || @@ -555,15 +556,20 @@ public class CaptureModule extends BaseModule<CaptureUI> implements PhotoControl else mState[id] = STATE_WAITING_AE_LOCK; } else { - runPrecaptureSequence(id); - // CONTROL_AE_STATE can be null on some devices - if(aeState == null || (aeState == CaptureResult - .CONTROL_AE_STATE_CONVERGED) && isFlashOff(id)) { - lockExposure(id); - } else { - runPrecaptureSequence(id); + if ((mLockRequestHashCode[id] == result.getRequest().hashCode()) || (mLockRequestHashCode[id] == 0)) { + + // CONTROL_AE_STATE can be null on some devices + if(aeState == null || (aeState == CaptureResult + .CONTROL_AE_STATE_CONVERGED) && isFlashOff(id)) { + lockExposure(id); + } else { + runPrecaptureSequence(id); + } } } + } else if (mLockRequestHashCode[id] == result.getRequest().hashCode()){ + Log.i(TAG, "AF lock request result received, but not focused"); + mLockRequestHashCode[id] = 0; } break; } @@ -576,8 +582,16 @@ public class CaptureModule extends BaseModule<CaptureUI> implements PhotoControl aeState == CaptureResult.CONTROL_AE_STATE_PRECAPTURE || aeState == CaptureResult.CONTROL_AE_STATE_FLASH_REQUIRED || aeState == CaptureResult.CONTROL_AE_STATE_CONVERGED) { - if (mPrecaptureRequestHashCode[id] == result.getRequest().hashCode()) - lockExposure(id); + if ((mPrecaptureRequestHashCode[id] == result.getRequest().hashCode()) || (mPrecaptureRequestHashCode[id] == 0)) { + if (mLongshotActive && isFlashOn(id)) { + checkAfAeStatesAndCapture(id); + } else { + lockExposure(id); + } + } + } else if (mPrecaptureRequestHashCode[id] == result.getRequest().hashCode()) { + Log.i(TAG, "AE trigger request result received, but not converged"); + mPrecaptureRequestHashCode[id] = 0; } break; } @@ -1033,6 +1047,14 @@ public class CaptureModule extends BaseModule<CaptureUI> implements PhotoControl if(id == MONO_ID && !canStartMonoPreview()) { mCaptureSession[id].setRepeatingRequest(mPreviewRequestBuilder[id] .build(), mCaptureCallback, mCameraHandler); + } else { + // for longshot flash, need to re-configure the preview flash mode. + if (mLongshotActive && isFlashOn(id)) { + mCaptureSession[id].stopRepeating(); + applyFlash(mPreviewRequestBuilder[id], id); + mCaptureSession[id].setRepeatingRequest(mPreviewRequestBuilder[id] + .build(), mCaptureCallback, mCameraHandler); + } } } catch (CameraAccessException e) { e.printStackTrace(); @@ -1042,6 +1064,7 @@ public class CaptureModule extends BaseModule<CaptureUI> implements PhotoControl if (mState[id] == STATE_WAITING_TOUCH_FOCUS) { mCameraHandler.removeMessages(CANCEL_TOUCH_FOCUS, mCameraId[id]); mState[id] = STATE_WAITING_AF_LOCK; + mLockRequestHashCode[id] = 0; return; } @@ -1296,6 +1319,7 @@ public class CaptureModule extends BaseModule<CaptureUI> implements PhotoControl applySettingsForPrecapture(builder, id); CaptureRequest request = builder.build(); mPrecaptureRequestHashCode[id] = request.hashCode(); + mState[id] = STATE_WAITING_PRECAPTURE; mCaptureSession[id].capture(request, mCaptureCallback, mCameraHandler); } catch (CameraAccessException e) { @@ -2848,6 +2872,11 @@ public class CaptureModule extends BaseModule<CaptureUI> implements PhotoControl return mSettingsManager.getValue(SettingsManager.KEY_FLASH_MODE).equals("1"); } + private boolean isFlashOn(int id) { + if (!mSettingsManager.isFlashSupported(id)) return false; + return mSettingsManager.getValue(SettingsManager.KEY_FLASH_MODE).equals("on"); + } + private void initializePreviewConfiguration(int id) { mPreviewRequestBuilder[id].set(CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest .CONTROL_AF_TRIGGER_IDLE); |