SF: Simplify per-display refresh rate selection

Remove verbose, single-use helper functions/types to centralize the
selection logic and merge two passes. Avoid allocation and hashing.

Fix the algorithm to not choose a refresh rate based on total score
unless it is common to all displays, and not be thrown off by equal
scores.

Bug: 241285191
Test: libsurfaceflinger_unittest
Change-Id: I355dea767c6b564a04a51476f0cc235a1fceb879
diff --git a/services/surfaceflinger/Scheduler/Scheduler.h b/services/surfaceflinger/Scheduler/Scheduler.h
index 25fa714..6633b05 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.h
+++ b/services/surfaceflinger/Scheduler/Scheduler.h
@@ -33,11 +33,12 @@
 #include <ui/GraphicTypes.h>
 #pragma clang diagnostic pop // ignored "-Wconversion -Wextra"
 
-#include <DisplayDevice.h>
 #include <scheduler/Features.h>
 #include <scheduler/Time.h>
+#include <ui/DisplayId.h>
 
 #include "Display/DisplayMap.h"
+#include "DisplayDevice.h"
 #include "EventThread.h"
 #include "FrameRateOverrideMappings.h"
 #include "LayerHistory.h"
@@ -108,19 +109,6 @@
     ~ISchedulerCallback() = default;
 };
 
-// Holds the total score of the FPS and
-// number of displays the FPS is found in.
-struct AggregatedFpsScore {
-    float totalScore;
-    size_t numDisplays;
-};
-
-// Represents the RefreshRateRankings and GlobalSignals for the selected RefreshRateRankings.
-struct RefreshRateRankingsAndSignals {
-    std::vector<RefreshRateRanking> refreshRateRankings;
-    GlobalSignals globalSignals;
-};
-
 class Scheduler : android::impl::MessageQueue {
     using Impl = android::impl::MessageQueue;
 
@@ -132,6 +120,9 @@
     void setRefreshRateConfigs(std::shared_ptr<RefreshRateConfigs>)
             EXCLUDES(mRefreshRateConfigsLock);
 
+    void registerDisplay(sp<const DisplayDevice>);
+    void unregisterDisplay(PhysicalDisplayId);
+
     void run();
 
     void createVsyncSchedule(FeatureFlags);
@@ -257,9 +248,6 @@
         return mLayerHistory.getLayerFramerate(now, id);
     }
 
-    void registerDisplay(const sp<const DisplayDevice>&);
-    void unregisterDisplay(PhysicalDisplayId);
-
 private:
     friend class TestableScheduler;
 
@@ -293,10 +281,6 @@
     // Returns the best display mode per display.
     std::vector<DisplayModeConfig> getBestDisplayModeConfigs() const REQUIRES(mPolicyLock);
 
-    // Returns the list of DisplayModeConfigs per display for the chosenFps.
-    std::vector<DisplayModeConfig> getDisplayModeConfigsForTheChosenFps(
-            Fps chosenFps, const std::vector<RefreshRateRankingsAndSignals>&) const;
-
     GlobalSignals makeGlobalSignals() const REQUIRES(mPolicyLock);
 
     bool updateFrameRateOverrides(GlobalSignals, Fps displayRefreshRate) REQUIRES(mPolicyLock);
@@ -344,9 +328,7 @@
 
     mutable std::mutex mPolicyLock;
 
-    // Holds the Physical displays registered through the SurfaceFlinger, used for making
-    // the refresh rate selections.
-    display::PhysicalDisplayMap<PhysicalDisplayId, const sp<const DisplayDevice>> mDisplays;
+    display::PhysicalDisplayMap<PhysicalDisplayId, sp<const DisplayDevice>> mDisplays;
 
     struct Policy {
         // Policy for choosing the display mode.