am fbb2da7a: am a3909a93: Work around crash when display is removed.

* commit 'fbb2da7a4d3588a9deea835e4b94d1c3547735e4':
  Work around crash when display is removed.
This commit is contained in:
Jeff Brown
2012-09-10 17:10:56 -07:00
committed by Android Git Automerger

View File

@@ -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);