Do not startPeriodTransition for OFF displays

Inspired by discussion in Ida666af9a3a9b2e940c1f861ce3b765f67738f1f.
resyncAllToHardwareVsync calls resyncToHardwareVsyncLocked for *all*
physical displays, even if they are turned off. This can be seen in
dumpsys - for example, on a two-display device on which only one display
has turned on since boot, mPeriodConfirmationInProgress may be set to
1 (true) for the display that is off.

Correct this by checking Scheduler's record of the display's PowerMode.
Skip resyncToHardwareVsyncLocked if the display is OFF. (This matches
Scheduler::onHardwareVsyncRequest's decision of whether to call the
mSchedulerCallback's requestHardwareVsync.) This prevents attempting to
start a period transition, as well as making hardware VSYNCs allowed.

Bug: 255601557
Test: adb shell dumpsys SurfaceFlinger --vsync
Test: atest libsurfaceflinger_unittest:SchedulerTest
Change-Id: I88e7451622c259056d26748c64fcaa0bdcb836b8
diff --git a/services/surfaceflinger/Scheduler/Scheduler.cpp b/services/surfaceflinger/Scheduler/Scheduler.cpp
index af9fc70..6eea7f1 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.cpp
+++ b/services/surfaceflinger/Scheduler/Scheduler.cpp
@@ -510,8 +510,11 @@
     std::scoped_lock lock(mDisplayLock);
     ftl::FakeGuard guard(kMainThreadContext);
 
-    for (const auto& [id, _] : mDisplays) {
-        resyncToHardwareVsyncLocked(id, allowToEnable);
+    for (const auto& [id, display] : mDisplays) {
+        if (display.powerMode != hal::PowerMode::OFF ||
+            !FlagManager::getInstance().multithreaded_present()) {
+            resyncToHardwareVsyncLocked(id, allowToEnable);
+        }
     }
 }