Disable ADPF CPU hints for SF unless active display is on

Currently AOD is bugged and does not always match refresh rate between
SF and HWC, which disrupts ADPF hint sessions in SF which are sensitive
to refresh rate (b/218066882). This patch disables ADPF CPU hints for
the AOD case until this issue is resolved.

Bug: b/240619471
Test: atest libsurfaceflinger_unittest:libsurfaceflinger_unittest.SurfaceFlingerPowerHintTest
Change-Id: I4fa617a108f14da9df278c4a449795363ec29cf3
Merged-In: I4fa617a108f14da9df278c4a449795363ec29cf3
(cherry picked from commit ba8d15a176ba57dfd692b8c98a7ad884b0d9260c)
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 8621d31..83ec4ec 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2085,7 +2085,11 @@
     }
 
     // Save this once per commit + composite to ensure consistency
-    mPowerHintSessionEnabled = mPowerAdvisor->usePowerHintSession();
+    // TODO (b/240619471): consider removing active display check once AOD is fixed
+    const auto activeDisplay =
+            FTL_FAKE_GUARD(mStateLock, getDisplayDeviceLocked(mActiveDisplayToken));
+    mPowerHintSessionEnabled = mPowerAdvisor->usePowerHintSession() && activeDisplay &&
+            activeDisplay->getPowerMode() == hal::PowerMode::ON;
     if (mPowerHintSessionEnabled) {
         const auto& display = FTL_FAKE_GUARD(mStateLock, getDefaultDisplayDeviceLocked()).get();
         // get stable vsync period from display mode