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

Commit db70a978 authored by Eino-Ville Talvala's avatar Eino-Ville Talvala
Browse files

Camera2: Legacy: Do not remap EACCES error code to PERMISSION_DENIED

This remap causes non-Legacy and Legacy devices to have different
error behavior when the camera permission is removed from a pre-M
application.

Without the remap, both routes map to CameraAccessException with
code CAMERA_DISABLED.

Bug: 21604925
Change-Id: I4ab18dca961cc7cedaccba0531253c9c4ef1d60e
parent 81f2992f
Loading
Loading
Loading
Loading
+1 −10
Original line number Diff line number Diff line
@@ -88,15 +88,6 @@ public class CameraDeviceUserShim implements ICameraDeviceUser {
        mSurfaceIdCounter = 0;
    }

    private static int translateErrorsFromCamera1(int errorCode) {
        switch (errorCode) {
            case CameraBinderDecorator.EACCES:
                return CameraBinderDecorator.PERMISSION_DENIED;
            default:
                return errorCode;
        }
    }

    /**
     * Create a separate looper/thread for the camera to run on; open the camera.
     *
@@ -140,7 +131,7 @@ public class CameraDeviceUserShim implements ICameraDeviceUser {
            // Save the looper so that we can terminate this thread
            // after we are done with it.
            mLooper = Looper.myLooper();
            mInitErrors = translateErrorsFromCamera1(mCamera.cameraInitUnspecified(mCameraId));
            mInitErrors = mCamera.cameraInitUnspecified(mCameraId);
            mStartDone.open();
            Looper.loop();  // Blocks forever until #close is called.
        }