Loading services/core/java/com/android/server/wm/LaunchParamsController.java +18 −2 Original line number Diff line number Diff line Loading @@ -133,12 +133,20 @@ class LaunchParamsController { mTmpParams); // No changes, return. if (mTmpParams.isEmpty() || mTmpParams.mBounds.isEmpty()) { if (mTmpParams.isEmpty()) { return false; } mService.deferWindowLayout(); try { if (mTmpParams.mBounds.isEmpty()) { if (!mTmpParams.mBoundsSet) { return false; } // reset the task bounds task.setBounds(mTmpParams.mBounds); return true; } if (task.getRootTask().inMultiWindowMode()) { if (!mTmpParams.mAppBounds.isEmpty()) { task.getRequestedOverrideConfiguration().windowConfiguration.setAppBounds( Loading Loading @@ -176,6 +184,8 @@ class LaunchParamsController { /** The bounds within the parent container. */ @NonNull final Rect mBounds = new Rect(); /** Whether the bounds have been set. */ boolean mBoundsSet = false; /** The bounds within the parent container respecting insets. Usually empty. */ @NonNull final Rect mAppBounds = new Rect(); Loading @@ -195,6 +205,7 @@ class LaunchParamsController { /** Sets values back to default. {@link #isEmpty} will return {@code true} once called. */ void reset() { mBounds.setEmpty(); mBoundsSet = false; mAppBounds.setEmpty(); mPreferredTaskDisplayArea = null; mWindowingMode = WINDOWING_MODE_UNDEFINED; Loading @@ -204,6 +215,7 @@ class LaunchParamsController { /** Copies the values set on the passed in {@link LaunchParams}. */ void set(LaunchParams params) { mBounds.set(params.mBounds); mBoundsSet = params.mBoundsSet; mAppBounds.set(params.mAppBounds); mPreferredTaskDisplayArea = params.mPreferredTaskDisplayArea; mWindowingMode = params.mWindowingMode; Loading @@ -213,6 +225,7 @@ class LaunchParamsController { /** Merges the values set on the passed in {@link LaunchParams}. */ void merge(LaunchParams params) { mBounds.set(params.mBounds); mBoundsSet = params.mBoundsSet; mAppBounds.set(params.mAppBounds); mPreferredTaskDisplayArea = params.mPreferredTaskDisplayArea; mWindowingMode = params.mWindowingMode; Loading @@ -225,7 +238,8 @@ class LaunchParamsController { /** Returns {@code true} if no values have been explicitly set. */ boolean isEmpty() { return mBounds.isEmpty() && mAppBounds.isEmpty() && mPreferredTaskDisplayArea == null return (mBounds.isEmpty() && !mBoundsSet) && mAppBounds.isEmpty() && mPreferredTaskDisplayArea == null && mWindowingMode == WINDOWING_MODE_UNDEFINED && mNeedsSafeRegionBounds == null; } Loading @@ -248,12 +262,14 @@ class LaunchParamsController { if (mWindowingMode != that.mWindowingMode) return false; if (!mAppBounds.equals(that.mAppBounds)) return false; if (!Objects.equals(mNeedsSafeRegionBounds, that.mNeedsSafeRegionBounds)) return false; if (mBoundsSet != that.mBoundsSet) return false; return !mBounds.isEmpty() ? mBounds.equals(that.mBounds) : that.mBounds.isEmpty(); } @Override public int hashCode() { int result = !mBounds.isEmpty() ? mBounds.hashCode() : 0; result = 31 * result + Boolean.hashCode(mBoundsSet); result = 31 * result + mAppBounds.hashCode(); result = 31 * result + (mPreferredTaskDisplayArea != null ? mPreferredTaskDisplayArea.hashCode() : 0); Loading services/core/java/com/android/server/wm/TaskLaunchParamsModifier.java +1 −0 Original line number Diff line number Diff line Loading @@ -225,6 +225,7 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier { // TODO: Investigate whether we can migrate this clause to the // |canApplyBoundsFromActivityOptions| case above. outParams.mBounds.set(options.getLaunchBounds()); outParams.mBoundsSet = true; hasInitialBounds = true; if (DEBUG) appendLog("multiwindow-activity-options-bounds=" + outParams.mBounds); } Loading services/tests/wmtests/src/com/android/server/wm/LaunchParamsControllerTests.java +25 −0 Original line number Diff line number Diff line Loading @@ -504,6 +504,31 @@ public class LaunchParamsControllerTests extends WindowTestsBase { assertEquals(expected, task.getRequestedOverrideBounds()); } /** * Ensures that {@link LaunchParamsModifier} request for bounds to be cleared during layout * is honored if window is in multiwindow mode. */ @Test public void testLayoutTaskBoundsChangeMultiWindow_applyRequestedEmptyBounds() { final Rect emptyBounds = new Rect(); final LaunchParams params = new LaunchParams(); params.mBounds.set(emptyBounds); params.mBoundsSet = true; final InstrumentedPositioner positioner = new InstrumentedPositioner(RESULT_DONE, params); final Task task = new TaskBuilder(mAtm.mTaskSupervisor) .setWindowingMode(WINDOWING_MODE_MULTI_WINDOW).build(); task.setBounds(10, 20, 30, 40); mController.registerModifier(positioner); assertNotEquals(emptyBounds, task.getBounds()); layoutTask(task); assertEquals(emptyBounds, task.getRequestedOverrideBounds()); } /** * Ensures that {@link LaunchParamsModifier} requests specifying bounds during * layout are set to last non-fullscreen bounds. Loading Loading
services/core/java/com/android/server/wm/LaunchParamsController.java +18 −2 Original line number Diff line number Diff line Loading @@ -133,12 +133,20 @@ class LaunchParamsController { mTmpParams); // No changes, return. if (mTmpParams.isEmpty() || mTmpParams.mBounds.isEmpty()) { if (mTmpParams.isEmpty()) { return false; } mService.deferWindowLayout(); try { if (mTmpParams.mBounds.isEmpty()) { if (!mTmpParams.mBoundsSet) { return false; } // reset the task bounds task.setBounds(mTmpParams.mBounds); return true; } if (task.getRootTask().inMultiWindowMode()) { if (!mTmpParams.mAppBounds.isEmpty()) { task.getRequestedOverrideConfiguration().windowConfiguration.setAppBounds( Loading Loading @@ -176,6 +184,8 @@ class LaunchParamsController { /** The bounds within the parent container. */ @NonNull final Rect mBounds = new Rect(); /** Whether the bounds have been set. */ boolean mBoundsSet = false; /** The bounds within the parent container respecting insets. Usually empty. */ @NonNull final Rect mAppBounds = new Rect(); Loading @@ -195,6 +205,7 @@ class LaunchParamsController { /** Sets values back to default. {@link #isEmpty} will return {@code true} once called. */ void reset() { mBounds.setEmpty(); mBoundsSet = false; mAppBounds.setEmpty(); mPreferredTaskDisplayArea = null; mWindowingMode = WINDOWING_MODE_UNDEFINED; Loading @@ -204,6 +215,7 @@ class LaunchParamsController { /** Copies the values set on the passed in {@link LaunchParams}. */ void set(LaunchParams params) { mBounds.set(params.mBounds); mBoundsSet = params.mBoundsSet; mAppBounds.set(params.mAppBounds); mPreferredTaskDisplayArea = params.mPreferredTaskDisplayArea; mWindowingMode = params.mWindowingMode; Loading @@ -213,6 +225,7 @@ class LaunchParamsController { /** Merges the values set on the passed in {@link LaunchParams}. */ void merge(LaunchParams params) { mBounds.set(params.mBounds); mBoundsSet = params.mBoundsSet; mAppBounds.set(params.mAppBounds); mPreferredTaskDisplayArea = params.mPreferredTaskDisplayArea; mWindowingMode = params.mWindowingMode; Loading @@ -225,7 +238,8 @@ class LaunchParamsController { /** Returns {@code true} if no values have been explicitly set. */ boolean isEmpty() { return mBounds.isEmpty() && mAppBounds.isEmpty() && mPreferredTaskDisplayArea == null return (mBounds.isEmpty() && !mBoundsSet) && mAppBounds.isEmpty() && mPreferredTaskDisplayArea == null && mWindowingMode == WINDOWING_MODE_UNDEFINED && mNeedsSafeRegionBounds == null; } Loading @@ -248,12 +262,14 @@ class LaunchParamsController { if (mWindowingMode != that.mWindowingMode) return false; if (!mAppBounds.equals(that.mAppBounds)) return false; if (!Objects.equals(mNeedsSafeRegionBounds, that.mNeedsSafeRegionBounds)) return false; if (mBoundsSet != that.mBoundsSet) return false; return !mBounds.isEmpty() ? mBounds.equals(that.mBounds) : that.mBounds.isEmpty(); } @Override public int hashCode() { int result = !mBounds.isEmpty() ? mBounds.hashCode() : 0; result = 31 * result + Boolean.hashCode(mBoundsSet); result = 31 * result + mAppBounds.hashCode(); result = 31 * result + (mPreferredTaskDisplayArea != null ? mPreferredTaskDisplayArea.hashCode() : 0); Loading
services/core/java/com/android/server/wm/TaskLaunchParamsModifier.java +1 −0 Original line number Diff line number Diff line Loading @@ -225,6 +225,7 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier { // TODO: Investigate whether we can migrate this clause to the // |canApplyBoundsFromActivityOptions| case above. outParams.mBounds.set(options.getLaunchBounds()); outParams.mBoundsSet = true; hasInitialBounds = true; if (DEBUG) appendLog("multiwindow-activity-options-bounds=" + outParams.mBounds); } Loading
services/tests/wmtests/src/com/android/server/wm/LaunchParamsControllerTests.java +25 −0 Original line number Diff line number Diff line Loading @@ -504,6 +504,31 @@ public class LaunchParamsControllerTests extends WindowTestsBase { assertEquals(expected, task.getRequestedOverrideBounds()); } /** * Ensures that {@link LaunchParamsModifier} request for bounds to be cleared during layout * is honored if window is in multiwindow mode. */ @Test public void testLayoutTaskBoundsChangeMultiWindow_applyRequestedEmptyBounds() { final Rect emptyBounds = new Rect(); final LaunchParams params = new LaunchParams(); params.mBounds.set(emptyBounds); params.mBoundsSet = true; final InstrumentedPositioner positioner = new InstrumentedPositioner(RESULT_DONE, params); final Task task = new TaskBuilder(mAtm.mTaskSupervisor) .setWindowingMode(WINDOWING_MODE_MULTI_WINDOW).build(); task.setBounds(10, 20, 30, 40); mController.registerModifier(positioner); assertNotEquals(emptyBounds, task.getBounds()); layoutTask(task); assertEquals(emptyBounds, task.getRequestedOverrideBounds()); } /** * Ensures that {@link LaunchParamsModifier} requests specifying bounds during * layout are set to last non-fullscreen bounds. Loading