diff options
author | junjiez <junjiez@codeaurora.org> | 2017-09-19 11:15:01 +0800 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2017-11-17 01:49:19 -0800 |
commit | d87fe31b196cc11ba9bec68d51fd1459b27737af (patch) | |
tree | 57c0e34277362635a91c4686cd17d873d7ace3b7 /src/com/android/camera/CaptureModule.java | |
parent | 1fa22656c1fe62782d287f9427d8e56fbddee8fd (diff) | |
download | android_packages_apps_Snap-d87fe31b196cc11ba9bec68d51fd1459b27737af.tar.gz android_packages_apps_Snap-d87fe31b196cc11ba9bec68d51fd1459b27737af.tar.bz2 android_packages_apps_Snap-d87fe31b196cc11ba9bec68d51fd1459b27737af.zip |
SnapdragonCamera:support multi camera switch
add a new option in dev options to swtich
camera by camera Id.
Change-Id: Ieeb6f462024c3b155dc5fb532fd737313b9904de
Diffstat (limited to 'src/com/android/camera/CaptureModule.java')
-rwxr-xr-x | src/com/android/camera/CaptureModule.java | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java index 7dd2e59ff..d43f22117 100755 --- a/src/com/android/camera/CaptureModule.java +++ b/src/com/android/camera/CaptureModule.java @@ -655,7 +655,10 @@ public class CaptureModule implements CameraModule, PhotoController, Log.e(TAG, "onError " + id + " " + error); mCameraOpenCloseLock.release(); mCamerasOpened = false; + if (null != mActivity) { + Toast.makeText(mActivity,"open camera error id =" + id, + Toast.LENGTH_LONG).show(); mActivity.finish(); } } @@ -815,6 +818,8 @@ public class CaptureModule implements CameraModule, PhotoController, } public boolean isBackCamera() { + String switchValue = mSettingsManager.getValue(SettingsManager.KEY_SWITCH_CAMERA); + if (switchValue != null && !switchValue.equals("-1") ) return false; String value = mSettingsManager.getValue(SettingsManager.KEY_CAMERA_ID); if (value == null) return true; if (Integer.parseInt(value) == BAYER_ID) return true; @@ -973,7 +978,10 @@ public class CaptureModule implements CameraModule, PhotoController, break; } } else { - createSession(FRONT_ID); + int switchId = Integer.parseInt( + mSettingsManager.getValue(SettingsManager.KEY_SWITCH_CAMERA)); + int cameraId = switchId == -1? FRONT_ID : switchId; + createSession(cameraId); } } @@ -1051,7 +1059,8 @@ public class CaptureModule implements CameraModule, PhotoController, // Finally, we start displaying the camera preview. // for cases where we are in dual mode with mono preview off, // don't set repeating request for mono - if(id == MONO_ID && !canStartMonoPreview()) { + if(id == MONO_ID && !canStartMonoPreview() + && getCameraMode() == DUAL_MODE) { mCaptureSession[id].capture(mPreviewRequestBuilder[id] .build(), mCaptureCallback, mCameraHandler); } else { @@ -1331,10 +1340,13 @@ public class CaptureModule implements CameraModule, PhotoController, break; } } else { - if (takeZSLPicture(FRONT_ID)) { + int switchId = Integer.parseInt( + mSettingsManager.getValue(SettingsManager.KEY_SWITCH_CAMERA)); + int cameraId = switchId == -1? FRONT_ID : switchId; + if(takeZSLPicture(cameraId)) { return; } - lockFocus(FRONT_ID); + lockFocus(cameraId); } } } @@ -2459,7 +2471,10 @@ public class CaptureModule implements CameraModule, PhotoController, break; } } else { - msg.arg1 = FRONT_ID; + int switchId = Integer.parseInt( + mSettingsManager.getValue(SettingsManager.KEY_SWITCH_CAMERA)); + int cameraId = switchId == -1? FRONT_ID : switchId; + msg.arg1 = cameraId; mCameraHandler.sendMessage(msg); } mUI.showSurfaceView(); @@ -2800,7 +2815,10 @@ public class CaptureModule implements CameraModule, PhotoController, } return 0; } else { - return FRONT_ID; + int switchId = Integer.parseInt( + mSettingsManager.getValue(SettingsManager.KEY_SWITCH_CAMERA)); + int cameraId = switchId == -1? FRONT_ID : switchId; + return cameraId; } } @@ -3083,6 +3101,7 @@ public class CaptureModule implements CameraModule, PhotoController, private void updateVideoSize() { String videoSize = mSettingsManager.getValue(SettingsManager.KEY_VIDEO_QUALITY); + if (videoSize == null) return; mVideoSize = parsePictureSize(videoSize); Size[] prevSizes = mSettingsManager.getSupportedOutputSize(getMainCameraId(), MediaRecorder.class); @@ -3642,7 +3661,18 @@ public class CaptureModule implements CameraModule, PhotoController, updateHFRSetting(); boolean hfr = mHighSpeedCapture && !mHighSpeedRecordingMode; - mProfile = CamcorderProfile.get(cameraId, size); + if (CamcorderProfile.hasProfile(cameraId, size)) { + mProfile = CamcorderProfile.get(cameraId, size); + } else { + if (!"-1".equals(mSettingsManager.getValue(SettingsManager.KEY_SWITCH_CAMERA))) { + mProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH); + } else { + RotateTextToast.makeText(mActivity, R.string.error_app_unsupported_profile, + Toast.LENGTH_LONG).show(); + return; + } + } + int videoWidth = mProfile.videoFrameWidth; int videoHeight = mProfile.videoFrameHeight; mUnsupportedResolution = false; @@ -4587,6 +4617,7 @@ public class CaptureModule implements CameraModule, PhotoController, case SettingsManager.KEY_CAMERA_ID: case SettingsManager.KEY_MONO_ONLY: case SettingsManager.KEY_CLEARSIGHT: + case SettingsManager.KEY_SWITCH_CAMERA: case SettingsManager.KEY_MONO_PREVIEW: if (count == 0) restartAll(); return; |