SF: Fix condition to activate display on power-on
Since [1], getDefaultDisplayDeviceLocked's fallback when the active
display is outdated is to return the primary display, not `nullptr`.
During the initial call to setPowerModeInternal, `activeDisplay` is
no longer `nullptr`, but the primary display.
After [2], onActiveDisplayChangedLocked is expected to be called for
the primary display during boot. This was not the case though, since
the DisplayDevice::setPowerMode() update precedes the DisplayDevice::
isPoweredOn() query.
Fix this by querying before updating. Also, clean up `nullptr` checks
around onActiveDisplayChangedLocked.
[1] If83c908446e5e5267dfcb15189a26b779d75b216
[2] I15e0f5a280e62baf6d4e6ea2748d95342e79ac44
Fixes: 260663220
Test: The leader display ID is logged during single-display boot.
Test: SetPowerModeInternalTest.designatesLeaderDisplay
Change-Id: I0d20ce7f7ab3f9e90ef1c72263b8166865486d62
diff --git a/services/surfaceflinger/tests/unittests/TestableScheduler.h b/services/surfaceflinger/tests/unittests/TestableScheduler.h
index 54c10c5..b8a6063 100644
--- a/services/surfaceflinger/tests/unittests/TestableScheduler.h
+++ b/services/surfaceflinger/tests/unittests/TestableScheduler.h
@@ -87,6 +87,10 @@
Scheduler::unregisterDisplay(displayId);
}
+ std::optional<PhysicalDisplayId> leaderDisplayId() const NO_THREAD_SAFETY_ANALYSIS {
+ return mLeaderDisplayId;
+ }
+
void setLeaderDisplay(PhysicalDisplayId displayId) {
ftl::FakeGuard guard(kMainThreadContext);
Scheduler::setLeaderDisplay(displayId);