Commit Graph

132 Commits

Author SHA1 Message Date
Chris Li
e382326e3d Fix crash in getParentContainerBounds
Before, before TaskFragment appeared, the getTopNonFinishingActivity may
be null, and throw exception for no bounds found.
Now, make sure we always have Task bounds stored.

Bug: 228885031
Test: atest WMJetpackUnitTests:SplitControllerTest
Test: atest WMJetpackUnitTests:TaskContainerTest
Change-Id: I3744813a85f24941563c8ff8f284b2e45396f906
2022-04-20 15:45:09 +08:00
Chris Li
720ae87d6b Allow delete empty TaskFragment in PiP
We ignore WCT for TaskFragment in PiP, but in case the empty
TaskFragment is not removed before the Task enters PiP, we should allow
organizer to remove it.

Also make sure we have all requests in one WCT during
onTaskFragmentInfoChanged.

Bug: 225371112
Test: atest WmTests:TaskFragmentOrganizerControllerTest
Test: atest WMJetpackUnitTests:SplitControllerTest
Test: atest WMJetpackUnitTests:TaskFragmentContainerTest
Change-Id: I718bbb7f6c18c35048c671ed3c131eaf536cf265
2022-04-18 18:12:05 +08:00
Chris Li
63ece2d2e5 Notify organizer when the last activity in TaskFragment enter PiP
When the Task contains multiple activities, activity entering PiP will
be reparented to a new PiP Task. In this case, we should notify the
organizer about the behavior, and prevent the dependents from closing as
a result of an empty TaskFragment.

Bug: 225371112
Test: atest WmTests:TaskFragmentTest
Change-Id: I6f0138c0532d2d0249de38fd84d1a4690f266c07
2022-04-13 21:31:30 +08:00
Charles Chen
64d4564747 Merge "Promote WMJetpackUnitTests to presubmit" into tm-dev 2022-04-13 09:48:11 +00:00
Chris Li
c3b209094c No embed activity when Task is in PIP
Sidecar change for the case when the Task (single activity) is entering PIP.
No further request when the Task is in PIP.
Update presentation when exit PIP.

Bug: 225371112
Test: manual test Video app
Change-Id: I610b9bd753423679338ca1c0fd49273a28ab56b6
2022-04-11 23:12:37 +08:00
Diego Vela
9af4098658 Fix crash when unfolding a device.
Fix a crash when unfolding a device with reference implementation.
There is a crash because we get a callback before changes propagate.

Bug: 218980376
Test: manual - open the fold samples with config changing app.
 fold and unfold the device.
Change-Id: I3c99058e47e29b18a30921bc23b14182e970ac65
2022-04-08 20:16:33 -07:00
Charles Chen
77071e8140 Promote WMJetpackUnitTests to presubmit
Test: atest TestMappingsValidation#testTestSuiteSetting
Test: atest -p frameworks/base/libs/WindowManager/Jetpack/src:presubmit
Bug: 227710854
Change-Id: I2f8ac0452f26501d972cd9a12f0d0a3a90f7a8ae
2022-04-08 15:51:50 +08:00
Shivam Agrawal
87550b067a Merge changes from topic "embedding-race-condition" into tm-dev
* changes:
  Send Split Info Callback before Activity#onCreate
  Revert "Removing TaskFragment token from LaunchActivityItem"
2022-04-05 18:36:49 +00:00
Pablo Gamito
e2a041cf92 Merge "Update component ids from Winscope to Flicker" am: d41316339d am: 1016b2d3c2 am: b9a97d8d9b
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2055046

Change-Id: If7f4442f602e60ca1a5322e02484cace47ce89a3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-05 15:19:51 +00:00
Pablo Gamito
1016b2d3c2 Merge "Update component ids from Winscope to Flicker" am: d41316339d
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2055046

