Loading services/core/java/com/android/server/am/ActivityStarter.java +1 −13 Original line number Diff line number Diff line Loading @@ -26,9 +26,6 @@ import static android.app.ActivityManager.START_RETURN_INTENT_TO_CALLER; import static android.app.ActivityManager.START_RETURN_LOCK_TASK_MODE_VIOLATION; import static android.app.ActivityManager.START_SUCCESS; import static android.app.ActivityManager.START_TASK_TO_FRONT; import static android.app.WindowConfiguration.ACTIVITY_TYPE_ASSISTANT; import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; Loading Loading @@ -1249,7 +1246,7 @@ class ActivityStarter { mLaunchBounds.setEmpty(); mSupervisor.getLaunchingBoundsController().calculateBounds(inTask, null /*layout*/, r, options, mLaunchBounds); sourceRecord, options, mLaunchBounds); mLaunchMode = r.launchMode; Loading Loading @@ -2170,15 +2167,6 @@ class ActivityStarter { } } private Rect getOverrideBounds(ActivityRecord r, ActivityOptions options, TaskRecord inTask) { Rect newBounds = null; if (mSupervisor.canUseActivityOptionsLaunchBounds(options) && (r.isResizeable() || (inTask != null && inTask.isResizeable()))) { newBounds = TaskRecord.validateBounds(options.getLaunchBounds()); } return newBounds; } private boolean isLaunchModeOneOf(int mode1, int mode2) { return mode1 == mLaunchMode || mode2 == mLaunchMode; } Loading services/core/java/com/android/server/am/LaunchingActivityPositioner.java +2 −1 Original line number Diff line number Diff line Loading @@ -34,7 +34,8 @@ public class LaunchingActivityPositioner implements LaunchingBoundsPositioner { @Override public int onCalculateBounds(TaskRecord task, ActivityInfo.WindowLayout layout, ActivityRecord activity, ActivityOptions options, Rect current, Rect result) { ActivityRecord activity, ActivityRecord source, ActivityOptions options, Rect current, Rect result) { // We only care about figuring out bounds for activities. if (activity == null) { return RESULT_SKIP; Loading services/core/java/com/android/server/am/LaunchingBoundsController.java +10 −7 Original line number Diff line number Diff line Loading @@ -62,12 +62,13 @@ class LaunchingBoundsController { * @param task The {@link TaskRecord} currently being positioned. * @param layout The specified {@link WindowLayout}. * @param activity The {@link ActivityRecord} currently being positioned. * @param source The {@link ActivityRecord} from which activity was started from. * @param options The {@link ActivityOptions} specified for the activity. * @param result The resulting bounds. If no bounds are set, {@link Rect#isEmpty()} will be * true. * {@code true}. */ void calculateBounds(TaskRecord task, WindowLayout layout, ActivityRecord activity, ActivityOptions options, Rect result) { ActivityRecord source, ActivityOptions options, Rect result) { result.setEmpty(); // We start at the last registered {@link LaunchingBoundsPositioner} as this represents Loading @@ -78,8 +79,8 @@ class LaunchingBoundsController { mTmpCurrent.set(result); final LaunchingBoundsPositioner positioner = mPositioners.get(i); switch(positioner.onCalculateBounds(task, layout, activity, options, mTmpCurrent, mTmpResult)) { switch(positioner.onCalculateBounds(task, layout, activity, source, options, mTmpCurrent, mTmpResult)) { case RESULT_SKIP: // Do not apply any results when we are told to skip continue; Loading @@ -100,7 +101,8 @@ class LaunchingBoundsController { * @return {@code true} if bounds were set on the task. {@code false} otherwise. */ boolean layoutTask(TaskRecord task, WindowLayout layout) { calculateBounds(task, layout, null /*activity*/, null /*options*/, mTmpRect); calculateBounds(task, layout, null /*activity*/, null /*source*/, null /*options*/, mTmpRect); if (mTmpRect.isEmpty()) { return false; Loading Loading @@ -145,6 +147,7 @@ class LaunchingBoundsController { * @param task The {@link TaskRecord} currently being positioned. * @param layout The specified {@link WindowLayout}. * @param activity The {@link ActivityRecord} currently being positioned. * @param source The {@link ActivityRecord} activity was started from. * @param options The {@link ActivityOptions} specified for the activity. * @param current The current bounds. This can differ from the initial bounds as it * represents the modified bounds up to this point. Loading @@ -155,6 +158,6 @@ class LaunchingBoundsController { */ @Result int onCalculateBounds(TaskRecord task, WindowLayout layout, ActivityRecord activity, ActivityOptions options, Rect current, Rect result); ActivityRecord source, ActivityOptions options, Rect current, Rect result); } } services/core/java/com/android/server/am/LaunchingTaskPositioner.java +2 −1 Original line number Diff line number Diff line Loading @@ -79,7 +79,8 @@ class LaunchingTaskPositioner implements LaunchingBoundsController.LaunchingBoun */ @Override public int onCalculateBounds(TaskRecord task, ActivityInfo.WindowLayout layout, ActivityRecord activity, ActivityOptions options, Rect current, Rect result) { ActivityRecord activity, ActivityRecord source, ActivityOptions options, Rect current, Rect result) { // We can only apply positioning if we're in a freeform stack. if (task == null || task.getStack() == null || !task.inFreeformWindowingMode()) { return RESULT_SKIP; Loading services/tests/servicestests/src/com/android/server/am/LaunchingActivityPositionerTests.java +10 −10 Original line number Diff line number Diff line Loading @@ -79,35 +79,35 @@ public class LaunchingActivityPositionerTests extends ActivityTestsBase { public void testSkippedInvocations() throws Exception { // No specified activity should be ignored assertEquals(RESULT_SKIP, mPositioner.onCalculateBounds(null /*task*/, null /*layout*/, null /*activity*/, null /*options*/, mCurrent, mResult)); null /*activity*/, null /*source*/, null /*options*/, mCurrent, mResult)); // No specified activity options should be ignored assertEquals(RESULT_SKIP, mPositioner.onCalculateBounds(null /*task*/, null /*layout*/, mActivity, null /*options*/, mCurrent, mResult)); mActivity, null /*source*/, null /*options*/, mCurrent, mResult)); // launch bounds specified should be ignored. final ActivityOptions options = ActivityOptions.makeBasic(); assertEquals(RESULT_SKIP, mPositioner.onCalculateBounds(null /*task*/, null /*layout*/, mActivity, options /*options*/, mCurrent, mResult)); mActivity, null /*source*/, options /*options*/, mCurrent, mResult)); // Non-resizeable records should be ignored mActivity.info.resizeMode = ActivityInfo.RESIZE_MODE_UNRESIZEABLE; assertFalse(mActivity.isResizeable()); assertEquals(RESULT_SKIP, mPositioner.onCalculateBounds(null /*task*/, null /*layout*/, mActivity, options /*options*/, mCurrent, mResult)); mActivity, null /*source*/, options /*options*/, mCurrent, mResult)); // make record resizeable mActivity.info.resizeMode = ActivityInfo.RESIZE_MODE_RESIZEABLE; assertTrue(mActivity.isResizeable()); assertEquals(RESULT_SKIP, mPositioner.onCalculateBounds(null /*task*/, null /*layout*/, mActivity, options /*options*/, mCurrent, mResult)); mActivity, null /*source*/, options /*options*/, mCurrent, mResult)); // Does not support freeform mService.mSupportsFreeformWindowManagement = false; assertFalse(mService.mStackSupervisor.canUseActivityOptionsLaunchBounds(options)); assertEquals(RESULT_SKIP, mPositioner.onCalculateBounds(null /*task*/, null /*layout*/, mActivity, options /*options*/, mCurrent, mResult)); mActivity, null /*source*/, options /*options*/, mCurrent, mResult)); mService.mSupportsFreeformWindowManagement = true; options.setLaunchBounds(new Rect()); Loading @@ -115,15 +115,15 @@ public class LaunchingActivityPositionerTests extends ActivityTestsBase { // Invalid bounds assertEquals(RESULT_SKIP, mPositioner.onCalculateBounds(null /*task*/, null /*layout*/, mActivity, options /*options*/, mCurrent, mResult)); mActivity, null /*source*/, options /*options*/, mCurrent, mResult)); options.setLaunchBounds(new Rect(0, 0, -1, -1)); assertEquals(RESULT_SKIP, mPositioner.onCalculateBounds(null /*task*/, null /*layout*/, mActivity, options /*options*/, mCurrent, mResult)); mActivity, null /*source*/, options /*options*/, mCurrent, mResult)); // Valid bounds should cause the positioner to be applied. options.setLaunchBounds(new Rect(0, 0, 100, 100)); assertEquals(RESULT_DONE, mPositioner.onCalculateBounds(null /*task*/, null /*layout*/, mActivity, options /*options*/, mCurrent, mResult)); mActivity, null /*source*/, options /*options*/, mCurrent, mResult)); } @Test Loading @@ -137,7 +137,7 @@ public class LaunchingActivityPositionerTests extends ActivityTestsBase { options.setLaunchBounds(proposedBounds); assertEquals(RESULT_DONE, mPositioner.onCalculateBounds(null /*task*/, null /*layout*/, mActivity, options /*options*/, mCurrent, mResult)); mActivity, null /*source*/, options /*options*/, mCurrent, mResult)); assertEquals(mResult, proposedBounds); } } Loading
services/core/java/com/android/server/am/ActivityStarter.java +1 −13 Original line number Diff line number Diff line Loading @@ -26,9 +26,6 @@ import static android.app.ActivityManager.START_RETURN_INTENT_TO_CALLER; import static android.app.ActivityManager.START_RETURN_LOCK_TASK_MODE_VIOLATION; import static android.app.ActivityManager.START_SUCCESS; import static android.app.ActivityManager.START_TASK_TO_FRONT; import static android.app.WindowConfiguration.ACTIVITY_TYPE_ASSISTANT; import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; Loading Loading @@ -1249,7 +1246,7 @@ class ActivityStarter { mLaunchBounds.setEmpty(); mSupervisor.getLaunchingBoundsController().calculateBounds(inTask, null /*layout*/, r, options, mLaunchBounds); sourceRecord, options, mLaunchBounds); mLaunchMode = r.launchMode; Loading Loading @@ -2170,15 +2167,6 @@ class ActivityStarter { } } private Rect getOverrideBounds(ActivityRecord r, ActivityOptions options, TaskRecord inTask) { Rect newBounds = null; if (mSupervisor.canUseActivityOptionsLaunchBounds(options) && (r.isResizeable() || (inTask != null && inTask.isResizeable()))) { newBounds = TaskRecord.validateBounds(options.getLaunchBounds()); } return newBounds; } private boolean isLaunchModeOneOf(int mode1, int mode2) { return mode1 == mLaunchMode || mode2 == mLaunchMode; } Loading
services/core/java/com/android/server/am/LaunchingActivityPositioner.java +2 −1 Original line number Diff line number Diff line Loading @@ -34,7 +34,8 @@ public class LaunchingActivityPositioner implements LaunchingBoundsPositioner { @Override public int onCalculateBounds(TaskRecord task, ActivityInfo.WindowLayout layout, ActivityRecord activity, ActivityOptions options, Rect current, Rect result) { ActivityRecord activity, ActivityRecord source, ActivityOptions options, Rect current, Rect result) { // We only care about figuring out bounds for activities. if (activity == null) { return RESULT_SKIP; Loading
services/core/java/com/android/server/am/LaunchingBoundsController.java +10 −7 Original line number Diff line number Diff line Loading @@ -62,12 +62,13 @@ class LaunchingBoundsController { * @param task The {@link TaskRecord} currently being positioned. * @param layout The specified {@link WindowLayout}. * @param activity The {@link ActivityRecord} currently being positioned. * @param source The {@link ActivityRecord} from which activity was started from. * @param options The {@link ActivityOptions} specified for the activity. * @param result The resulting bounds. If no bounds are set, {@link Rect#isEmpty()} will be * true. * {@code true}. */ void calculateBounds(TaskRecord task, WindowLayout layout, ActivityRecord activity, ActivityOptions options, Rect result) { ActivityRecord source, ActivityOptions options, Rect result) { result.setEmpty(); // We start at the last registered {@link LaunchingBoundsPositioner} as this represents Loading @@ -78,8 +79,8 @@ class LaunchingBoundsController { mTmpCurrent.set(result); final LaunchingBoundsPositioner positioner = mPositioners.get(i); switch(positioner.onCalculateBounds(task, layout, activity, options, mTmpCurrent, mTmpResult)) { switch(positioner.onCalculateBounds(task, layout, activity, source, options, mTmpCurrent, mTmpResult)) { case RESULT_SKIP: // Do not apply any results when we are told to skip continue; Loading @@ -100,7 +101,8 @@ class LaunchingBoundsController { * @return {@code true} if bounds were set on the task. {@code false} otherwise. */ boolean layoutTask(TaskRecord task, WindowLayout layout) { calculateBounds(task, layout, null /*activity*/, null /*options*/, mTmpRect); calculateBounds(task, layout, null /*activity*/, null /*source*/, null /*options*/, mTmpRect); if (mTmpRect.isEmpty()) { return false; Loading Loading @@ -145,6 +147,7 @@ class LaunchingBoundsController { * @param task The {@link TaskRecord} currently being positioned. * @param layout The specified {@link WindowLayout}. * @param activity The {@link ActivityRecord} currently being positioned. * @param source The {@link ActivityRecord} activity was started from. * @param options The {@link ActivityOptions} specified for the activity. * @param current The current bounds. This can differ from the initial bounds as it * represents the modified bounds up to this point. Loading @@ -155,6 +158,6 @@ class LaunchingBoundsController { */ @Result int onCalculateBounds(TaskRecord task, WindowLayout layout, ActivityRecord activity, ActivityOptions options, Rect current, Rect result); ActivityRecord source, ActivityOptions options, Rect current, Rect result); } }
services/core/java/com/android/server/am/LaunchingTaskPositioner.java +2 −1 Original line number Diff line number Diff line Loading @@ -79,7 +79,8 @@ class LaunchingTaskPositioner implements LaunchingBoundsController.LaunchingBoun */ @Override public int onCalculateBounds(TaskRecord task, ActivityInfo.WindowLayout layout, ActivityRecord activity, ActivityOptions options, Rect current, Rect result) { ActivityRecord activity, ActivityRecord source, ActivityOptions options, Rect current, Rect result) { // We can only apply positioning if we're in a freeform stack. if (task == null || task.getStack() == null || !task.inFreeformWindowingMode()) { return RESULT_SKIP; Loading
services/tests/servicestests/src/com/android/server/am/LaunchingActivityPositionerTests.java +10 −10 Original line number Diff line number Diff line Loading @@ -79,35 +79,35 @@ public class LaunchingActivityPositionerTests extends ActivityTestsBase { public void testSkippedInvocations() throws Exception { // No specified activity should be ignored assertEquals(RESULT_SKIP, mPositioner.onCalculateBounds(null /*task*/, null /*layout*/, null /*activity*/, null /*options*/, mCurrent, mResult)); null /*activity*/, null /*source*/, null /*options*/, mCurrent, mResult)); // No specified activity options should be ignored assertEquals(RESULT_SKIP, mPositioner.onCalculateBounds(null /*task*/, null /*layout*/, mActivity, null /*options*/, mCurrent, mResult)); mActivity, null /*source*/, null /*options*/, mCurrent, mResult)); // launch bounds specified should be ignored. final ActivityOptions options = ActivityOptions.makeBasic(); assertEquals(RESULT_SKIP, mPositioner.onCalculateBounds(null /*task*/, null /*layout*/, mActivity, options /*options*/, mCurrent, mResult)); mActivity, null /*source*/, options /*options*/, mCurrent, mResult)); // Non-resizeable records should be ignored mActivity.info.resizeMode = ActivityInfo.RESIZE_MODE_UNRESIZEABLE; assertFalse(mActivity.isResizeable()); assertEquals(RESULT_SKIP, mPositioner.onCalculateBounds(null /*task*/, null /*layout*/, mActivity, options /*options*/, mCurrent, mResult)); mActivity, null /*source*/, options /*options*/, mCurrent, mResult)); // make record resizeable mActivity.info.resizeMode = ActivityInfo.RESIZE_MODE_RESIZEABLE; assertTrue(mActivity.isResizeable()); assertEquals(RESULT_SKIP, mPositioner.onCalculateBounds(null /*task*/, null /*layout*/, mActivity, options /*options*/, mCurrent, mResult)); mActivity, null /*source*/, options /*options*/, mCurrent, mResult)); // Does not support freeform mService.mSupportsFreeformWindowManagement = false; assertFalse(mService.mStackSupervisor.canUseActivityOptionsLaunchBounds(options)); assertEquals(RESULT_SKIP, mPositioner.onCalculateBounds(null /*task*/, null /*layout*/, mActivity, options /*options*/, mCurrent, mResult)); mActivity, null /*source*/, options /*options*/, mCurrent, mResult)); mService.mSupportsFreeformWindowManagement = true; options.setLaunchBounds(new Rect()); Loading @@ -115,15 +115,15 @@ public class LaunchingActivityPositionerTests extends ActivityTestsBase { // Invalid bounds assertEquals(RESULT_SKIP, mPositioner.onCalculateBounds(null /*task*/, null /*layout*/, mActivity, options /*options*/, mCurrent, mResult)); mActivity, null /*source*/, options /*options*/, mCurrent, mResult)); options.setLaunchBounds(new Rect(0, 0, -1, -1)); assertEquals(RESULT_SKIP, mPositioner.onCalculateBounds(null /*task*/, null /*layout*/, mActivity, options /*options*/, mCurrent, mResult)); mActivity, null /*source*/, options /*options*/, mCurrent, mResult)); // Valid bounds should cause the positioner to be applied. options.setLaunchBounds(new Rect(0, 0, 100, 100)); assertEquals(RESULT_DONE, mPositioner.onCalculateBounds(null /*task*/, null /*layout*/, mActivity, options /*options*/, mCurrent, mResult)); mActivity, null /*source*/, options /*options*/, mCurrent, mResult)); } @Test Loading @@ -137,7 +137,7 @@ public class LaunchingActivityPositionerTests extends ActivityTestsBase { options.setLaunchBounds(proposedBounds); assertEquals(RESULT_DONE, mPositioner.onCalculateBounds(null /*task*/, null /*layout*/, mActivity, options /*options*/, mCurrent, mResult)); mActivity, null /*source*/, options /*options*/, mCurrent, mResult)); assertEquals(mResult, proposedBounds); } }