M810项目配置了两个后摄,需要实现双后摄切换:
vendor/mediatek/proprietary/packages/apps/Camera2/feature/setting/cameraswitcher/src/com/mediatek/camera/feature/setting/CameraSwitcher.java
+ private static final String CAMERA_FACING_BACK2 = "back2";
................
+ private void switchCameraInNormal() {
+ //String nextFacing = mFacing.equals(CAMERA_FACING_BACK) ? CAMERA_FACING_FRONT
+ // : CAMERA_FACING_BACK;
+ String nextFacing = CAMERA_FACING_BACK;
+ String newCameraId;
+ if(mFacing.equals(CAMERA_FACING_BACK)){
+ nextFacing = CAMERA_FACING_BACK2;
+ newCameraId = CameraUtil.getCamIdsByFacing(true, mApp.getActivity()).get(1);
+ }else if(mFacing.equals(CAMERA_FACING_BACK2)){
+ nextFacing = CAMERA_FACING_FRONT;
+ newCameraId = CameraUtil.getCamIdsByFacing(false, mApp.getActivity()).get(0);
+ }else{
+ nextFacing = CAMERA_FACING_BACK;
+ newCameraId = CameraUtil.getCamIdsByFacing(true, mApp.getActivity()).get(0);
+ }
+ boolean success = mApp.notifyCameraSelected(newCameraId);
+ if (success) {
+ android.util.Log.d("wangqing","[switchCameraInNormal], switch camera success.");
+ mFacing = nextFacing;
+ mDataStore.setValue(KEY_CAMERA_SWITCHER, mFacing,
+ getStoreScope(), true);
+ }else{
+ android.util.Log.d("wangqing","failed");
+ }
+ mSwitcherView.setContentDescription(mFacing);
+ }
用上述代码替换原有的switchCameraInNormal()方法。
标签:newCameraId,双后,BACK,FACING,CAMERA,mFacing,切换,nextFacing From: https://www.cnblogs.com/a-n-yan/p/17648715.html