diff options
author | Wale Ogunwale <ogunwale@google.com> | 2015-09-16 15:43:05 -0700 |
---|---|---|
committer | Wale Ogunwale <ogunwale@google.com> | 2015-09-16 22:23:47 -0700 |
commit | 61b009e0591df4fcaf5c57c6ce598044263d952f (patch) | |
tree | 1da44da9a24596f64a680b6853d8fff37470f098 | |
parent | 3b2658011819cfe1bed61763bb666bde6e919f79 (diff) |
Don't crop home activity windows to stack bounds.
We crop windows to their stack bounds when the docked stack
exists. We don't want to do this for the home activity since
the docked stack isn't visible when the home activity is visible.
Change-Id: Ibb3157dabbb6c979358ddc2098a01c6ddf6540e8
10 files changed, 39 insertions, 22 deletions
diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl index 33c51ff367c9..32ef99582ac9 100644 --- a/core/java/android/view/IWindowManager.aidl +++ b/core/java/android/view/IWindowManager.aidl @@ -98,11 +98,12 @@ interface IWindowManager * @param taskBounds Bounds to use when creating a new Task with the input task Id if * the task doesn't exist yet. * @param configuration Configuration that is being used with this task. + * @param cropWindowsToStack True if the app windows should be cropped to the stack bounds. */ void addAppToken(int addPos, IApplicationToken token, int taskId, int stackId, int requestedOrientation, boolean fullscreen, boolean showWhenLocked, int userId, int configChanges, boolean voiceInteraction, boolean launchTaskBehind, - in Rect taskBounds, in Configuration configuration); + in Rect taskBounds, in Configuration configuration, boolean cropWindowsToStack); /** * * @param token The token we are adding to the input task Id. diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java index b6f3dc8fe138..3fcffd78d049 100644 --- a/services/core/java/com/android/server/am/ActivityStack.java +++ b/services/core/java/com/android/server/am/ActivityStack.java @@ -4606,7 +4606,7 @@ final class ActivityStack { r.task.taskId, mStackId, r.info.screenOrientation, r.fullscreen, (r.info.flags & ActivityInfo.FLAG_SHOW_FOR_ALL_USERS) != 0, r.userId, r.info.configChanges, task.voiceSession != null, r.mLaunchTaskBehind, - bounds, task.mOverrideConfig); + bounds, task.mOverrideConfig, !r.isHomeActivity()); r.taskConfigOverride = task.mOverrideConfig; } diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java index 4f62909c061a..ff216c5c763d 100644 --- a/services/core/java/com/android/server/wm/AppWindowToken.java +++ b/services/core/java/com/android/server/wm/AppWindowToken.java @@ -112,6 +112,9 @@ class AppWindowToken extends WindowToken { boolean mLaunchTaskBehind; boolean mEnteringAnimation; + // True if the windows associated with this token should be cropped to their stack bounds. + boolean mCropWindowsToStack; + // This application will have its window replaced due to relaunch. This allows window manager // to differentiate between simple removal of a window and replacement. In the latter case it // will preserve the old window until the new one is drawn. diff --git a/services/core/java/com/android/server/wm/DragState.java b/services/core/java/com/android/server/wm/DragState.java index f9809b161144..1e628ffb102c 100644 --- a/services/core/java/com/android/server/wm/DragState.java +++ b/services/core/java/com/android/server/wm/DragState.java @@ -415,7 +415,7 @@ class DragState { continue; } - child.getStackBounds(mTmpRect, !BOUNDS_FOR_TOUCH); + child.getVisibleBounds(mTmpRect, !BOUNDS_FOR_TOUCH); if (!mTmpRect.contains(x, y)) { // outside of this window's activity stack == don't tell about drags continue; diff --git a/services/core/java/com/android/server/wm/InputMonitor.java b/services/core/java/com/android/server/wm/InputMonitor.java index 38988b922c73..4244205aabf8 100644 --- a/services/core/java/com/android/server/wm/InputMonitor.java +++ b/services/core/java/com/android/server/wm/InputMonitor.java @@ -178,7 +178,7 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks { if (modal && child.mAppToken != null) { // Limit the outer touch to the activity stack region. flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL; - child.getStackBounds(mTmpRect, BOUNDS_FOR_TOUCH); + child.getVisibleBounds(mTmpRect, BOUNDS_FOR_TOUCH); inputWindowHandle.touchableRegion.set(mTmpRect); } else { // Not modal or full screen modal diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 7f5e752a6c9c..9608a999cb01 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -3058,7 +3058,7 @@ public class WindowManagerService extends IWindowManager.Stub public void addAppToken(int addPos, IApplicationToken token, int taskId, int stackId, int requestedOrientation, boolean fullscreen, boolean showForAllUsers, int userId, int configChanges, boolean voiceInteraction, boolean launchTaskBehind, - Rect taskBounds, Configuration config) { + Rect taskBounds, Configuration config, boolean cropWindowsToStack) { if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS, "addAppToken()")) { throw new SecurityException("Requires MANAGE_APP_TOKENS permission"); @@ -3092,6 +3092,7 @@ public class WindowManagerService extends IWindowManager.Stub atoken.layoutConfigChanges = (configChanges & (ActivityInfo.CONFIG_SCREEN_SIZE | ActivityInfo.CONFIG_ORIENTATION)) != 0; atoken.mLaunchTaskBehind = launchTaskBehind; + atoken.mCropWindowsToStack = cropWindowsToStack; if (DEBUG_TOKEN_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v(TAG, "addAppToken: " + atoken + " to stack=" + stackId + " task=" + taskId + " at " + addPos); @@ -5634,7 +5635,7 @@ public class WindowManagerService extends IWindowManager.Stub int right = wf.right - cr.right; int bottom = wf.bottom - cr.bottom; frame.union(left, top, right, bottom); - ws.getStackBounds(stackBounds, !BOUNDS_FOR_TOUCH); + ws.getVisibleBounds(stackBounds, !BOUNDS_FOR_TOUCH); if (!frame.intersect(stackBounds)) { // Set frame empty if there's no intersection. frame.setEmpty(); diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index d48ba5716f94..94bc8d75829c 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -935,26 +935,37 @@ final class WindowState implements WindowManagerPolicy.WindowState { } /** - * Retrieves the bounds of the window stack. + * Retrieves the visible bounds of the window. * @param bounds The rect which gets the bounds. * @param forTouch Pass in BOUNDS_FOR_TOUCH to get touch related bounds, otherwise visible * bounds will be returned. */ - void getStackBounds(Rect bounds, boolean forTouch) { - final TaskStack stack = getStack(); - if (stack != null) { - stack.getBounds(bounds); - if (forTouch == BOUNDS_FOR_TOUCH) { - if (stack.mStackId == FREEFORM_WORKSPACE_STACK_ID) { - final DisplayMetrics displayMetrics = getDisplayContent().getDisplayMetrics(); - final int delta = - mService.dipToPixel(RESIZE_HANDLE_WIDTH_IN_DP, displayMetrics); - bounds.inset(-delta, -delta); - } + void getVisibleBounds(Rect bounds, boolean forTouch) { + final boolean useStackBounds = mAppToken != null && mAppToken.mCropWindowsToStack; + boolean isFreeform = false; + bounds.setEmpty(); + if (useStackBounds) { + final TaskStack stack = getStack(); + if (stack != null) { + stack.getBounds(bounds); + isFreeform = stack.mStackId == FREEFORM_WORKSPACE_STACK_ID; + } + } else { + final Task task = getTask(); + if (task != null) { + task.getBounds(bounds); + isFreeform = task.inFreeformWorkspace(); } + } + if (bounds.isEmpty()) { + bounds.set(mFrame); return; } - bounds.set(mFrame); + if (forTouch && isFreeform) { + final DisplayMetrics displayMetrics = getDisplayContent().getDisplayMetrics(); + final int delta = mService.dipToPixel(RESIZE_HANDLE_WIDTH_IN_DP, displayMetrics); + bounds.inset(-delta, -delta); + } } public long getInputDispatchingTimeoutNanos() { diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java index dfc9784249a9..2fe7fd658243 100644 --- a/services/core/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java @@ -1377,7 +1377,8 @@ class WindowStateAnimator { } private void adjustCropToStackBounds(WindowState w, Rect clipRect) { - if (w.getAttrs().type == LayoutParams.TYPE_BASE_APPLICATION) { + final AppWindowToken appToken = w.mAppToken; + if (appToken != null && appToken.mCropWindowsToStack) { TaskStack stack = w.getTask().mStack; stack.getBounds(mTmpStackBounds); final int surfaceX = (int) mSurfaceX; diff --git a/tests/permission/src/com/android/framework/permission/tests/WindowManagerPermissionTests.java b/tests/permission/src/com/android/framework/permission/tests/WindowManagerPermissionTests.java index 95f676e08895..b9e7500598d1 100644 --- a/tests/permission/src/com/android/framework/permission/tests/WindowManagerPermissionTests.java +++ b/tests/permission/src/com/android/framework/permission/tests/WindowManagerPermissionTests.java @@ -94,7 +94,7 @@ public class WindowManagerPermissionTests extends TestCase { try { mWm.addAppToken(0, null, 0, 0, 0, false, false, 0, 0, false, false, null, - Configuration.EMPTY); + Configuration.EMPTY, false); fail("IWindowManager.addAppToken did not throw SecurityException as" + " expected"); } catch (SecurityException e) { diff --git a/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java b/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java index ed8b56e1e601..778d1a5e51ac 100644 --- a/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java +++ b/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java @@ -76,7 +76,7 @@ public class IWindowManagerImpl implements IWindowManager { @Override public void addAppToken(int arg0, IApplicationToken arg1, int arg2, int arg3, int arg4, boolean arg5, boolean arg6, int arg7, int arg8, boolean arg9, boolean arg10, - Rect arg11, Configuration arg12) throws RemoteException { + Rect arg11, Configuration arg12, boolean arg13) throws RemoteException { // TODO Auto-generated method stub } |