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

Commit 483a178a authored by malikakash's avatar malikakash
Browse files

Introduce injectSessionParams API in CameraManager

Bug: 308984721
Test: Manual Test
Change-Id: I7847cbe77d07773fc656bfd52583a647639882e7
parent a8aa4eca
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;