Commit Graph

486 Commits

Author SHA1 Message Date
Vadim Caen
a2e45f1ed1 Prevent callback registration when back flag is disabled
When the enableOnBackInvokedCallback is set to false (or not set),
registering an OnBackInvokedCallback should be a no-op to avoid
overriding the default compat callback.

Test: Manual testing registering a callback on an app with the flag
disabled and doing a back gesture. Currently we don't have test
executing a back gesture so automated tests are not possible

Bug: 235206960

Change-Id: I54d843f11130a78ed5a68cbe4722e601a2086ee1
Merged-In: I54d843f11130a78ed5a68cbe4722e601a2086ee1
(cherry picked from commit aa48dc3c2d)
2022-06-20 11:40:18 +02:00
Charles Chen
eb86759eec Merge "Respect minimum dimensions for embedded Activities" into tm-dev 2022-06-15 03:32:04 +00: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
chaviw
783ae3c7d9 Make sure VRI waits for SV to draw before report
VRI is not currently waiting for SV to draw since SV may start its draw
before VRI opened the SyncSet. If that happens, VRI will not include SV
in its SyncSet and report draw finished even if SV is not complete.

This fix has SV create its own SyncSet when redrawNeeded. Then if VRI
creates a sync, SV will merge its own SyncSet into that one. If SV
already finished drawing, then nothing will get merged, but it means SV
is ready already. If SV is not finished, VRI will now also wait for SV's
draw to finish before calling finishDraw.

Test: Long delay in surfaceRedrawNeededAsync
Test: SurfaceSyncerTest
Bug: 230998394

Change-Id: I44331b8f54951e6dc633a4845bbf690abde0f95e
2022-06-10 12:15:00 -05:00
Vadim Caen
a147b66f61 Merge "Transfer the actual dispatcher when the window is preserved" into tm-dev 2022-06-01 14:35:57 +00:00
Iris Yang
d7df1b2804 Merge "Use DeviceProfile to determine whether to exclude tasks from Recent" into tm-dev 2022-05-27 17:39:23 +00:00
Iris Yang
30356d273a Use DeviceProfile to determine whether to exclude tasks from Recent
For Android Auto, tasks should exclude from Recents by default.
For App streaming device profile, tasks should be showed from Recents.

This change also keep the most recent task of "Default display" in
Recents even if it's excluded from Recents.

Bug: 232385935
Test: atest WmTests:RecentTasksTest
Change-Id: Ic01ed6bbae1f2b77f8664196cbc59b248f5ec3b4
2022-05-27 12:15:45 +08:00
Vadim Caen
13048f123b Transfer the actual dispatcher when the window is preserved
When recreating the Activity, if the window is preserved,
onAttachedToWindow won't be called and PhoneWindow.onViewRootImplSet
won't be called either, where we set the actual dispatcher to the
Activiy's proxy dispatcher.

So when the window is preserved, we directly assign the actual Dispatcher
from the preserved Window to the new PhoneWindow

Fixes: 228571903
Test: In progress
Test: Open an app with OnBackInvokedCallback enabled, split to top,
      close the other application, do a back gesture
Change-Id: I050247501df8f6cf6cd0024a6233f88a035f6279
2022-05-25 19:46:37 +02:00
Vadim Caen
5eb57dc714 Disable debug logging
Bug: 227173606
Test: N/A
Change-Id: Ia03f7b6e5d9dfb6e247fab4526d6293b3600d398
2022-05-25 17:08:55 +02:00
Shan Huang
6a770ceb14 Transfer IME callbacks when app's focused root view changes.
Previously when curRootView changes IMM, the back callbacks are not
moved to the new focused ViewRootImpl. As a result if IME is up during
the focus change, the back callback would fail to unregister when
IME tries to hide itself.

Test: atest InputMethodServiceLifecycleTest
Test: atest CtsInputMethodTestCases:InputMethodServiceTest
Test atest CtsInputMethodTestCases:KeyboardVisibilityControlTest
Bug: 232660571
Bug: 232331013

Change-Id: Id30e51c74afbcce1f22d87af77e8404b4f0ae7d2
2022-05-16 22:51:06 +00:00
Shan Huang
c16b574055 Fix IME callback not being re-registered on screen off / on.
Bug:231917948
Bug:229355440
Test: atest InputMethodServiceLifecycleTest
Test: atest CtsInputMethodTestCases:InputMethodServiceTest
Test atest CtsInputMethodTestCases:KeyboardVisibilityControlTest