Change-Id: Id635b8ae570d38e9a935edf30537eb027c7be794
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-05 14:33:00 +00:00
Pablo Gamito
85c38bd427 Update component ids from Winscope to Flicker
Test: N/A
Change-Id: I5bc614c406535b0f282cb9d948e426e879d3a069
2022-04-04 22:31:02 +00:00
Diego Vela
dbda026b6f Merge "Fix emulator not emitting folding feature." into tm-dev 2022-04-04 16:33:04 +00:00
Diego Vela
cb70f07113 Fix emulator not emitting folding feature.
Fix emulator not working for folds. Emulator is using DeviceStateManager
and that creates a mismatch on how data is merged.
Remove priority data produce as it adds more complexity than necessary.

Bug: 218872245
Test: Manual - build and run the emulator.
 Install the samples from the androidx.window:window-samples module
 Run folding feature sample.
Change-Id: I1f274a208952ff1418f2873356deacc588b99a2d
2022-04-01 13:31:47 -07:00
Shivam Agrawal
d865985891 Send Split Info Callback before Activity#onCreate
The onTaskFragmentInfo callback from the server
triggered by the creation of a new activity may not
reach the client before Activity#onCreate is called
because of undeterministic IPC call order. However, the
application should get a split info update that includes
the newly launched activity before the Activity#onCreate
is called for that activity so that the application
knows that the activity will be in a split, which may
influence UI decisions.

Bug: b/218791665 b/200303250
Test: atest ActivityEmbeddingLaunchTests
Change-Id: If69c077db8ca390d41446e1329a448b3dd074293
2022-04-01 13:31:30 -04:00
Chris Li
add68184dd Register remote animation per Task
Before, we register remote animation per organizer, and assume it only
organizes in one Task. Now, we register per organizer Task if there is a
rule that supports split in the Task width.

Bug: 207720388
Test: atest WMJetpackUnitTests
Change-Id: Iac4e10af9aa0e7846c81b036b2cf708b6cbe627e
2022-04-01 16:47:46 +08:00
Charles Chen
745801fe80 Make WM Jetpack unit tests mockable
Also adding a test to prove it's usable.

Test: atest SplitControllerTest
Bug: 219652919
Change-Id: I8a01ab0fb7e74739a626624f00a772c136771de7
2022-03-30 06:13:34 +00:00
TreeHugger Robot
e210469f90 Merge "Initial infra for WM Jetpack unit tests" into tm-dev 2022-03-25 00:12:18 +00:00
Charles Chen
08e542d05f Initial infra for WM Jetpack unit tests
Bug: 219652919
Test: atest WMJetpackUnitTests
Change-Id: I0b3793de206edd6a88a72dbd5daa1be4504e171d
2022-03-24 22:35:54 +08:00
Charles Chen
8ed70153bc Merge "Add OWNERS file for WM Jetpack library tests" am: 992d43abd4 am: fcbd3d06f9 am: 8f9750fe0c
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2039283

Change-Id: I40a72a6d41502b8ca077da71696ec1026d748738
2022-03-24 11:07:53 +00:00
Charles Chen
8f9750fe0c Merge "Add OWNERS file for WM Jetpack library tests" am: 992d43abd4 am: fcbd3d06f9
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2039283

Change-Id: Icddd7147cab0d31afed5bcc984a2998447af2b83
2022-03-24 04:33:43 +00:00
Diego Vela
5e0a25ea58 Fix Emulator not emitting folding features.
Fix emulator not emitting folding features. Emitting the fold state was
removed since it works differently for emulators. Emulators write to
settings while the reference implementation reads the value from
DeviceStateManager. Update the setting producer to also read the state
from settings.

Bug: 218872245
Test: Manual - open window manager samples on an emulator.
Change-Id: I7def87bd406c2ae5b1ac27be58a3b22a239c3e82
2022-03-24 03:19:20 +00:00
Charles Chen
451e2ee39d Add OWNERS file for WM Jetpack library tests
Test: presubmit
Bug: 219652919
Change-Id: I95c609eeff47bef9ae45a5e9847eb56efc622b83
2022-03-24 00:11:32 +08:00
Diego Vela
98ca72c5f8 DO NOT MERGE Fix Emulator not emitting folding features.
Fix emulator not emitting folding features. Emitting the fold state was
removed since it works differently for emulators. Emulators write to
settings while the reference implementation reads the value from
DeviceStateManager. Update the setting producer to also read the state
from settings.

