Commit Graph

508 Commits

Author SHA1 Message Date
Arthur Hung
0099ca8fab Ignore back invoke when window focus has lost
The back invoke target could lost focus during back navigation.
To prevent the non-focused window could still trigger back action cause
some unexpected behavior, this CL will listen focus changed and skip the
back invoke call.

Test: launch a trampoline activity and trigger back before next activity
shown.
Test: atest WindowOnBackInvokedDispatcherTest
Bug: 238050065

Change-Id: Ifd345b2283c5d07628e2884db6e4e13f3ec31e83
2022-07-20 04:26:45 +00:00
Chris Li
b6cca29bb5 Add ActivityEmbedding transition handler in Shell
Jumpcut for transitions that are all embedded.

Bug: 207070762
Test: pass existing
Change-Id: I8da7647477d24b895ff1b140fca7c8774918c531
2022-07-18 21:44:31 +08:00
Jeff Chang
89f86c1813 Handle the uncontrolled task in split-screen
Exit the split-screen in case users put the uncontrolled task into
split-screen. This CL do below change to support handling this task.
   1. If no controlling activity appeared, dismiss the split screen
      and show a toast to inform users.
   2. Reparent all tasks out of split root when dismissing instead of
      just reparent controlling tasks.
   3. Disable the split-item from launcher for tasks that are
      uncontrolled.

Bug: 230461945
Bug: 208646963
Bug: 238032411
Test: atest MultiWindowTests
      atest WMShellUnitTests
Change-Id: Iab59561e9d532b10dab8f5063047c4b68b73eb87
2022-07-08 12:40:27 +08:00
Louis Chang
cf3b16d69b Merge "Do not filter out the size configs if no configuration buckets" into tm-qpr-dev 2022-06-28 01:35:56 +00:00
Tiger Huang
228988d5e7 Merge "Send the attached frame to the client" into tm-qpr-dev 2022-06-23 06:11:07 +00:00
Vadim Caen
9e2a134dde Merge "Prevent callback registration when back flag is disabled" into tm-dev am: 1c6de844ce am: 0592820f44
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18794217

Change-Id: I367c3888b726f0f7c83d382881741478e715d549
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-20 21:19:32 +00:00
Tiger Huang
157514510f Send the attached frame to the client
The attached frame is the frame of the parent window that its child
attaches to, as long as the child is not
TYPE_APPLICATION_ATTACHED_DIALOG. It is a factor while computing the
window frame.

Previously, we let the child obtain the attached frame from its parent
view root. However, if the parent and the child are not in the same
process, it can be tricky.

This CL sends the attached frame from the server to the client via
ClientWindowFrames. In this way, the child can compute its window frame
without having to accessing the parent view root.

Bug: 161810301
Bug: 175861127
Test: atest ActivityRecordTests WindowLayoutTests
Change-Id: Ia844a4c927027e305a56114216eaee2bf7933b1f
2022-06-20 21:09:40 +08:00
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
Chavi Weingarten
acc2838241 Merge "Make sure VRI waits for SV to draw before report" into tm-dev am: 4c2c7ebfaa am: 1ee9e52fe4
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18820396

Change-Id: I8284e93eeac89f6693ccef251ceda92db41d0b85
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-13 23:38:17 +00:00
Louis Chang
8ec32dd023 Do not filter out the size configs if no configuration buckets
Otherwise, the activity may not be relaunched in the right
configuration.

Bug: 235449822
Bug: 235774601
Test: start Settings
Test: atest SizeConfigurationBucketsTest
Change-Id: I3c1d63114b570e1f740408a4381888b0697c2c94
2022-06-13 18:05:13 +08:00
Hongwei Wang
ce21971ecf Add flag to explicitly set setCanAffectSystemUiFlags
Within the PictureInPictureSurfaceTransaction class, one can explicitly
express the intention to call Task#setCanAffectSystemUiFlags(false) and
it is typically used if an Activity is entering PiP.

Video: http://recall/-/b1EZhgUkQcpML5OwZekLBN/dlG6qSf9pT2f4YlIe2Klb3
Video: http://recall/-/b1EZhgUkQcpML5OwZekLBN/cfXwlpol5vi2AER32rKu2x
Bug: 213598210
Test: 1. follow the reproduce steps in the bug. \
      2. make sure PiP from split-screen has no regressions. \
      see also the videos.
