summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Antonio Kantek <kanant@google.com> 2024-12-19 17:36:27 -0800
committer Android (Google) Code Review <android-gerrit@google.com> 2024-12-19 17:36:27 -0800
commit0f40f95bbcefb075d4041a121857e480bde91828 (patch)
treecd08327c749c9077ae5ff50afe46503a8345a006
parent1f37df17434958ff93b552c7603e993dd7caabe5 (diff)
parenta64554044543fc5174fddff9e35612c503e0dc7a (diff)
Merge "Move the list of visible background user allowed keys to KeyEvent" into main
-rw-r--r--core/java/android/view/KeyEvent.java26
-rw-r--r--services/core/java/com/android/server/policy/PhoneWindowManager.java20
2 files changed, 27 insertions, 19 deletions
diff --git a/core/java/android/view/KeyEvent.java b/core/java/android/view/KeyEvent.java
index 38e4e2760d25..ad43c7b7cdc3 100644
--- a/core/java/android/view/KeyEvent.java
+++ b/core/java/android/view/KeyEvent.java
@@ -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() {
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index ec0f25169d75..17b712de3be6 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -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;
@@ -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;
@@ -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;
}