From 7a237059c6d500f7f8005f90bba96427eb499265 Mon Sep 17 00:00:00 2001 From: Phil Weaver Date: Wed, 12 Jul 2017 14:04:16 -0700 Subject: [PATCH] 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 +++++ .../java/com/android/server/wm/Session.java | 9 +++++ .../server/wm/WindowManagerService.java | 37 ++++++++++++++++++ .../com/android/server/wm/WindowState.java | 38 +++++++++++++++++++ .../server/wm/WindowStateAnimator.java | 2 + 7 files changed, 124 insertions(+) diff --git a/api/system-current.txt b/api/system-current.txt index d1c03942229fa..4b3078ac2f98d 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 fe2423093c881..dfeeb1aa26ca6 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -646,6 +646,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; @@ -1253,6 +1272,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 74a3530276481..b4c7462cfa775 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -2142,6 +2142,15 @@ + + +