Revert "Create a VsyncSchedule per display"

This reverts commit 31d41415101ff3483ce1cc5a9c2ef322490a05bd.

Conflicts:
    services/surfaceflinger/Scheduler/EventThread.cpp
    services/surfaceflinger/SurfaceFlinger.cpp

Bug: 267562341
Test: ARC Regression Dashboard
Change-Id: I0757a7df540fad316b2db42e4c77f1c73bc49420
diff --git a/services/surfaceflinger/Scheduler/VsyncSchedule.h b/services/surfaceflinger/Scheduler/VsyncSchedule.h
index ffb7ad5..173b1d0 100644
--- a/services/surfaceflinger/Scheduler/VsyncSchedule.h
+++ b/services/surfaceflinger/Scheduler/VsyncSchedule.h
@@ -19,10 +19,8 @@
 #include <memory>
 #include <string>
 
-#include <ftl/enum.h>
 #include <scheduler/Features.h>
 #include <scheduler/Time.h>
-#include <ui/DisplayId.h>
 
 namespace android {
 class EventThreadTest;
@@ -34,8 +32,6 @@
 
 namespace android::scheduler {
 
-struct ISchedulerCallback;
-
 // TODO(b/185535769): Rename classes, and remove aliases.
 class VSyncDispatch;
 class VSyncTracker;
@@ -47,7 +43,8 @@
 // Schedule that synchronizes to hardware VSYNC of a physical display.
 class VsyncSchedule {
 public:
-    VsyncSchedule(PhysicalDisplayId, FeatureFlags);
+    explicit VsyncSchedule(FeatureFlags);
+    VsyncSchedule(VsyncSchedule&&);
     ~VsyncSchedule();
 
     Period period() const;
@@ -58,71 +55,30 @@
     VsyncTracker& getTracker() { return *mTracker; }
     VsyncController& getController() { return *mController; }
 
-    // TODO(b/185535769): Once these are hidden behind the API, they may no
-    // longer need to be shared_ptrs.
-    using DispatchPtr = std::shared_ptr<VsyncDispatch>;
-    using TrackerPtr = std::shared_ptr<VsyncTracker>;
-
     // TODO(b/185535769): Remove once VsyncSchedule owns all registrations.
-    DispatchPtr getDispatch() { return mDispatch; }
+    VsyncDispatch& getDispatch() { return *mDispatch; }
 
     void dump(std::string&) const;
 
-    // Turn on hardware vsyncs, unless mHwVsyncState is Disallowed, in which
-    // case this call is ignored.
-    void enableHardwareVsync(ISchedulerCallback&) EXCLUDES(mHwVsyncLock);
-
-    // Disable hardware vsyncs. If `disallow` is true, future calls to
-    // enableHardwareVsync are ineffective until allowHardwareVsync is called.
-    void disableHardwareVsync(ISchedulerCallback&, bool disallow) EXCLUDES(mHwVsyncLock);
-
-    // Restore the ability to enable hardware vsync.
-    void allowHardwareVsync() EXCLUDES(mHwVsyncLock);
-
-    // If true, enableHardwareVsync can enable hardware vsync (if not already
-    // enabled). If false, enableHardwareVsync does nothing.
-    bool isHardwareVsyncAllowed() const EXCLUDES(mHwVsyncLock);
-
-protected:
-    using ControllerPtr = std::unique_ptr<VsyncController>;
-
-    // For tests.
-    VsyncSchedule(PhysicalDisplayId, TrackerPtr, DispatchPtr, ControllerPtr);
-
 private:
     friend class TestableScheduler;
     friend class android::EventThreadTest;
     friend class android::fuzz::SchedulerFuzzer;
 
-    static TrackerPtr createTracker(PhysicalDisplayId);
-    static DispatchPtr createDispatch(TrackerPtr);
-    static ControllerPtr createController(PhysicalDisplayId, VsyncTracker&, FeatureFlags);
+    using TrackerPtr = std::unique_ptr<VsyncTracker>;
+    using DispatchPtr = std::unique_ptr<VsyncDispatch>;
+    using ControllerPtr = std::unique_ptr<VsyncController>;
 
-    mutable std::mutex mHwVsyncLock;
-    enum class HwVsyncState {
-        // Hardware vsyncs are currently enabled.
-        Enabled,
+    // For tests.
+    VsyncSchedule(TrackerPtr, DispatchPtr, ControllerPtr);
 
-        // Hardware vsyncs are currently disabled. They can be enabled by a call
-        // to `enableHardwareVsync`.
-        Disabled,
-
-        // Hardware vsyncs are not currently allowed (e.g. because the display
-        // is off).
-        Disallowed,
-
-        ftl_last = Disallowed,
-    };
-    HwVsyncState mHwVsyncState GUARDED_BY(mHwVsyncLock) = HwVsyncState::Disallowed;
-
-    // The last state, which may be the current state, or the state prior to setting to Disallowed.
-    HwVsyncState mLastHwVsyncState GUARDED_BY(mHwVsyncLock) = HwVsyncState::Disabled;
+    static TrackerPtr createTracker();
+    static DispatchPtr createDispatch(VsyncTracker&);
+    static ControllerPtr createController(VsyncTracker&, FeatureFlags);
 
     class PredictedVsyncTracer;
     using TracerPtr = std::unique_ptr<PredictedVsyncTracer>;
 
-    const PhysicalDisplayId mId;
-
     // Effectively const except in move constructor.
     TrackerPtr mTracker;
     DispatchPtr mDispatch;