Commit Graph

205 Commits

Author SHA1 Message Date
Charles Chen
894d516094 Merge "Add stub for WindowExtensions v2 APIs" into tm-qpr-dev 2022-09-15 06:34:13 +00:00
Chris Li
48bf845657 Merge "Update ActivityEmbedding split open/close animation adapter for legacy" into tm-qpr-dev 2022-09-15 06:27:37 +00:00
Charles Chen
e4ce409770 Add stub for WindowExtensions v2 APIs
To make WM extensions consistent with androidx branch.

Test: build pass
Bug: 207494880
Change-Id: I1d3ed66804baa99154dbdfd208f8c37767895c27
2022-09-14 11:11:50 +08:00
Chris Li
d5e6eea948 Update ActivityEmbedding split open/close animation adapter for legacy
Make sure the open/close a pair of activities act as one.
Cleanup unused adapter that was introduced for scaling animation, which
is replaced with x coordinate animation in T.

Bug: 241043533
Test: manually verify the animation with legacy transition
Change-Id: I3202895d204d618b4a2d95c9709614a0114543da
2022-09-13 09:51:13 +08:00
Chris Li
08966df3e8 Handle embedding startActivity Intent when calling from application
Before, we only resolve the Intent if it is called with Activity
context, which skip handling cross-process embedding if the
startActivity is called with Application context.

Now, when startActivity is called with Application context, we will
check if the Intent should be embedded in the known Task in the
organizer process.

Bug: 244411454
Test: atest WMJetpackUnitTests:SplitControllerTest
Change-Id: Ic1ee4f23330b4ce35888c0eabd1ee8eb13d13140
2022-09-07 11:14:46 +08:00
TreeHugger Robot
379c38b1ae Merge "Update TaskFragmentToken for Activity relaunch" into tm-qpr-dev 2022-09-01 21:51:47 +00:00
Chris Li
dc7cb3659d Add TaskFragmentOrganizer#applyTransaction with request transition
Instead of having WM Core to "guess" when to request transtiion, let the
organizer to tell whether or not it needs to be applied immediately.

With the shouldApplyIndependently parameter, we can make sure the future
runtime API to change split layout won't affect other ongoing
transition.

Bug: 207070762
Test: atest WmTests:TaskFragmentOrganizerControllerTest
Change-Id: I658b0ba1ae9decc741f09cb53bfff2c45ea076a0
2022-09-01 12:00:31 +08:00
Chris Li
f1bf8d6d9d Update TaskFragmentToken for Activity relaunch
Before, we store the TaskFragmentToken in ActivityClientRecord from
LaunchActivityItem, which won't update if the Activity is relaunched.
Now, we update the token when the activity is reparented to make sure
the token is up-to-date when relaunched.

Also make sure that when activity is destroyed, it is no longer
available using SplitController#getContainerWithActivity(Activity).

Bug: 243330085
Test: atest WMJetpackUnitTests:TaskFragmentContainerTest
Change-Id: I37f1a442c6f1bfb40f04f61eb4f9a3d8d09733ee
2022-08-31 11:37:17 +08:00
Chris Li
93a5865a6f Make sure the secondary TaskFragment is above the primary
Before, we may reuse the existing TaskFragment for secondary activity,
which may be below the primary TaskFragment. Now, we make sure the
secondary TaskFragment is always on top.

Bug: 244254584
Test: atest WMJetpackUnitTests:SplitPresenterTest
Test: atest WMJetpackUnitTests:TaskFragmentContainerTest
Change-Id: Id4c240af71fbd344126ae8bbbad57d9c2150d550
2022-08-30 17:32:48 +08:00
Chris Li
513a9ffcbb Handle TaskFragmentOrganizer#onTransactionReady in sync
Refactor TaskFragmentOrganizer#onTransactionReady to
SplitController#onTransactionReady to make sure that the
transaction is handled in one sync block.

