1919
2020#include " PointerControllerInterface.h"
2121
22+ #include < input/DisplayViewport.h>
2223#include < input/Input.h>
2324#include < input/InputDevice.h>
24- #include < input/DisplayViewport.h>
2525#include < input/VelocityControl.h>
2626#include < input/VelocityTracker.h>
27- #include < utils/Thread .h>
27+ #include < utils/Errors .h>
2828#include < utils/RefBase.h>
2929
3030#include < stddef.h>
4444
4545namespace android {
4646
47- /* Processes raw input events and sends cooked event data to an input listener. */
47+ // --- InputReaderInterface ---
48+
49+ /* The interface for the InputReader shared library.
50+ *
51+ * Manages one or more threads that process raw input events and sends cooked event data to an
52+ * input listener.
53+ *
54+ * The implementation must guarantee thread safety for this interface. However, since the input
55+ * listener is NOT thread safe, all calls to the listener must happen from the same thread.
56+ */
4857class InputReaderInterface : public virtual RefBase {
4958protected:
5059 InputReaderInterface () { }
@@ -56,18 +65,17 @@ class InputReaderInterface : public virtual RefBase {
5665 * This method may be called on any thread (usually by the input manager). */
5766 virtual void dump (std::string& dump) = 0;
5867
59- /* Called by the heatbeat to ensures that the reader has not deadlocked. */
68+ /* Called by the heartbeat to ensures that the reader has not deadlocked. */
6069 virtual void monitor () = 0;
6170
6271 /* Returns true if the input device is enabled. */
6372 virtual bool isInputDeviceEnabled (int32_t deviceId) = 0;
6473
65- /* Runs a single iteration of the processing loop.
66- * Nominally reads and processes one incoming message from the EventHub.
67- *
68- * This method should be called on the input reader thread.
69- */
70- virtual void loopOnce () = 0;
74+ /* Makes the reader start processing events from the kernel. */
75+ virtual status_t start () = 0;
76+
77+ /* Makes the reader stop processing any more events. */
78+ virtual status_t stop () = 0;
7179
7280 /* Gets information about all input devices.
7381 *
@@ -104,17 +112,7 @@ class InputReaderInterface : public virtual RefBase {
104112 virtual bool canDispatchToDisplay (int32_t deviceId, int32_t displayId) = 0;
105113};
106114
107- /* Reads raw events from the event hub and processes them, endlessly. */
108- class InputReaderThread : public Thread {
109- public:
110- explicit InputReaderThread (const sp<InputReaderInterface>& reader);
111- virtual ~InputReaderThread ();
112-
113- private:
114- sp<InputReaderInterface> mReader ;
115-
116- virtual bool threadLoop ();
117- };
115+ // --- InputReaderConfiguration ---
118116
119117/*
120118 * Input reader configuration.
@@ -285,6 +283,8 @@ struct InputReaderConfiguration {
285283 std::vector<DisplayViewport> mDisplays ;
286284};
287285
286+ // --- TouchAffineTransformation ---
287+
288288struct TouchAffineTransformation {
289289 float x_scale;
290290 float x_ymix;
@@ -307,6 +307,8 @@ struct TouchAffineTransformation {
307307 void applyTo (float & x, float & y) const ;
308308};
309309
310+ // --- InputReaderPolicyInterface ---
311+
310312/*
311313 * Input reader policy interface.
312314 *
@@ -316,8 +318,8 @@ struct TouchAffineTransformation {
316318 * The actual implementation is partially supported by callbacks into the DVM
317319 * via JNI. This interface is also mocked in the unit tests.
318320 *
319- * These methods must NOT re-enter the input reader since they may be called while
320- * holding the input reader lock .
321+ * These methods will NOT re-enter the input reader interface, so they may be called from
322+ * any method in the input reader interface .
321323 */
322324class InputReaderPolicyInterface : public virtual RefBase {
323325protected:
0 commit comments