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

Commit aae38963 authored by Shuzhen Wang's avatar Shuzhen Wang
Browse files

Camera: Handle hidden physical camera without camcorder profile

For hidden physical sub-camera, if there is no camcorder profile,
use stream configuration map to figure out maximum recording size.

Test: RobustnessTest
Bug: 133819902
Change-Id: Ie0e76b51b1942b6fd3612c0b849a07bbb5d205e9
parent b8735359
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -857,8 +857,10 @@ public final class CameraManager {
     *
     * @param cameraId a non-{@code null} camera identifier
     * @return {@code true} if cameraId is a hidden physical camera device
     *
     * @hide
     */
    private boolean isHiddenPhysicalCamera(String cameraId) {
    public static boolean isHiddenPhysicalCamera(String cameraId) {
        try {
            ICameraService cameraService = CameraManagerGlobal.get().getCameraService();
            // If no camera service, no support
+10 −4
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.graphics.ImageFormat.Format;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraCharacteristics.Key;
import android.hardware.camera2.CameraDevice;
import android.hardware.camera2.CameraManager;
import android.hardware.camera2.CameraMetadata;
import android.hardware.camera2.params.StreamConfigurationMap;
import android.hardware.camera2.utils.HashCodeHelpers;
@@ -661,6 +662,7 @@ public final class MandatoryStreamCombination {
        private List<Integer> mCapabilities;
        private int mHwLevel, mCameraId;
        private StreamConfigurationMap mStreamConfigMap;
        private boolean mIsHiddenPhysicalCamera;

        private final Size kPreviewSizeBound = new Size(1920, 1088);

@@ -680,6 +682,8 @@ public final class MandatoryStreamCombination {
            mCapabilities = capabilities;
            mStreamConfigMap = sm;
            mHwLevel = hwLevel;
            mIsHiddenPhysicalCamera =
                    CameraManager.isHiddenPhysicalCamera(Integer.toString(mCameraId));
        }

        /**
@@ -893,8 +897,10 @@ public final class MandatoryStreamCombination {
            Size recordingMaxSize = new Size(0, 0);
            Size previewMaxSize = new Size(0, 0);
            Size vgaSize = new Size(640, 480);
            if (isExternalCamera()) {
                recordingMaxSize = getMaxExternalRecordingSize();
            // For external camera, or hidden physical camera, CamcorderProfile may not be
            // available, so get maximum recording size using stream configuration map.
            if (isExternalCamera() || mIsHiddenPhysicalCamera) {
                recordingMaxSize = getMaxCameraRecordingSize();
            } else {
                recordingMaxSize = getMaxRecordingSize();
            }
@@ -1123,12 +1129,12 @@ public final class MandatoryStreamCombination {
        }

        /**
         * Return the maximum supported video size for external cameras using data from
         * Return the maximum supported video size for cameras using data from
         * the stream configuration map.
         *
         * @return Maximum supported video size.
         */
        private @NonNull Size getMaxExternalRecordingSize() {
        private @NonNull Size getMaxCameraRecordingSize() {
            final Size FULLHD = new Size(1920, 1080);

            Size[] videoSizeArr = mStreamConfigMap.getOutputSizes(