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
15 files changed