From 08d9641024101f8a6edecb4eb1ffc15ca1cf011a Mon Sep 17 00:00:00 2001 From: Byunghun Jeon Date: Mon, 23 May 2016 16:19:08 -0700 Subject: SnapdragonCamera: Fix savepath set to SD card crash Fix crash issue when fix savepath is set to SD card and the app is restarted. This is due to not updating storage information. When the module starts up, we need to call storage update so that it will set to proper initial value, not causing crash. Also only update focus UI when AF state is not null. Change-Id: I1a3e444b42eb988ed622d047b1f3dc42bec7a119 CRs-Fixed: 1018118 --- src/com/android/camera/CaptureModule.java | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java index 9d09343ea..2b28f9946 100644 --- a/src/com/android/camera/CaptureModule.java +++ b/src/com/android/camera/CaptureModule.java @@ -226,6 +226,7 @@ public class CaptureModule implements CameraModule, PhotoController, private boolean mFirstPreviewLoaded; private int[] mPrecaptureRequestHashCode = new int[MAX_NUM_CAM]; private int[] mLockRequestHashCode = new int[MAX_NUM_CAM]; + private final Handler mHandler = new MainHandler(); private class MediaSaveNotifyThread extends Thread { private Uri uri; @@ -340,7 +341,7 @@ public class CaptureModule implements CameraModule, PhotoController, private CameraCaptureSession.CaptureCallback mCaptureCallback = new CameraCaptureSession.CaptureCallback() { - private void process(CaptureResult result) { + private void updateState(CaptureResult result) { int id = (int) result.getRequest().getTag(); if (!mFirstPreviewLoaded) { @@ -420,7 +421,6 @@ public class CaptureModule implements CameraModule, PhotoController, CaptureResult partialResult) { int id = (int) partialResult.getRequest().getTag(); if (id == getMainCameraId()) updateFocusStateChange(partialResult); - process(partialResult); } @Override @@ -429,7 +429,7 @@ public class CaptureModule implements CameraModule, PhotoController, TotalCaptureResult result) { int id = (int) result.getRequest().getTag(); if (id == getMainCameraId()) updateFocusStateChange(result); - process(result); + updateState(result); } }; @@ -1438,7 +1438,12 @@ public class CaptureModule implements CameraModule, PhotoController, initializeSecondTime(); } mUI.reInitUI(); - mActivity.updateStorageSpaceAndHint(); + mHandler.post(new Runnable() { + @Override + public void run() { + mActivity.updateStorageSpaceAndHint(); + } + }); estimateJpegFileSize(); mUI.enableShutter(true); } @@ -2117,7 +2122,8 @@ public class CaptureModule implements CameraModule, PhotoController, } private void updateFocusStateChange(CaptureResult result) { - final int resultAFState = result.get(CaptureResult.CONTROL_AF_STATE); + final Integer resultAFState = result.get(CaptureResult.CONTROL_AF_STATE); + if (resultAFState == null) return; // Report state change when AF state has changed. if (resultAFState != mLastResultAFState && mFocusStateListener != null) { @@ -2335,4 +2341,14 @@ public class CaptureModule implements CameraModule, PhotoController, unlockFocus(BAYER_ID); unlockFocus(MONO_ID); } + + /** + * This Handler is used to post message back onto the main thread of the + * application + */ + private class MainHandler extends Handler { + public MainHandler() { + super(Looper.getMainLooper()); + } + } } -- cgit v1.2.3