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

Commit e23f1d90 authored by Emilian Peev's avatar Emilian Peev
Browse files

Camera: Only override rotate&crop for Camera2 clients

Legacy camera clients can and will use 'setDisplayOrientation'
to explicitly set a preview stream transformation depending on
the sensor orientation and the device rotation.
To maintain backward compatibility and honor the client
configuration, avoid overriding rotate&crop in case we have a
legacy client connection.
Additionally do not override rotate&crop for stream configurations
that include SurfaceView(HW_COMPOSER) outputs.

Test: Manual using camera application
Bug: 201005727
Change-Id: I3e32049bdd560724840780f96372c177ed2f4d20
parent b50402ed
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -1834,7 +1834,8 @@ 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 (CameraServiceProxyWrapper::isRotateAndCropOverrideNeeded(clientPackageName,
        } else if ((effectiveApiLevel == API_2) &&
                CameraServiceProxyWrapper::isRotateAndCropOverrideNeeded(clientPackageName,
                        orientation, facing) ) {
            client->setRotateAndCropOverride(ANDROID_SCALER_ROTATE_AND_CROP_90);
        }
@@ -2211,7 +2212,7 @@ Status CameraService::notifyDisplayConfigurationChange() {
    for (auto& current : clients) {
        if (current != nullptr) {
            const auto basicClient = current->getValue();
            if (basicClient.get() != nullptr) {
            if (basicClient.get() != nullptr && basicClient->canCastToApiClient(API_2)) {
                if (CameraServiceProxyWrapper::isRotateAndCropOverrideNeeded(
                            basicClient->getPackageName(), basicClient->getCameraOrientation(),
                            basicClient->getCameraFacing())) {
+20 −1
Original line number Diff line number Diff line
@@ -2677,6 +2677,7 @@ status_t Camera3Device::configureStreamsLocked(int operatingMode,
    }

    mGroupIdPhysicalCameraMap.clear();
    bool composerSurfacePresent = false;
    for (size_t i = 0; i < mOutputStreams.size(); i++) {

        // Don't configure bidi streams twice, nor add them twice to the list
@@ -2716,6 +2717,10 @@ status_t Camera3Device::configureStreamsLocked(int operatingMode,
            const String8& physicalCameraId = mOutputStreams[i]->getPhysicalCameraId();
            mGroupIdPhysicalCameraMap[streamGroupId].insert(physicalCameraId);
        }

        if (outputStream->usage & GraphicBuffer::USAGE_HW_COMPOSER) {
            composerSurfacePresent = true;
        }
    }

    config.streams = streams.editArray();
@@ -2783,6 +2788,8 @@ status_t Camera3Device::configureStreamsLocked(int operatingMode,
        }
    }

    mRequestThread->setComposerSurface(composerSurfacePresent);

    // Request thread needs to know to avoid using repeat-last-settings protocol
    // across configure_streams() calls
    if (notifyRequestThread) {
@@ -4179,6 +4186,7 @@ Camera3Device::RequestThread::RequestThread(wp<Camera3Device> parent,
        mCurrentAfTriggerId(0),
        mCurrentPreCaptureTriggerId(0),
        mRotateAndCropOverride(ANDROID_SCALER_ROTATE_AND_CROP_NONE),
        mComposerOutput(false),
        mCameraMute(ANDROID_SENSOR_TEST_PATTERN_MODE_OFF),
        mCameraMuteChanged(false),
        mRepeatingLastFrameNumber(
@@ -4829,7 +4837,11 @@ status_t Camera3Device::RequestThread::prepareHalRequests() {
        bool triggersMixedIn = (triggerCount > 0 || mPrevTriggers > 0);
        mPrevTriggers = triggerCount;

        bool rotateAndCropChanged = overrideAutoRotateAndCrop(captureRequest);
        // Do not override rotate&crop for stream configurations that include
        // SurfaceViews(HW_COMPOSER) output. The display rotation there will be
        // compensated by NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY
        bool rotateAndCropChanged = mComposerOutput ? false :
            overrideAutoRotateAndCrop(captureRequest);
        bool testPatternChanged = overrideTestPattern(captureRequest);

        // If the request is the same as last, or we had triggers now or last time or
@@ -5335,6 +5347,13 @@ status_t Camera3Device::RequestThread::setRotateAndCropAutoBehavior(
    return OK;
}

status_t Camera3Device::RequestThread::setComposerSurface(bool composerSurfacePresent) {
    ATRACE_CALL();
    Mutex::Autolock l(mTriggerMutex);
    mComposerOutput = composerSurfacePresent;
    return OK;
}

status_t Camera3Device::RequestThread::setCameraMute(int32_t muteMode) {
    ATRACE_CALL();
    Mutex::Autolock l(mTriggerMutex);
+2 −0
Original line number Diff line number Diff line
@@ -919,6 +919,7 @@ class Camera3Device :

        status_t setRotateAndCropAutoBehavior(
                camera_metadata_enum_android_scaler_rotate_and_crop_t rotateAndCropValue);
        status_t setComposerSurface(bool composerSurfacePresent);

        status_t setCameraMute(int32_t muteMode);

@@ -1071,6 +1072,7 @@ class Camera3Device :
        uint32_t           mCurrentAfTriggerId;
        uint32_t           mCurrentPreCaptureTriggerId;
        camera_metadata_enum_android_scaler_rotate_and_crop_t mRotateAndCropOverride;
        bool               mComposerOutput;
        int32_t            mCameraMute; // 0 = no mute, otherwise the TEST_PATTERN_MODE to use
        bool               mCameraMuteChanged;