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

Commit 6d45db87 authored by Emilian Peev's avatar Emilian Peev
Browse files

Camera: Check for rotate and crop support during connect

Rotate and crop related service proxy queries can
introduce binder delays.
Check whether rotate and crop is supported before
trying to configure any overrides when clients are
connecting to a particular camera.
Additionally do the same check for the auto frame
override as well.

Bug: 320388288
Test: Camera CTS,
Manual using camera application

Change-Id: Id4e3cc2593aa6b1f8c39d4e8da4ef65a275168b7
parent dbff6b4c
Loading
Loading
Loading
Loading
+55 −29
Original line number Diff line number Diff line
@@ -2256,6 +2256,22 @@ Status CameraService::connectHelper(const sp<CALLBACK>& cameraCb, const std::str
        // Enable/disable camera service watchdog
        client->setCameraServiceWatchdog(mCameraServiceWatchdogEnabled);

        CameraMetadata chars;
        bool rotateAndCropSupported = true;
        err = mCameraProviderManager->getCameraCharacteristics(cameraId, overrideForPerfClass,
                &chars, overrideToPortrait);
        if (err == OK) {
            auto availableRotateCropEntry = chars.find(
                    ANDROID_SCALER_AVAILABLE_ROTATE_AND_CROP_MODES);
            if (availableRotateCropEntry.count <= 1) {
                rotateAndCropSupported = false;
            }
        } else {
            ALOGE("%s: Unable to query static metadata for camera %s: %s (%d)", __FUNCTION__,
                    cameraId.c_str(), strerror(-err), err);
        }

        if (rotateAndCropSupported) {
            // Set rotate-and-crop override behavior
            if (mOverrideRotateAndCropMode != ANDROID_SCALER_ROTATE_AND_CROP_AUTO) {
                client->setRotateAndCropOverride(mOverrideRotateAndCropMode);
@@ -2281,7 +2297,16 @@ Status CameraService::connectHelper(const sp<CALLBACK>& cameraCb, const std::str
                    mCameraServiceProxyWrapper->getRotateAndCropOverride(
                        clientPackageName, facing, multiuser_get_user_id(clientUid)));
            }
        }

        bool autoframingSupported = true;
        auto availableAutoframingEntry = chars.find(ANDROID_CONTROL_AUTOFRAMING_AVAILABLE);
        if ((availableAutoframingEntry.count == 1) && (availableAutoframingEntry.data.u8[0] ==
                    ANDROID_CONTROL_AUTOFRAMING_AVAILABLE_FALSE)) {
            autoframingSupported = false;
        }

        if (autoframingSupported) {
            // Set autoframing override behaviour
            if (mOverrideAutoframingMode != ANDROID_CONTROL_AUTOFRAMING_AUTO) {
                client->setAutoframingOverride(mOverrideAutoframingMode);
@@ -2290,6 +2315,7 @@ Status CameraService::connectHelper(const sp<CALLBACK>& cameraCb, const std::str
                    mCameraServiceProxyWrapper->getAutoframingOverride(
                        clientPackageName));
            }
        }

        // Set camera muting behavior
        bool isCameraPrivacyEnabled =