Bug: 240519866
Test: pass existing for refactor
Change-Id: I9e7191e2b71ba262e1a3f8c947f9354698382972
2022-08-27 07:38:50 +08:00
Charles Chen
e85f761308 Merge "Add WindowContext support to WindowLayoutComponentImpl" into tm-qpr-dev 2022-08-25 08:28:25 +00:00
Diego Vela
fe97a18570 Avoid Concurrent Exception in BaseDataProducer.
Add locks to protect the list of consumers.
We are seeing concurrent modification exceptions because
DeviceStateManager sends changes on a separate thread.

Bug: 241464751
Test: n/a could not generate a non-flaky test.
Change-Id: Ie49c0f4f16db39187c98609ac57734e468c3f507
2022-08-24 17:46:07 +00:00
Charles Chen
8ee9dd3b6d Add WindowContext support to WindowLayoutComponentImpl
To make activity embedding library able to listen to folding state
change consistently, we should add WindowContext support to
WindowLayoutComponentImpl, which only supported Activity previously.

This CL can also benefit VoiceInteractionSession support on
WindowLayoutComponent.

Bug: 207494880
Bug: 204073440
Test: use in follow-up CL and report folding state change successfully

Change-Id: I7a4fea6ed00b52996c7cffb33aadb934abe811c8
2022-08-25 01:34:27 +08:00
Kenneth Ford
51d289b772 Merge changes from topic "rear-display-qpr" into tm-qpr-dev
* changes:
  Increments Extensions API version for Rear display API's
  Adds support for enabling and disabling rear display mode.
  Adds extensions implementation for WindowAreaComponent and rear display status listeners
2022-08-22 23:12:02 +00:00
Chris Li
f215542792 Merge "Apply TaskFragmentOrganizer changes in one WCT (2/2)" into tm-qpr-dev 2022-08-21 02:07:04 +00:00
Chris Li
660101fdc7 Apply TaskFragmentOrganizer changes in one WCT (2/2)
Before, when receive TaskFragment transaction, we apply changes in
multiple WindowContainerTransactions. Now, update to apply all changes
in one WCT for the whole TaskFragment transaction.

Bug: 240519866
Test: pass existing
Change-Id: I943d6232ff226ed6f67367fa9b7f73e1f861de64
Merged-In: I943d6232ff226ed6f67367fa9b7f73e1f861de64
2022-08-20 20:19:57 +08:00
Fiona Campbell
a01ccaae13 Merge changes I36ea0ffc,I1f3797c5,I01aeeedd into tm-qpr-dev
* changes:
  Add constraints to window duration scale
  Add constraints to animation duration scales
  Ensure animation scales are within bounds
2022-08-19 14:49:40 +00:00
Chris Li
e9a1037439 Apply TaskFragmentOrganizer changes in one WCT (1/2)
Before, when receive TaskFragment transaction, we apply changes in
multiple WindowContainerTransactions. Now, update to apply all changes
in one WCT for the whole TaskFragment transaction.

Will update the TestAPI in the followup cl.

Bug: 240519866
Test: pass existing
Change-Id: I2e15b187bee95193874d76bc6963d3e01eba3910
2022-08-17 08:51:03 +08:00
Chris Li
99da16cdc8 Address TaskFragmentOrganizer style comments
1. Rename onActivityReparentToTask to onActivityReparentedToTask
2. Annotate @NonNull and @Nullable for the Extensions methods that are
   not yet annotated.

Bug: 240519866
Test: Refactor and add annotation. Pass existing tests.
Change-Id: I85c5927e6e7261cae3bce715b1955523d430e1e2
2022-08-17 08:46:28 +08:00
Fiona Campbell
43ca1914b2 Ensure animation scales are within bounds
Ensure that all uses of TRANSITION_ANIMATION_SCALE setting are bounded
between 0 and 20.

Bug: 238178261
Test: adb shell dumpsys window windows | grep "Animation setting"

