DO NOT MERGE libcameraservice: Provide flag for overriding camera output to portrait.
Apps commonly do not handle landscape orientation cameras correctly. In
order to prevent stretching and rotation issues in these apps, this
patch adds a flag to override the behavior of these landscape cameras
to produce a portrait image instead by changing the SENSOR_ORIENTATION
reported by CameraCharacteristics and applying a 90 degree rotate and
crop.
Change-Id: I64ed52812326edc11f1cdb6bfbdbe75fcb8b1fb8
Bug: 250678880
Test: Ran on foldable device with several camera apps to verify behavior.
diff --git a/services/camera/libcameraservice/device3/Camera3Device.h b/services/camera/libcameraservice/device3/Camera3Device.h
index bcb7695..1a21c12 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.h
+++ b/services/camera/libcameraservice/device3/Camera3Device.h
@@ -82,7 +82,8 @@
friend class AidlCamera3Device;
public:
- explicit Camera3Device(const String8& id, bool overrideForPerfClass, bool legacyClient = false);
+ explicit Camera3Device(const String8& id, bool overrideForPerfClass, bool overrideToPortrait,
+ bool legacyClient = false);
virtual ~Camera3Device();
// Delete and optionally close native handles and clear the input vector afterward
@@ -788,7 +789,8 @@
sp<HalInterface> interface,
const Vector<int32_t>& sessionParamKeys,
bool useHalBufManager,
- bool supportCameraMute);
+ bool supportCameraMute,
+ bool overrideToPortrait);
~RequestThread();
void setNotificationListener(wp<NotificationListener> listener);
@@ -1065,6 +1067,7 @@
const bool mUseHalBufManager;
const bool mSupportCameraMute;
+ const bool mOverrideToPortrait;
};
virtual sp<RequestThread> createNewRequestThread(wp<Camera3Device> /*parent*/,
@@ -1072,7 +1075,8 @@
sp<HalInterface> /*interface*/,
const Vector<int32_t>& /*sessionParamKeys*/,
bool /*useHalBufManager*/,
- bool /*supportCameraMute*/) = 0;
+ bool /*supportCameraMute*/,
+ bool /*overrideToPortrait*/) = 0;
sp<RequestThread> mRequestThread;
@@ -1342,6 +1346,10 @@
// performance class.
bool mOverrideForPerfClass;
+ // Whether the camera framework overrides the device characteristics for
+ // app compatibility reasons.
+ bool mOverrideToPortrait;
+
// The current minimum expected frame duration based on AE_TARGET_FPS_RANGE
nsecs_t mMinExpectedDuration = 0;
// Whether the camera device runs at fixed frame rate based on AE_MODE and