Loading core/java/android/view/KeyEvent.java +26 −0 Original line number Diff line number Diff line Loading @@ -2590,6 +2590,32 @@ public class KeyEvent extends InputEvent implements Parcelable { return keyCode == KeyEvent.KEYCODE_ALT_LEFT || keyCode == KeyEvent.KEYCODE_ALT_RIGHT; } /** * Returns whether the key code passed as argument is allowed for visible background users. * Visible background users are expected to run on secondary displays with certain limitations * on system keys. * * @hide */ public static boolean isVisibleBackgroundUserAllowedKey(int keyCode) { switch (keyCode) { case KeyEvent.KEYCODE_POWER: case KeyEvent.KEYCODE_SLEEP: case KeyEvent.KEYCODE_WAKEUP: case KeyEvent.KEYCODE_CALL: case KeyEvent.KEYCODE_ENDCALL: case KeyEvent.KEYCODE_ASSIST: case KeyEvent.KEYCODE_VOICE_ASSIST: case KeyEvent.KEYCODE_MUTE: case KeyEvent.KEYCODE_VOLUME_MUTE: case KeyEvent.KEYCODE_RECENT_APPS: case KeyEvent.KEYCODE_APP_SWITCH: case KeyEvent.KEYCODE_NOTIFICATION: return false; } return true; } /** {@inheritDoc} */ @Override public final int getDeviceId() { Loading services/core/java/com/android/server/policy/PhoneWindowManager.java +1 −19 Original line number Diff line number Diff line Loading @@ -191,7 +191,6 @@ import android.service.dreams.IDreamManager; import android.service.vr.IPersistentVrStateCallbacks; import android.speech.RecognizerIntent; import android.telecom.TelecomManager; import android.util.ArraySet; import android.util.Log; import android.util.MathUtils; import android.util.MutableBoolean; Loading Loading @@ -725,23 +724,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { private final boolean mVisibleBackgroundUsersEnabled = isVisibleBackgroundUsersEnabled(); // Key codes that should be ignored for visible background users in MUMD environment. private static final Set<Integer> KEY_CODES_IGNORED_FOR_VISIBLE_BACKGROUND_USERS = new ArraySet<>(Arrays.asList( KeyEvent.KEYCODE_POWER, KeyEvent.KEYCODE_SLEEP, KeyEvent.KEYCODE_WAKEUP, KeyEvent.KEYCODE_CALL, KeyEvent.KEYCODE_ENDCALL, KeyEvent.KEYCODE_ASSIST, KeyEvent.KEYCODE_VOICE_ASSIST, KeyEvent.KEYCODE_MUTE, KeyEvent.KEYCODE_VOLUME_MUTE, KeyEvent.KEYCODE_RECENT_APPS, KeyEvent.KEYCODE_APP_SWITCH, KeyEvent.KEYCODE_NOTIFICATION )); private static final int MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK = 3; private static final int MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK = 4; private static final int MSG_KEYGUARD_DRAWN_COMPLETE = 5; Loading Loading @@ -5127,7 +5109,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // There are key events that perform the operation as the current user, // and these should be ignored for visible background users. if (mVisibleBackgroundUsersEnabled && KEY_CODES_IGNORED_FOR_VISIBLE_BACKGROUND_USERS.contains(keyCode) && !KeyEvent.isVisibleBackgroundUserAllowedKey(keyCode) && !isKeyEventForCurrentUser(event.getDisplayId(), keyCode, null)) { return 0; } Loading Loading
core/java/android/view/KeyEvent.java +26 −0 Original line number Diff line number Diff line Loading @@ -2590,6 +2590,32 @@ public class KeyEvent extends InputEvent implements Parcelable { return keyCode == KeyEvent.KEYCODE_ALT_LEFT || keyCode == KeyEvent.KEYCODE_ALT_RIGHT; } /** * Returns whether the key code passed as argument is allowed for visible background users. * Visible background users are expected to run on secondary displays with certain limitations * on system keys. * * @hide */ public static boolean isVisibleBackgroundUserAllowedKey(int keyCode) { switch (keyCode) { case KeyEvent.KEYCODE_POWER: case KeyEvent.KEYCODE_SLEEP: case KeyEvent.KEYCODE_WAKEUP: case KeyEvent.KEYCODE_CALL: case KeyEvent.KEYCODE_ENDCALL: case KeyEvent.KEYCODE_ASSIST: case KeyEvent.KEYCODE_VOICE_ASSIST: case KeyEvent.KEYCODE_MUTE: case KeyEvent.KEYCODE_VOLUME_MUTE: case KeyEvent.KEYCODE_RECENT_APPS: case KeyEvent.KEYCODE_APP_SWITCH: case KeyEvent.KEYCODE_NOTIFICATION: return false; } return true; } /** {@inheritDoc} */ @Override public final int getDeviceId() { Loading
services/core/java/com/android/server/policy/PhoneWindowManager.java +1 −19 Original line number Diff line number Diff line Loading @@ -191,7 +191,6 @@ import android.service.dreams.IDreamManager; import android.service.vr.IPersistentVrStateCallbacks; import android.speech.RecognizerIntent; import android.telecom.TelecomManager; import android.util.ArraySet; import android.util.Log; import android.util.MathUtils; import android.util.MutableBoolean; Loading Loading @@ -725,23 +724,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { private final boolean mVisibleBackgroundUsersEnabled = isVisibleBackgroundUsersEnabled(); // Key codes that should be ignored for visible background users in MUMD environment. private static final Set<Integer> KEY_CODES_IGNORED_FOR_VISIBLE_BACKGROUND_USERS = new ArraySet<>(Arrays.asList( KeyEvent.KEYCODE_POWER, KeyEvent.KEYCODE_SLEEP, KeyEvent.KEYCODE_WAKEUP, KeyEvent.KEYCODE_CALL, KeyEvent.KEYCODE_ENDCALL, KeyEvent.KEYCODE_ASSIST, KeyEvent.KEYCODE_VOICE_ASSIST, KeyEvent.KEYCODE_MUTE, KeyEvent.KEYCODE_VOLUME_MUTE, KeyEvent.KEYCODE_RECENT_APPS, KeyEvent.KEYCODE_APP_SWITCH, KeyEvent.KEYCODE_NOTIFICATION )); private static final int MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK = 3; private static final int MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK = 4; private static final int MSG_KEYGUARD_DRAWN_COMPLETE = 5; Loading Loading @@ -5127,7 +5109,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // There are key events that perform the operation as the current user, // and these should be ignored for visible background users. if (mVisibleBackgroundUsersEnabled && KEY_CODES_IGNORED_FOR_VISIBLE_BACKGROUND_USERS.contains(keyCode) && !KeyEvent.isVisibleBackgroundUserAllowedKey(keyCode) && !isKeyEventForCurrentUser(event.getDisplayId(), keyCode, null)) { return 0; } Loading