From d4a5fd1ce32b25c8a8d7af35c4676011d64faa22 Mon Sep 17 00:00:00 2001 From: Phil Weaver Date: Wed, 12 Jul 2017 14:04:16 -0700 Subject: Back-port fixes for b/62196835 Bug: 62196835 Test: Created an accessibility service that displays a system and a toast overlay, confirmed that it disappeared when we reached the accessibility permission screen that uses this flag. Change-Id: Ic51ead670fc480e549512ba1d02f49d9c13bc3f0 --- api/system-current.txt | 1 + core/java/android/view/WindowManager.java | 28 ++++++++++++++++ core/res/AndroidManifest.xml | 9 +++++ .../core/java/com/android/server/wm/Session.java | 10 ++++++ .../android/server/wm/WindowManagerService.java | 37 +++++++++++++++++++++ .../java/com/android/server/wm/WindowState.java | 38 ++++++++++++++++++++++ .../com/android/server/wm/WindowStateAnimator.java | 2 ++ 7 files changed, 125 insertions(+) diff --git a/api/system-current.txt b/api/system-current.txt index 3c88e5979c8e..27119593d352 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -104,6 +104,7 @@ package android { field public static final java.lang.String GLOBAL_SEARCH = "android.permission.GLOBAL_SEARCH"; field public static final java.lang.String HARDWARE_TEST = "android.permission.HARDWARE_TEST"; field public static final java.lang.String HDMI_CEC = "android.permission.HDMI_CEC"; + field public static final java.lang.String HIDE_NON_SYSTEM_OVERLAY_WINDOWS = "android.permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS"; field public static final java.lang.String INJECT_EVENTS = "android.permission.INJECT_EVENTS"; field public static final java.lang.String INSTALL_GRANT_RUNTIME_PERMISSIONS = "android.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS"; field public static final java.lang.String INSTALL_LOCATION_PROVIDER = "android.permission.INSTALL_LOCATION_PROVIDER"; diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java index 45bc1df33469..21b7f6116bbc 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -569,6 +569,25 @@ public interface WindowManager extends ViewManager { */ public static final int LAST_SYSTEM_WINDOW = 2999; + /** + * Return true if the window type is an alert window. + * + * @param type The window type. + * @return If the window type is an alert window. + * @hide + */ + public static boolean isSystemAlertWindowType(int type) { + switch (type) { + case TYPE_PHONE: + case TYPE_PRIORITY_PHONE: + case TYPE_SYSTEM_ALERT: + case TYPE_SYSTEM_ERROR: + case TYPE_SYSTEM_OVERLAY: + return true; + } + return false; + } + /** @deprecated this is ignored, this value is set automatically when needed. */ @Deprecated public static final int MEMORY_TYPE_NORMAL = 0; @@ -1127,6 +1146,15 @@ public interface WindowManager extends ViewManager { */ public static final int PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT = 0x00001000; + /** + * Flag to indicate that any window added by an application process that is of type + * {@link #TYPE_TOAST} or that requires + * {@link android.app.AppOpsManager#OP_SYSTEM_ALERT_WINDOW} permission should be hidden when + * this window is visible. + * @hide + */ + public static final int PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS = 0x00080000; + /** * Control flags that are private to the platform. * @hide diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index b2b0b5fcbee7..00d52d1b62df 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -1845,6 +1845,15 @@ + + +