Revert "TouchEvent (4/n) Firing event when setting mInTouchMode"

This reverts commit 4eecba7daea5100d69bf8c2d3efbbba222dc8cf5.

Reason for revert: May have broken com.android.system.ui tests (b/201320240)

Change-Id: Ib5bdbd2804a46e1f4c0cfbeec70fa0db7fdadaa0
Bug: 201320240
Bug: 193718270
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 53c34f6..f094fee 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -88,9 +88,6 @@
 // Log debug messages about input focus tracking.
 constexpr bool DEBUG_FOCUS = false;
 
-// Log debug messages about touch mode event
-constexpr bool DEBUG_TOUCH_MODE = false;
-
 // Log debug messages about touch occlusion
 // STOPSHIP(b/169067926): Set to false
 constexpr bool DEBUG_TOUCH_OCCLUSION = true;
@@ -537,23 +534,6 @@
     return transformedXy - transformedOrigin;
 }
 
-// Returns true if the event type passed as argument represents a user activity.
-bool isUserActivityEvent(const EventEntry& eventEntry) {
-    switch (eventEntry.type) {
-        case EventEntry::Type::FOCUS:
-        case EventEntry::Type::POINTER_CAPTURE_CHANGED:
-        case EventEntry::Type::DRAG:
-        case EventEntry::Type::TOUCH_MODE_CHANGED:
-        case EventEntry::Type::SENSOR:
-        case EventEntry::Type::CONFIGURATION_CHANGED:
-            return false;
-        case EventEntry::Type::DEVICE_RESET:
-        case EventEntry::Type::KEY:
-        case EventEntry::Type::MOTION:
-            return true;
-    }
-}
-
 } // namespace
 
 // --- InputDispatcher ---
@@ -572,7 +552,7 @@
         // mInTouchMode will be initialized by the WindowManager to the default device config.
         // To avoid leaking stack in case that call never comes, and for tests,
         // initialize it here anyways.
-        mInTouchMode(kDefaultInTouchMode),
+        mInTouchMode(true),
         mMaximumObscuringOpacityForTouch(1.0f),
         mFocusedDisplayId(ADISPLAY_ID_DEFAULT),
         mWindowTokenWithPointerCapture(nullptr),
@@ -1810,9 +1790,9 @@
             displayId = motionEntry.displayId;
             break;
         }
-        case EventEntry::Type::TOUCH_MODE_CHANGED:
         case EventEntry::Type::POINTER_CAPTURE_CHANGED:
         case EventEntry::Type::FOCUS:
+        case EventEntry::Type::TOUCH_MODE_CHANGED:
         case EventEntry::Type::CONFIGURATION_CHANGED:
         case EventEntry::Type::DEVICE_RESET:
         case EventEntry::Type::SENSOR:
@@ -2793,8 +2773,11 @@
 }
 
 void InputDispatcher::pokeUserActivityLocked(const EventEntry& eventEntry) {
-    if (!isUserActivityEvent(eventEntry)) {
-        // Not poking user activity if the event type does not represent a user activity
+    if (eventEntry.type == EventEntry::Type::FOCUS ||
+        eventEntry.type == EventEntry::Type::POINTER_CAPTURE_CHANGED ||
+        eventEntry.type == EventEntry::Type::DRAG) {
+        // Focus or pointer capture changed events are passed to apps, but do not represent user
+        // activity.
         return;
     }
     int32_t displayId = getTargetDisplayId(eventEntry);
@@ -2830,7 +2813,16 @@
             eventType = USER_ACTIVITY_EVENT_BUTTON;
             break;
         }
-        default: {
+        case EventEntry::Type::TOUCH_MODE_CHANGED: {
+            break;
+        }
+
+        case EventEntry::Type::FOCUS:
+        case EventEntry::Type::CONFIGURATION_CHANGED:
+        case EventEntry::Type::DEVICE_RESET:
+        case EventEntry::Type::SENSOR:
+        case EventEntry::Type::POINTER_CAPTURE_CHANGED:
+        case EventEntry::Type::DRAG: {
             LOG_ALWAYS_FATAL("%s events are not user activity",
                              ftl::enum_string(eventEntry.type).c_str());
             break;
@@ -3803,7 +3795,7 @@
         ALOGD("notifyConfigurationChanged - eventTime=%" PRId64, args->eventTime);
     }
 
-    bool needWake = false;
+    bool needWake;
     { // acquire lock
         std::scoped_lock _l(mLock);
 
@@ -3898,7 +3890,7 @@
               std::to_string(t.duration().count()).c_str());
     }
 
-    bool needWake = false;
+    bool needWake;
     { // acquire lock
         mLock.lock();
 
@@ -3975,7 +3967,7 @@
               std::to_string(t.duration().count()).c_str());
     }
 
-    bool needWake = false;
+    bool needWake;
     { // acquire lock
         mLock.lock();
 
@@ -4040,7 +4032,7 @@
               ftl::enum_string(args->sensorType).c_str());
     }
 
-    bool needWake = false;
+    bool needWake;
     { // acquire lock
         mLock.lock();
 
@@ -4090,7 +4082,7 @@
               args->deviceId);
     }
 
-    bool needWake = false;
+    bool needWake;
     { // acquire lock
         std::scoped_lock _l(mLock);
 
@@ -4110,7 +4102,7 @@
               args->request.enable ? "true" : "false");
     }
 
-    bool needWake = false;
+    bool needWake;
     { // acquire lock
         std::scoped_lock _l(mLock);
         auto entry = std::make_unique<PointerCaptureChangedEntry>(args->id, args->eventTime,
@@ -4927,29 +4919,9 @@
 }
 
 void InputDispatcher::setInTouchMode(bool inTouchMode) {
-    bool needWake = false;
-    {
-        std::scoped_lock lock(mLock);
-        if (mInTouchMode == inTouchMode) {
-            return;
-        }
-        if (DEBUG_TOUCH_MODE) {
-            ALOGD("Request to change touch mode from %s to %s", toString(mInTouchMode),
-                  toString(inTouchMode));
-            // TODO(b/198487159): Also print the current last interacted apps.
-        }
-
-        // TODO(b/198499018): Store touch mode per display.
-        mInTouchMode = inTouchMode;
-
-        // TODO(b/198487159): Enforce that only last interacted apps can change touch mode.
-        auto entry = std::make_unique<TouchModeEntry>(mIdGenerator.nextId(), now(), inTouchMode);
-        needWake = enqueueInboundEventLocked(std::move(entry));
-    } // release lock
-
-    if (needWake) {
-        mLooper->wake();
-    }
+    std::scoped_lock lock(mLock);
+    mInTouchMode = inTouchMode;
+    // TODO(b/193718270): Fire TouchModeEvent here.
 }
 
 void InputDispatcher::setMaximumObscuringOpacityForTouch(float opacity) {