Change-Id: I01aeeeddcbcdce0824d61db6b8f4a8946595131d
2022-08-15 11:16:33 +00:00
Kenneth Ford
22740a10df Increments Extensions API version for Rear display API's
Bug: 207686851
Test: Build & Run
Change-Id: If417305d4974ee4c3fae4e2fe535e1095cfea459
2022-08-09 20:54:05 +00:00
Kenneth Ford
3ea6a2da82 Adds support for enabling and disabling rear display mode.
This adds the functionality for enabling rear display mode in
WindowAreaComponentImpl.

Bug: 207686851
Test: ExtensionWindowAreaComponentTest
Change-Id: If8ac9d23e16e7aa5e12bdedbe4688226aff32d38
2022-08-09 20:53:54 +00:00
Kenneth Ford
571d4a6d62 Adds extensions implementation for WindowAreaComponent and rear display status listeners
This cl includes the functionality of adding/removing
listeners for Rear Display status.

Bug: 207686851
Test: ExtensionWindowAreaComponentTest
Change-Id: I2d4d519a5e4933cd2b1319f2da99845f647006eb
2022-08-09 20:53:34 +00:00
Chris Li
8980a9fe87 Pass Task configuration changed for all TaskFragments at once
Before, we passed Task configuration changed for every embedded
TaskFragment. Now, we only passed one Task configuration changed for the
whole Task. The organizer will then update TaskFragments in the Task
accordingly.

Bug: 240519866
Test: atest WmTests:TaskFragmentOrganizerControllerTest
Change-Id: I755c11a1bcee0dd0305a090b229e867b79eee46d
2022-08-04 10:50:11 +08:00
Louis Chang
61bfe6e0dc Sending TaskFragmentInfo and operation type in #onTaskFragmentError
So, the TaskFragmentOrganizer can know what exact operation was
failed and perform error handles if needed.

Removes the pending appeared activities when starting/reparenting
activity into a TaskFragment was failed.

Deprecating the #onTaskFragmentError method with another overloaded
version, but still making sure the deprecated one is called in order
to make it compatible with Android T CTS.

Bug: 236668365
Bug: 233989810
Test: atest TaskFragmentTest
Test: atest TaskFragmentOrganizerControllerTest
Test: atest TaskFragmentOrganizerTest
Test: atest TaskFragmentOrganizerPolicyTest
Change-Id: Id328d037536d32b3acb9c424d36052b6dca8628a
Merged-In: Id328d037536d32b3acb9c424d36052b6dca8628a
2022-07-28 01:36:38 +00:00
Louis Chang
f2a5491fda Merge "Prevent waiting if no new activity instance launched" into tm-qpr-dev 2022-07-20 08:14:27 +00:00
Louis Chang
5a36e6bc9e Prevent waiting if no new activity instance launched
An existing task can be brought to front while starting
an Intent. In that case, the launching TaskFragment will
remain empty because no new activity instance created.

Monitor the activity launch result and prevent waiting
if the activity instance was not created and cleared the
pending appeared intent.

Bug: 233989810
Test: atest TaskFragmentContainerTest
Test: atest SplitControllerTest
Change-Id: I1bdf516673b71892921da14bdcdb9d1c23ce0a9a
2022-07-19 15:12:37 +00:00
Andrii Kulian
356b008ce9 Add a dedicated method to check task windowing mode
Trying to get a task information via ActivityManager#getAppTasks()
will not report tasks that aren't associated with calling package
by the root activity package name. For activities that are from
a different package the task wasn't found, so the windowing mode
couldn't be checked and WM Extensions didn't report any display
features.

This CL adds a dedicated method to check the task windowing mode
for a given activity token.

