Revert "Reject inconsistent globally injected events"

This reverts commit f6abbf4b919b121614384ab2286bcaf16bedd344.

Reason for revert: DroidMonitor: Potential culprit for http://b/372964183 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted

Change-Id: I9cdb4dfb4ca14a90d7527e5f546380ea6ec1d62f
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index f618277..4b43c27 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -4796,39 +4796,6 @@
     }
 }
 
-bool InputDispatcher::shouldRejectInjectedMotionLocked(const MotionEvent& motionEvent,
-                                                       DeviceId deviceId,
-                                                       ui::LogicalDisplayId displayId,
-                                                       std::optional<gui::Uid> targetUid,
-                                                       int32_t flags) {
-    // Don't verify targeted injection, since it will only affect the caller's
-    // window, and the windows are typically destroyed at the end of the test.
-    if (targetUid.has_value()) {
-        return false;
-    }
-
-    // Verify all other injected streams, whether the injection is coming from apps or from
-    // input filter. Print an error if the stream becomes inconsistent with this event.
-    // An inconsistent injected event sent could cause a crash in the later stages of
-    // dispatching pipeline.
-    auto [it, _] = mInputFilterVerifiersByDisplay.try_emplace(displayId,
-                                                              std::string("Injection on ") +
-                                                                      displayId.toString());
-    InputVerifier& verifier = it->second;
-
-    Result<void> result =
-            verifier.processMovement(deviceId, motionEvent.getSource(), motionEvent.getAction(),
-                                     motionEvent.getPointerCount(),
-                                     motionEvent.getPointerProperties(),
-                                     motionEvent.getSamplePointerCoords(), flags);
-    if (!result.ok()) {
-        logDispatchStateLocked();
-        LOG(ERROR) << "Inconsistent event: " << motionEvent << ", reason: " << result.error();
-        return true;
-    }
-    return false;
-}
-
 InputEventInjectionResult InputDispatcher::injectInputEvent(const InputEvent* event,
                                                             std::optional<gui::Uid> targetUid,
                                                             InputEventInjectionSync syncMode,
@@ -4939,10 +4906,32 @@
 
             mLock.lock();
 
-            if (shouldRejectInjectedMotionLocked(motionEvent, resolvedDeviceId, displayId,
-                                                 targetUid, flags)) {
-                mLock.unlock();
-                return InputEventInjectionResult::FAILED;
+            {
+                // Verify all injected streams, whether the injection is coming from apps or from
+                // input filter. Print an error if the stream becomes inconsistent with this event.
+                // An inconsistent injected event sent could cause a crash in the later stages of
+                // dispatching pipeline.
+                auto [it, _] =
+                        mInputFilterVerifiersByDisplay.try_emplace(displayId,
+                                                                   std::string("Injection on ") +
+                                                                           displayId.toString());
+                InputVerifier& verifier = it->second;
+
+                Result<void> result =
+                        verifier.processMovement(resolvedDeviceId, motionEvent.getSource(),
+                                                 motionEvent.getAction(),
+                                                 motionEvent.getPointerCount(),
+                                                 motionEvent.getPointerProperties(),
+                                                 motionEvent.getSamplePointerCoords(), flags);
+                if (!result.ok()) {
+                    logDispatchStateLocked();
+                    LOG(ERROR) << "Inconsistent event: " << motionEvent
+                               << ", reason: " << result.error();
+                    if (policyFlags & POLICY_FLAG_INJECTED_FROM_ACCESSIBILITY) {
+                        mLock.unlock();
+                        return InputEventInjectionResult::FAILED;
+                    }
+                }
             }
 
             const nsecs_t* sampleEventTimes = motionEvent.getSampleEventTimes();