Bug: 218872245
Test: Manual - open window manager samples on an emulator.
Change-Id: I7def87bd406c2ae5b1ac27be58a3b22a239c3e82
2022-03-22 21:05:04 -07:00
Chris Li
b3410923ce Group ActivityEmbedding split by Task id
When the app is the host of multiple Tasks, there can be split pairs in
each Task.

Before, we treated all split as in one Task, which can sometimes cause
issue. Now, we group them by Task id, so that they won't affect each
other.

Bug: 207720388
Test: test with Settings deep link
Change-Id: Iaa9865461d984df10c6db237a87ee0903b70e7da
2022-03-21 17:33:12 +08:00
Chris Li
53c2f64d1e Merge "ActivityEmbedding: launch into the same side container" into sc-v2-dev 2022-03-17 10:33:42 +00:00
Chris Li
06617390e3 Offset animation layer for TaskFragment open/close
It is possible to have a fullscreen closing TF between two resume TFs
(this can happen when closing the fullscreen TF results the bottom
activity open a new activity into split). In that case, we don't want
the fullscreen TF to hide the activity below it during cross fade
animation.

Fix: 214175523
Test: manually verify with Settings
Change-Id: I4350114d800442308c9c53f474ba60542c8a86e5
(cherry picked from commit c562f322b2)
2022-03-16 03:52:16 +00:00
Chris Li
d530d65cfa ActivityEmbedding: launch into the same side container
When primary activity launches a new intent with a split rule with same
presentation (split ratio), we can launch the new activity to the
existing secondary container.

Bug: 216492188
Test: manual
Change-Id: Iad6d238c6dfb009402376a725136be6c6fdab98c
(cherry picked from commit 449fceaa1c)
2022-03-16 03:36:57 +00:00
Charles Chen
f7a3e79fa3 Fix placeholder not shown after launch again
This issue is regressed by [1].
When we verify if the container is top active container,
we should filter out the case that the Activity is not in
TaskFragmentContainer.

fixes: 224431790
Test: manual - test steps mentioned in bug

[1]: 3d419be76f

Change-Id: Iae3b2b903bf15448d429b8edd25ceeef97e74738
2022-03-15 15:47:24 +08:00
Chris Li
c562f322b2 Offset animation layer for TaskFragment open/close
It is possible to have a fullscreen closing TF between two resume TFs
(this can happen when closing the fullscreen TF results the bottom
activity open a new activity into split). In that case, we don't want
the fullscreen TF to hide the activity below it during cross fade
animation.

Fix: 214175523
Test: manually verify with Settings
Change-Id: I4350114d800442308c9c53f474ba60542c8a86e5
2022-03-09 17:33:56 +08:00
Diego Vela
6c39d4fb3c DO NOT MERGE Listen for config changes when updating features.
Listen for configuration changes to push out folding feature changes.
Fixes a bug where the reference implementation would not emit the
correct folding feature if a configuration changed. The effect was that
you would see the folding feature for portait while in landscape or
vice-versa.

Maintains parity with Sidecar providing updates for Activities that do
not handle configuration changes.

Bug: 205342008, 206697963
Test: Manual - Open the sample app and use the application that &&
  handles configuration changes.  &&
  Expect the folding feature to match the physical orientation
Test: Manual - open an app that handles PiP and folding features &&
  Flattend the device and put app into PiP &&
  Fold device and put PiP app in full screen. &&
  Expect the app to react to fold.
Test: atest CtsWindowManagerJetpackTestCases
Change-Id: I726827c9f1482ddd0b55a6839e34660deb340767
2022-03-08 05:04:40 +00:00
Diego Vela
396a7965c3 DO NOT MERGE Add LifecycleCallback adapter.
Add a lifecycle callback adapter to remove empty code blocks.

Bug: 205342008
Test: n/a small code clean up.
Change-Id: I5454fbcb24c26079369fd20e519c809b00c261ae
2022-03-08 05:04:33 +00:00
Diego Vela
e5c6ad5d79 DO NOT MERGE Merge state producer and feature producer.
Merge device state producer and display feature producer so that
FoldingFeature data has a single data pipeline. This should make it
easier to retrigger reading data if other signals are necessary.

