From 15382f108108083e0e1b059dc1db57712659420e Mon Sep 17 00:00:00 2001 From: Vishnu Nair Date: Wed, 23 Jan 2019 14:01:35 -0800 Subject: [PATCH] WM: Switch to using APPLICATION_OVERLAY window type for ErrorDialogs SYSTEM_ALERT window type is deprecated and they will be placed below APPLICATION_OVERLAY windows. If an ANR dialog is shown for an app that is currently drawing windows of type APPLICATION_OVERLAY, the dialog may not be shown. Bug: 119559674 Test: Manual test with anr dialogs + presubmit Change-Id: I3aa09ee9ac6b30989c399eae9f305240a638307c --- .../core/java/com/android/server/am/BaseErrorDialog.java | 6 +++--- .../com/android/server/policy/PhoneWindowManager.java | 1 + .../com/android/server/policy/WindowManagerPolicy.java | 8 ++++---- .../core/java/com/android/server/wm/DisplayPolicy.java | 4 +++- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/services/core/java/com/android/server/am/BaseErrorDialog.java b/services/core/java/com/android/server/am/BaseErrorDialog.java index aabb5877764e1..dc9a4bf1ad943 100644 --- a/services/core/java/com/android/server/am/BaseErrorDialog.java +++ b/services/core/java/com/android/server/am/BaseErrorDialog.java @@ -16,8 +16,6 @@ package com.android.server.am; -import com.android.internal.R; - import android.app.AlertDialog; import android.content.Context; import android.os.Handler; @@ -26,6 +24,8 @@ import android.view.KeyEvent; import android.view.WindowManager; import android.widget.Button; +import com.android.internal.R; + public class BaseErrorDialog extends AlertDialog { private static final int ENABLE_BUTTONS = 0; private static final int DISABLE_BUTTONS = 1; @@ -36,7 +36,7 @@ public class BaseErrorDialog extends AlertDialog { super(context, com.android.internal.R.style.Theme_DeviceDefault_Dialog_AppError); context.assertRuntimeOverlayThemable(); - getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); + getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY); getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); WindowManager.LayoutParams attrs = getWindow().getAttributes(); diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index 41cab2d7ebd32..054c2a522ebc6 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -2570,6 +2570,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { } private static final int[] WINDOW_TYPES_WHERE_HOME_DOESNT_WORK = { + WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY, WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, WindowManager.LayoutParams.TYPE_SYSTEM_ERROR, }; diff --git a/services/core/java/com/android/server/policy/WindowManagerPolicy.java b/services/core/java/com/android/server/policy/WindowManagerPolicy.java index e1a911e8ada5d..1d829707f1808 100644 --- a/services/core/java/com/android/server/policy/WindowManagerPolicy.java +++ b/services/core/java/com/android/server/policy/WindowManagerPolicy.java @@ -825,16 +825,16 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants { // like the ANR / app crashed dialogs return canAddInternalSystemWindow ? 11 : 10; case TYPE_APPLICATION_OVERLAY: - return 12; + return canAddInternalSystemWindow ? 13 : 12; case TYPE_DREAM: // used for Dreams (screensavers with TYPE_DREAM windows) - return 13; + return 14; case TYPE_INPUT_METHOD: // on-screen keyboards and other such input method user interfaces go here. - return 14; + return 15; case TYPE_INPUT_METHOD_DIALOG: // on-screen keyboards and other such input method user interfaces go here. - return 15; + return 16; case TYPE_STATUS_BAR: return 17; case TYPE_STATUS_BAR_PANEL: diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java index 6d3c69385a098..40063326e76ef 100644 --- a/services/core/java/com/android/server/wm/DisplayPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayPolicy.java @@ -58,6 +58,7 @@ import static android.view.WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLES import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING; import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE; import static android.view.WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST; +import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_BOOT_PROGRESS; import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER; @@ -2029,7 +2030,8 @@ public class DisplayPolicy { of.set(displayFrames.mRestricted); df.set(displayFrames.mRestricted); pf.set(displayFrames.mRestricted); - } else if (type == TYPE_TOAST || type == TYPE_SYSTEM_ALERT) { + } else if (type == TYPE_TOAST || type == TYPE_SYSTEM_ALERT + || type == TYPE_APPLICATION_OVERLAY) { // These dialogs are stable to interim decor changes. cf.set(displayFrames.mStable); of.set(displayFrames.mStable);