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

Commit 1376fcd4 authored by Prabir Pradhan's avatar Prabir Pradhan
Browse files

InputDispatcher: Update tests to verify spy window gesture monitors

Before we enable spy window gesture monitors, we update the tests to
ensure that the behavior of a gesture monitor will not change when its
implementation is switched to a spy window.

Bug: 162194035
Test: atest inputflinger_tests
Change-Id: Id2130d782a04abbdcbf0cc412e53ad849ccb9275
parent a27a2108
Loading
Loading
Loading
Loading
+14 −4
Original line number Original line Diff line number Diff line
@@ -548,6 +548,7 @@ InputDispatcher::InputDispatcher(const sp<InputDispatcherPolicyInterface>& polic
        mAppSwitchSawKeyDown(false),
        mAppSwitchSawKeyDown(false),
        mAppSwitchDueTime(LONG_LONG_MAX),
        mAppSwitchDueTime(LONG_LONG_MAX),
        mNextUnblockedEvent(nullptr),
        mNextUnblockedEvent(nullptr),
        mMonitorDispatchingTimeout(DEFAULT_INPUT_DISPATCHING_TIMEOUT),
        mDispatchEnabled(false),
        mDispatchEnabled(false),
        mDispatchFrozen(false),
        mDispatchFrozen(false),
        mInputFilterEnabled(false),
        mInputFilterEnabled(false),
@@ -707,8 +708,13 @@ nsecs_t InputDispatcher::processAnrsLocked() {
    return LONG_LONG_MIN;
    return LONG_LONG_MIN;
}
}


std::chrono::nanoseconds InputDispatcher::getDispatchingTimeoutLocked(const sp<IBinder>& token) {
std::chrono::nanoseconds InputDispatcher::getDispatchingTimeoutLocked(
    sp<WindowInfoHandle> window = getWindowHandleLocked(token);
        const sp<Connection>& connection) {
    if (connection->monitor) {
        return mMonitorDispatchingTimeout;
    }
    const sp<WindowInfoHandle> window =
            getWindowHandleLocked(connection->inputChannel->getConnectionToken());
    if (window != nullptr) {
    if (window != nullptr) {
        return window->getDispatchingTimeout(DEFAULT_INPUT_DISPATCHING_TIMEOUT);
        return window->getDispatchingTimeout(DEFAULT_INPUT_DISPATCHING_TIMEOUT);
    }
    }
@@ -3205,8 +3211,7 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime,
    while (connection->status == Connection::Status::NORMAL && !connection->outboundQueue.empty()) {
    while (connection->status == Connection::Status::NORMAL && !connection->outboundQueue.empty()) {
        DispatchEntry* dispatchEntry = connection->outboundQueue.front();
        DispatchEntry* dispatchEntry = connection->outboundQueue.front();
        dispatchEntry->deliveryTime = currentTime;
        dispatchEntry->deliveryTime = currentTime;
        const std::chrono::nanoseconds timeout =
        const std::chrono::nanoseconds timeout = getDispatchingTimeoutLocked(connection);
                getDispatchingTimeoutLocked(connection->inputChannel->getConnectionToken());
        dispatchEntry->timeoutTime = currentTime + timeout.count();
        dispatchEntry->timeoutTime = currentTime + timeout.count();


        // Publish the event.
        // Publish the event.
@@ -6400,4 +6405,9 @@ void InputDispatcher::cancelCurrentTouch() {
    mLooper->wake();
    mLooper->wake();
}
}


void InputDispatcher::setMonitorDispatchingTimeoutForTest(std::chrono::nanoseconds timeout) {
    std::scoped_lock _l(mLock);
    mMonitorDispatchingTimeout = timeout;
}

} // namespace android::inputdispatcher
} // namespace android::inputdispatcher
+8 −1
Original line number Original line Diff line number Diff line
@@ -148,6 +148,9 @@ public:


    void cancelCurrentTouch() override;
    void cancelCurrentTouch() override;


    // Public to allow tests to verify that a Monitor can get ANR.
    void setMonitorDispatchingTimeoutForTest(std::chrono::nanoseconds timeout);

private:
private:
    enum class DropReason {
    enum class DropReason {
        NOT_DROPPED,
        NOT_DROPPED,
@@ -324,8 +327,12 @@ private:
    bool runCommandsLockedInterruptable() REQUIRES(mLock);
    bool runCommandsLockedInterruptable() REQUIRES(mLock);
    void postCommandLocked(Command&& command) REQUIRES(mLock);
    void postCommandLocked(Command&& command) REQUIRES(mLock);


    // The dispatching timeout to use for Monitors.
    std::chrono::nanoseconds mMonitorDispatchingTimeout GUARDED_BY(mLock);

    nsecs_t processAnrsLocked() REQUIRES(mLock);
    nsecs_t processAnrsLocked() REQUIRES(mLock);
    std::chrono::nanoseconds getDispatchingTimeoutLocked(const sp<IBinder>& token) REQUIRES(mLock);
    std::chrono::nanoseconds getDispatchingTimeoutLocked(const sp<Connection>& connection)
            REQUIRES(mLock);


    // Input filter processing.
    // Input filter processing.
    bool shouldSendKeyToInputFilterLocked(const NotifyKeyArgs* args) REQUIRES(mLock);
    bool shouldSendKeyToInputFilterLocked(const NotifyKeyArgs* args) REQUIRES(mLock);