SF backdoor for primary display hotplug
This is a backdoor for SurfaceFlinger which injects a hotplug
event for the primary display. This causes SF to deallocate and
reallocate the display state including framebuffers. From the
user perspective this should look like a noop because HWC will
return the same display properties.
Bug: 167670568
Test: adb shell service call SurfaceFlinger 1037
Change-Id: Ie52aac67571ed41c1a796797b7d7c54bcbdd9bdc
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 661cee9..6478497 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -5035,9 +5035,9 @@
code == IBinder::SYSPROPS_TRANSACTION) {
return OK;
}
- // Numbers from 1000 to 1036 are currently used for backdoors. The code
+ // Numbers from 1000 to 1037 are currently used for backdoors. The code
// in onTransact verifies that the user is root, and has access to use SF.
- if (code >= 1000 && code <= 1036) {
+ if (code >= 1000 && code <= 1037) {
ALOGV("Accessing SurfaceFlinger through backdoor code: %u", code);
return OK;
}
@@ -5379,6 +5379,23 @@
}
return NO_ERROR;
}
+ // Inject a hotplug connected event for the primary display. This will deallocate and
+ // reallocate the display state including framebuffers.
+ case 1037: {
+ const auto token = getInternalDisplayToken();
+
+ sp<DisplayDevice> display;
+ {
+ Mutex::Autolock lock(mStateLock);
+ display = getDisplayDeviceLocked(token);
+ }
+ const auto hwcId =
+ getHwComposer().fromPhysicalDisplayId(PhysicalDisplayId(*display->getId()));
+
+ onHotplugReceived(getBE().mComposerSequenceId, *hwcId, hal::Connection::CONNECTED);
+
+ return NO_ERROR;
+ }
}
}
return err;