Loading services/camera/libcameraservice/CameraService.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -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))); Loading Loading @@ -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(), Loading services/camera/libcameraservice/api1/Camera2Client.cpp +29 −0 Original line number Diff line number Diff line Loading @@ -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> Loading @@ -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" Loading Loading @@ -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; } Loading Loading @@ -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); Loading Loading @@ -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); Loading Loading @@ -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)); } Loading services/camera/libcameraservice/api1/Camera2Client.h +7 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading
services/camera/libcameraservice/CameraService.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -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))); Loading Loading @@ -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(), Loading
services/camera/libcameraservice/api1/Camera2Client.cpp +29 −0 Original line number Diff line number Diff line Loading @@ -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> Loading @@ -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" Loading Loading @@ -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; } Loading Loading @@ -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); Loading Loading @@ -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); Loading Loading @@ -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)); } Loading
services/camera/libcameraservice/api1/Camera2Client.h +7 −0 Original line number Diff line number Diff line Loading @@ -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; Loading