Change-Id: I8dc1425aa9338b37128d308bf58fd15c39d04a88
2022-05-12 14:19:05 +00:00
Ming-Shin Lu
576bba9bb0 Fix memory usage issue on WindowTokenClient
As WindowTokenClient#{onConfigurationChanged, onWindowTokenRemoved}
requires to post on mainthread, in case posting runnable accquires more
java objects to increase java heap memory, use PooledLambda to obtain
cached runnable for saving memory usage.

Also, use ActivityThread.currentActivityThread.getHandler to get the
main handler rather than creating the new object.

Fix: 215447496
Test: run MemoryOnBoot
Change-Id: Idb2c01a0da02ff669e1a3f1a55f4841f7aa258ba
2022-05-09 03:15:22 +00:00
Shan Huang
a6666f2221 Migrate IME to handle back with OnBackInvokedDispatcher.
We currently close the IME by having the target application forward KEYCODE_BACK to the IME process through InputMethodManager#dispatchInputEvent and having the IME handle the keycode in InputMethodService#onKeyDown. When apps opt in to OnBackInvokedDispatcher API, we will not dispatch KEYCODE_BACK to apps anymore. Thus we need to migrate IME to the new API for it to close on back invocation.

This implementation forwards OnBackInvokedCallbacks from the IME process
to the app process. This is necessary because all callbacks need to
exist in the app process for them to be considered by hardware back keys. While back gestures go through WM to resolve callbacks from the focused window, hw keys are directly sent to the focused window's ViewRootImpl, bypassing server side back nav logic.

Bug: 228358882
Test: atest CtsInputMethodTestCases:KeyboardVisibilityControlTest
Test: atest CtsInputMethodTestCases:InputMethodServiceTest
Test: atest CtsInputMethodTestCases
Change-Id: Ie207b63b11a56c9b2173f26b734a27b13ebccc60
2022-05-04 05:31:08 +00:00
Chris Li
301ff2fec1 Merge "Keep the focus on the primary when launch ActivityEmbedding placeholder" into tm-dev 2022-04-27 04:16:53 +00:00
Charles Chen
57edb1f789 Merge "Revert^2 Fix testRegisterComponentCallbacksOnWindowContext flaky" into tm-dev 2022-04-26 08:33:59 +00:00
Mariia Sandrikova
42f304140f Merge "Exception for Kids Mode from ignoreOrientationRequest." into tm-dev 2022-04-25 14:11:11 +00:00
Charles Chen
f3787b207a Revert^2 Fix testRegisterComponentCallbacksOnWindowContext flaky
This flakiness is due to race of config updates when WindowContext attaches to
DisplyArea.
This CL fixed it by:
1. Don't dispatch config updates to the client side when registering to
   DA. We have reported the value by the return value of
   #attachWindowContextToDisplayArea.
2. Add lock in WindowTokenClient#onConfigurationChanged to avoid race.
   During applying DA's config to WindowContext, WindowContext may get another
   callback from the server side and dispatch to ComponentCallbacks
   unexpectedly.

Bug: 190019118
fixes: 228911504
Bug: 230022846
Test: atest RegisterComponentCallbacksTest --iterations
Test: atest WindowContextTest WindowContextTests
Test: atest WindowMetricsWindowContextTests
Change-Id: I2d749a058c7a3828c8c8288040236f005aa00ab6
2022-04-25 20:24:43 +08:00
Mariia Sandrikova
9182b74df1 Exception for Kids Mode from ignoreOrientationRequest.
Fix: 229304143
Test: manual and DisplayContentTests
Change-Id: I3136db620afdf016a900f3441ee3010ae9662f0f
2022-04-24 16:28:31 +00:00
Chris Li
c21254f45b Keep the focus on the primary when launch ActivityEmbedding placeholder
Default focus should be on primaryActivity when a placeholder is shown.
This is a short term improvement as focus navigation works from primary
to secondary but not in reverse.

Fix: 229138140
Test: atest WmTests:TaskFragmentOrganizerControllerTest
Change-Id: Ic4e2280e4b37a8fa04fc532245a5d0cfa4e5e012
2022-04-24 16:57:10 +08:00
Chris Li
9e08260cce Add TaskFragmentOrganizer#onActivityReparentToTask
When the activity exits PiP and is reparented to the original Task, the
organizer should handle it as a new launch.

