diff options
author | 2017-06-13 18:50:57 +0000 | |
---|---|---|
committer | 2017-06-13 18:51:04 +0000 | |
commit | 8ab4d1114564d725e8a2e6da1bd1be9eab76eb7d (patch) | |
tree | b6d32abb676f4b8816f5db33d2cd03e70ef1ba7e | |
parent | c7ea7effde64c682ba8ddaca0fd9ac4354029e41 (diff) | |
parent | d18712695c6b8861e6b22f9ef64709022ae94ee1 (diff) |
Merge "Address issues surrounding freezing by display." into oc-dev
3 files changed, 32 insertions, 8 deletions
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index ccc8f63e4355..54983c8998fc 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -314,6 +314,9 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo // the display's direct children should be allowed. private boolean mRemovingDisplay = false; + // {@code false} if this display is in the processing of being created. + private boolean mDisplayReady = false; + private final WindowLayersController mLayersController; WallpaperController mWallpaperController; int mInputMethodAnimLayerAdjustment; @@ -720,7 +723,6 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo */ DisplayContent(Display display, WindowManagerService service, WindowLayersController layersController, WallpaperController wallpaperController) { - if (service.mRoot.getDisplayContent(display.getDisplayId()) != null) { throw new IllegalArgumentException("Display with ID=" + display.getDisplayId() + " already exists=" + service.mRoot.getDisplayContent(display.getDisplayId()) @@ -748,6 +750,15 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo // Add itself as a child to the root container. mService.mRoot.addChild(this, null); + + // TODO(b/62541591): evaluate whether this is the best spot to declare the + // {@link DisplayContent} ready for use. + mDisplayReady = true; + } + + boolean isReady() { + // The display is ready when the system and the individual display are both ready. + return mService.mDisplayReady && mDisplayReady; } int getDisplayId() { diff --git a/services/core/java/com/android/server/wm/WindowAnimator.java b/services/core/java/com/android/server/wm/WindowAnimator.java index 03b5b827db74..aabf2bed1dd4 100644 --- a/services/core/java/com/android/server/wm/WindowAnimator.java +++ b/services/core/java/com/android/server/wm/WindowAnimator.java @@ -108,7 +108,8 @@ public class WindowAnimator { } void addDisplayLocked(final int displayId) { - // Create the DisplayContentsAnimator object by retrieving it. + // Create the DisplayContentsAnimator object by retrieving it if the associated + // {@link DisplayContent} exists. getDisplayContentsAnimatorLocked(displayId); if (displayId == DEFAULT_DISPLAY) { mInitialized = true; @@ -356,8 +357,16 @@ public class WindowAnimator { } private DisplayContentsAnimator getDisplayContentsAnimatorLocked(int displayId) { + if (displayId < 0) { + return null; + } + DisplayContentsAnimator displayAnimator = mDisplayContentsAnimators.get(displayId); - if (displayAnimator == null) { + + // It is possible that this underlying {@link DisplayContent} has been removed. In this + // case, we do not want to create an animator associated with it as {link #animate} will + // fail. + if (displayAnimator == null && mService.mRoot.getDisplayContent(displayId) != null) { displayAnimator = new DisplayContentsAnimator(); mDisplayContentsAnimators.put(displayId, displayAnimator); } @@ -365,8 +374,10 @@ public class WindowAnimator { } void setScreenRotationAnimationLocked(int displayId, ScreenRotationAnimation animation) { - if (displayId >= 0) { - getDisplayContentsAnimatorLocked(displayId).mScreenRotationAnimation = animation; + final DisplayContentsAnimator animator = getDisplayContentsAnimatorLocked(displayId); + + if (animator != null) { + animator.mScreenRotationAnimation = animation; } } @@ -374,7 +385,9 @@ public class WindowAnimator { if (displayId < 0) { return null; } - return getDisplayContentsAnimatorLocked(displayId).mScreenRotationAnimation; + + DisplayContentsAnimator animator = getDisplayContentsAnimatorLocked(displayId); + return animator != null? animator.mScreenRotationAnimation : null; } void requestRemovalOfReplacedWindows(WindowState win) { diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 77e2f71016fe..9e3edef768d7 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -5890,8 +5890,8 @@ public class WindowManagerService extends IWindowManager.Stub return; } - if (!mDisplayReady || !mPolicy.isScreenOn()) { - // No need to freeze the screen before the system is ready or if + if (!displayContent.isReady() || !mPolicy.isScreenOn()) { + // No need to freeze the screen before the display is ready, system is ready, or if // the screen is off. return; } |