for (int displayNdx = displays.length - 1; displayNdx >= 0; --displayNdx) {
final int displayId = displays[displayNdx].getDisplayId();
ActivityDisplay activityDisplay = new ActivityDisplay(displayId);
+ if (activityDisplay.mDisplay == null) {
+ throw new IllegalStateException("Default Display does not exist");
+ }
mActivityDisplays.put(displayId, activityDisplay);
}
newDisplay = mActivityDisplays.get(displayId) == null;
if (newDisplay) {
ActivityDisplay activityDisplay = new ActivityDisplay(displayId);
+ if (activityDisplay.mDisplay == null) {
+ Slog.w(TAG, "Display " + displayId + " gone before initialization complete");
+ return;
+ }
mActivityDisplays.put(displayId, activityDisplay);
}
}
ActivityDisplay() {
}
+ // After instantiation, check that mDisplay is not null before using this. The alternative
+ // is for this to throw an exception if mDisplayManager.getDisplay() returns null.
ActivityDisplay(int displayId) {
- init(mDisplayManager.getDisplay(displayId));
+ final Display display = mDisplayManager.getDisplay(displayId);
+ if (display == null) {
+ return;
+ }
+ init(display);
}
void init(Display display) {