Loading services/inputflinger/dispatcher/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -94,6 +94,7 @@ cc_defaults { cc_library_static { name: "libinputdispatcher", host_supported: true, defaults: [ "inputflinger_defaults", "libinputdispatcher_defaults", Loading services/inputflinger/reporter/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ filegroup { cc_defaults { name: "libinputreporter_defaults", srcs: [":libinputreporter_sources"], host_supported: true, shared_libs: [ "liblog", "libutils", Loading services/inputflinger/tests/InputDispatcher_test.cpp +32 −11 Original line number Diff line number Diff line Loading @@ -1727,19 +1727,21 @@ static InputEventInjectionResult injectMotionEvent( InputEventInjectionSync injectionMode = InputEventInjectionSync::WAIT_FOR_RESULT, nsecs_t eventTime = systemTime(SYSTEM_TIME_MONOTONIC), std::optional<int32_t> targetUid = {}, uint32_t policyFlags = DEFAULT_POLICY_FLAGS) { MotionEvent event = MotionEventBuilder(action, source) MotionEventBuilder motionBuilder = MotionEventBuilder(action, source) .displayId(displayId) .eventTime(eventTime) .rawXCursorPosition(cursorPosition.x) .rawYCursorPosition(cursorPosition.y) .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER) .x(position.x) .y(position.y)) .build(); .pointer( PointerBuilder(/*id=*/0, ToolType::FINGER).x(position.x).y(position.y)); if (MotionEvent::getActionMasked(action) == ACTION_DOWN) { motionBuilder.downTime(eventTime); } // Inject event until dispatch out. return injectMotionEvent(dispatcher, event, injectionTimeout, injectionMode, targetUid, policyFlags); return injectMotionEvent(dispatcher, motionBuilder.build(), injectionTimeout, injectionMode, targetUid, policyFlags); } static InputEventInjectionResult injectMotionDown( Loading Loading @@ -4921,6 +4923,25 @@ TEST_F(InputDispatcherTest, FocusedWindow_SystemKeyIgnoresDisableUserActivity) { mFakePolicy->assertUserActivityPoked(); } TEST_F(InputDispatcherTest, InjectedTouchesPokeUserActivity) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window", ADISPLAY_ID_DEFAULT); mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {window}}}); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(mDispatcher, AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, {100, 100})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; window->consumeMotionEvent( AllOf(WithMotionAction(ACTION_DOWN), WithDisplayId(ADISPLAY_ID_DEFAULT))); // Should have poked user activity mFakePolicy->assertUserActivityPoked(); } TEST_F(InputDispatcherTest, UnfocusedWindow_DoesNotReceiveFocusEventOrKeyEvent) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, Loading Loading
services/inputflinger/dispatcher/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -94,6 +94,7 @@ cc_defaults { cc_library_static { name: "libinputdispatcher", host_supported: true, defaults: [ "inputflinger_defaults", "libinputdispatcher_defaults", Loading
services/inputflinger/reporter/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ filegroup { cc_defaults { name: "libinputreporter_defaults", srcs: [":libinputreporter_sources"], host_supported: true, shared_libs: [ "liblog", "libutils", Loading
services/inputflinger/tests/InputDispatcher_test.cpp +32 −11 Original line number Diff line number Diff line Loading @@ -1727,19 +1727,21 @@ static InputEventInjectionResult injectMotionEvent( InputEventInjectionSync injectionMode = InputEventInjectionSync::WAIT_FOR_RESULT, nsecs_t eventTime = systemTime(SYSTEM_TIME_MONOTONIC), std::optional<int32_t> targetUid = {}, uint32_t policyFlags = DEFAULT_POLICY_FLAGS) { MotionEvent event = MotionEventBuilder(action, source) MotionEventBuilder motionBuilder = MotionEventBuilder(action, source) .displayId(displayId) .eventTime(eventTime) .rawXCursorPosition(cursorPosition.x) .rawYCursorPosition(cursorPosition.y) .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER) .x(position.x) .y(position.y)) .build(); .pointer( PointerBuilder(/*id=*/0, ToolType::FINGER).x(position.x).y(position.y)); if (MotionEvent::getActionMasked(action) == ACTION_DOWN) { motionBuilder.downTime(eventTime); } // Inject event until dispatch out. return injectMotionEvent(dispatcher, event, injectionTimeout, injectionMode, targetUid, policyFlags); return injectMotionEvent(dispatcher, motionBuilder.build(), injectionTimeout, injectionMode, targetUid, policyFlags); } static InputEventInjectionResult injectMotionDown( Loading Loading @@ -4921,6 +4923,25 @@ TEST_F(InputDispatcherTest, FocusedWindow_SystemKeyIgnoresDisableUserActivity) { mFakePolicy->assertUserActivityPoked(); } TEST_F(InputDispatcherTest, InjectedTouchesPokeUserActivity) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window", ADISPLAY_ID_DEFAULT); mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {window}}}); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(mDispatcher, AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, {100, 100})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; window->consumeMotionEvent( AllOf(WithMotionAction(ACTION_DOWN), WithDisplayId(ADISPLAY_ID_DEFAULT))); // Should have poked user activity mFakePolicy->assertUserActivityPoked(); } TEST_F(InputDispatcherTest, UnfocusedWindow_DoesNotReceiveFocusEventOrKeyEvent) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, Loading