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

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

Merge "Camera: Enable the rotate&crop heuristics in the legacy shim layer"...

Merge "Camera: Enable the rotate&crop heuristics in the legacy shim layer" into tm-dev am: ba81ad85

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



Change-Id: I658b7438aa6ebd468f37f054f66588eb0935abb4
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents ab90214d ba81ad85
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -1893,8 +1893,7 @@ 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) {

        } else {
          client->setRotateAndCropOverride(
              CameraServiceProxyWrapper::getRotateAndCropOverride(
                  clientPackageName, facing, multiuser_get_user_id(clientUid)));
@@ -2432,7 +2431,7 @@ Status CameraService::notifyDisplayConfigurationChange() {
    for (auto& current : clients) {
        if (current != nullptr) {
            const auto basicClient = current->getValue();
            if (basicClient.get() != nullptr && basicClient->canCastToApiClient(API_2)) {
            if (basicClient.get() != nullptr) {
              basicClient->setRotateAndCropOverride(
                  CameraServiceProxyWrapper::getRotateAndCropOverride(
                      basicClient->getPackageName(),
+29 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include <utils/Log.h>
#include <utils/Trace.h>

#include <camera/CameraUtils.h>
#include <cutils/properties.h>
#include <gui/Surface.h>
#include <android/hardware/camera2/ICameraDeviceCallbacks.h>
@@ -33,6 +34,7 @@
#include "api1/client2/CaptureSequencer.h"
#include "api1/client2/CallbackProcessor.h"
#include "api1/client2/ZslProcessor.h"
#include "device3/RotateAndCropMapper.h"
#include "utils/CameraThreadState.h"
#include "utils/CameraServiceProxyWrapper.h"

@@ -68,6 +70,10 @@ Camera2Client::Camera2Client(const sp<CameraService>& cameraService,
{
    ATRACE_CALL();

    mRotateAndCropMode = ANDROID_SCALER_ROTATE_AND_CROP_NONE;
    mRotateAndCropIsSupported = false;
    mRotateAndCropPreviewTransform = 0;

    SharedParameters::Lock l(mParameters);
    l.mParameters.state = Parameters::DISCONNECTED;
}
@@ -116,6 +122,14 @@ status_t Camera2Client::initializeImpl(TProviderPtr providerPtr, const String8&
        l.mParameters.isDeviceZslSupported = isZslEnabledInStillTemplate();
    }

    const CameraMetadata& staticInfo = mDevice->info();
    mRotateAndCropIsSupported = camera3::RotateAndCropMapper::isNeeded(&staticInfo);
    // The 'mRotateAndCropMode' value only accounts for the necessary adjustment
    // when the display rotates. The sensor orientation still needs to be calculated
    // and applied similar to the Camera2 path.
    CameraUtils::getRotationTransform(staticInfo, OutputConfiguration::MIRROR_MODE_AUTO,
            &mRotateAndCropPreviewTransform);

    String8 threadName;

    mStreamingProcessor = new StreamingProcessor(this);
@@ -1676,6 +1690,11 @@ status_t Camera2Client::commandSetDisplayOrientationL(int degrees) {
        return BAD_VALUE;
    }
    SharedParameters::Lock l(mParameters);
    if (mRotateAndCropMode != ANDROID_SCALER_ROTATE_AND_CROP_NONE) {
        ALOGI("%s: Rotate and crop set to: %d, skipping display orientation!", __FUNCTION__,
                mRotateAndCropMode);
        transform = mRotateAndCropPreviewTransform;
    }
    if (transform != l.mParameters.previewTransform &&
            getPreviewStreamId() != NO_STREAM) {
        mDevice->setStreamTransform(getPreviewStreamId(), transform);
@@ -2297,6 +2316,16 @@ int32_t Camera2Client::getGlobalAudioRestriction() {
status_t Camera2Client::setRotateAndCropOverride(uint8_t rotateAndCrop) {
    if (rotateAndCrop > ANDROID_SCALER_ROTATE_AND_CROP_AUTO) return BAD_VALUE;

    {
        Mutex::Autolock icl(mBinderSerializationLock);
        if (mRotateAndCropIsSupported) {
            mRotateAndCropMode = rotateAndCrop;
        } else {
            mRotateAndCropMode = ANDROID_SCALER_ROTATE_AND_CROP_NONE;
            return OK;
        }
    }

    return mDevice->setRotateAndCropAutoBehavior(
        static_cast<camera_metadata_enum_android_scaler_rotate_and_crop_t>(rotateAndCrop));
}
+7 −0
Original line number Diff line number Diff line
@@ -238,6 +238,13 @@ private:
    status_t initializeImpl(TProviderPtr providerPtr, const String8& monitorTags);

    bool isZslEnabledInStillTemplate();
    // The current rotate & crop mode passed by camera service
    uint8_t mRotateAndCropMode;
    // Contains the preview stream transformation that would normally be applied
    // when the display rotation is 0
    int mRotateAndCropPreviewTransform;
    // Flag indicating camera device support for the rotate & crop interface
    bool mRotateAndCropIsSupported;

    mutable Mutex mLatestRequestMutex;
    Condition mLatestRequestSignal;