From b4ec0a312de422440374638195d4709cc74227e9 Mon Sep 17 00:00:00 2001 From: Wale Ogunwale Date: Mon, 14 Dec 2015 10:31:43 -0800 Subject: [PATCH] Fixed bug with task record not updating to fullscreen sometimes null is normally passed in to AMS.resizeStack API if the caller wants to change the stack size to fullscreen. However, it is possible for the caller to also pass in a bounds that corresponds to the fullscreen bounds of the display the stack is on. When this happens, the call to window manager to resize the stack correctly detects that the bounds is equal to the fullsceen bounds of the display and sets the stack to fullscreen, but the task record state isn't updated to fullscreen since they were previously calculated on the activity manager side. We now check if the bounds corresponds to the fullscreen bounds on the activity manager side and set it to null so that the task record state is correctly updated. Bug: 25683717 Change-Id: Ife753c6e6c034fd8df663ab897d245f1d354bda7 --- .../android/server/am/ActivityStackSupervisor.java | 8 ++++++++ .../core/java/com/android/server/wm/TaskStack.java | 8 ++++++++ .../com/android/server/wm/WindowManagerService.java | 12 +++++++++++- .../com/android/server/wm/WindowSurfacePlacer.java | 5 +++-- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java index 9fff0c81d3ae2..e8100f0d3928c 100644 --- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java +++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java @@ -3124,6 +3124,14 @@ public final class ActivityStackSupervisor implements DisplayListener { Trace.traceBegin(TRACE_TAG_ACTIVITY_MANAGER, "am.resizeStack_" + stackId); mWindowManager.deferSurfaceLayout(); try { + + if (bounds != null && mWindowManager.isFullscreenBounds(stackId, bounds)) { + // The bounds passed in corresponds to the fullscreen bounds which we normally + // represent with null. Go ahead and set it to null so that all tasks configuration + // can have the right fullscreen state. + bounds = null; + } + ActivityRecord r = stack.topRunningActivityLocked(); mTmpBounds.clear(); diff --git a/services/core/java/com/android/server/wm/TaskStack.java b/services/core/java/com/android/server/wm/TaskStack.java index 49d9efe68558b..b9618791b848a 100644 --- a/services/core/java/com/android/server/wm/TaskStack.java +++ b/services/core/java/com/android/server/wm/TaskStack.java @@ -144,6 +144,14 @@ public class TaskStack implements DimLayer.DimLayerUser { return true; } + boolean isFullscreenBounds(Rect bounds) { + if (mDisplayContent == null || bounds == null) { + return true; + } + mDisplayContent.getLogicalDisplayRect(mTmpRect); + return mTmpRect.equals(bounds); + } + private boolean setBounds(Rect bounds) { boolean oldFullscreen = mFullscreen; int rotation = Surface.ROTATION_0; diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 816cab732ade3..4c4495b89f593 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -458,7 +458,6 @@ public class WindowManagerService extends IWindowManager.Stub EmulatorDisplayOverlay mEmulatorDisplayOverlay; final float[] mTmpFloats = new float[9]; - final Rect mTmpContentRect = new Rect(); boolean mDisplayReady; boolean mSafeMode; @@ -4829,6 +4828,17 @@ public class WindowManagerService extends IWindowManager.Stub } } + /** Returns true if the input bounds corresponds to the fullscreen bounds the stack is on. */ + public boolean isFullscreenBounds(int stackId, Rect bounds) { + synchronized (mWindowMap) { + final TaskStack stack = mStackIdToStack.get(stackId); + if (stack == null || bounds == null) { + return true; + } + return stack.isFullscreenBounds(bounds); + } + } + /** * Re-sizes a stack and its containing tasks. * @param stackId Id of stack to resize. diff --git a/services/core/java/com/android/server/wm/WindowSurfacePlacer.java b/services/core/java/com/android/server/wm/WindowSurfacePlacer.java index 50bdf257d7ee6..6001321a92dce 100644 --- a/services/core/java/com/android/server/wm/WindowSurfacePlacer.java +++ b/services/core/java/com/android/server/wm/WindowSurfacePlacer.java @@ -96,6 +96,7 @@ class WindowSurfacePlacer { private long mUserActivityTimeout = -1; private boolean mUpdateRotation = false; private final Rect mTmpStartRect = new Rect(); + private final Rect mTmpContentRect = new Rect(); // Set to true when the display contains content to show the user. // When false, the display manager may choose to mirror or blank the display. @@ -862,8 +863,8 @@ class WindowSurfacePlacer { mService.mScreenRect.set(0, 0, dw, dh); } - mService.mPolicy.getContentRectLw(mService.mTmpContentRect); - displayContent.resize(mService.mTmpContentRect); + mService.mPolicy.getContentRectLw(mTmpContentRect); + displayContent.resize(mTmpContentRect); int seq = mService.mLayoutSeq+1; if (seq < 0) seq = 0;