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
This commit is contained in:
Josep del Rio
2023-02-22 23:02:12 +00:00
committed by Josep del Río
parent d77e0d9929
commit d7e5d6da36
3 changed files with 8 additions and 15 deletions

View File

@@ -2978,15 +2978,8 @@ 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.
}
return key_consumed;
}
toggleNotificationPanel();
return key_consumed;
}
break;
case KeyEvent.KEYCODE_S:

View File

@@ -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();
}
/**

View File

@@ -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() {