SF: Hook up VSYNC injection to Scheduler

This CL refactors VSYNC injection to interface with the Scheduler API,
and removes otherwise unused EventThread members.

Bug: 128863962
Test: sffakehwc_test
Change-Id: I2ba143bb78baf3e66a47b90163eacf0d0e431124
diff --git a/services/surfaceflinger/Scheduler/Scheduler.h b/services/surfaceflinger/Scheduler/Scheduler.h
index 0c8c335..a5971fe 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.h
+++ b/services/surfaceflinger/Scheduler/Scheduler.h
@@ -36,6 +36,7 @@
 
 class DispSync;
 class FenceTime;
+class InjectVSyncSource;
 struct DisplayStateInfo;
 
 class Scheduler {
@@ -63,7 +64,6 @@
     sp<IDisplayEventConnection> createDisplayEventConnection(ConnectionHandle,
                                                              ISurfaceComposer::ConfigChanged);
 
-    EventThread* getEventThread(ConnectionHandle);
     sp<EventThreadConnection> getEventConnection(ConnectionHandle);
 
     void onHotplugReceived(ConnectionHandle, PhysicalDisplayId, bool connected);
@@ -77,6 +77,12 @@
 
     void getDisplayStatInfo(DisplayStatInfo* stats);
 
+    // Returns injector handle if injection has toggled, or an invalid handle otherwise.
+    ConnectionHandle enableVSyncInjection(bool enable);
+
+    // Returns false if injection is disabled.
+    bool injectVSync(nsecs_t when);
+
     void enableHardwareVsync();
     void disableHardwareVsync(bool makeUnavailable);
 
@@ -138,12 +144,10 @@
     Scheduler(std::unique_ptr<DispSync>, std::unique_ptr<EventControlThread>,
               const scheduler::RefreshRateConfigs&);
 
-    // Creates a connection on the given EventThread and forwards the given callbacks.
-    std::unique_ptr<EventThread> makeEventThread(const char* connectionName, nsecs_t phaseOffsetNs,
-                                                 nsecs_t offsetThresholdForNextVsync,
-                                                 impl::EventThread::InterceptVSyncsCallback&&);
+    std::unique_ptr<VSyncSource> makePrimaryDispSyncSource(const char* name, nsecs_t phaseOffsetNs,
+                                                           nsecs_t offsetThresholdForNextVsync);
 
-    // Create a connection on the given EventThread and forward the resync callback.
+    // Create a connection on the given EventThread.
     ConnectionHandle createConnection(std::unique_ptr<EventThread>);
     sp<EventThreadConnection> createConnectionInternal(EventThread*,
                                                        ISurfaceComposer::ConfigChanged);
@@ -173,6 +177,10 @@
     ConnectionHandle::Id mNextConnectionHandleId = 0;
     std::unordered_map<ConnectionHandle, Connection> mConnections;
 
+    bool mInjectVSyncs = false;
+    InjectVSyncSource* mVSyncInjector = nullptr;
+    ConnectionHandle mInjectorConnectionHandle;
+
     std::mutex mHWVsyncLock;
     bool mPrimaryHWVsyncEnabled GUARDED_BY(mHWVsyncLock) = false;
     bool mHWVsyncAvailable GUARDED_BY(mHWVsyncLock) = false;