From a3909a93958676d341424d574752bc7b3280d421 Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Sun, 9 Sep 2012 00:57:09 -0700 Subject: Work around crash when display is removed. After a display is removed, there may be a brief time when a Context still exists that is bound to it. We need to provide metrics in this case. Bug: 7131637 Change-Id: I11b264a000653adbf0f3da399eaab66c4b40fb2a --- core/java/android/app/ActivityThread.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'core/java/android/app/ActivityThread.java') diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 97dcec0..38e6970 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -1586,7 +1586,15 @@ public final class ActivityThread { CompatibilityInfoHolder cih = new CompatibilityInfoHolder(); cih.set(ci); Display d = displayManager.getCompatibleDisplay(displayId, cih); - d.getMetrics(dm); + if (d != null) { + d.getMetrics(dm); + } else { + // Display no longer exists + // FIXME: This would not be a problem if we kept the Display object around + // instead of using the raw display id everywhere. The Display object caches + // its information even after the display has been removed. + dm.setToDefaults(); + } //Slog.i("foo", "New metrics: w=" + metrics.widthPixels + " h=" // + metrics.heightPixels + " den=" + metrics.density // + " xdpi=" + metrics.xdpi + " ydpi=" + metrics.ydpi); -- cgit v1.1