SF: add display id to 1035 backdoor
Bug: 179593619
Test: adb shell service call SurfaceFlinger 1035 i32 <mode id> i64 <display id>
Change-Id: Ifc7fe51989c2315f2c935995fd981ace5260c9c4
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index e72fad0..24f6b37 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -5582,9 +5582,24 @@
const int modeId = data.readInt32();
mDebugDisplayModeSetByBackdoor = false;
- const auto displayId = getInternalDisplayId();
+ const auto displayId = [&]() -> std::optional<PhysicalDisplayId> {
+ uint64_t inputDisplayId = 0;
+ if (data.readUint64(&inputDisplayId) == NO_ERROR) {
+ const auto token = getPhysicalDisplayToken(
+ static_cast<PhysicalDisplayId>(inputDisplayId));
+ if (!token) {
+ ALOGE("No display with id: %" PRIu64, inputDisplayId);
+ return std::nullopt;
+ }
+
+ return std::make_optional<PhysicalDisplayId>(inputDisplayId);
+ }
+
+ return getInternalDisplayId();
+ }();
+
if (!displayId) {
- ALOGE("No internal display found.");
+ ALOGE("No display found");
return NO_ERROR;
}
@@ -6297,6 +6312,11 @@
"Can only set override policy on the primary display");
LOG_ALWAYS_FATAL_IF(!policy && !overridePolicy, "Can only clear the override policy");
+ if (mDebugDisplayModeSetByBackdoor) {
+ // ignore this request as mode is overridden by backdoor
+ return NO_ERROR;
+ }
+
if (!display->isPrimary()) {
// TODO(b/144711714): For non-primary displays we should be able to set an active mode
// as well. For now, just call directly to initiateModeChange but ideally
@@ -6323,11 +6343,6 @@
return NO_ERROR;
}
- if (mDebugDisplayModeSetByBackdoor) {
- // ignore this request as mode is overridden by backdoor
- return NO_ERROR;
- }
-
status_t setPolicyResult = overridePolicy
? mRefreshRateConfigs->setOverridePolicy(policy)
: mRefreshRateConfigs->setDisplayManagerPolicy(*policy);