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

Commit 5368ebf6 authored by Emilian Peev's avatar Emilian Peev
Browse files

Camera: Query the rotate&crop compensation value

Instead of checking whether rotate&crop compensation is needed,
let the service proxy estimate the specific value that needs
to be applied.

Bug: 202567080
Test: Manual using camera applications,
Camera CTS

Change-Id: I59f44e74a8214b04e417153f52d95fec792e35b7
parent cf173b84
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -37,8 +37,11 @@ interface ICameraServiceProxy
    oneway void notifyCameraState(in CameraSessionStats cameraSessionStats);

    /**
     * Reports whether the top activity needs a rotate and crop override.
     * Returns the necessary rotate and crop override for the top activity which
     * will be one of ({@link android.hardware.camera2.CameraMetadata#SCALER_ROTATE_AND_CROP_NONE},
     * {@link android.hardware.camera2.CameraMetadata#SCALER_ROTATE_AND_CROP_90},
     * {@link android.hardware.camera2.CameraMetadata#SCALER_ROTATE_AND_CROP_180},
     * {@link android.hardware.camera2.CameraMetadata#SCALER_ROTATE_AND_CROP_270}).
     */
    boolean isRotateAndCropOverrideNeeded(String packageName, int sensorOrientation,
            int lensFacing);
    int getRotateAndCropOverride(String packageName, int lensFacing);
}
+6 −11
Original line number Diff line number Diff line
@@ -1834,10 +1834,9 @@ Status CameraService::connectHelper(const sp<CALLBACK>& cameraCb, const String8&
        // Set rotate-and-crop override behavior
        if (mOverrideRotateAndCropMode != ANDROID_SCALER_ROTATE_AND_CROP_AUTO) {
            client->setRotateAndCropOverride(mOverrideRotateAndCropMode);
        } else if ((effectiveApiLevel == API_2) &&
                CameraServiceProxyWrapper::isRotateAndCropOverrideNeeded(clientPackageName,
                        orientation, facing) ) {
            client->setRotateAndCropOverride(ANDROID_SCALER_ROTATE_AND_CROP_90);
        } else if (effectiveApiLevel == API_2) {
            client->setRotateAndCropOverride(CameraServiceProxyWrapper::getRotateAndCropOverride(
                    clientPackageName, facing));
        }

        // Set camera muting behavior
@@ -2218,13 +2217,9 @@ Status CameraService::notifyDisplayConfigurationChange() {
        if (current != nullptr) {
            const auto basicClient = current->getValue();
            if (basicClient.get() != nullptr && basicClient->canCastToApiClient(API_2)) {
                if (CameraServiceProxyWrapper::isRotateAndCropOverrideNeeded(
                            basicClient->getPackageName(), basicClient->getCameraOrientation(),
                            basicClient->getCameraFacing())) {
                    basicClient->setRotateAndCropOverride(ANDROID_SCALER_ROTATE_AND_CROP_90);
                } else {
                    basicClient->setRotateAndCropOverride(ANDROID_SCALER_ROTATE_AND_CROP_NONE);
                }
                basicClient->setRotateAndCropOverride(
                        CameraServiceProxyWrapper::getRotateAndCropOverride(
                            basicClient->getPackageName(), basicClient->getCameraFacing()));
            }
        }
    }
+3 −5
Original line number Diff line number Diff line
@@ -120,13 +120,11 @@ void CameraServiceProxyWrapper::pingCameraServiceProxy() {
    proxyBinder->pingForUserUpdate();
}

bool CameraServiceProxyWrapper::isRotateAndCropOverrideNeeded(
        String16 packageName, int sensorOrientation, int lensFacing) {
int CameraServiceProxyWrapper::getRotateAndCropOverride(String16 packageName, int lensFacing) {
    sp<ICameraServiceProxy> proxyBinder = getCameraServiceProxy();
    if (proxyBinder == nullptr) return true;
    bool ret = true;
    auto status = proxyBinder->isRotateAndCropOverrideNeeded(packageName, sensorOrientation,
            lensFacing, &ret);
    int ret = 0;
    auto status = proxyBinder->getRotateAndCropOverride(packageName, lensFacing, &ret);
    if (!status.isOk()) {
        ALOGE("%s: Failed during top activity orientation query: %s", __FUNCTION__,
                status.exceptionMessage().c_str());
+2 −3
Original line number Diff line number Diff line
@@ -91,9 +91,8 @@ public:
    // Ping camera service proxy for user update
    static void pingCameraServiceProxy();

    // Check whether the current top activity needs a rotate and crop override.
    static bool isRotateAndCropOverrideNeeded(String16 packageName, int sensorOrientation,
            int lensFacing);
    // Return the current top activity rotate and crop override.
    static int getRotateAndCropOverride(String16 packageName, int lensFacing);
};

} // android