From 94d4c34b167813a979c52c2c71e67d6307f05bf7 Mon Sep 17 00:00:00 2001 From: Joshua Tsuji Date: Mon, 4 May 2020 14:00:24 -0400 Subject: [PATCH] Add TYPE_TRUSTED_APPLICATION_OVERLAY. Also, make Bubbles a TYPE_TRUSTED_APPLICATION_OVERLAY! Test: make a permission dialog appear while bubbles appear (wait for any HUNs to go away) Fixes: 149320322 Change-Id: Ib4b93635929cf996753a21717383c327256477b3 --- core/java/android/view/WindowManager.java | 8 ++++++++ .../com/android/systemui/bubbles/BubbleController.java | 2 +- .../com/android/server/policy/WindowManagerPolicy.java | 2 ++ .../core/java/com/android/server/wm/DisplayPolicy.java | 6 ++++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java index 9a3c7066e7f8c..8cb05da93b7f8 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -1216,6 +1216,14 @@ public interface WindowManager extends ViewManager { */ public static final int TYPE_STATUS_BAR_ADDITIONAL = FIRST_SYSTEM_WINDOW + 41; + /** + * Similar to TYPE_APPLICATION_OVERLAY, but trusted to overlay other windows since it is + * is coming from the system. + * @hide + */ + // TODO(b/155781676): Remove and replace call points with trustedOverlay when that is ready. + public static final int TYPE_TRUSTED_APPLICATION_OVERLAY = FIRST_SYSTEM_WINDOW + 42; + /** * End of types of system windows. */ diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java index ad8d57bbf23f2..ca0cd77dfbb4b 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java @@ -634,7 +634,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi // themselves. ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, - WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY, + WindowManager.LayoutParams.TYPE_TRUSTED_APPLICATION_OVERLAY, // Start not focusable - we'll become focusable when expanded so the ActivityView // can use the IME. WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE diff --git a/services/core/java/com/android/server/policy/WindowManagerPolicy.java b/services/core/java/com/android/server/policy/WindowManagerPolicy.java index da07223686d73..b3e162d473db5 100644 --- a/services/core/java/com/android/server/policy/WindowManagerPolicy.java +++ b/services/core/java/com/android/server/policy/WindowManagerPolicy.java @@ -56,6 +56,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG; import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ERROR; import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_TOAST; +import static android.view.WindowManager.LayoutParams.TYPE_TRUSTED_APPLICATION_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION; import static android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION_STARTING; import static android.view.WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY; @@ -790,6 +791,7 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants { // in a higher layer than TYPE_APPLICATION_OVERLAY. return canAddInternalSystemWindow ? 13 : 10; case TYPE_APPLICATION_OVERLAY: + case TYPE_TRUSTED_APPLICATION_OVERLAY: return 12; case TYPE_INPUT_METHOD: // on-screen keyboards and other such input method user interfaces go here. diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java index 53b536cf712f1..eb5cff6d5ad85 100644 --- a/services/core/java/com/android/server/wm/DisplayPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayPolicy.java @@ -95,6 +95,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ALERT; import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ERROR; import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_TOAST; +import static android.view.WindowManager.LayoutParams.TYPE_TRUSTED_APPLICATION_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION; import static android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION_STARTING; import static android.view.WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY; @@ -996,6 +997,11 @@ public class DisplayPolicy { android.Manifest.permission.STATUS_BAR_SERVICE, callingPid, callingUid, "DisplayPolicy"); break; + case TYPE_TRUSTED_APPLICATION_OVERLAY: + mContext.enforcePermission( + android.Manifest.permission.INTERNAL_SYSTEM_WINDOW, callingPid, callingUid, + "DisplayPolicy"); + break; case TYPE_STATUS_BAR_PANEL: return WindowManagerGlobal.ADD_INVALID_TYPE; }