Bug: 236295340
Test: ActivityEmbeddingIntegrationTests#testDisplayFeaturesWithEmbedding_differentPackage
Change-Id: If2dbc337c4b8cb909914cc28ae4db28a82ff9de3
2022-07-15 02:44:38 +00:00
Chris Li
8129e9da51 Merge "Do not freeze window in WM Core if Shell transition is enabled" into tm-qpr-dev 2022-06-30 14:05:18 +00:00
Issei Suzuki
d5fec58feb Merge "Pass keyguard occluded status in onAnimationCancelled." into tm-qpr-dev 2022-06-28 17:24:33 +00:00
Charles Chen
09478bf50c Merge "Expand SplitContainer if min dimensions not satisfied" into tm-qpr-dev 2022-06-25 06:26:53 +00:00
Issei Suzuki
a60723b1c8 Pass keyguard occluded status in onAnimationCancelled.
Test: No visible changes yet. Pass existing tests.
Bug: 235463625
Change-Id: Iabee71bc76e19f20702f8a2739f565aa915f9b52
Merged-In: Iabee71bc76e19f20702f8a2739f565aa915f9b52
2022-06-25 01:36:07 +00:00
Charles Chen
bd2723cf6e Expand SplitContainer if min dimensions not satisfied
Before this CL, SplitController creates new SplitContainer if
min dimensions of new lauched Activity/Intent is not satisfied.
This CL changes to expand the existing SplitContainer

Bug: 232871351
Test: atest SplitPresenterTest
Change-Id: Id8d122f7d95d1c6a3574b02ddd2b6afbc548f853
2022-06-24 23:50:12 +08:00
Louis Chang
966a4e4e81 Merge "Do nothing when a finishing Activity configuration changed" into tm-dev am: 725d1534ad am: 3ff8feac5a
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19008927

Change-Id: I88bad53e137f2fe321928ba8b833f0f8b2ecea22
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-23 01:07:10 +00:00
Louis Chang
725d1534ad Merge "Do nothing when a finishing Activity configuration changed" into tm-dev 2022-06-23 00:30:19 +00:00
Chris Li
89b0876763 Do not freeze window in WM Core if Shell transition is enabled
Also disable legacy animation override from the organizer since it will never be used with Shell transition enabled.

Bug: 207070762
Test: pass existing
Change-Id: I16aaad606acb51bb47e881d5d533a5a3b1e1fbc9
2022-06-22 15:25:56 +00:00
Louis Chang
b6297b6a46 Do nothing when a finishing Activity configuration changed
Primary Activity and secondary Activity were both finished
while starting another Activity with FLAG_ACTIVITY_CLEAR_TASK
flag. The secondary container was then removed and the primary
container was resized to fullscreen while the organizer gets
the secondary TaskFragment info-changed event. And the primary
container was removed by primary TaskFragment info-changed event
afterward.

Since the primary Activity was resized before completely being
destroyed. The organizer got an onActivityConfigurationChanged c
allback and resulted in another placeholder activity being launched.

Bug: 236272623
Test: making Duo calls
Change-Id: I851828f739a4937725510d99cbdfae9ed212a023
2022-06-21 09:19:05 +00:00
Andrii Kulian
fad7f25eeb Check Task windowing mode when reporting display features
If an application uses ActivityEmbedding it would not be able to
observe display features (like folds or hinges) because they are
filtered out for activities in multi-window mode. One of the reasons
is because the client won't always know the correct position of the
window on screen in multi-window, and the position of the hinge could
be translated incorrectly to the task coordinate space.

However, it would still be OK to report the display features
when activities are in multi-window due to ActivityEmbedding as
long as the task is not in multi-window.

Bug: 236295340
Test: Sample app with embedding and display features.
Merged-In: I00f62574124df6df61f121228bd91ff9bc751c2a
Change-Id: I00f62574124df6df61f121228bd91ff9bc751c2a
2022-06-17 17:15:18 +00:00
Andrii Kulian
2eae3a52a7 Check Task windowing mode when reporting display features
If an application uses ActivityEmbedding it would not be able to
observe display features (like folds or hinges) because they are
filtered out for activities in multi-window mode. One of the reasons
is because the client won't always know the correct position of the
window on screen in multi-window, and the position of the hinge could
be translated incorrectly to the task coordinate space.