Bug: 225371112
Test: atest WmTests:TaskFragmentTest
Test: atest WmTests:TaskFragmentOrganizerControllerTest
Change-Id: Ia7e32e995a35e167b0d76e701c972b269ae068cc
2022-04-22 17:36:02 +08:00
Tony Huang
34e18413a8 Merge "Remove some functions @hide in WindowContainerTransaction" into tm-dev 2022-04-20 03:35:17 +00:00
Chavi Weingarten
c9eb12f88b Merge "Add SurfaceSyncer markdown file" into tm-dev 2022-04-19 22:08:31 +00:00
chaviw
2d62f58c6b Add SurfaceSyncer markdown file
Test: N/A
Bug: 200284684
Change-Id: I133cb86aa69c55adb390fce72407fb6f1a32e4f4
2022-04-19 09:36:11 -05:00
TreeHugger Robot
e16244c3cd Merge "Make BackEvent#getTouchX and BackEvent#getTouchY floats." into tm-dev 2022-04-16 01:51:10 +00:00
Wei Sheng Shih
2aac68104f Merge "Clear the system bars color when removing the splash screen window." into tm-dev 2022-04-15 02:18:23 +00:00
Shan Huang
316179540e Make BackEvent#getTouchX and BackEvent#getTouchY floats.
Bug: 228533817
Test: Try swipe back to home on Flag Flipper (with Predictive Back
Animation toggle enabled in Flipper) and make sure animation looks good.
Try in both landscape and portrait mode.

Change-Id: If2165827a0f66f8e0bd8f78483577c3ac4c9f213
2022-04-14 19:34:26 +00: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
Tony Huang
29f1e898dc Remove some functions @hide in WindowContainerTransaction
To using these function in CTS tests, we need to remove @hide.

Bug: 229024233
Test: build pass
Change-Id: I7102918593ef8886888604492e39c1f952408ec7
2022-04-13 17:30:00 +08:00
Vadim Caen
7d7fa82fe4 Merge "Fix splashscreen listener not being called" into tm-dev 2022-04-11 09:58:15 +00:00
Shaun Corkran
e360c271c6 Merge "Decide on navigation to task by policy in Virtual Device" into tm-dev 2022-04-08 18:29:23 +00:00
Shan Huang
be460cbac4 Merge "Create OnBackInvokedCallbackInfo to wrap callback and its priority." into tm-dev 2022-04-08 04:07:53 +00:00
Vadim Caen
3fb34bfe77 Fix splashscreen listener not being called
Bug: 228313271
Test: AndroidX SplashscreenParametrizedTest
Change-Id: Ia68016ddc73e4d1f5d18f076d4474e0e3086c138
2022-04-07 16:52:47 +02:00
Shaun Corkran
8e9e270de7 Decide on navigation to task by policy in Virtual Device
Adds the implementation to allow or block navigation to a
new task in the policy controller for a virtual device. Will
only change behavior if the cross navigation allow or block
list is included and the navigation does not occur from
the default display.

Bug: 223915401
Test: atest WmTests:DisplayWindowPolicyControllerHelperTests
      atest CtsVirtualDevicesTestCases
      atest WmTests:ActivityStarterTests
      Added test in ag/17503735
Change-Id: I3dfb9dd93c0edf4634320c52a3fc40c4bf473085
2022-04-07 07:45:59 +00:00
TreeHugger Robot
8e814271bb Merge "Disable debug log in WindowContextController" into tm-dev 2022-04-07 06:04:52 +00:00
Shan Huang
b353af0387 Create OnBackInvokedCallbackInfo to wrap callback and its priority.
Main motivation is to store a back callback's exact priority value in WM. This is required by the IME migration (ag/17076160) to compare the priority levels of IME window callback and focused window callback in BackNavigationController.

This also consolidates the WindowState#mSystemOnBackInvokedCallback and WindowState#mApplicationOnBackInvokedCallback fields into one field, as tracking two fields for one callback was error prone. We had to remember to clear the application / system field when the other field is set, and failing to do so has resulted in bugs such as b/222675481.


Bug: 224856664
Test: atest BackNavigationControllerTest
Test: atest WindowOnBackInvokedDispatcherTest
Test: m -j and test back behavior throughout the system on apps that
opted in and out.

Change-Id: Ic57113610d934f33d2c9ca4cef59f39a9b87e832
2022-04-07 05:11:42 +00:00
Shan Huang
f608b18317 Merge "Split predictive back bitmask flags into a few boolean flags." into tm-dev 2022-04-07 00:24:47 +00:00
Chris Li
cbc449164b Merge "Register remote animation per Task" into tm-dev 2022-04-02 10:36:24 +00:00
Shan Huang
69a3984aae Remove OnBackInvokedDispatcherOwner interface.
Test: m -j update-api. Build and flash and test back behavior throughout
the system.
Bug: 227500290

