diff options
author | Senpo Hu <senpo@google.com> | 2014-09-25 10:53:12 -0700 |
---|---|---|
committer | Senpo Hu <senpo@google.com> | 2014-09-25 11:07:41 -0700 |
commit | ee3123ba4b4cc107423441bb8d687c14a2dc4b9a (patch) | |
tree | b1424d1bcfc425e42cbbad82a78552e3c3303b0b | |
parent | da6f3accc02c942b1f2dd1c248edb6a0bd66ee10 (diff) | |
download | android_packages_apps_Camera2-ee3123ba4b4cc107423441bb8d687c14a2dc4b9a.tar.gz android_packages_apps_Camera2-ee3123ba4b4cc107423441bb8d687c14a2dc4b9a.tar.bz2 android_packages_apps_Camera2-ee3123ba4b4cc107423441bb8d687c14a2dc4b9a.zip |
Stability: add null check for all CameraProxy obj references in PhotoModule.
Bug: 17643705
Bug: 17604028
Change-Id: I6073f32bae286168c040f5667494ede1384ce3fc
-rw-r--r-- | src/com/android/camera/PhotoModule.java | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java index 7afa9156e..43103080a 100644 --- a/src/com/android/camera/PhotoModule.java +++ b/src/com/android/camera/PhotoModule.java @@ -749,7 +749,9 @@ public class PhotoModule CameraCapabilities.SceneMode.AUTO)); } updateParametersSceneMode(); - mCameraDevice.applySettings(mCameraSettings); + if (mCameraDevice != null) { + mCameraDevice.applySettings(mCameraSettings); + } updateSceneMode(); } } @@ -906,7 +908,7 @@ public class PhotoModule @Override public void startFaceDetection() { - if (mFaceDetectionStarted) { + if (mFaceDetectionStarted || mCameraDevice == null) { return; } if (mCameraCapabilities.getMaxNumOfFacesSupported() > 0) { @@ -920,7 +922,7 @@ public class PhotoModule @Override public void stopFaceDetection() { - if (!mFaceDetectionStarted) { + if (!mFaceDetectionStarted || mCameraDevice == null) { return; } if (mCameraCapabilities.getMaxNumOfFacesSupported() > 0) { @@ -1970,7 +1972,7 @@ public class PhotoModule // eventually recurse back into startPreview(). // To avoid calling startPreview() twice, we must acquire // mStartPreviewLock. - if (mStartPreviewLock) { + if (mStartPreviewLock || mCameraDevice == null) { // do nothing return; } @@ -2155,6 +2157,10 @@ public class PhotoModule } private void updateParametersPictureSize() { + if (mCameraDevice == null) { + return; + } + SettingsManager settingsManager = mActivity.getSettingsManager(); String pictureSizeKey = isCameraFrontFacing() ? Keys.KEY_PICTURE_SIZE_FRONT : Keys.KEY_PICTURE_SIZE_BACK; @@ -2284,6 +2290,9 @@ public class PhotoModule @TargetApi(Build.VERSION_CODES.JELLY_BEAN) private void updateAutoFocusMoveCallback() { + if (mCameraDevice == null) { + return; + } if (mCameraSettings.getCurrentFocusMode() == CameraCapabilities.FocusMode.CONTINUOUS_PICTURE) { mCameraDevice.setAutoFocusMoveCallback(mHandler, @@ -2327,8 +2336,6 @@ public class PhotoModule updateCameraParametersPreference(); } - // some monkey tests can get here when shutting the app down - // make sure mCameraDevice is still valid, b/17604028 if (mCameraDevice != null) { mCameraDevice.applySettings(mCameraSettings); } |