CameraService: Implement SCALER_ROTATE_AND_CROP_AUTO, part 1
When an app sets SCALER_ROTATE_AND_CROP to AUTO, the camera service
needs to select the right ROTATE_AND_CROP mode given the application
UI state at the moment, received from the window manager.
In addition, some of the metadata in the active array coordinate
system needs to be converted to/from the cropped+rotated coordinate
system to ensure roundtripping UI information works as before.
Also ensure that the available rotate and crop metadata field is
always available, with a value of NONE if nothing else.
This commit adds support for doing the coordinate transforms and
overriding AUTO to a concrete value; it does not wire up a connection
to another system service to receive the correct override value, but
does add a command to set the override value for all current camera
clients.
Test: New CTS tests pass, unit tests for RotateAndCropMapper pass
Bug: 134631897
Change-Id: Icc45530e2cfbaf838a1e4d04e4fd2aef8122e8e1
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index 8666b7b..01d6c8e 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -1731,6 +1731,11 @@
}
}
+ // Set rotate-and-crop override behavior
+ if (mOverrideRotateAndCropMode != ANDROID_SCALER_ROTATE_AND_CROP_AUTO) {
+ client->setRotateAndCropOverride(mOverrideRotateAndCropMode);
+ }
+
if (shimUpdateOnly) {
// If only updating legacy shim parameters, immediately disconnect client
mServiceLock.unlock();
@@ -3810,6 +3815,10 @@
return handleResetUidState(args, err);
} else if (args.size() >= 2 && args[0] == String16("get-uid-state")) {
return handleGetUidState(args, out, err);
+ } else if (args.size() >= 2 && args[0] == String16("set-rotate-and-crop")) {
+ return handleSetRotateAndCrop(args);
+ } else if (args.size() >= 1 && args[0] == String16("get-rotate-and-crop")) {
+ return handleGetRotateAndCrop(out);
} else if (args.size() == 1 && args[0] == String16("help")) {
printHelp(out);
return NO_ERROR;
@@ -3880,11 +3889,43 @@
}
}
+status_t CameraService::handleSetRotateAndCrop(const Vector<String16>& args) {
+ int rotateValue = atoi(String8(args[1]));
+ if (rotateValue < ANDROID_SCALER_ROTATE_AND_CROP_NONE ||
+ rotateValue > ANDROID_SCALER_ROTATE_AND_CROP_AUTO) return BAD_VALUE;
+ Mutex::Autolock lock(mServiceLock);
+
+ mOverrideRotateAndCropMode = rotateValue;
+
+ if (rotateValue == ANDROID_SCALER_ROTATE_AND_CROP_AUTO) return OK;
+
+ const auto clients = mActiveClientManager.getAll();
+ for (auto& current : clients) {
+ if (current != nullptr) {
+ const auto basicClient = current->getValue();
+ if (basicClient.get() != nullptr) {
+ basicClient->setRotateAndCropOverride(rotateValue);
+ }
+ }
+ }
+
+ return OK;
+}
+
+status_t CameraService::handleGetRotateAndCrop(int out) {
+ Mutex::Autolock lock(mServiceLock);
+
+ return dprintf(out, "rotateAndCrop override: %d\n", mOverrideRotateAndCropMode);
+}
+
status_t CameraService::printHelp(int out) {
return dprintf(out, "Camera service commands:\n"
" get-uid-state <PACKAGE> [--user USER_ID] gets the uid state\n"
" set-uid-state <PACKAGE> <active|idle> [--user USER_ID] overrides the uid state\n"
" reset-uid-state <PACKAGE> [--user USER_ID] clears the uid state override\n"
+ " set-rotate-and-crop <ROTATION> overrides the rotate-and-crop value for AUTO backcompat\n"
+ " Valid values 0=0 deg, 1=90 deg, 2=180 deg, 3=270 deg, 4=No override\n"
+ " get-rotate-and-crop returns the current override rotate-and-crop value\n"
" help print this message\n");
}