Change-Id: Ibdb13d02e044741d05d99f1cad96e43dc0129fe4
2022-04-01 20:27:34 +00:00
Vadim Caen
d0923a2197 Merge "Split animation methods out of OnBackInvokedCallback" into tm-dev 2022-04-01 20:13:30 +00:00
Vadim Caen
c627777dda Split animation methods out of OnBackInvokedCallback
This makes OnBackInvokedCallback SAM compatible

Bug: 227789359
Test: atest \
        CtsWindowManagerDeviceTestCases:android.server.wm.BackNavigationLegacyTest \
        CtsWindowManagerDeviceTestCases:android.server.wm.BackNavigationTests \
        WmTests:com.android.server.wm.BackNavigationControllerTests \
        FrameworksCoreTests:android.window.BackNavigationTest \
        FrameworksCoreTests:android.window.WindowOnBackInvokedDispatcherTest \
        CtsViewTestCases:android.view.cts.OnBackInvokedDispatcherTest
Change-Id: Iab86b0488f1b3048eb02042191acaeb6a645a0bc
2022-04-01 20:09:26 +00:00
Vadim Caen
a28e989921 Merge "Some cleanup logging and test for back navigation" into tm-dev 2022-04-01 15:57:59 +00:00
Vadim Caen
71297c8aab Some cleanup logging and test for back navigation
- Better logging
 - Remove method form OnBackInvokedDispatcher interface (but not the
   implementation)
 - Add test for ag/17211289

Bug: 222675481
Test: BackNavigationControllerTests#testUnregisterCallbacksWithSystemCallback
Change-Id: I6a3ae30da7e29dddda116acd8fa0c9af4b9faa6e
2022-04-01 15:57:49 +00: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
wilsonshih
d92645873e Clear the system bars color when removing the splash screen window.
There can reset the system bars color once the splash screen window is
going to be removed, so the real system bars color can be
controlled by app, without waiting for the reveal animation.
Also clear this effect when transfer splash screen to client, so client
can control the color on their own.

Bug: 196550450
Test: verify no status bar color changed when playing reveal animation.
Change-Id: Ibb353d350fa2921188c8c4b54f8e029ee3869c16
2022-04-01 13:39:51 +08:00
Nick Chameyev
3f12009a16 Migrate unfold animation to Shell transitions [Part 1]
Adds a trigger to DisplayContent that creates
unfold transition before applying the display size
and marks it as ready when the sizes are applied.

Adds a placeholder animation for fullscreen tasks.

Bug: 204925795
Test: enable shell transitions, open an app, unfold =>
 check that app surface is animated
Change-Id: Ia88178a7c7849a99c17b4d18117a05b2a0fb8b7f
2022-03-31 10:38:56 +00:00
Hongwei Wang
b2a5b198cd Merge "Handle PiP shadow radius in WMShell" into tm-dev 2022-03-30 22:23:51 +00:00
Shan Huang
82f3bb31ea Merge "Remove DISPATCH_BACK_INVOCATION_AHEAD_OF_TIME." into tm-dev 2022-03-30 14:58:54 +00:00
Shan Huang
cb6810c3d8 Split predictive back bitmask flags into a few boolean flags.
This is such that they can be controlled from Flag Flipper UI.

Boolean flags introduced:
persist.wm.debug.predictive_back - Overall switch for the new back infra
persist.wm.debug.predictive_back_anim - Animation switch
persist.wm.debug.predictive_back_always_enforce - Switch to ignore per
app opt-in flag and always enforce new behavior
persist.wm.debug.predictive_back_screenshot - Screenshot switch. Not
added to Flipper yet.

Test: Flip the flags in Flipper and verify behavior is as expected.

Change-Id: Icff098035119fb83f393e20c6ac590be2f22c845
2022-03-29 23:42:37 +00:00
Shan Huang
778d3d83f8 Remove DISPATCH_BACK_INVOCATION_AHEAD_OF_TIME.
We are not gating the new back dispatch by targetSdkVersion in T. The new dispatch is controlled by the enableOnBackInvokedCallback app
manifest flag (which defaults to false).

Test: m -j update-api
Bug: 195946584
Change-Id: Iab59051ec5b6336ca4d42cc47015fe86a3f37942
2022-03-29 20:47:53 +00:00
Chavi Weingarten
8089e6f249 Merge "Force draw during a blast sync and disable rt animations" into tm-dev 2022-03-29 18:38:02 +00:00