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

Commit c4d4b588 authored by Andrea Arcangeli's avatar Andrea Arcangeli Committed by Andrew Dodd
Browse files

resume: fix recents showing up when waking the device with the home button



The previous fix, resolved the problem most of the time, but the home
long press would still happen once in a while during resume from RAM.

This is probably still somewhat dependent on timing but the notifyKey
runs immediately first thing after resume, so this fix should solve the
problem completely and it should be enough.

Signed-off-by: default avatarAndrea Arcangeli <andrea@cpushare.com>
parent 0c4133fe
Loading
Loading
Loading
Loading
+15 −8
Original line number Diff line number Diff line
@@ -196,6 +196,7 @@ InputDispatcher::InputDispatcher(const sp<InputDispatcherPolicyInterface>& polic
    mLooper = new Looper(false);

    mKeyRepeatState.lastKeyEntry = NULL;
    mKeyRepeatState.wakeKeyDownTime = 0;

    policy->getDispatcherConfiguration(&mConfig);
}
@@ -236,13 +237,6 @@ void InputDispatcher::dispatchOnce() {
void InputDispatcher::dispatchOnceInnerLocked(nsecs_t* nextWakeupTime) {
    nsecs_t currentTime = now();

    // Reset the key repeat timer whenever we disallow key events, even if the next event
    // is not a key.  This is to ensure that we abort a key repeat if the device is just coming
    // out of sleep.
    if (!mPolicy->isKeyRepeatEnabled() || !mDispatchEnabled) {
        resetKeyRepeatLocked();
    }

    // If dispatching is frozen, do not process timeouts or try to deliver any new events.
    if (mDispatchFrozen) {
#if DEBUG_FOCUS
@@ -682,7 +676,8 @@ bool InputDispatcher::dispatchKeyLocked(nsecs_t currentTime, KeyEntry* entry,
        if (entry->repeatCount == 0
                && entry->action == AKEY_EVENT_ACTION_DOWN
                && (entry->policyFlags & POLICY_FLAG_TRUSTED)
                && (!(entry->policyFlags & POLICY_FLAG_DISABLE_KEY_REPEAT))) {
                && (!(entry->policyFlags & POLICY_FLAG_DISABLE_KEY_REPEAT))
                && entry->downTime != mKeyRepeatState.wakeKeyDownTime) {
            if (mKeyRepeatState.lastKeyEntry
                    && mKeyRepeatState.lastKeyEntry->keyCode == entry->keyCode) {
                // We have seen two identical key downs in a row which indicates that the device
@@ -2311,6 +2306,18 @@ void InputDispatcher::notifyKey(const NotifyKeyArgs* args) {
        return;
    }

    // This is to ensure that we abort a key repeat if the device is
    // just coming out of sleep. Recording the downtime of the wake
    // key before taking the mutex is quite important because the java
    // thread otherwise runs first and finishes waking up the device
    // before the InputDispatcher can notice. We can't run
    // resetKeyRepeatLocked() here without the mutex, so we just
    // record the wake key downTime out of order after checking if the
    // dispatcher is enabled (lockless too) so we can skip the repeat
    // later.
    if (!mDispatchEnabled)
        mKeyRepeatState.wakeKeyDownTime = args->downTime;

    uint32_t policyFlags = args->policyFlags;
    int32_t flags = args->flags;
    int32_t metaState = args->metaState;
+1 −0
Original line number Diff line number Diff line
@@ -890,6 +890,7 @@ private:
    struct KeyRepeatState {
        KeyEntry* lastKeyEntry; // or null if no repeat
        nsecs_t nextRepeatTime;
        volatile nsecs_t wakeKeyDownTime; // lockless
    } mKeyRepeatState;

    void resetKeyRepeatLocked();