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

Commit 7a5a5a93 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Camera: Pass targetSdkVersion to camera service APIs" into sc-dev am: 59239bf7

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14801971

Change-Id: I013f8f9952993631bb5fb031622832a6ad81e472
parents 77728db1 59239bf7
Loading
Loading
Loading
Loading
+14 −7
Original line number Diff line number Diff line
@@ -2511,9 +2511,9 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri
     * <p>Not all output formats may be supported in a configuration with
     * an input stream of a particular format. For more details, see
     * android.scaler.availableInputOutputFormatsMap.</p>
     * <p>The following table describes the minimum required output stream
     * configurations based on the hardware level
     * ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL android.info.supportedHardwareLevel}), prior to Android 12:</p>
     * <p>For applications targeting SDK version older than 31, the following table
     * describes the minimum required output stream configurations based on the hardware level
     * ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL android.info.supportedHardwareLevel}):</p>
     * <table>
     * <thead>
     * <tr>
@@ -2574,10 +2574,13 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri
     * </tr>
     * </tbody>
     * </table>
     * <p>Starting from Android 12, the camera device may not support JPEG sizes smaller than the
     * minimum of 1080p and the camera sensor active array size. The requirements for
     * IMPLEMENTATION_DEFINED and YUV_420_888 stay the same. This new minimum required output
     * stream configurations are illustrated by the table below:</p>
     * <p>For applications targeting SDK version 31 or newer, if the mobile device declares to be
     * {@link android.os.Build.VERSION_CDOES.MEDIA_PERFORMANCE_CLASS media performance class} S,
     * the primary camera devices (first rear/front camera in the camera ID list) will not
     * support JPEG sizes smaller than 1080p. If the application configures a JPEG stream
     * smaller than 1080p, the camera device will round up the JPEG image size to at least
     * 1080p. The requirements for IMPLEMENTATION_DEFINED and YUV_420_888 stay the same.
     * This new minimum required output stream configurations are illustrated by the table below:</p>
     * <table>
     * <thead>
     * <tr>
@@ -2644,6 +2647,10 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri
     * </tr>
     * </tbody>
     * </table>
     * <p>For applications targeting SDK version 31 or newer, if the mobile device doesn't declare
     * to be media performance class S, or if the camera device isn't a primary rear/front
     * camera, the minimum required output stream configurations are the same as for applications
     * targeting SDK version older than 31.</p>
     * <p>Refer to {@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES android.request.availableCapabilities} for additional
     * mandatory stream configurations on a per-capability basis.</p>
     * <p>Exception on 176x144 (QCIF) resolution: camera devices usually have a fixed capability for
