Loading packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcutListSearch.java +0 −25 Original line number Diff line number Diff line Loading @@ -23,10 +23,7 @@ import static com.android.systemui.Flags.validateKeyboardShortcutHelperIconUri; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.ActivityManager; import android.app.AppGlobals; import android.app.SynchronousUserSwitchObserver; import android.app.UserSwitchObserver; import android.content.ComponentName; import android.content.Context; import android.content.Intent; Loading Loading @@ -151,13 +148,6 @@ public final class KeyboardShortcutListSearch { private KeyCharacterMap mKeyCharacterMap; private KeyCharacterMap mBackupKeyCharacterMap; private final UserSwitchObserver mUserSwitchObserver = new SynchronousUserSwitchObserver() { @Override public void onUserSwitching(int newUserId) throws RemoteException { dismiss(); } }; @VisibleForTesting KeyboardShortcutListSearch(Context context, WindowManager windowManager) { this.mContext = new ContextThemeWrapper( Loading Loading @@ -474,14 +464,6 @@ public final class KeyboardShortcutListSearch { mBackgroundHandler = new Handler(mHandlerThread.getLooper()); } if (validateKeyboardShortcutHelperIconUri()) { try { ActivityManager.getService().registerUserSwitchObserver(mUserSwitchObserver, TAG); } catch (RemoteException e) { Log.e(TAG, "could not register user switch observer", e); } } retrieveKeyCharacterMap(deviceId); mAppShortcutsReceived = false; mImeShortcutsReceived = false; Loading Loading @@ -563,13 +545,6 @@ public final class KeyboardShortcutListSearch { mKeyboardShortcutsBottomSheetDialog = null; } mHandlerThread.quit(); if (validateKeyboardShortcutHelperIconUri()) { try { ActivityManager.getService().unregisterUserSwitchObserver(mUserSwitchObserver); } catch (RemoteException e) { Log.e(TAG, "Could not unregister user switch observer", e); } } } private KeyboardShortcutMultiMappingGroup getMultiMappingSystemShortcuts(Context context) { Loading packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java +0 −25 Original line number Diff line number Diff line Loading @@ -24,12 +24,9 @@ import static com.android.systemui.Flags.validateKeyboardShortcutHelperIconUri; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.ActivityManager; import android.app.AlertDialog; import android.app.AppGlobals; import android.app.Dialog; import android.app.SynchronousUserSwitchObserver; import android.app.UserSwitchObserver; import android.content.ComponentName; import android.content.Context; import android.content.DialogInterface; Loading Loading @@ -137,13 +134,6 @@ public final class KeyboardShortcuts { @Nullable private List<KeyboardShortcutGroup> mReceivedAppShortcutGroups = null; @Nullable private List<KeyboardShortcutGroup> mReceivedImeShortcutGroups = null; private final UserSwitchObserver mUserSwitchObserver = new SynchronousUserSwitchObserver() { @Override public void onUserSwitching(int newUserId) throws RemoteException { dismiss(); } }; @VisibleForTesting KeyboardShortcuts(Context context, WindowManager windowManager) { this.mContext = new ContextThemeWrapper( Loading Loading @@ -394,14 +384,6 @@ public final class KeyboardShortcuts { mBackgroundHandler = new Handler(mHandlerThread.getLooper()); } if (validateKeyboardShortcutHelperIconUri()) { try { ActivityManager.getService().registerUserSwitchObserver(mUserSwitchObserver, TAG); } catch (RemoteException e) { Log.e(TAG, "could not register user switch observer", e); } } retrieveKeyCharacterMap(deviceId); mReceivedAppShortcutGroups = null; Loading Loading @@ -476,13 +458,6 @@ public final class KeyboardShortcuts { mKeyboardShortcutsDialog = null; } mHandlerThread.quit(); if (validateKeyboardShortcutHelperIconUri()) { try { ActivityManager.getService().unregisterUserSwitchObserver(mUserSwitchObserver); } catch (RemoteException e) { Log.e(TAG, "Could not unregister user switch observer", e); } } } private KeyboardShortcutGroup getSystemShortcuts() { Loading services/core/java/com/android/server/policy/PhoneWindowManager.java +4 −1 Original line number Diff line number Diff line Loading @@ -486,7 +486,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { boolean mBootMessageNeedsHiding; volatile boolean mBootAnimationDismissable; private KeyguardServiceDelegate mKeyguardDelegate; @VisibleForTesting KeyguardServiceDelegate mKeyguardDelegate; private boolean mKeyguardBound; final DrawnListener mKeyguardDrawnCallback = new DrawnListener() { @Override Loading Loading @@ -6516,6 +6516,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { @Override public void setSwitchingUser(boolean switching) { mKeyguardDelegate.setSwitchingUser(switching); if (switching) { dismissKeyboardShortcutsMenu(); } } @Override Loading services/tests/wmtests/src/com/android/server/policy/PhoneWindowManagerTests.java +22 −1 Original line number Diff line number Diff line Loading @@ -54,6 +54,8 @@ import androidx.test.filters.SmallTest; import com.android.server.LocalServices; import com.android.server.pm.UserManagerInternal; import com.android.server.policy.keyguard.KeyguardServiceDelegate; import com.android.server.statusbar.StatusBarManagerInternal; import com.android.server.wm.ActivityTaskManagerInternal; import com.android.server.wm.DisplayPolicy; import com.android.server.wm.DisplayRotation; Loading @@ -78,6 +80,7 @@ public class PhoneWindowManagerTests { PhoneWindowManager mPhoneWindowManager; private ActivityTaskManagerInternal mAtmInternal; private StatusBarManagerInternal mStatusBarManagerInternal; private Context mContext; @Before Loading @@ -90,6 +93,9 @@ public class PhoneWindowManagerTests { LocalServices.addService(ActivityTaskManagerInternal.class, mAtmInternal); mPhoneWindowManager.mActivityTaskManagerInternal = mAtmInternal; LocalServices.addService(WindowManagerInternal.class, mock(WindowManagerInternal.class)); mStatusBarManagerInternal = mock(StatusBarManagerInternal.class); LocalServices.addService(StatusBarManagerInternal.class, mStatusBarManagerInternal); mPhoneWindowManager.mKeyguardDelegate = mock(KeyguardServiceDelegate.class); } @After Loading @@ -98,6 +104,7 @@ public class PhoneWindowManagerTests { reset(mContext); LocalServices.removeServiceForTest(ActivityTaskManagerInternal.class); LocalServices.removeServiceForTest(WindowManagerInternal.class); LocalServices.removeServiceForTest(StatusBarManagerInternal.class); } @Test Loading Loading @@ -206,6 +213,20 @@ public class PhoneWindowManagerTests { assertThat(outAppOp[0]).isEqualTo(AppOpsManager.OP_NONE); } @Test public void userSwitching_keyboardShortcutHelperDismissed() { mPhoneWindowManager.setSwitchingUser(true); verify(mStatusBarManagerInternal).dismissKeyboardShortcutsMenu(); } @Test public void userNotSwitching_keyboardShortcutHelperDismissed() { mPhoneWindowManager.setSwitchingUser(false); verify(mStatusBarManagerInternal, never()).dismissKeyboardShortcutsMenu(); } private void mockStartDockOrHome() throws Exception { doNothing().when(ActivityManager.getService()).stopAppSwitches(); when(mAtmInternal.startHomeOnDisplay( Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcutListSearch.java +0 −25 Original line number Diff line number Diff line Loading @@ -23,10 +23,7 @@ import static com.android.systemui.Flags.validateKeyboardShortcutHelperIconUri; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.ActivityManager; import android.app.AppGlobals; import android.app.SynchronousUserSwitchObserver; import android.app.UserSwitchObserver; import android.content.ComponentName; import android.content.Context; import android.content.Intent; Loading Loading @@ -151,13 +148,6 @@ public final class KeyboardShortcutListSearch { private KeyCharacterMap mKeyCharacterMap; private KeyCharacterMap mBackupKeyCharacterMap; private final UserSwitchObserver mUserSwitchObserver = new SynchronousUserSwitchObserver() { @Override public void onUserSwitching(int newUserId) throws RemoteException { dismiss(); } }; @VisibleForTesting KeyboardShortcutListSearch(Context context, WindowManager windowManager) { this.mContext = new ContextThemeWrapper( Loading Loading @@ -474,14 +464,6 @@ public final class KeyboardShortcutListSearch { mBackgroundHandler = new Handler(mHandlerThread.getLooper()); } if (validateKeyboardShortcutHelperIconUri()) { try { ActivityManager.getService().registerUserSwitchObserver(mUserSwitchObserver, TAG); } catch (RemoteException e) { Log.e(TAG, "could not register user switch observer", e); } } retrieveKeyCharacterMap(deviceId); mAppShortcutsReceived = false; mImeShortcutsReceived = false; Loading Loading @@ -563,13 +545,6 @@ public final class KeyboardShortcutListSearch { mKeyboardShortcutsBottomSheetDialog = null; } mHandlerThread.quit(); if (validateKeyboardShortcutHelperIconUri()) { try { ActivityManager.getService().unregisterUserSwitchObserver(mUserSwitchObserver); } catch (RemoteException e) { Log.e(TAG, "Could not unregister user switch observer", e); } } } private KeyboardShortcutMultiMappingGroup getMultiMappingSystemShortcuts(Context context) { Loading
packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java +0 −25 Original line number Diff line number Diff line Loading @@ -24,12 +24,9 @@ import static com.android.systemui.Flags.validateKeyboardShortcutHelperIconUri; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.ActivityManager; import android.app.AlertDialog; import android.app.AppGlobals; import android.app.Dialog; import android.app.SynchronousUserSwitchObserver; import android.app.UserSwitchObserver; import android.content.ComponentName; import android.content.Context; import android.content.DialogInterface; Loading Loading @@ -137,13 +134,6 @@ public final class KeyboardShortcuts { @Nullable private List<KeyboardShortcutGroup> mReceivedAppShortcutGroups = null; @Nullable private List<KeyboardShortcutGroup> mReceivedImeShortcutGroups = null; private final UserSwitchObserver mUserSwitchObserver = new SynchronousUserSwitchObserver() { @Override public void onUserSwitching(int newUserId) throws RemoteException { dismiss(); } }; @VisibleForTesting KeyboardShortcuts(Context context, WindowManager windowManager) { this.mContext = new ContextThemeWrapper( Loading Loading @@ -394,14 +384,6 @@ public final class KeyboardShortcuts { mBackgroundHandler = new Handler(mHandlerThread.getLooper()); } if (validateKeyboardShortcutHelperIconUri()) { try { ActivityManager.getService().registerUserSwitchObserver(mUserSwitchObserver, TAG); } catch (RemoteException e) { Log.e(TAG, "could not register user switch observer", e); } } retrieveKeyCharacterMap(deviceId); mReceivedAppShortcutGroups = null; Loading Loading @@ -476,13 +458,6 @@ public final class KeyboardShortcuts { mKeyboardShortcutsDialog = null; } mHandlerThread.quit(); if (validateKeyboardShortcutHelperIconUri()) { try { ActivityManager.getService().unregisterUserSwitchObserver(mUserSwitchObserver); } catch (RemoteException e) { Log.e(TAG, "Could not unregister user switch observer", e); } } } private KeyboardShortcutGroup getSystemShortcuts() { Loading
services/core/java/com/android/server/policy/PhoneWindowManager.java +4 −1 Original line number Diff line number Diff line Loading @@ -486,7 +486,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { boolean mBootMessageNeedsHiding; volatile boolean mBootAnimationDismissable; private KeyguardServiceDelegate mKeyguardDelegate; @VisibleForTesting KeyguardServiceDelegate mKeyguardDelegate; private boolean mKeyguardBound; final DrawnListener mKeyguardDrawnCallback = new DrawnListener() { @Override Loading Loading @@ -6516,6 +6516,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { @Override public void setSwitchingUser(boolean switching) { mKeyguardDelegate.setSwitchingUser(switching); if (switching) { dismissKeyboardShortcutsMenu(); } } @Override Loading
services/tests/wmtests/src/com/android/server/policy/PhoneWindowManagerTests.java +22 −1 Original line number Diff line number Diff line Loading @@ -54,6 +54,8 @@ import androidx.test.filters.SmallTest; import com.android.server.LocalServices; import com.android.server.pm.UserManagerInternal; import com.android.server.policy.keyguard.KeyguardServiceDelegate; import com.android.server.statusbar.StatusBarManagerInternal; import com.android.server.wm.ActivityTaskManagerInternal; import com.android.server.wm.DisplayPolicy; import com.android.server.wm.DisplayRotation; Loading @@ -78,6 +80,7 @@ public class PhoneWindowManagerTests { PhoneWindowManager mPhoneWindowManager; private ActivityTaskManagerInternal mAtmInternal; private StatusBarManagerInternal mStatusBarManagerInternal; private Context mContext; @Before Loading @@ -90,6 +93,9 @@ public class PhoneWindowManagerTests { LocalServices.addService(ActivityTaskManagerInternal.class, mAtmInternal); mPhoneWindowManager.mActivityTaskManagerInternal = mAtmInternal; LocalServices.addService(WindowManagerInternal.class, mock(WindowManagerInternal.class)); mStatusBarManagerInternal = mock(StatusBarManagerInternal.class); LocalServices.addService(StatusBarManagerInternal.class, mStatusBarManagerInternal); mPhoneWindowManager.mKeyguardDelegate = mock(KeyguardServiceDelegate.class); } @After Loading @@ -98,6 +104,7 @@ public class PhoneWindowManagerTests { reset(mContext); LocalServices.removeServiceForTest(ActivityTaskManagerInternal.class); LocalServices.removeServiceForTest(WindowManagerInternal.class); LocalServices.removeServiceForTest(StatusBarManagerInternal.class); } @Test Loading Loading @@ -206,6 +213,20 @@ public class PhoneWindowManagerTests { assertThat(outAppOp[0]).isEqualTo(AppOpsManager.OP_NONE); } @Test public void userSwitching_keyboardShortcutHelperDismissed() { mPhoneWindowManager.setSwitchingUser(true); verify(mStatusBarManagerInternal).dismissKeyboardShortcutsMenu(); } @Test public void userNotSwitching_keyboardShortcutHelperDismissed() { mPhoneWindowManager.setSwitchingUser(false); verify(mStatusBarManagerInternal, never()).dismissKeyboardShortcutsMenu(); } private void mockStartDockOrHome() throws Exception { doNothing().when(ActivityManager.getService()).stopAppSwitches(); when(mAtmInternal.startHomeOnDisplay( Loading