OSDN Git Service

Provide activity details for task layout in ActivityStarter.
authorBryce Lee <brycelee@google.com>
Thu, 16 Nov 2017 05:25:03 +0000 (21:25 -0800)
committerBryce Lee <brycelee@google.com>
Tue, 28 Nov 2017 17:42:54 +0000 (09:42 -0800)
When a task is created as the result of an activity starter, there
are details present in the starter than can be useful for layout,
such as the source and launching activity records. This changelist
adds these details to the layout invocation.

Change-Id: I2d6d22c8390b03004d020d6d92196bb2a85fdd3d
Fixes: 68719294
Test: go/wm-smoke

services/core/java/com/android/server/am/ActivityStack.java
services/core/java/com/android/server/am/ActivityStarter.java
services/core/java/com/android/server/am/LaunchingBoundsController.java
services/tests/servicestests/src/com/android/server/am/ActivityStarterTests.java

index 4816998..5083e1b 100644 (file)
@@ -4988,13 +4988,22 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
     TaskRecord createTaskRecord(int taskId, ActivityInfo info, Intent intent,
             IVoiceInteractionSession voiceSession, IVoiceInteractor voiceInteractor,
             boolean toTop) {
+        return createTaskRecord(taskId, info, intent, voiceSession, voiceInteractor, toTop,
+                null /*activity*/, null /*source*/, null /*options*/);
+    }
+
+    TaskRecord createTaskRecord(int taskId, ActivityInfo info, Intent intent,
+            IVoiceInteractionSession voiceSession, IVoiceInteractor voiceInteractor,
+            boolean toTop, ActivityRecord activity, ActivityRecord source,
+            ActivityOptions options) {
         final TaskRecord task = new TaskRecord(mService, taskId, info, intent, voiceSession,
                 voiceInteractor);
         // add the task to stack first, mTaskPositioner might need the stack association
         addTask(task, toTop, "createTaskRecord");
         final boolean isLockscreenShown = mService.mStackSupervisor.getKeyguardController()
                 .isKeyguardShowing(mDisplayId != INVALID_DISPLAY ? mDisplayId : DEFAULT_DISPLAY);
-        if (!mStackSupervisor.getLaunchingBoundsController().layoutTask(task, info.windowLayout)
+        if (!mStackSupervisor.getLaunchingBoundsController()
+                .layoutTask(task, info.windowLayout, activity, source, options)
                 && !matchParentBounds() && task.isResizeable() && !isLockscreenShown) {
             task.updateOverrideConfiguration(getOverrideBounds());
         }
index 03162bb..6010422 100644 (file)
@@ -1756,7 +1756,8 @@ class ActivityStarter {
                     mSupervisor.getNextTaskIdForUserLocked(mStartActivity.userId),
                     mNewTaskInfo != null ? mNewTaskInfo : mStartActivity.info,
                     mNewTaskIntent != null ? mNewTaskIntent : mIntent, mVoiceSession,
-                    mVoiceInteractor, !mLaunchTaskBehind /* toTop */);
+                    mVoiceInteractor, !mLaunchTaskBehind /* toTop */, mStartActivity, mSourceRecord,
+                    mOptions);
             addOrReparentStartingActivity(task, "setTaskFromReuseOrCreateNewTask - mReuseTask");
             updateBounds(mStartActivity.getTask(), mLaunchBounds);
 
@@ -1965,7 +1966,7 @@ class ActivityStarter {
         final ActivityRecord prev = mTargetStack.getTopActivity();
         final TaskRecord task = (prev != null) ? prev.getTask() : mTargetStack.createTaskRecord(
                 mSupervisor.getNextTaskIdForUserLocked(mStartActivity.userId), mStartActivity.info,
-                mIntent, null, null, true);
+                mIntent, null, null, true, mStartActivity, mSourceRecord, mOptions);
         addOrReparentStartingActivity(task, "setTaskToCurrentTopOrCreateNewTask");
         mTargetStack.positionChildWindowContainerAtTop(task);
         if (DEBUG_TASKS) Slog.v(TAG_TASKS, "Starting new activity " + mStartActivity
index c762f7f..5aa7f58 100644 (file)
@@ -101,8 +101,12 @@ 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 /*source*/, null /*options*/,
-                mTmpRect);
+        return layoutTask(task, layout, null /*activity*/, null /*source*/, null /*options*/);
+    }
+
+    boolean layoutTask(TaskRecord task, WindowLayout layout, ActivityRecord activity,
+            ActivityRecord source, ActivityOptions options) {
+        calculateBounds(task, layout, activity, source, options, mTmpRect);
 
         if (mTmpRect.isEmpty()) {
             return false;
index b4919b6..1cec0d9 100644 (file)
@@ -277,4 +277,10 @@ public class ActivityStarterTests extends ActivityTestsBase {
             verify(options, times(1)).abort();
         }
     }
+
+// TODO(b/69270257): Add test to verify task layout is passed additional data such as activity and
+// source.
+//    @Test
+//    public void testCreateTaskLayout() {
+//    }
 }