Let InputDispatcher handle its own thread
We move the threading logic from InputManger to InputDispatcher by
removing dispatchOnce() method from InputDispatcherInterface and adding
a start() and stop() method in its place.
Bug: 130819454
Test: atest inputflinger_tests
Test: Touch input works on crosshatch
Change-Id: I1d06be2330a2f8b9261fd5c5323a486d6aa544e8
diff --git a/services/inputflinger/dispatcher/InputDispatcher.h b/services/inputflinger/dispatcher/InputDispatcher.h
index 38f8674..96a09e3 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.h
+++ b/services/inputflinger/dispatcher/InputDispatcher.h
@@ -82,8 +82,8 @@
virtual void dump(std::string& dump) override;
virtual void monitor() override;
virtual bool waitForIdle() override;
-
- virtual void dispatchOnce() override;
+ virtual status_t start() override;
+ virtual status_t stop() override;
virtual void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) override;
virtual void notifyKey(const NotifyKeyArgs* args) override;
@@ -124,6 +124,9 @@
STALE,
};
+ class InputDispatcherThread;
+ sp<InputDispatcherThread> mThread;
+
sp<InputDispatcherPolicyInterface> mPolicy;
android::InputDispatcherConfiguration mConfig;
@@ -141,6 +144,11 @@
DropReason mLastDropReason GUARDED_BY(mLock);
+ // With each iteration, InputDispatcher nominally processes one queued event,
+ // a timeout, or a response from an input consumer.
+ // This method should only be called on the input dispatcher's own thread.
+ void dispatchOnce();
+
void dispatchOnceInnerLocked(nsecs_t* nextWakeupTime) REQUIRES(mLock);
// Enqueues an inbound event. Returns true if mLooper->wake() should be called.