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

Commit 64d27855 authored by Tracy Zhou's avatar Tracy Zhou
Browse files

Map new home and back keyboard shortcuts

Back: META+~, META+DEL (mapped to KEYCODE_BACK in InputDispatcher), META+DPAD_LEFT
Home: META+H, META+ENTER (mapped to KEYCODE_HOME in InputDispatcher)

Fixes: 246660997
Fixes: 258853738
Test: manual
Change-Id: I6691b903c9e247ab6924d1ddb202991c7b0df1f2
parent 74848985
Loading
Loading
Loading
Loading
+32 −10
Original line number Diff line number Diff line
@@ -2873,16 +2873,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {

        switch(keyCode) {
            case KeyEvent.KEYCODE_HOME:
                // First we always handle the home key here, so applications
                // can never break it, although if keyguard is on, we do let
                // it handle it, because that gives us the correct 5 second
                // timeout.
                DisplayHomeButtonHandler handler = mDisplayHomeButtonHandlers.get(displayId);
                if (handler == null) {
                    handler = new DisplayHomeButtonHandler(displayId);
                    mDisplayHomeButtonHandlers.put(displayId, handler);
                }
                return handler.handleHomeButton(focusedToken, event);
                return handleHomeShortcuts(displayId, focusedToken, event);
            case KeyEvent.KEYCODE_MENU:
                // Hijack modified menu keys for debugging features
                final int chordBug = KeyEvent.META_SHIFT_ON;
@@ -2913,6 +2904,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    return key_consumed;
                }
                break;
            case KeyEvent.KEYCODE_H:
                if (down && event.isMetaPressed()) {
                    return handleHomeShortcuts(displayId, focusedToken, event);
                }
                break;
            case KeyEvent.KEYCODE_I:
                if (down && event.isMetaPressed()) {
                    showSystemSettings();
@@ -2952,6 +2948,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                if (down && event.isMetaPressed() && event.isCtrlPressed() && repeatCount == 0) {
                    enterStageSplitFromRunningApp(true /* leftOrTop */);
                    return key_consumed;
                } else if (!down && event.isMetaPressed()) {
                    boolean backKeyHandled = backKeyPress();
                    if (backKeyHandled) {
                        return key_consumed;
                    }
                }
                break;
            case KeyEvent.KEYCODE_DPAD_RIGHT:
@@ -2960,6 +2961,14 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    return key_consumed;
                }
                break;
            case KeyEvent.KEYCODE_GRAVE:
                if (!down && event.isMetaPressed()) {
                    boolean backKeyHandled = backKeyPress();
                    if (backKeyHandled) {
                        return key_consumed;
                    }
                }
                break;
            case KeyEvent.KEYCODE_SLASH:
                if (down && repeatCount == 0 && event.isMetaPressed() && !keyguardOn) {
                    toggleKeyboardShortcutsMenu(event.getDeviceId());
@@ -3175,6 +3184,19 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        return key_not_consumed;
    }

    private int handleHomeShortcuts(int displayId, IBinder focusedToken, KeyEvent event) {
        // First we always handle the home key here, so applications
        // can never break it, although if keyguard is on, we do let
        // it handle it, because that gives us the correct 5 second
        // timeout.
        DisplayHomeButtonHandler handler = mDisplayHomeButtonHandlers.get(displayId);
        if (handler == null) {
            handler = new DisplayHomeButtonHandler(displayId);
            mDisplayHomeButtonHandlers.put(displayId, handler);
        }
        return handler.handleHomeButton(focusedToken, event);
    }

    private void toggleMicrophoneMuteFromKey() {
        if (mSensorPrivacyManager.supportsSensorToggle(
                SensorPrivacyManager.TOGGLE_TYPE_SOFTWARE,