Revert "Send mapper events via context"

This reverts commit cec3f6a94b1cd510d6c2f7ef9935db95fa115297.

As we discussed with Chris and Michael, it is more natural to keep the
flow of inputreader -> inputdevice -> inputmapper -> inputlistener
rather than having to come back to inputreader.

This also reduces the redundancy of having to mimic the inputlistener
interface inside the inputreader context.

Bug: 169866723
Test: atest inputflinger_tests
Change-Id: I4244947810d99ff40cfffaa34f6374aa18a238c6
diff --git a/services/inputflinger/reader/InputReader.cpp b/services/inputflinger/reader/InputReader.cpp
index c044393..14fb77b 100644
--- a/services/inputflinger/reader/InputReader.cpp
+++ b/services/inputflinger/reader/InputReader.cpp
@@ -339,7 +339,8 @@
     updateGlobalMetaStateLocked();
 
     // Enqueue configuration changed.
-    mContext.notifyConfigurationChanged(when);
+    NotifyConfigurationChangedArgs args(mContext.getNextId(), when);
+    mQueuedListener->notifyConfigurationChanged(&args);
 }
 
 void InputReader::refreshConfigurationLocked(uint32_t changes) {
@@ -366,7 +367,9 @@
     }
 
     if (changes & InputReaderConfiguration::CHANGE_POINTER_CAPTURE) {
-        mContext.notifyPointerCaptureChanged(now, mConfig.pointerCapture);
+        const NotifyPointerCaptureChangedArgs args(mContext.getNextId(), now,
+                                                   mConfig.pointerCapture);
+        mQueuedListener->notifyPointerCaptureChanged(&args);
     }
 }
 
@@ -885,69 +888,16 @@
     return mReader->mPolicy.get();
 }
 
+InputListenerInterface* InputReader::ContextImpl::getListener() {
+    return mReader->mQueuedListener.get();
+}
+
 EventHubInterface* InputReader::ContextImpl::getEventHub() {
     return mReader->mEventHub.get();
 }
 
-void InputReader::ContextImpl::notifyConfigurationChanged(nsecs_t when) {
-    NotifyConfigurationChangedArgs args(mIdGenerator.nextId(), when);
-    mReader->mQueuedListener->notifyConfigurationChanged(&args);
-}
-
-void InputReader::ContextImpl::notifyKey(nsecs_t eventTime, int32_t deviceId, uint32_t source,
-                                         int32_t displayId, uint32_t policyFlags, int32_t action,
-                                         int32_t flags, int32_t keyCode, int32_t scanCode,
-                                         int32_t metaState, nsecs_t downTime) {
-    NotifyKeyArgs args(mIdGenerator.nextId(), eventTime, deviceId, source, displayId, policyFlags,
-                       action, flags, keyCode, scanCode, metaState, downTime);
-    mReader->mQueuedListener->notifyKey(&args);
-}
-void InputReader::ContextImpl::notifyMotion(
-        nsecs_t eventTime, int32_t deviceId, uint32_t source, int32_t displayId,
-        uint32_t policyFlags, int32_t action, int32_t actionButton, int32_t flags,
-        int32_t metaState, int32_t buttonState, MotionClassification classification,
-        int32_t edgeFlags, uint32_t pointerCount, const PointerProperties* pointerProperties,
-        const PointerCoords* pointerCoords, float xPrecision, float yPrecision,
-        float xCursorPosition, float yCursorPosition, nsecs_t downTime,
-        const std::vector<TouchVideoFrame>& videoFrames) {
-    NotifyMotionArgs args(mIdGenerator.nextId(), eventTime, deviceId, source, displayId,
-                          policyFlags, action, actionButton, flags, metaState, buttonState,
-                          classification, edgeFlags, pointerCount, pointerProperties, pointerCoords,
-                          xPrecision, yPrecision, xCursorPosition, yCursorPosition, downTime,
-                          videoFrames);
-    mReader->mQueuedListener->notifyMotion(&args);
-}
-
-void InputReader::ContextImpl::notifySensor(nsecs_t when, int32_t deviceId,
-                                            InputDeviceSensorType sensorType,
-                                            InputDeviceSensorAccuracy accuracy,
-                                            bool accuracyChanged, nsecs_t timestamp,
-                                            std::vector<float> values) {
-    NotifySensorArgs args(mIdGenerator.nextId(), when, deviceId, AINPUT_SOURCE_SENSOR, sensorType,
-                          accuracy, accuracyChanged, timestamp, std::move(values));
-    mReader->mQueuedListener->notifySensor(&args);
-}
-
-void InputReader::ContextImpl::notifyVibratorState(nsecs_t when, int32_t deviceId, bool isOn) {
-    NotifyVibratorStateArgs args(mIdGenerator.nextId(), when, deviceId, isOn);
-    mReader->mQueuedListener->notifyVibratorState(&args);
-}
-
-void InputReader::ContextImpl::notifySwitch(nsecs_t eventTime, uint32_t switchValues,
-                                            uint32_t switchMask) {
-    NotifySwitchArgs args(mIdGenerator.nextId(), eventTime, 0 /*policyFlags*/, switchValues,
-                          switchMask);
-    mReader->mQueuedListener->notifySwitch(&args);
-}
-
-void InputReader::ContextImpl::notifyDeviceReset(nsecs_t when, int32_t deviceId) {
-    NotifyDeviceResetArgs args(mIdGenerator.nextId(), when, deviceId);
-    mReader->mQueuedListener->notifyDeviceReset(&args);
-}
-
-void InputReader::ContextImpl::notifyPointerCaptureChanged(nsecs_t when, bool hasCapture) {
-    const NotifyPointerCaptureChangedArgs args(mIdGenerator.nextId(), when, hasCapture);
-    mReader->mQueuedListener->notifyPointerCaptureChanged(&args);
+int32_t InputReader::ContextImpl::getNextId() {
+    return mIdGenerator.nextId();
 }
 
 } // namespace android