Merge "Camera: Connect activity resizing state to camera service" into sc-dev
diff --git a/camera/aidl/android/hardware/ICameraServiceProxy.aidl b/camera/aidl/android/hardware/ICameraServiceProxy.aidl
index d428b4e..bbb0289 100644
--- a/camera/aidl/android/hardware/ICameraServiceProxy.aidl
+++ b/camera/aidl/android/hardware/ICameraServiceProxy.aidl
@@ -35,4 +35,10 @@
* Update the status of a camera device.
*/
oneway void notifyCameraState(in CameraSessionStats cameraSessionStats);
+
+ /**
+ * Reports whether the top activity needs a rotate and crop override.
+ */
+ boolean isRotateAndCropOverrideNeeded(String packageName, int sensorOrientation,
+ int lensFacing);
}
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index 99d10d2..6cd20a1 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -743,7 +743,7 @@
return Status::ok();
}
-int CameraService::getDeviceVersion(const String8& cameraId, int* facing) {
+int CameraService::getDeviceVersion(const String8& cameraId, int* facing, int* orientation) {
ATRACE_CALL();
int deviceVersion = 0;
@@ -760,6 +760,9 @@
res = mCameraProviderManager->getCameraInfo(cameraId.string(), &info);
if (res != OK) return -1;
*facing = info.facing;
+ if (orientation) {
+ *orientation = info.orientation;
+ }
}
return deviceVersion;
@@ -1555,6 +1558,7 @@
sp<CLIENT> client = nullptr;
int facing = -1;
+ int orientation = 0;
bool isNdk = (clientPackageName.size() == 0);
{
// Acquire mServiceLock and prevent other clients from connecting
@@ -1620,7 +1624,7 @@
// give flashlight a chance to close devices if necessary.
mFlashlight->prepareDeviceOpen(cameraId);
- int deviceVersion = getDeviceVersion(cameraId, /*out*/&facing);
+ int deviceVersion = getDeviceVersion(cameraId, /*out*/&facing, /*out*/&orientation);
if (facing == -1) {
ALOGE("%s: Unable to get camera device \"%s\" facing", __FUNCTION__, cameraId.string());
return STATUS_ERROR_FMT(ERROR_INVALID_OPERATION,
@@ -1688,6 +1692,9 @@
// Set rotate-and-crop override behavior
if (mOverrideRotateAndCropMode != ANDROID_SCALER_ROTATE_AND_CROP_AUTO) {
client->setRotateAndCropOverride(mOverrideRotateAndCropMode);
+ } else if (CameraServiceProxyWrapper::isRotateAndCropOverrideNeeded(clientPackageName,
+ orientation, facing)) {
+ client->setRotateAndCropOverride(ANDROID_SCALER_ROTATE_AND_CROP_90);
}
// Set camera muting behavior
diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h
index dbfc6c3..092d916 100644
--- a/services/camera/libcameraservice/CameraService.h
+++ b/services/camera/libcameraservice/CameraService.h
@@ -213,7 +213,8 @@
/////////////////////////////////////////////////////////////////////
// CameraDeviceFactory functionality
- int getDeviceVersion(const String8& cameraId, int* facing = NULL);
+ int getDeviceVersion(const String8& cameraId, int* facing = nullptr,
+ int* orientation = nullptr);
/////////////////////////////////////////////////////////////////////
// Shared utilities
diff --git a/services/camera/libcameraservice/utils/CameraServiceProxyWrapper.cpp b/services/camera/libcameraservice/utils/CameraServiceProxyWrapper.cpp
index 0557fcc..76927c0 100644
--- a/services/camera/libcameraservice/utils/CameraServiceProxyWrapper.cpp
+++ b/services/camera/libcameraservice/utils/CameraServiceProxyWrapper.cpp
@@ -120,6 +120,21 @@
proxyBinder->pingForUserUpdate();
}
+bool CameraServiceProxyWrapper::isRotateAndCropOverrideNeeded(
+ String16 packageName, int sensorOrientation, int lensFacing) {
+ sp<ICameraServiceProxy> proxyBinder = getCameraServiceProxy();
+ if (proxyBinder == nullptr) return true;
+ bool ret = true;
+ auto status = proxyBinder->isRotateAndCropOverrideNeeded(packageName, sensorOrientation,
+ lensFacing, &ret);
+ if (!status.isOk()) {
+ ALOGE("%s: Failed during top activity orientation query: %s", __FUNCTION__,
+ status.exceptionMessage().c_str());
+ }
+
+ return ret;
+}
+
void CameraServiceProxyWrapper::updateProxyDeviceState(const CameraSessionStats& sessionStats) {
sp<ICameraServiceProxy> proxyBinder = getCameraServiceProxy();
if (proxyBinder == nullptr) return;
diff --git a/services/camera/libcameraservice/utils/CameraServiceProxyWrapper.h b/services/camera/libcameraservice/utils/CameraServiceProxyWrapper.h
index 9525935..ad9db68 100644
--- a/services/camera/libcameraservice/utils/CameraServiceProxyWrapper.h
+++ b/services/camera/libcameraservice/utils/CameraServiceProxyWrapper.h
@@ -90,6 +90,10 @@
// 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);
};
} // android