Bug: 205342008
Test: manual - run sample app.
Change-Id: I7b66a45be8fcbb1a66d9aa8eab235d83877526ea
2022-03-08 05:04:22 +00:00
Diego Vela
882901805b DO NOT MERGE Remove DisplayFeature from common package.
Remove DisplayFeature interface from the common package since it
actually represents a CommonFoldingFeature. This makes the code
a little confusing since it is not properly named.

Bug: 205342008
Test: manual - run WindowManager samples.
Change-Id: I18e609fb71004544e7de1f346ccef9ac04efb0d7
2022-03-08 05:04:11 +00:00
Diego Vela
6cdd132341 Listen for config changes when updating features.
Listen for configuration changes to push out folding feature changes.
Fixes a bug where the reference implementation would not emit the
correct folding feature if a configuration changed. The effect was that
you would see the folding feature for portait while in landscape or
vice-versa.
Maintains parity with Sidecar providing updates for Activities that do
not handle configuration changes.

Bug: 205342008, 206697963
Test: Manual - Open the sample app and use the application that &&
  handles configuration changes.  &&
  Expect the folding feature to match the physical orientation
Test: Manual - open an app that handles PiP and folding features &&
  Flattend the device and put app into PiP &&
  Fold device and put PiP app in full screen. &&
  Expect the app to react to fold.
Test: atest CtsWindowManagerJetpackTestCases
Change-Id: I726827c9f1482ddd0b55a6839e34660deb340767
2022-03-04 18:56:25 +00:00
Diego Vela
3b9f2b53b9 Add LifecycleCallback adapter.
Add a lifecycle callback adapter to remove empty code blocks.

Bug: 205342008
Test: n/a small code clean up.
Change-Id: I5454fbcb24c26079369fd20e519c809b00c261ae
2022-03-04 18:56:04 +00:00
Diego Vela
2756dd3d30 Merge state producer and feature producer.
Merge device state producer and display feature producer so that
FoldingFeature data has a single data pipeline. This should make it
easier to retrigger reading data if other signals are necessary.

Bug: 205342008
Test: manual - run sample app.
Change-Id: I7b66a45be8fcbb1a66d9aa8eab235d83877526ea
2022-03-04 18:55:55 +00:00
Diego Vela
3084663801 Remove DisplayFeature from common package.
Remove DisplayFeature interface from the common package since it really
represents a CommonFoldingFeature. This makes the code a little
confusing since it is not properly named.

Bug: 205342008
Test: manual - run WindowManager samples.
Change-Id: I18e609fb71004544e7de1f346ccef9ac04efb0d7
2022-03-04 18:55:41 +00:00
charlesccchen@google.com
3d419be76f Limit launching placeholder to top TaskFragment
Currently, we launch placeholder Activity if Activity is not split
and matches placeholder rule. However, there's a scenario that
the Activity which matches placeholder rule is occulded by a fullscreen
Activity, but SplitController still launches placeholder on top of the
fullscreen Activity.

This CL verifies if the Activity located TaskFragmentContainer is on top
to launch placeholder. It also makes #getTopActiveContainer consider
Activity from other process by verifying #getRunningActivityCount.

Test: manual - Repro steps in bugs
Bug: 214175523

Change-Id: Id287d8c5235918b78ccd43bfddf9bb17ee0ff2e8
2022-03-02 12:48:28 +00:00
Chris Li
fddf0a84f0 Merge "ActivityEmbedding: launch into the same side container" 2022-02-15 09:41:12 +00:00
Chris Li
449fceaa1c ActivityEmbedding: launch into the same side container
When primary activity launches a new intent with a split rule with same
presentation (split ratio), we can launch the new activity to the
existing secondary container.

Bug: 216492188
Test: manual
Change-Id: Iad6d238c6dfb009402376a725136be6c6fdab98c
2022-02-15 15:02:59 +08:00
Andrii Kulian
97b59a72fa Verify cross-uid activity embedding
By default activities cannot be embedded by non-privileged
processes. Apps can either declare their activities to be available
for untrusted embedding, or limit it to certain trusted hosts.

