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

Commit d7e5d6da authored by Josep del Rio's avatar Josep del Rio Committed by Josep del Río
Browse files

Toggle notifications panel via actions shortcut

At the moment Meta+N will just expand the notifications panel. This
change will allow the user to also collapse it using the same
shortcut again.

Bug: 270438762
Test: flashed and tested on device with physical keyboard
Change-Id: I96494b9d18dbaa6c9002d88acebebc80af20f5b4
parent d77e0d99
Loading
Loading
Loading
Loading
+2 −9
Original line number Diff line number Diff line
@@ -2978,16 +2978,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                break;
            case KeyEvent.KEYCODE_N:
                if (down && event.isMetaPressed()) {
                    IStatusBarService service = getStatusBarService();
                    if (service != null) {
                        try {
                            service.expandNotificationsPanel();
                        } catch (RemoteException e) {
                            // do nothing.
                        }
                    toggleNotificationPanel();
                    return key_consumed;
                }
                }
                break;
            case KeyEvent.KEYCODE_S:
                if (down && event.isMetaPressed() && event.isCtrlPressed() && repeatCount == 0) {
+2 −2
Original line number Diff line number Diff line
@@ -141,9 +141,9 @@ public class ModifierShortcutTests extends ShortcutKeyTestBase {
     */
    @Test
    public void testMetaN() throws RemoteException {
        mPhoneWindowManager.overrideExpandNotificationsPanel();
        mPhoneWindowManager.overrideTogglePanel();
        sendKeyCombination(new int[]{KEYCODE_META_LEFT, KEYCODE_N}, 0);
        mPhoneWindowManager.assertExpandNotification();
        mPhoneWindowManager.assertTogglePanel();
    }

    /**
+4 −4
Original line number Diff line number Diff line
@@ -322,12 +322,12 @@ class TestPhoneWindowManager {
        doReturn(true).when(mTelecomManager).endCall();
    }

    void overrideExpandNotificationsPanel() {
    void overrideTogglePanel() {
        // Can't directly mock on IStatusbarService, use spyOn and override the specific api.
        mPhoneWindowManager.getStatusBarService();
        spyOn(mPhoneWindowManager.mStatusBarService);
        try {
            doNothing().when(mPhoneWindowManager.mStatusBarService).expandNotificationsPanel();
            doNothing().when(mPhoneWindowManager.mStatusBarService).togglePanel();
        } catch (RemoteException e) {
            e.printStackTrace();
        }
@@ -428,9 +428,9 @@ class TestPhoneWindowManager {
        Assert.assertTrue(intentCaptor.getValue().getAction() == Intent.ACTION_BUG_REPORT);
    }

    void assertExpandNotification() throws RemoteException {
    void assertTogglePanel() throws RemoteException {
        waitForIdle();
        verify(mPhoneWindowManager.mStatusBarService).expandNotificationsPanel();
        verify(mPhoneWindowManager.mStatusBarService).togglePanel();
    }

    void assertToggleShortcutsMenu() {