+9 −7
Original line number Diff line number Diff line
@@ -217,7 +217,7 @@ public final class CameraManager {
            @NonNull Map<String, SessionConfiguration> cameraIdAndSessionConfig)
            throws CameraAccessException {
        return CameraManagerGlobal.get().isConcurrentSessionConfigurationSupported(
                cameraIdAndSessionConfig);
                cameraIdAndSessionConfig, mContext.getApplicationInfo().targetSdkVersion);
    }

    /**
@@ -413,7 +413,8 @@ public final class CameraManager {
        try {
            for (String physicalCameraId : physicalCameraIds) {
                CameraMetadataNative physicalCameraInfo =
                        cameraService.getCameraCharacteristics(physicalCameraId);
                        cameraService.getCameraCharacteristics(physicalCameraId,
                                mContext.getApplicationInfo().targetSdkVersion);
                StreamConfiguration[] configs = physicalCameraInfo.get(
                        CameraCharacteristics.
                                SCALER_PHYSICAL_CAMERA_MULTI_RESOLUTION_STREAM_CONFIGURATIONS);
@@ -472,7 +473,8 @@ public final class CameraManager {
            try {
                Size displaySize = getDisplaySize();

                CameraMetadataNative info = cameraService.getCameraCharacteristics(cameraId);
                CameraMetadataNative info = cameraService.getCameraCharacteristics(cameraId,
                        mContext.getApplicationInfo().targetSdkVersion);
                try {
                    info.setCameraId(Integer.parseInt(cameraId));
                } catch (NumberFormatException e) {
@@ -590,7 +592,7 @@ public final class CameraManager {
                }
                cameraUser = cameraService.connectDevice(callbacks, cameraId,
                    mContext.getOpPackageName(),  mContext.getAttributionTag(), uid,
                    oomScoreOffset);
                    oomScoreOffset, mContext.getApplicationInfo().targetSdkVersion);
            } catch (ServiceSpecificException e) {
                if (e.errorCode == ICameraService.ERROR_DEPRECATED_HAL) {
                    throw new AssertionError("Should've gone down the shim path");
@@ -1613,8 +1615,8 @@ public final class CameraManager {
        }

        public boolean isConcurrentSessionConfigurationSupported(
                @NonNull Map<String, SessionConfiguration> cameraIdsAndSessionConfigurations)
                throws CameraAccessException {
                @NonNull Map<String, SessionConfiguration> cameraIdsAndSessionConfigurations,
                int targetSdkVersion) throws CameraAccessException {

            if (cameraIdsAndSessionConfigurations == null) {
                throw new IllegalArgumentException("cameraIdsAndSessionConfigurations was null");
@@ -1650,7 +1652,7 @@ public final class CameraManager {
                }
                try {
                    return mCameraService.isConcurrentSessionConfigurationSupported(
                            cameraIdsAndConfigs);
                            cameraIdsAndConfigs, targetSdkVersion);
                } catch (ServiceSpecificException e) {
                   throwAsPublicException(e);
                } catch (RemoteException e) {
+3 −2
Original line number Diff line number Diff line
@@ -566,8 +566,9 @@ static jint android_hardware_Camera_native_setup(JNIEnv *env, jobject thiz,
    env->ReleaseStringChars(clientPackageName,
                            reinterpret_cast<const jchar*>(rawClientName));

    sp<Camera> camera =
            Camera::connect(cameraId, clientName, Camera::USE_CALLING_UID, Camera::USE_CALLING_PID);
    int targetSdkVersion = android_get_application_target_sdk_version();
    sp<Camera> camera = Camera::connect(cameraId, clientName, Camera::USE_CALLING_UID,
                                        Camera::USE_CALLING_PID, targetSdkVersion);
    if (camera == NULL) {
        return -EACCES;
    }
+4 −2
Original line number Diff line number Diff line
@@ -158,7 +158,8 @@ public class CameraBinderTest extends AndroidTestCase {
            ICamera cameraUser = mUtils.getCameraService()
                    .connect(dummyCallbacks, cameraId, clientPackageName,
                            ICameraService.USE_CALLING_UID,
                            ICameraService.USE_CALLING_PID);
                            ICameraService.USE_CALLING_PID,
                            getContext().getApplicationInfo().targetSdkVersion);
            assertNotNull(String.format("Camera %s was null", cameraId), cameraUser);

            Log.v(TAG, String.format("Camera %s connected", cameraId));
@@ -262,7 +263,8 @@ public class CameraBinderTest extends AndroidTestCase {
                    mUtils.getCameraService().connectDevice(
                        dummyCallbacks, String.valueOf(cameraId),
                        clientPackageName, clientAttributionTag,
                        ICameraService.USE_CALLING_UID, 0 /*oomScoreOffset*/);
                        ICameraService.USE_CALLING_UID, 0 /*oomScoreOffset*/,
                        getContext().getApplicationInfo().targetSdkVersion);
            assertNotNull(String.format("Camera %s was null", cameraId), cameraUser);

            Log.v(TAG, String.format("Camera %s connected", cameraId));
+3 −2
Original line number Diff line number Diff line
@@ -244,7 +244,7 @@ public class CameraDeviceBinderTest extends AndroidTestCase {

        mCameraUser = mUtils.getCameraService().connectDevice(mMockCb, mCameraId,
                clientPackageName, clientAttributionTag, ICameraService.USE_CALLING_UID,
                /*oomScoreOffset*/0);
                /*oomScoreOffset*/0, getContext().getApplicationInfo().targetSdkVersion);
        assertNotNull(String.format("Camera %s was null", mCameraId), mCameraUser);
        mHandlerThread = new HandlerThread(TAG);
        mHandlerThread.start();
@@ -416,7 +416,8 @@ public class CameraDeviceBinderTest extends AndroidTestCase {

    @SmallTest
    public void testCameraCharacteristics() throws RemoteException {
        CameraMetadataNative info = mUtils.getCameraService().getCameraCharacteristics(mCameraId);
        CameraMetadataNative info = mUtils.getCameraService().getCameraCharacteristics(mCameraId,
                getContext().getApplicationInfo().targetSdkVersion);

        assertFalse(info.isEmpty());
        assertNotNull(info.get(CameraCharacteristics.SCALER_AVAILABLE_FORMATS));