However, it would still be OK to report the display features
when activities are in multi-window due to ActivityEmbedding as
long as the task is not in multi-window.

Bug: 236295340
Test: Sample app with embedding and display features.
Change-Id: I00f62574124df6df61f121228bd91ff9bc751c2a
2022-06-17 06:46:40 +00:00
An An Yu
588e1f94d2 Setup T style clear top transition animation for ActivityEmbedding.
This registers system default clear-top xmls and propagate the
showBackdrop flag.
Test: atest RemoteAnimationsControllerTest
Bug: 221048002

Change-Id: I664f7edd181fd7d625b7010a77cd1f7b58fc3113
2022-06-14 13:36:57 -07:00
Charles Chen
fa3f9ca94c Respect minimum dimensions for embedded Activities
Before this CL, minimum dimensions of Activity wasn't respected,
that said, an Activity could be embedded in a TaskFragment of which
bounds are smaller its minimum dimensions.
This CL add the minimum dimensions on several places:

WM core:
1. Verify minimum dimension requirement before adding an Activity to
   a TaskFragment. It'll be early return if the requirement is not
   satisfied.
2. Propagate the minimum dimensions to the client side through
   TaskFragmentInfo to notify the requirement.
3. If TaskFragmentOrganizer tries to shrink a TaskFragment to
   the bounds that smaller than minimum dimensions of its children
   Activity, switch to match the parent bounds.
AndroidX Window extensions:
1. Early return if TaskFragment is resized to the bounds that smaller
   than minimum dimensions which dispatched from the server side.
2. When organizer tries to show Activities side-by-side, verify if
   minimum dimensions requirement of the primary Activiy. If the
   requirement is not satisfied, show Activities in fullscreen
   instead.
TODO: Add an API to check if an Activity intent is allowed to embed
   in a TaskFragment.

Bug: 232871351
Test: atest TaskFragmentOrganizerControllerTest
Test: atest TaskFragmentOrganizerTest TaskFragmentOrganizerPolicyTest
Test: atest SplitActivityLifecycleTest
Test: atest CtsWindowManagerJetpackTestCases
Test: atest WmJetpackUnitTests

Merged-In: Ib46c2cec2a0735b9e3f3420f2cb94754801b86b9
Change-Id: Ib46c2cec2a0735b9e3f3420f2cb94754801b86b9
2022-06-15 00:32:34 +08:00
Charles Chen
482fbfabd7 Respect minimum dimensions for embedded Activities
Before this CL, minimum dimensions of Activity wasn't respected,
that said, an Activity could be embedded in a TaskFragment of which
bounds are smaller its minimum dimensions.
This CL add the minimum dimensions on several places:

WM core:
1. Verify minimum dimension requirement before adding an Activity to
   a TaskFragment. It'll be early return if the requirement is not
   satisfied.
2. Propagate the minimum dimensions to the client side through
   TaskFragmentInfo to notify the requirement.
3. If TaskFragmentOrganizer tries to shrink a TaskFragment to
   the bounds that smaller than minimum dimensions of its children
   Activity, switch to match the parent bounds.
AndroidX Window extensions:
1. Early return if TaskFragment is resized to the bounds that smaller
   than minimum dimensions which dispatched from the server side.
2. When organizer tries to show Activities side-by-side, verify if
   minimum dimensions requirement of the primary Activiy. If the
   requirement is not satisfied, show Activities in fullscreen
   instead.
TODO: Add an API to check if an Activity intent is allowed to embed
   in a TaskFragment.

Bug: 232871351
Test: atest TaskFragmentOrganizerControllerTest
Test: atest TaskFragmentOrganizerTest TaskFragmentOrganizerPolicyTest
Test: atest SplitActivityLifecycleTest
Test: atest CtsWindowManagerJetpackTestCases
Test: atest WmJetpackUnitTests

