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

Commit c371be30 authored by Ruben Brunk's avatar Ruben Brunk Committed by Android (Google) Code Review
Browse files

Merge "camera2: Remove CameraAccessException throw for vendor tag setup."

parents dbcd3aa2 b6a78106
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -114,7 +114,10 @@ public class CameraAccessException extends AndroidException {
        mReason = problem;
    }

    private static String getDefaultMessage(int problem) {
    /**
     * @hide
     */
    public static String getDefaultMessage(int problem) {
        switch (problem) {
            case CAMERA_IN_USE:
                return "The camera device is in use already";
+14 −3
Original line number Diff line number Diff line
@@ -85,8 +85,7 @@ public final class CameraManager {
            CameraBinderDecorator.throwOnError(
                    CameraMetadataNative.nativeSetupGlobalVendorTagDescriptor());
        } catch (CameraRuntimeException e) {
            throw new IllegalStateException("Failed to setup camera vendor tags",
                    e.asChecked());
            handleRecoverableSetupErrors(e, "Failed to set up vendor tags");
        }

        try {
@@ -424,6 +423,18 @@ public final class CameraManager {
        return mDeviceIdList;
    }

    private void handleRecoverableSetupErrors(CameraRuntimeException e, String msg) {
        int problem = e.getReason();
        switch (problem) {
            case CameraAccessException.CAMERA_DISCONNECTED:
                String errorMsg = CameraAccessException.getDefaultMessage(problem);
                Log.w(TAG, msg + ": " + errorMsg);
                break;
            default:
                throw new IllegalStateException(msg, e.asChecked());
        }
    }

    // TODO: this class needs unit tests
    // TODO: extract class into top level
    private class CameraServiceListener extends ICameraServiceListener.Stub {