From 6ca2eccdbbd4f11698bd5312812b4d171ff3c8ce 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 (cherry picked from commit 41ff5389daa6e6ce4aa853bfae96e5ced0b1d8df) --- 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 | 9 +++++ .../android/server/wm/WindowManagerService.java | 37 +++++++++++++++++++++ .../java/com/android/server/wm/WindowState.java | 38 ++++++++++++++++++++++ .../com/android/server/wm/WindowStateAnimator.java | 2 ++ 7 files changed, 124 insertions(+) diff --git a/api/system-current.txt b/api/system-current.txt index 0fe164a269cd..6b6f7e99e4b1 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -112,6 +112,7 @@ package android { field public static final java.lang.String GRANT_RUNTIME_PERMISSIONS = "android.permission.GRANT_RUNTIME_PERMISSIONS"; 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 395f73844b07..169f7e170dd6 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -655,6 +655,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; @@ -1262,6 +1281,15 @@ public interface WindowManager extends ViewManager { */ public static final int PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE = 0x00040000; + /** + * 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 c79d50067f93..43deb02d6fa6 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -2151,6 +2151,15 @@ + + +