diff options
author | Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de> | 2016-12-12 15:11:28 +0100 |
---|---|---|
committer | Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de> | 2016-12-12 15:11:28 +0100 |
commit | d507150f2a5750e055cc6e6f2b74796b55f8f97a (patch) | |
tree | 1a2c3903897fc29e8bf6d760a448b5310c0d1499 /src/com/android/camera | |
parent | 6bd4443818dc11fc08c0ec20745ec75a8bd647ca (diff) | |
parent | 79171ff1cb60c83a020cae25c73b415c6812a90e (diff) | |
download | LegacyCamera-d507150f2a5750e055cc6e6f2b74796b55f8f97a.zip LegacyCamera-d507150f2a5750e055cc6e6f2b74796b55f8f97a.tar.gz LegacyCamera-d507150f2a5750e055cc6e6f2b74796b55f8f97a.tar.bz2 |
Merge branch 'master' of https://android.googlesource.com/platform/packages/apps/LegacyCamera into replicant-6.0
Diffstat (limited to 'src/com/android/camera')
-rw-r--r-- | src/com/android/camera/Camera.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java index f7de7f6..254db28 100644 --- a/src/com/android/camera/Camera.java +++ b/src/com/android/camera/Camera.java @@ -1089,7 +1089,21 @@ public class Camera extends ActivityBase implements FocusManager.Listener, private void getPreferredCameraId() { mPreferences = new ComboPreferences(this); CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal()); - mCameraId = CameraSettings.readPreferredCameraId(mPreferences); + + mNumberOfCameras = CameraHolder.instance().getNumberOfCameras(); + int attemptedCameraId = CameraSettings.readPreferredCameraId(mPreferences); + + // It is possible that the user can connect/disconnect cameras + // between device boots. + // We need to check that the preferred camera ID + // does not refer to a disconnected camera. + if (attemptedCameraId >= mNumberOfCameras) { + Log.v(TAG, "Preferred camera (id= " + attemptedCameraId + + ") missing. Defaulting to the first one"); + mCameraId = 0; + } else { + mCameraId = attemptedCameraId; + } // Testing purpose. Launch a specific camera through the intent extras. int intentCameraId = Util.getCameraFacingIntentExtras(this); @@ -1148,7 +1162,6 @@ public class Camera extends ActivityBase implements FocusManager.Listener, mPreferences.setLocalId(this, mCameraId); CameraSettings.upgradeLocalPreferences(mPreferences.getLocal()); - mNumberOfCameras = CameraHolder.instance().getNumberOfCameras(); mQuickCapture = getIntent().getBooleanExtra(EXTRA_QUICK_CAPTURE, false); // we need to reset exposure for the preview |