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

Commit 47881f64 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Always trigger assistant gesture on STEM_PRIMARY long press." into main

parents b93f614c 379b4805
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -2725,12 +2725,17 @@ public class PhoneWindowManager implements WindowManagerPolicy {

        @Override
        void onLongPress(long eventTime) {
            // Long-press should be triggered only if app doesn't handle it.
            if (mLongPressOnStemPrimaryBehavior == LONG_PRESS_PRIMARY_LAUNCH_VOICE_ASSISTANT) {
                // Long-press to assistant gesture is not overridable by apps.
                stemPrimaryLongPress(eventTime);
            } else {
                // Other long-press actions should be triggered only if app doesn't handle it.
                mDeferredKeyActionExecutor.queueKeyAction(
                        KeyEvent.KEYCODE_STEM_PRIMARY,
                        eventTime,
                        () -> stemPrimaryLongPress(eventTime));
            }
        }

        @Override
        void onMultiPress(long downTime, int count, int unusedDisplayId) {
+20 −0
Original line number Diff line number Diff line
@@ -193,6 +193,26 @@ public class StemKeyGestureTests extends ShortcutKeyTestBase {
        mPhoneWindowManager.assertStatusBarStartAssist();
    }

    @Test
    public void stemLongKey_appHasOverridePermission_consumedByApp_triggerStatusBarToStartAssist() {
        overrideBehavior(
                STEM_PRIMARY_BUTTON_LONG_PRESS,
                LONG_PRESS_PRIMARY_LAUNCH_VOICE_ASSISTANT);
        setUpPhoneWindowManager(/* supportSettingsUpdate= */ true);
        mPhoneWindowManager.overrideShouldEarlyShortPressOnStemPrimary(false);
        mPhoneWindowManager.setupAssistForLaunch();
        mPhoneWindowManager.overrideSearchManager(null);
        mPhoneWindowManager.overrideStatusBarManagerInternal();
        mPhoneWindowManager.overrideIsUserSetupComplete(true);
        mPhoneWindowManager.overrideFocusedWindowButtonOverridePermission(true);

        setDispatchedKeyHandler(keyEvent -> true);

        sendKey(KEYCODE_STEM_PRIMARY, /* longPress= */ true);

        mPhoneWindowManager.assertStatusBarStartAssist();
    }

    @Test
    public void stemDoubleKey_EarlyShortPress_AllAppsThenSwitchToMostRecent()
            throws RemoteException {