Loading include/input/InputEventBuilders.h +0 −3 Original line number Diff line number Diff line Loading @@ -250,9 +250,6 @@ class MotionEventBuilder { public: MotionEventBuilder(int32_t action, int32_t source) { mAction = action; if (mAction == AMOTION_EVENT_ACTION_CANCEL) { mFlags |= AMOTION_EVENT_FLAG_CANCELED; } mSource = source; mEventTime = systemTime(SYSTEM_TIME_MONOTONIC); mDownTime = mEventTime; Loading services/inputflinger/dispatcher/InputDispatcher.cpp +26 −37 Original line number Diff line number Diff line Loading @@ -4794,39 +4794,6 @@ void InputDispatcher::notifyPointerCaptureChanged(const NotifyPointerCaptureChan } } 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, Loading Loading @@ -4937,11 +4904,33 @@ InputEventInjectionResult InputDispatcher::injectInputEvent(const InputEvent* ev mLock.lock(); if (shouldRejectInjectedMotionLocked(motionEvent, resolvedDeviceId, displayId, targetUid, flags)) { { // 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(); const size_t pointerCount = motionEvent.getPointerCount(); Loading services/inputflinger/dispatcher/InputDispatcher.h +0 −4 Original line number Diff line number Diff line Loading @@ -299,10 +299,6 @@ private: // Event injection and synchronization. std::condition_variable mInjectionResultAvailable; bool shouldRejectInjectedMotionLocked(const MotionEvent& motion, DeviceId deviceId, ui::LogicalDisplayId displayId, std::optional<gui::Uid> targetUid, int32_t flags) REQUIRES(mLock); void setInjectionResult(const EventEntry& entry, android::os::InputEventInjectionResult injectionResult); void transformMotionEntryForInjectionLocked(MotionEntry&, Loading services/inputflinger/tests/InputDispatcher_test.cpp +0 −16 Original line number Diff line number Diff line Loading @@ -12889,22 +12889,6 @@ TEST_F(InputDispatcherDragTests, DragAndDropFinishedWhenCancelCurrentTouch) { // Remove drag window mDispatcher->onWindowInfosChanged({{*mWindow->getInfo(), *mSecondWindow->getInfo()}, {}, 0, 0}); // Complete the first event stream, even though the injection will fail because there aren't any // valid targets to dispatch this event to. This is still needed to make the input stream // consistent ASSERT_EQ(InputEventInjectionResult::FAILED, injectMotionEvent(*mDispatcher, MotionEventBuilder(ACTION_CANCEL, AINPUT_SOURCE_TOUCHSCREEN) .displayId(ui::LogicalDisplayId::DEFAULT) .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER) .x(150) .y(50)) .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER) .x(50) .y(50)) .build(), INJECT_EVENT_TIMEOUT, InputEventInjectionSync::WAIT_FOR_RESULT)); // Inject a simple gesture, ensure dispatcher not crashed ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, Loading
include/input/InputEventBuilders.h +0 −3 Original line number Diff line number Diff line Loading @@ -250,9 +250,6 @@ class MotionEventBuilder { public: MotionEventBuilder(int32_t action, int32_t source) { mAction = action; if (mAction == AMOTION_EVENT_ACTION_CANCEL) { mFlags |= AMOTION_EVENT_FLAG_CANCELED; } mSource = source; mEventTime = systemTime(SYSTEM_TIME_MONOTONIC); mDownTime = mEventTime; Loading
services/inputflinger/dispatcher/InputDispatcher.cpp +26 −37 Original line number Diff line number Diff line Loading @@ -4794,39 +4794,6 @@ void InputDispatcher::notifyPointerCaptureChanged(const NotifyPointerCaptureChan } } 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, Loading Loading @@ -4937,11 +4904,33 @@ InputEventInjectionResult InputDispatcher::injectInputEvent(const InputEvent* ev mLock.lock(); if (shouldRejectInjectedMotionLocked(motionEvent, resolvedDeviceId, displayId, targetUid, flags)) { { // 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(); const size_t pointerCount = motionEvent.getPointerCount(); Loading
services/inputflinger/dispatcher/InputDispatcher.h +0 −4 Original line number Diff line number Diff line Loading @@ -299,10 +299,6 @@ private: // Event injection and synchronization. std::condition_variable mInjectionResultAvailable; bool shouldRejectInjectedMotionLocked(const MotionEvent& motion, DeviceId deviceId, ui::LogicalDisplayId displayId, std::optional<gui::Uid> targetUid, int32_t flags) REQUIRES(mLock); void setInjectionResult(const EventEntry& entry, android::os::InputEventInjectionResult injectionResult); void transformMotionEntryForInjectionLocked(MotionEntry&, Loading
services/inputflinger/tests/InputDispatcher_test.cpp +0 −16 Original line number Diff line number Diff line Loading @@ -12889,22 +12889,6 @@ TEST_F(InputDispatcherDragTests, DragAndDropFinishedWhenCancelCurrentTouch) { // Remove drag window mDispatcher->onWindowInfosChanged({{*mWindow->getInfo(), *mSecondWindow->getInfo()}, {}, 0, 0}); // Complete the first event stream, even though the injection will fail because there aren't any // valid targets to dispatch this event to. This is still needed to make the input stream // consistent ASSERT_EQ(InputEventInjectionResult::FAILED, injectMotionEvent(*mDispatcher, MotionEventBuilder(ACTION_CANCEL, AINPUT_SOURCE_TOUCHSCREEN) .displayId(ui::LogicalDisplayId::DEFAULT) .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER) .x(150) .y(50)) .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER) .x(50) .y(50)) .build(), INJECT_EVENT_TIMEOUT, InputEventInjectionSync::WAIT_FOR_RESULT)); // Inject a simple gesture, ensure dispatcher not crashed ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,