Eliminate potential for NPE in WindowAnimator.
Fixes bug 7209850.
Change-Id: I8c8751ab240ea389a2a779c94c05fe786ca8762a
diff --git a/services/java/com/android/server/wm/WindowAnimator.java b/services/java/com/android/server/wm/WindowAnimator.java
index 0a4e6d3..377e89c 100644
--- a/services/java/com/android/server/wm/WindowAnimator.java
+++ b/services/java/com/android/server/wm/WindowAnimator.java
@@ -139,10 +139,8 @@
}
void addDisplayLocked(final int displayId) {
- DisplayContentsAnimator displayAnimator = getDisplayContentsAnimatorLocked(displayId);
- displayAnimator.mWindowAnimationBackgroundSurface =
- new DimSurface(mService.mFxSession, displayId);
- displayAnimator.mDimAnimator = new DimAnimator(mService.mFxSession, displayId);
+ // Create the DisplayContentsAnimator object by retrieving it.
+ getDisplayContentsAnimatorLocked(displayId);
if (displayId == Display.DEFAULT_DISPLAY) {
mInitialized = true;
}
@@ -787,7 +785,7 @@
private DisplayContentsAnimator getDisplayContentsAnimatorLocked(int displayId) {
DisplayContentsAnimator displayAnimator = mDisplayContentsAnimators.get(displayId);
if (displayAnimator == null) {
- displayAnimator = new DisplayContentsAnimator();
+ displayAnimator = new DisplayContentsAnimator(displayId);
mDisplayContentsAnimators.put(displayId, displayAnimator);
}
return displayAnimator;
@@ -801,11 +799,17 @@
return getDisplayContentsAnimatorLocked(displayId).mScreenRotationAnimation;
}
- private static class DisplayContentsAnimator {
+ private class DisplayContentsAnimator {
WinAnimatorList mWinAnimators = new WinAnimatorList();
- DimAnimator mDimAnimator = null;
+ final DimAnimator mDimAnimator;
DimAnimator.Parameters mDimParams = null;
- DimSurface mWindowAnimationBackgroundSurface = null;
+ final DimSurface mWindowAnimationBackgroundSurface;
ScreenRotationAnimation mScreenRotationAnimation = null;
+
+ public DisplayContentsAnimator(int displayId) {
+ mDimAnimator = new DimAnimator(mService.mFxSession, displayId);
+ mWindowAnimationBackgroundSurface =
+ new DimSurface(mService.mFxSession, displayId);
+ }
}
}