Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 03887028 authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

Merge branch '6761-master-camera_fix' into 'master'

camera: Avoid aux camera changes for non-aux device

See merge request !57
parents 8391a047 e4c0be84
Loading
Loading
Loading
Loading
Loading
+57 −34
Original line number Diff line number Diff line
@@ -403,12 +403,14 @@ public class MainActivity extends AppCompatActivity {
            getWindow().setAttributes(layout);
        }

        if (getResources().getBoolean(R.bool.zoom_level_switch_supported)) {
            cameraManager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
            camerafinder = new CameraFinder(cameraManager);
            cameraModel = camerafinder.getCameraModels();
            cameraIdentifier = new CameraIdentifier(cameraModel);
            camerafinder.init();
            cameraIdentifier.init();
        }

        // Setup multi-camera buttons (must be done after creating preview so we know which Camera API is being used,
        // and before initialising on-screen visibility).
@@ -422,7 +424,6 @@ public class MainActivity extends AppCompatActivity {
        int n_cameras = preview.getCameraControllerManager().getNumberOfCameras();
        if (getResources().getBoolean(R.bool.zoom_level_switch_supported)) {
            n_cameras = camerafinder.getAllCameraIdList().size();
        }
            if( n_cameras > 2 ) {
                this.back_camera_ids = new ArrayList<>();
                this.front_camera_ids = new ArrayList<>();
@@ -456,6 +457,28 @@ public class MainActivity extends AppCompatActivity {
                        }
                    }
                }
            }
        } else if (n_cameras > 2) {
            this.back_camera_ids = new ArrayList<>();
            this.front_camera_ids = new ArrayList<>();
            this.other_camera_ids = new ArrayList<>();
            for (int i = 0; i < n_cameras; i++) {
                switch (preview.getCameraControllerManager().getFacing(i)) {
                    case FACING_BACK:
                        back_camera_ids.add(i);
                        break;
                    case FACING_FRONT:
                        front_camera_ids.add(i);
                        break;
                    default:
                        // we assume any unknown cameras are also external
                        other_camera_ids.add(i);
                        break;
                }
            }
        }

        if (n_cameras > 2) {
            if( MyDebug.LOG ) {
                Log.d(TAG, "back_camera_ids: " + back_camera_ids);
                Log.d(TAG, "front_camera_ids: " + front_camera_ids);
+1 −1
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <bool name="zoom_level_switch_supported">false</bool>
    <bool name="allow_logical_camera_ids">false</bool>
    <bool name="allow_logical_camera_ids">true</bool>

    <!-- An array of (0: back camera / 1: front camera, approximate zoom ratio).
     These values will be added to the lens switcher if one or more cameras uses the