diff options
| author | 2021-12-22 13:49:35 -0800 | |
|---|---|---|
| committer | 2022-02-15 23:44:42 -0800 | |
| commit | 544007604f1fb2b0d51b9d05120afff587dcdc3d (patch) | |
| tree | c8de92ba95c2b97a4c49e7cd400d4182bb09788a /libs/WindowManager/Shell | |
| parent | ef65f3d98d6a70afdbc2d4852ee805ef1005fbec (diff) | |
Add Content PiP support with launch-into-pip API
Terms
- Host activity, the activity that the content-pip is originated from.
There should be some UI affordance on Host activity user can tap to
enter content-pip
- Container activity, the activity that carries the content from Host
Activity and transits to PiP mode
Workflow in brief
- Container activity is defined in the same application as Host activity
- A new ActivityOptions#makeLaunchIntoPip API is added, Host activity
uses this API to construct ActivityOptions to launch the Container
activity directly into pip mode.
- ActivityStarter sets a reference on Container activity pointing to
Host activity upon creation and moves the activity to pinned task
- WMShell transits Container activity to pinned mode
- When user taps on `Expand` button in PiP menu, WMShell calls
WCT#startTask with the task id to bring the Host task to front
Content hand-off
- Since Host activity is the one starts Container activity, it can
replace its content with some placeholder right after startActivity
- This CL also makes the assumption that Host activity can establish a
communication channel with the Container activity, such as using the
ResultReceiver parcelable. Therefore it's out of scope to provide
extra callback to Host activity on lifecycle events of Container activity.
See also the design doc go/content-pip-v2 and the end-to-end demo in
ApiDemos `App > Activity > Picture in Picture`
Bug: 165793661
Video: http://recall/-/aaaaaabFQoRHlzixHdtY/e9Mp5rvxYBrNOdGSUoSXHO
Test: manual, see Video
Test: atest WmTests:ActivityOptionsTest \
WmTests:ActivityRecordTests \
WmTests:ActivityStarterTests \
PinnedStackTests
Change-Id: I2bebfea8d1930b0b7e495d91cfd5ddc7c347da68
Diffstat (limited to 'libs/WindowManager/Shell')
| -rw-r--r-- | libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java index 67b39839826c..13d9081bb3ba 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java @@ -310,6 +310,10 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, return mPipTransitionState.isInPip(); } + private boolean isLaunchIntoPipTask() { + return mPictureInPictureParams != null && mPictureInPictureParams.isLaunchIntoPip(); + } + /** * Returns whether the entry animation is waiting to be started. */ @@ -397,6 +401,10 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, } final WindowContainerTransaction wct = new WindowContainerTransaction(); + if (isLaunchIntoPipTask()) { + exitLaunchIntoPipTask(wct); + return; + } if (ENABLE_SHELL_TRANSITIONS) { if (requestEnterSplit && mSplitScreenOptional.isPresent()) { @@ -468,6 +476,14 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, }); } + private void exitLaunchIntoPipTask(WindowContainerTransaction wct) { + wct.startTask(mTaskInfo.launchIntoPipHostTaskId, null /* ActivityOptions */); + mTaskOrganizer.applyTransaction(wct); + + // Remove the PiP with fade-out animation right after the host Task is brought to front. + removePip(); + } + private void applyWindowingModeChangeOnExit(WindowContainerTransaction wct, int direction) { // Reset the final windowing mode. wct.setWindowingMode(mToken, getOutPipWindowingMode()); @@ -729,7 +745,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, } /** - * Note that dismissing PiP is now originated from SystemUI, see {@link #exitPip(int)}. + * Note that dismissing PiP is now originated from SystemUI, see {@link #exitPip(int, boolean)}. * Meanwhile this callback is invoked whenever the task is removed. For instance: * - as a result of removeRootTasksInWindowingModes from WM * - activity itself is died |