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

Commit bfe3e433 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Introduce injectSessionParams API in CameraManager" into main

parents 19bd7034 483a178a
Loading
Loading
Loading
Loading
+48 −1
Original line number Diff line number Diff line
@@ -1851,6 +1851,29 @@ public final class CameraManager {
        CameraManagerGlobal.get().remapCameraIds(cameraIdRemapping);
    }

    /**
     * Injects session params into existing clients in the CameraService.
     *
     * @param cameraId       The camera id of client to inject session params into.
     *                       If no such client exists for cameraId, no injection will
     *                       take place.
     * @param sessionParams  A {@link CaptureRequest} object containing the
     *                       the sessionParams to inject into the existing client.
     *
     * @throws CameraAccessException    {@link CameraAccessException#CAMERA_DISCONNECTED} will be
     *                                  thrown if camera service is not available. Further, if
     *                                  if no such client exists for cameraId,
     *                                  {@link CameraAccessException#CAMERA_ERROR} will be thrown.
     * @throws SecurityException        If the caller does not have permission to inject session
     *                                  params
     * @hide
     */
    @RequiresPermission(android.Manifest.permission.CAMERA_INJECT_EXTERNAL_CAMERA)
    public void injectSessionParams(@NonNull String cameraId, @NonNull CaptureRequest sessionParams)
            throws CameraAccessException, SecurityException {
        CameraManagerGlobal.get().injectSessionParams(cameraId, sessionParams);
    }

    /**
     * Reports {@link CameraExtensionSessionStats} to the {@link ICameraService} to be logged for
     * currently active session. Validation is done downstream.
@@ -2110,6 +2133,30 @@ public final class CameraManager {
            }
        }

        /** Injects session params into an existing client for cameraid. */
        public void injectSessionParams(@NonNull String cameraId,
                @NonNull CaptureRequest sessionParams)
                throws CameraAccessException, SecurityException {
            synchronized (mLock) {
                ICameraService cameraService = getCameraService();
                if (cameraService == null) {
                    throw new CameraAccessException(
                            CameraAccessException.CAMERA_DISCONNECTED,
                            "Camera service is currently unavailable.");
                }

                try {
                    cameraService.injectSessionParams(cameraId, sessionParams.getNativeMetadata());
                } catch (ServiceSpecificException e) {
                    throwAsPublicException(e);
                } catch (RemoteException e) {
                    throw new CameraAccessException(
                            CameraAccessException.CAMERA_DISCONNECTED,
                            "Camera service is currently unavailable.");
                }
            }
        }

        private String[] extractCameraIdListLocked() {
            String[] cameraIds = null;
            int idCount = 0;