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/tests/unittests/TestableScheduler.h b/services/surfaceflinger/tests/unittests/TestableScheduler.h
index b036e99..2a1b88e 100644
--- a/services/surfaceflinger/tests/unittests/TestableScheduler.h
+++ b/services/surfaceflinger/tests/unittests/TestableScheduler.h
@@ -115,6 +115,15 @@
         Scheduler::setPacesetterDisplay(displayId);
     }
 
+    std::optional<hal::PowerMode> getDisplayPowerMode(PhysicalDisplayId id) {
+        ftl::FakeGuard guard1(kMainThreadContext);
+        ftl::FakeGuard guard2(mDisplayLock);
+        return mDisplays.get(id).transform(
+                [](const Display& display) { return display.powerMode; });
+    }
+
+    using Scheduler::resyncAllToHardwareVsync;
+
     auto& mutableAppConnectionHandle() { return mAppConnectionHandle; }
     auto& mutableLayerHistory() { return mLayerHistory; }
     auto& mutableAttachedChoreographers() { return mAttachedChoreographers; }