Revert "[11/n Dispatcher refactor] Move isTouchTrusted to WindowInfo"

Revert submission 31063667

Reason for revert: b/389024840

Reverted changes: /q/submissionid:31063667

Change-Id: I6e49f735d54317d86e309c31d1694c9ee75dc553
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 266e691..d4f067b 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -954,6 +954,7 @@
         mDispatchEnabled(false),
         mDispatchFrozen(false),
         mInputFilterEnabled(false),
+        mMaximumObscuringOpacityForTouch(1.0f),
         mFocusedDisplayId(ui::LogicalDisplayId::DEFAULT),
         mWindowTokenWithPointerCapture(nullptr),
         mAwaitedApplicationDisplayId(ui::LogicalDisplayId::INVALID),
@@ -3163,8 +3164,8 @@
     return info;
 }
 
-bool InputDispatcher::DispatcherWindowInfo::isTouchTrusted(
-        const TouchOcclusionInfo& occlusionInfo) const {
+bool InputDispatcher::isTouchTrustedLocked(
+        const DispatcherWindowInfo::TouchOcclusionInfo& occlusionInfo) const {
     if (occlusionInfo.hasBlockingOcclusion) {
         ALOGW("Untrusted touch due to occlusion by %s/%s", occlusionInfo.obscuringPackage.c_str(),
               occlusionInfo.obscuringUid.toString().c_str());
@@ -5270,9 +5271,8 @@
     return dump;
 }
 
-bool InputDispatcher::canWindowReceiveMotionLocked(
-        const sp<android::gui::WindowInfoHandle>& window,
-        const android::inputdispatcher::MotionEntry& motionEntry) const {
+bool InputDispatcher::canWindowReceiveMotionLocked(const sp<WindowInfoHandle>& window,
+                                                   const MotionEntry& motionEntry) const {
     const WindowInfo& info = *window->getInfo();
 
     // Skip spy window targets that are not valid for targeted injection.
@@ -5307,7 +5307,7 @@
     const auto [x, y] = resolveTouchedPosition(motionEntry);
     DispatcherWindowInfo::TouchOcclusionInfo occlusionInfo =
             mWindowInfos.computeTouchOcclusionInfo(window, x, y);
-    if (!mWindowInfos.isTouchTrusted(occlusionInfo)) {
+    if (!isTouchTrustedLocked(occlusionInfo)) {
         if (DEBUG_TOUCH_OCCLUSION) {
             ALOGD("Stack of obscuring windows during untrusted touch (%.1f, %.1f):", x, y);
             for (const auto& log : occlusionInfo.debugInfo) {
@@ -5751,8 +5751,13 @@
 }
 
 void InputDispatcher::setMaximumObscuringOpacityForTouch(float opacity) {
+    if (opacity < 0 || opacity > 1) {
+        LOG_ALWAYS_FATAL("Maximum obscuring opacity for touch should be >= 0 and <= 1");
+        return;
+    }
+
     std::scoped_lock lock(mLock);
-    mWindowInfos.setMaximumObscuringOpacityForTouch(opacity);
+    mMaximumObscuringOpacityForTouch = opacity;
 }
 
 std::tuple<const TouchState*, const TouchedWindow*, ui::LogicalDisplayId>
@@ -7357,11 +7362,4 @@
     return dump;
 }
 
-void InputDispatcher::DispatcherWindowInfo::setMaximumObscuringOpacityForTouch(float opacity) {
-    if (opacity < 0 || opacity > 1) {
-        LOG_ALWAYS_FATAL("Maximum obscuring opacity for touch should be >= 0 and <= 1");
-    }
-    mMaximumObscuringOpacityForTouch = opacity;
-}
-
 } // namespace android::inputdispatcher
diff --git a/services/inputflinger/dispatcher/InputDispatcher.h b/services/inputflinger/dispatcher/InputDispatcher.h
index 13fec2a..92cbad4 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.h
+++ b/services/inputflinger/dispatcher/InputDispatcher.h
@@ -290,8 +290,6 @@
 
         void removeDisplay(ui::LogicalDisplayId displayId);
 
-        void setMaximumObscuringOpacityForTouch(float opacity);
-
         // Get a reference to window handles by display, return an empty vector if not found.
         const std::vector<sp<android::gui::WindowInfoHandle>>& getWindowHandlesForDisplay(
                 ui::LogicalDisplayId displayId) const;
@@ -336,8 +334,6 @@
         sp<android::gui::WindowInfoHandle> findWallpaperWindowBelow(
                 const sp<android::gui::WindowInfoHandle>& windowHandle) const;
 
-        bool isTouchTrusted(const TouchOcclusionInfo& occlusionInfo) const;
-
         std::string dumpDisplayAndWindowInfo() const;
 
     private:
@@ -346,7 +342,6 @@
                 mWindowHandlesByDisplay;
         std::unordered_map<ui::LogicalDisplayId /*displayId*/, android::gui::DisplayInfo>
                 mDisplayInfos;
-        float mMaximumObscuringOpacityForTouch{1.0f};
     };
 
     DispatcherWindowInfo mWindowInfos GUARDED_BY(mLock);
@@ -448,6 +443,7 @@
     bool mDispatchEnabled GUARDED_BY(mLock);
     bool mDispatchFrozen GUARDED_BY(mLock);
     bool mInputFilterEnabled GUARDED_BY(mLock);
+    float mMaximumObscuringOpacityForTouch GUARDED_BY(mLock);
 
     // This map is not really needed, but it helps a lot with debugging (dumpsys input).
     // In the java layer, touch mode states are spread across multiple DisplayContent objects,
@@ -650,6 +646,8 @@
     void addDragEventLocked(const MotionEntry& entry) REQUIRES(mLock);
     void finishDragAndDrop(ui::LogicalDisplayId displayId, float x, float y) REQUIRES(mLock);
 
+    bool isTouchTrustedLocked(const DispatcherWindowInfo::TouchOcclusionInfo& occlusionInfo) const
+            REQUIRES(mLock);
     std::string getApplicationWindowLabel(const InputApplicationHandle* applicationHandle,
                                           const sp<android::gui::WindowInfoHandle>& windowHandle);