summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Nikolas Havrikov <havrikov@google.com> 2020-06-19 11:45:34 +0200
committer Nikolas Havrikov <havrikov@google.com> 2020-06-19 15:23:50 +0200
commit7771e6ebf536f69290be8eb88aaeae8c91231fd5 (patch)
tree038b7355a00f32f031e08269f8018d5e0b59e70d
parentfe471bb73a9c745eb9315a43be385fd2b5411a85 (diff)
Ensure mShowDialogs gets updated as part of global config update
The "App keeps crashing" dialog appears on Android TV even though it should not. This would usually be accounted for by setting mShowDialogs to false in the ActivityTaskManagerService on boot. However, this does not happen because the service uses a method of the ActivityTaskManager which pulls its configuration from the context, which at this point is not yet updated to reflect relevant values like the uiMode. This change solves this problem by introducing an internal method in the ActivityTaskManager, which acts on a given configuration instead of the one from the context. This is helpful because the caller ActivityTaskManagerService is holding on to the correct configuration in the first place. Furthermore, this change does not impact any outward-facing behavior, nor does it introduce code duplication as the old method of ActivityTaskManager new merely delegates its task to the new one with the same configuration it would have originally pulled from the context. Test: Manually on ADT-3 device Bug: 159019027 Change-Id: I0fac574a69a19243c2e62b967978ef5d8318ee51
-rw-r--r--core/java/android/app/ActivityTaskManager.java14
-rw-r--r--services/core/java/com/android/server/wm/ActivityTaskManagerService.java2
2 files changed, 12 insertions, 4 deletions
diff --git a/core/java/android/app/ActivityTaskManager.java b/core/java/android/app/ActivityTaskManager.java
index 1cc63da3db0a..0f31529451fb 100644
--- a/core/java/android/app/ActivityTaskManager.java
+++ b/core/java/android/app/ActivityTaskManager.java
@@ -433,13 +433,21 @@ public class ActivityTaskManager {
}
}
- /** Returns whether the current UI mode supports error dialogs (ANR, crash, etc). */
- public static boolean currentUiModeSupportsErrorDialogs(@NonNull Context context) {
- final Configuration config = context.getResources().getConfiguration();
+ /**
+ * @return whether the UI mode of the given config supports error dialogs (ANR, crash, etc).
+ * @hide
+ */
+ public static boolean currentUiModeSupportsErrorDialogs(@NonNull Configuration config) {
int modeType = config.uiMode & Configuration.UI_MODE_TYPE_MASK;
return (modeType != Configuration.UI_MODE_TYPE_CAR
&& !(modeType == Configuration.UI_MODE_TYPE_WATCH && Build.IS_USER)
&& modeType != Configuration.UI_MODE_TYPE_TELEVISION
&& modeType != Configuration.UI_MODE_TYPE_VR_HEADSET);
}
+
+ /** @return whether the current UI mode supports error dialogs (ANR, crash, etc). */
+ public static boolean currentUiModeSupportsErrorDialogs(@NonNull Context context) {
+ final Configuration config = context.getResources().getConfiguration();
+ return currentUiModeSupportsErrorDialogs(config);
+ }
}
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
index 6dd1ea934497..5fbb7a500161 100644
--- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
+++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
@@ -5413,7 +5413,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
final boolean hideDialogsSet = Settings.Global.getInt(mContext.getContentResolver(),
HIDE_ERROR_DIALOGS, 0) != 0;
mShowDialogs = inputMethodExists
- && ActivityTaskManager.currentUiModeSupportsErrorDialogs(mContext)
+ && ActivityTaskManager.currentUiModeSupportsErrorDialogs(config)
&& !hideDialogsSet;
}