Change-Id: Ib46c2cec2a0735b9e3f3420f2cb94754801b86b9
2022-05-31 23:25:18 +08:00
Chris Li
7c2912df8f Merge "Fix ConcurrentModificationException on finishing TaskFragment" into tm-dev am: 0d7ece81e8 am: 91b3e6b447
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18615113

Change-Id: I2e47be05d9862a8fb076e3430496707d1b249de6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-27 12:25:45 +00:00
Chris Li
4813b27d00 Fix ConcurrentModificationException on finishing TaskFragment
Fix: 228201646
Test: atest WMJetpackUnitTests:SplitControllerTest
Change-Id: I4569e48fa7e5c020f440f00f0027e560d33e647f
2022-05-27 11:17:50 +08:00
TreeHugger Robot
47a12740a2 Merge "Add pendingAppearedIntent to TaskFragmentContainer" into tm-dev am: 3f75b0485a am: 8fcee62b42
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18581805

Change-Id: Ibc0c69964a802f96e6982e5a5982d6a3a5032939
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-26 19:47:11 +00:00
Chris Li
f7f106b437 Add pendingAppearedIntent to TaskFragmentContainer
1. When an activity is launched without specifying launch TaskFragment,
   it may be placed to the primary TaskFragment of a split if all
   activities in secondary split are finishing. In this case, we still
   want to check if activity should be splitted with the activity below.

   In order to do that, we need to know if it should be split with the
   secondary TaskFragment, which may still be empty, so store the
   pending appeared Intent until the TaskFragment becomes non-empty.

   i.  The secondary TaskFragment can be empty when the primary trys to
       start the secondary during #onCreated.
   ii. If the Intent never actually started, it will trigger
       #onTaskFragmentAppearEmptyTimeout to update the existing top
       container.

2. When we are finishing a TaskFragment, we used to finish all
   activities in it as well. We should not do that for activity that is
   requested to be reparented (as pending appeared).

Fix: 233684054
Test: atest WMJetpackUnitTests:TaskFragmentContainerTest
Test: atest WMJetpackUnitTests:SplitControllerTest
Change-Id: I47329b23709da7e069a6a0c84124a3d7d08aae12
2022-05-26 06:31:44 +00:00
Andrii Kulian
0eea298a34 Merge "Synchronize SplitController" into tm-dev am: d4d0fee814 am: a15c08cb85
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18418602

Change-Id: I251c1d1e2ee68cf2fff3e56a0c5db5b24b9b61d8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-25 18:42:26 +00:00
Andrii Kulian
40a67faae4 Synchronize SplitController
Adding synchronization to the public methods in SplitController,
as they might be called on different threads and cause a
ConcurrentModificationException.

Bug: 228201646
Test: atest CtsWindowManagerJetpackTestCases --iterations 100
Change-Id: I2db9ccb5e9829487eae7aa85eff5f6153721cc04
2022-05-25 03:32:54 +00:00
TreeHugger Robot
f50591c036 Merge "Do not resolve activity creation if it is in unknown TaskFragment" into tm-dev am: 327887fad9 am: ef17f29be0
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18482930

Change-Id: I15badec21bb7a60ead9d8099510996bb5ef8f658
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-24 11:55:30 +00:00
Chris Li
9d4244ee6f Do not resolve activity creation if it is in unknown TaskFragment
This can happen in two cases:
1. The activity is embedded in another app. Then the current organizer
   shouldn't control it.
2. The activity is in a TaskFragment that the organizer just request to
   remove, but hasn't reach the server side. Then the activity will soon
   be finished with the TaskFragment.

In either case, the organizer shouldn't need to resolve it. Otherwise it
may incorrectly change the state, such as entering split for a finishing
activity.

Bug: 233295443
Test: atest WMJetpackUnitTests:SplitControllerTest
Change-Id: I5d2028dd45abd8d20a8e82bc4e51c4d6dc6e26ee
2022-05-24 10:05:14 +08:00