SF: Fix VSYNC injection
Disabling VSYNC injection causes the main thread to destroy the injected
EventThreadConnection, while it might be accessed by a Binder thread via
MessageQueue::invalidate.
Also, fix injection itself:
- The EventThread did not dispatch injected events, falling back to
fake VSYNC after timeout.
- The MessageQueue would try listening to invalid FDs when enabling
injection more than once.
- Injection was not disabled after each test.
Finally, rename MessageQueue members only used for injection since S.
Bug: 150226265
Test: Toggle VSYNC injection in a tight loop while using phone.
Test: sffakehwc_test --gtest_repeat=-1 --gtest_break_on_failure
--gtest_filter='*VsyncInjection'
Change-Id: Ia58859cd8a36749bf56bb94fa724efe7c1b27b46
diff --git a/services/surfaceflinger/Scheduler/Scheduler.cpp b/services/surfaceflinger/Scheduler/Scheduler.cpp
index 52bf483..0092c7a 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.cpp
+++ b/services/surfaceflinger/Scheduler/Scheduler.cpp
@@ -399,6 +399,10 @@
impl::EventThread::InterceptVSyncsCallback(),
impl::EventThread::ThrottleVsyncCallback());
+ // EventThread does not dispatch VSYNC unless the display is connected and powered on.
+ eventThread->onHotplugReceived(PhysicalDisplayId::fromPort(0), true);
+ eventThread->onScreenAcquired();
+
mInjectorConnectionHandle = createConnection(std::move(eventThread));
}