Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b3307ee4 authored by Arthur Hung's avatar Arthur Hung
Browse files

Add logs to trace no window touched and cancel event

To clarify some unresponsive touch problems, we have to know if the
event has really sent from firmware and some window could be touched
or it's dropped because of cancel.

- Add the explicit log where we did not really find a touched window.
- Add input_cacnel event log to identify the reason.

Test: atest inputflinger_tests
Bug: 201647070
Bug: 200837970
Change-Id: I17b1de6c96ddc11d2ca2efd00e30e00847b98406
parent f367330f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@

62000 input_interaction (windows|4)
62001 input_focus (window|3),(reason|3)
62003 input_cancel (window|3),(reason|3)

# NOTE - the range 1000000-2000000 is reserved for partners and others who
# want to define their own log tags without conflicting with the core platform.
 No newline at end of file
+12 −0
Original line number Diff line number Diff line
@@ -153,6 +153,7 @@ constexpr size_t RECENT_QUEUE_MAX_SIZE = 10;
// Event log tags. See EventLogTags.logtags for reference
constexpr int LOGTAG_INPUT_INTERACTION = 62000;
constexpr int LOGTAG_INPUT_FOCUS = 62001;
constexpr int LOGTAG_INPUT_CANCEL = 62003;

inline nsecs_t now() {
    return systemTime(SYSTEM_TIME_MONOTONIC);
@@ -2077,6 +2078,8 @@ InputEventInjectionResult InputDispatcher::findTouchedWindowTargetsLocked(

        // Handle the case where we did not find a window.
        if (newTouchedWindowHandle == nullptr) {
            ALOGD("No new touched window at (%" PRId32 ", %" PRId32 ") in display %" PRId32, x, y,
                  displayId);
            // Try to assign the pointer to the first foreground window we find, if there is one.
            newTouchedWindowHandle = tempTouchState.getFirstForegroundWindowHandle();
        }
@@ -2870,6 +2873,11 @@ void InputDispatcher::prepareDispatchCycleLocked(nsecs_t currentTime,
            if (!splitMotionEntry) {
                return; // split event was dropped
            }
            if (splitMotionEntry->action == AMOTION_EVENT_ACTION_CANCEL) {
                std::string reason = std::string("reason=pointer cancel on split window");
                android_log_event_list(LOGTAG_INPUT_CANCEL)
                        << connection->getInputChannelName().c_str() << reason << LOG_ID_EVENTS;
            }
            if (DEBUG_FOCUS) {
                ALOGD("channel '%s' ~ Split motion event.",
                      connection->getInputChannelName().c_str());
@@ -3575,6 +3583,10 @@ void InputDispatcher::synthesizeCancelationEventsForConnectionLocked(
              options.mode);
    }

    std::string reason = std::string("reason=").append(options.reason);
    android_log_event_list(LOGTAG_INPUT_CANCEL)
            << connection->getInputChannelName().c_str() << reason << LOG_ID_EVENTS;

    InputTarget target;
    sp<WindowInfoHandle> windowHandle =
            getWindowHandleLocked(connection->inputChannel->getConnectionToken());
+11 −0
Original line number Diff line number Diff line
@@ -2841,6 +2841,17 @@ TEST_F(InputDispatcherTest, GestureMonitor_NoWindowTransform) {
    ASSERT_EQ(ui::Transform(), event->getTransform());
}

TEST_F(InputDispatcherTest, GestureMonitor_NoWindow) {
    std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
    FakeMonitorReceiver monitor = FakeMonitorReceiver(mDispatcher, "GM_1", ADISPLAY_ID_DEFAULT,
                                                      true /*isGestureMonitor*/);

    ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
              injectMotionDown(mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT))
            << "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
    monitor.consumeMotionDown(ADISPLAY_ID_DEFAULT);
}

TEST_F(InputDispatcherTest, TestMoveEvent) {
    std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
    sp<FakeWindowHandle> window =