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

Commit 377b918c authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Fix screen turns off once triggering long press power behavior" into...

Merge "Fix screen turns off once triggering long press power behavior" into udc-qpr-dev am: 01a9c09f

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23823227



Change-Id: I4688b3f2eee2c34dd3b9e8df208b519eff75912a
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 7c7638c3 01a9c09f
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -314,7 +314,9 @@ public final class SingleKeyGestureDetector {
            if (eventTime < mLastDownTime + mActiveRule.getVeryLongPressTimeoutMs()) {
            if (eventTime < mLastDownTime + mActiveRule.getVeryLongPressTimeoutMs()) {
                mHandler.removeMessages(MSG_KEY_VERY_LONG_PRESS);
                mHandler.removeMessages(MSG_KEY_VERY_LONG_PRESS);
            } else {
            } else {
                mHandledByLongPress = mActiveRule.supportVeryLongPress();
                // If long press or very long press (~3.5s) had been handled, we should skip the
                // short press behavior.
                mHandledByLongPress |= mActiveRule.supportVeryLongPress();
            }
            }
        }
        }


+12 −0
Original line number Original line Diff line number Diff line
@@ -316,4 +316,16 @@ public class SingleKeyGestureTests {
        pressKey(KEYCODE_POWER, 0 /* pressTime */);
        pressKey(KEYCODE_POWER, 0 /* pressTime */);
        assertTrue(mShortPressed.await(mWaitTimeout, TimeUnit.MILLISECONDS));
        assertTrue(mShortPressed.await(mWaitTimeout, TimeUnit.MILLISECONDS));
    }
    }

    // Verify short press should not be triggered if no very long press behavior defined but the
    // press time exceeded the very long press timeout.
    @Test
    public void testTimeoutExceedVeryLongPress() throws InterruptedException {
        mVeryLongPressOnPowerBehavior = false;

        pressKey(KEYCODE_POWER, mVeryLongPressTime + 50);
        assertTrue(mLongPressed.await(mWaitTimeout, TimeUnit.MILLISECONDS));
        assertEquals(mVeryLongPressed.getCount(), 1);
        assertEquals(mShortPressed.getCount(), 1);
    }
}
}