Change-Id: I7c4624a89ff812f874270fe0092617328b557393
2022-06-10 11:28:15 -07: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
Tony Huang
15578338b5 [DO NOT MERGE] Fix founction not found on tm cts tests
We refactor setAdjacentRoots function on tm-qpr but cts suite is
still using tm branch and it lead to it cannot found previous
function. Add a temp function params same as old one on tm-qpr only
for pass tests.

Fix: 235169332
Test: atest MultiWindowTests on tm-dev codebase
Change-Id: I3eaea698089cec78ef7fcef17817317c55a7bfe6
2022-06-07 16:03:37 +08:00
Vadim Caen
8406eaa17c Merge "Transfer the actual dispatcher when the window is preserved" into tm-dev am: a147b66f61 am: 5d5f6b1cc1
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18601925

Change-Id: I79fd95197414b8cbd8ddc87c45a18866d64f4c2b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-01 15:46:26 +00: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
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
Iris Yang
595fa85a7a Merge "Use DeviceProfile to determine whether to exclude tasks from Recent" into tm-dev am: d7df1b2804 am: 157d4e274f
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18578468

Change-Id: I5804d5310d308a586c6ccb18d2b43c06a26b167c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-27 17:58:11 +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
TreeHugger Robot
7b87da4388 Merge "Disable debug logging" into tm-dev am: 3639805700 am: 73df4359eb
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18577113

Change-Id: I3d9c0763dc0c960f2b9cfbdc849d7a9a4f59a81b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-25 23:38:34 +00: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
Tony Huang
20e5039095 Remove the special logic of the divider bar z-ordering
Remove the divider bar z-ordering logic since the divider bar is
attached to a single-top root task for split screen now. Remove
split anchor too because it is for legacy split screen using.
Also removed corresponding tests which are no longer needed after
this patch.

Bug: 199236198
Test: pass existing tests
Change-Id: I3435a3c81de78804c8110eb38bbacd0a23b391ef
2022-05-20 14:58:55 +08:00
Shan Huang
76bf9ac13c Merge "Transfer IME callbacks when app's focused root view changes." into tm-dev am: f15480984d am: 40f337eabe
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18417321

Change-Id: Ic40a07c262f39693bec1aef68dddfbd7f0a5bcff
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-18 21:59:27 +00: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
ad8e47338c Merge "Fix IME callback not being re-registered on screen off / on." into tm-dev am: bd7ac0c646 am: 19220d853a
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18310689

Change-Id: I81f376c57805da0a4412bba8c852b607dc5cf04d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-12 23:34:11 +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
Evan Rosky
b54270fbf9 Don't hide IME windows in transition player
IME windows, like wallpaper windows, have their visibilities
managed outside of the transition system. This means that
altering their visibilities can get us stuck in situations
that can't be undone. So, like wallpaper, just check and
skip explicit visibility changes on IME windows.

Bug: 230733128
Test: messages in portrait, open ime, swipe to home, open
      messages in landscape, swipe home, open messages in
      portrait again (ime should be visible).
Change-Id: I0df284cce19f367003570a4e882dd6ffbc8dbef6
2022-05-10 18:28:01 -07:00
TreeHugger Robot
995d09ab66 Merge "Fix memory usage issue on WindowTokenClient" into tm-dev am: 20bb840b29 am: 1f29cb9232
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18186210

Change-Id: I5b93beb5f1b3ec0da87f16871807685f3db065fa
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-09 15:12:24 +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
78c429f948 Merge "Migrate IME to handle back with OnBackInvokedDispatcher." into tm-dev am: e3a61826eb am: 4472170cb9
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17952046

Change-Id: Icf52d1afb13bdab55270c3e6319b4d889d114db0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-06 20:19:10 +00:00
Darrell Shi
8176ed8b17 Add WM transit types for dream activity.
This change adds two WM transit types for opening and closing dream
activities, which allows the system to define transition in and out of
dreams, that are currently being overriden by other transitions.

Set the priority to be just below keyguard transit. The keyguard
occlude/unocclude already correctly handles the dream open/close
animation.

Bug: 222507937
Bug: 220311554
Test: atest WmTests:AppTransitionControllerTest
Test: manually on device by entering and exiting dreams over keyguard,
launcher, and settings. observed animation and relevant types of WM logs.

Change-Id: Iedfa279d56cd9d4c4679cb3b697ee74a98ef727b
2022-05-04 17:13:52 +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