This CL verifies that an application cannot embed activities that
didn't opt in, and verifies that in untrusted mode the host cannot
request SurfaceControl transactions or position the embedded
container outside of the task bounds.

Bug: 197364677
Test: ActivityEmbeddingCrossUidTests, TaskFragmentOrganizerTest
Change-Id: Ief54c9acae1a9a4152af710f67e7810afdcff9ba
2022-02-09 23:58:36 -08:00
Chris Li
dc955c5a74 Merge "Do not override animation when the parent bounds doesn't support split" into sc-v2-dev 2022-01-13 02:45:23 +00:00
Chris Li
c0acf094f2 Do not override animation when the parent bounds doesn't support split
Without this cl, we always override animation as long as there is any
organzied TaskFragment. And users may see different animation on the
same small screen before and after they have unfold and fold.

The idea is to only register the remote handler if the app currently has
at least one split rule that can fit the current Task bounds.

When there can be split, we want to always override the animation to
make it consistent.

When there won't be any split, we want to allow app to override
animation, so they can still provide the same experience as normal phone
on small screen.

Fix: 207804116
Fix: 196173550
Test: manual test with fold/unfold
Change-Id: I3ae194f89b35afc5734338fd3bb350e0cd364c85
2022-01-12 14:45:56 +08:00
Chris Li
be242f4684 Active container should contain non-finishing activity
Without this cl, the app will crash if a TaskFragment is closing when
the new top TaskFragment doesn't contain any non-finishing activity
(which should be closed later as well).

Before, when #cleanupContainer(), we will also update the new top active
container, but we didn't check if it contain any non finishing activity.

Fix: 212355346
Test: test with Settings with three finger click
Change-Id: I26538b85f1cf8e618a3f1ee6abada5a9f77f2b16
2022-01-12 14:37:27 +08:00
TreeHugger Robot
06328c7ada Merge "Block split Activity in lock task mode" into sc-v2-dev 2021-12-13 09:16:02 +00:00
Louis Chang
0399d9c951 Block split Activity in lock task mode
Before this CL, Activity was only blocked from finishing if it is the
last Activity in th Task to start lock task mode.
However, it may make half of screen black if the finishing Activity is
in one of adjacent TaskFragments.
This CL considers the scenario that two adjacent TaskFragments side-by-side.
If a finishing Activity leads to TaskFragment empty, and also make the
adjacent TaskFragment finish, block the Activity from finishing.

Bug: 205813709
Test: manual - use Settings in task pinning mode

Change-Id: I6116d644aeccc13460d302fe3b40953fa67dca6c
2021-12-10 09:15:07 +00:00
TreeHugger Robot
2176d951d0 Merge "Allow checking if an activity is organized" into sc-v2-dev 2021-12-08 15:18:29 +00:00
Andrii Kulian
bf54c4ad74 Allow checking if an activity is organized
Adds an interal method to check if an activity is being organized
by any process. This can be used by WM Jetpack Extensions APIs to
inform apps about their activities being embedded.

Bug: 204399167
Test: Manual, using demo app
Change-Id: I3a0ad021ad43c97bf9b92df05e9858aae143f62b
2021-12-08 17:29:34 +08:00
TreeHugger Robot
0cf8c02bf1 Merge "Fix NPE in SplitController#startActivityToSide" into sc-v2-dev 2021-12-07 22:38:37 +00:00
Shivam Agrawal
f382049442 Fix NPE in SplitController#startActivityToSide
SplitController#startActivityToSide is called from
SplitController#launchPlaceholderIfNecessary with
a null value for the failure callback. If the activity
launch to side fails, then startActivityToSide tries
to pass the failure to the failure callback, which is
null. This CL fixes this bug by checking if the failure
callback is null.

Bug: b/209296363
Test: existing tests pass
Test: launch settings app from overview and observe no crash
Change-Id: I6577d992f48acbaae6b0e9776e65933e779defe3
2021-12-07 13:45:23 -05:00