201 Commits

Author SHA1 Message Date
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
Vadim Caen
09f7f6f69b Merge changes from topic "presubmit-am-b87ddd3bbf2947f1aa639cddcee6ecb8" into tm-dev
* changes:
  Remove callback before WindowState removal
  Improve startBackNavigation stability
2022-03-28 18:53:26 +00:00
Vadim Caen
6a074eca5c Improve startBackNavigation stability
- Use the focused window instead of the topApp window
    - Instead we now rely on WindowManagerService to get
     the focused window.
    - SystemUI does not have ActivityRecord so we can't rely
     on the top window of the Task to find the correct
      window on which the callback will be called.

  - Introduce a Builder for BackNavigationInfo
    - This reduces the number of variable needed outside the synchonized
    block.
    - It also reduces the number of early return of BackNavigationInfo
    instances

  - Adding log messages to help further debug the method.

Test: BackNavigationControllerTests
Test: Manual dismiss of SystemUi dialog in QS
Bug: 216604581
Fixes: 221458292
Change-Id: I9ba2c7f89956f34d6338824502c210b3e58dc076

Introduce builder for BackNavigationInfo

Change-Id: I14b4a4b3abc8f417998b7b32831cb3d5c4faa491
2022-03-24 14:14:26 +01:00
Chris Li
94d10aec87 Merge "Disable all input on ActivityRecord during trusted animation" into tm-dev 2022-03-24 07:35:28 +00:00
Evan Rosky
7ca26cc4d7 Merge "Move the pendingTransaction stuff into BLASTSyncEngine" into tm-dev 2022-03-23 23:13:01 +00:00
Chris Li
a3e1134c46 Merge "Disable all input on ActivityRecord during untrusted animation" into tm-dev 2022-03-23 13:47:59 +00:00
Chris Li
b4c0c4e81b Disable all input on ActivityRecord during trusted animation
As a followup to ag/17258046, since we don't have any use case to
rely on handling input during animation, disable input even if it
is trusted embedding so that it could cover some edge-cases when
a previously truste host starts doing something bad.

Bug: 197364677
Test: atest WmTests:AppTransitionControllerTest
Change-Id: I7312b6ed961891c5c58adad73f660d4a18084c52
2022-03-23 17:49:56 +08:00
Chris Li
a53b05ca8c Disable all input on ActivityRecord during untrusted animation
For cross-process embedding, there can be activity of other app embedded
in untrusted mode. When it happens, we need to disable all input on the
Task if we are going to play client-driven animation to make sure the
host client can't abuse the animation leash.

Bug: 197364677
Test: atest WmTests:AppTransitionControllerTest
Change-Id: I3e299c0a43ac823b7df6af9d02c7168bd65d3271
2022-03-23 10:01:40 +08:00
Evan Rosky
35c049de96 Move the pendingTransaction stuff into BLASTSyncEngine
The functionality has morphed since its original transitions-only
incarnation. Now it is a general queue mechanism for SyncEngine.

So, move it into BLASTSyncEngine and clean-up the abstraction
a little-bit. This should make it more usable for some upcoming
fixes.

Bug: 222033492
Test: existing tests pass (just a refactor)
Change-Id: Ia057e816ad5635e9681d3273d139e494c18216d9
2022-03-22 16:01:49 -07:00
Issei Suzuki
f51bb0783b Merge "Migrate DEBUG_ANIM logcat message to ProtoLog." into tm-dev 2022-03-22 18:19:19 +00:00
TreeHugger Robot
697afc9660 Merge "Move DEBUG_INPUT_METHOD logs into proto logs for debugging IME snapshot" into tm-dev 2022-03-22 14:40:16 +00:00
Issei Suzuki
f3732b4991 Migrate DEBUG_ANIM logcat message to ProtoLog.
Added more log messages around animatingExit.

Bug: 205335975
Test: Existing builds and tests pass.
Change-Id: I4461eddd4a24c7bba1adef1571ce0fbf6d7db0a2
2022-03-21 14:00:13 +01:00
Ionut Hulub
8bda50023d Reparent ImeContainer under parent when organized.
If, for whatever reason, the SystemUI process crashed and restarted,
the IME wasn't functional anymore (it would not become visible).

That happened because, after the SystemUI crash, the IME was
unorganized for a while and the framework reparented its surface
under an activity.

With this commit we fix this issue by reparenting the IME under its
parent when it becomes organized again.

Manual Test: Checked that the IME becomes visible after a systemui
             crash.
Test: atest DisplayContentTests
      #testImeContainerIsReparentedUnderParentWhenOrganized
Bug: 224800157
Change-Id: I303baf96c905a9c4b444189b731f63c7d51a11f2

Change-Id: I4d2934516e528bf353395e1759f59612542bdb56
2022-03-21 16:16:20 +08:00
Ming-Shin Lu
db1e72190f Move DEBUG_INPUT_METHOD logs into proto logs for debugging IME snapshot
Bug: 224664116
Test: build, verify with enabling proto log:
 adb shell wm logging enable WM_DEBUG_IME, see if IME snapshot logs
 printed.

Change-Id: Ia61e6f3955178d9a4deb68ba1d8ae7d4ebb341d1
2022-03-21 15:32:42 +08:00
Naomi Musgrave
4b563a2d37 Merge "Capture the contents of a single task" into tm-dev 2022-03-17 17:03:48 +00:00
Naomi Musgrave
13194c3ca4 Capture the contents of a single task
Introduces layer mirorring of a single task, given the task is both
identified (future work - dependency on setup flow in SysUI) and the
flag is enabled (currently disabled).

Error handling (tearing down the VirtualDisplay if task recording setup failed)
will come in a future change

Bug: 216625226
Test: atest WmTests:DisplayContentTests
Test: atest WmTests:ContentRecorderTests
Change-Id: I16abd55ce75537ff8fbbb379e4970668ea02a230
2022-03-15 14:13:11 +00:00
Shan Huang
0e9d709e2f Implement back to launcher animation from shell and WM animation
controllers.

Test: m -j.
Test: Open and swipe back on pre-T and T apps.
Test: atest BackNavigationControllerTests
Test: atest BackAnimationControllerTest
Bug: 195946584

Change-Id: I981f8deff9fad75355ee0e8bbe08b375f4da6e74
2022-03-14 23:12:41 +00:00
Naomi Musgrave
472e00b0dc Refactor content recording out of DisplayContent
Bug: 216756854
Test: atest WmTests:ContentRecorderTests
Test: atest WmTests:DisplayContentTests
Change-Id: Idf8f5b22986f889348ca187b2f1f005da163e5e2
2022-03-02 18:34:57 +00:00
Naomi Musgrave
27655e1fc3 MediaProjection sets content recording details in WM directly.
Content recording relies upon a class describing current state.
rather than passing around details from media > display > wm.
WMService keeps track of the session in ContentRecordingController.
ContentRecordingController manages hand-off between different
DisplayContent instances, as the session details are changed.

Manually tested that fold/unfold handling when screen recording
from QS tile still works, and that taking over a screen cast
with a screen recording works.

Refactoring logic from DisplayContent into new recording
delegate will come in a future change.

Bug: 216756854
Test: atest FrameworksCoreTests:ContentRecordingSessionTest
Test: atest WmTests:DisplayContentTests
Test: atest WmTests:ContentRecordingControllerTests
Change-Id: Ib4f125dd703d362ac13fcbe469d00b345827e706
2022-03-02 18:32:34 +00:00
HQ Liu
964305e1b2 Remove the current input focused window when ANR
When a freeform app launched and focused, but its window is not ready,
the input focus stays on the window of the previously focused freeform
app. The focus should be removed from the previously foccused app, so
ANR can be triggered correctly.

Bug: 216852742
Test: atest AnrTests#slowOnCreateWithKeyEventTriggersAnr
Change-Id: Id00c147ffab9b11fb2abdf0f3020bc017a31bea7
2022-02-21 20:42:21 +00:00
Vadim Caen
625f5e286f Add enableOnBackInvokedCallaback manifest attribute
Add a manifest flag for applications to opt-out of the new back
navigation system.

Test: atest
CtsWindowManagerDeviceTestCases: android.server.wm.BackNavigationLegacyTest
Bug: 217709328
Change-Id: I43d09a37b126e59bdb8f20bb83cf6d99e53a1e91
2022-02-14 22:27:10 +01:00
Shan Huang
642b0d8cdd Invoke callbacks based on back navigation type.
Test: m -j.
Test: Open and swipe back on pre-T and T apps.
Test: atest .../BackNavigationControllerTests.java
Test: atest .../BackAnimationControllerTest.java
Bug: b/195946584
Change-Id: I00cf7ab5b57760d57d30ac74dc5b3443a4203f38
2022-02-11 22:59:04 +00:00
Vadim Caen
717e53a6a7 Save the OnBackInvokedCallback in WindowState
This CL enable OnBackInvokedCallback to be saved in a WindowState and
queried by the BackNavigationController to be returned when
ATM.startBackNavigation() is called.

The DecorView provides a PendingOnBackInvokedDispatcher that can receive
callback registration before being added to a ViewRootImpl.

Test: atest FrameworksCoreTests:BackNavigationTest
Bug: 131727607
Change-Id: I01528a22ea4a6583a56ade4eab69136d727855d0
2022-02-02 22:08:02 +01:00
Riddle Hsu
4b86a040b4 Ensure that participated activities are not omitted by ancestor
... when preparing transition targets.

Previously, the first step of the calculation finds the top participant
if possible, and once there is one, only the level above task will be
added. Because it assumes that the parent of participant can represent
it. But there are more than one participants belong to an ancestor, the
descendants may have individual changes, so they should be still in the
transition targets. Otherwise the animation may have nothing to do.

Now all valid participants are added into the target lists, and then
combine the targets from bottom to up based on depth. So it can be
done in 1 pass (originally it requires 3 passes when launching a new
task from home, 4 passes when starting recents).

The population of ChangeInfo#mParent is moved after tryPromo so it
can skip the targets which were removed, and the parent info can
be updated in a single place.

Bug: 213867980
Test: TransitionTests#testOpenActivityInTheSameTaskWithDisplayChange
Test: adb shell setprop persist.debug.shell_transit 1; reboot
      Start a landscape activity from a portrait activity in the
      same task. The animation should not jump cut.

Change-Id: I23a3326611dcb5664b204748280ae15b2377f318
2022-01-25 17:28:24 +08:00
Chris Li
7481586ab6 Merge changes Ida331585,I255fb336
* changes:
  Queue applySyncTransaction calls when there is active BLAST sync
  Queue startTransition calls made while already collecting
2022-01-25 02:19:36 +00:00
Tiger Huang
697660ac69 Merge "Let the client set transform hint on its own" 2022-01-23 18:02:11 +00:00
Galia Peycheva
5c57f3bebf Merge changes from topic "keep_clear_areas"
* changes:
  Add keep clear rects API
  Add WMS support for keep-clear areas
2022-01-22 17:25:09 +00:00
Tiger Huang
5242af609e Let the client set transform hint on its own
This is a step to move the layout logic to the client side. We won't
invoke IWindowSession#relayout then.

Bug: 161810301
Test: atest WmTests
Change-Id: Ib5ac048a573907af0a81f3e228575d9458862cfd
2022-01-22 19:22:23 +08:00
Tiger Huang
c5ee8aa405 Merge "Pipe display install orientation 2/2" 2022-01-22 08:01:00 +00:00
Galia Peycheva
92edc518ff Add WMS support for keep-clear areas
Test: atest DisplayContentTests#testKeepClearAreasMultipleWindows
Test: atest WindowStateTests#testKeepClearAreas
Bug: 183746978
Change-Id: I974bf4254003467c8aa9a4f7aa618ab96985dd38
2022-01-22 08:50:02 +01:00
Vishnu Nair
80d665bbbc Pipe display install orientation 2/2
This is a step to move the layout logic to the client side. We won't
invoke IWindowSession#relayout then, and the client should be able to
set the transform hint on its own.

Bug: 161810301
Test: presubmit
Change-Id: Ib12a76fcc9906b3d9c487fb89bbe4520c682379a
2022-01-22 00:16:32 +08:00
Chris Li
1b97f8262c Queue applySyncTransaction calls when there is active BLAST sync
We currently queue applySyncTransaction in WM Shell, but it doesn't sync
with Shell transition collection. However, when both happen, it may
cause issue because the BLASTSyncEngine currently only support 1 sync at
a time.

Move the Shell transition queue to WindowOrganizerController as we only
queue organizer sync. Unfortunately, unlike organizer sync that is in
one WCT, we can't prevent any core-initiated transition.

We don't expect it to happen, but if it does, we need to handle them
case by case.

Fix: 213866869
Test: atest WMShellFlickerTests:ExpandBubbleScreen
Change-Id: Ida331585b018e848e2f801da55cb6a4b999950f4
2022-01-21 13:00:25 +08:00
Evan Rosky
72a8241ff7 Queue startTransition calls made while already collecting
Shell Transitions only supports 1 transition collecting at a time.
This limitation comes from BLASTSyncEngine. However, because Shell
can call startTransition at any time (and doesn't have a way to
know if WM is already "collecting" for a transition), we can't
just crash in this case. We also can't just use the existing
transition because it has a different "client" expecting results.

So, the best we can do is queue them up. Fortunately, the
startTransition API Shell uses is designed such that all the
relevant operations are in one WCT, so we can maintain server-side
correctness.

This CL adds a queueing mechanism for these situations. In practice,
this should actually never be needed; however, it is *technically*
possible and automated tests are more likely to hit it.

Bug: 183993924
Test: pass existing
Change-Id: I255fb336cb30c7d1e1b82188a31f9c693b9e138c
2022-01-21 12:59:05 +08:00
Vadim Caen
a4ca5286d2 Server infrastructure for back nav animation (BackNav 1/n)
This CL introduces the BackNavigationController that gathers the
required data to be passed to WMShell to create the back animation

These data are passed via the BackNavigationInfo Parcelable.

The CL also containes a basic screenshoting mechanism as a temporary
solution until a proper screenshoting infrastructure is created
(b/207481538).

Test: atest BackNavigationControllerTests
Bug: 131727607
Change-Id: Ibd7fc78e590794daf35f7718ddfa53e7f439813b
2022-01-18 10:42:21 +01:00
Charles Chen
1c671ce110 Merge "Choose TDA by DisplayAreaPolicy for WindowContext" 2022-01-13 09:29:59 +00:00
Mariia Sandrikova
24f4d8a952 [2/n] Camera Compat UI: Add interfaces for client-server communication.
Changes:
- Listens to changes from the client coming through IActivityClientController#requestCompatCameraControl to ActivityRecord#updateCameraCompatState
- ActivityRecord#updateCameraCompatState sends updated state via TaskInfo to WM Shell
- ITaskOrganizerController#updateCameraCompatControlState to dispatch the user interactions with the control from WM Shell triggers callback to ActivityRecord#updateCameraCompatStateFromUser
- ActivityRecord#updateCameraCompatStateFromUser remembers the user's choice and asks client to apply treatment through ICompatCameraControlCallback

Feature is guarded with config_isCameraCompatControlForStretchedIssuesEnabled

Test: atest WMShellUnitTests:ShellTaskOrganizerTests, atest WmTests:ActivityRecordTests
Bug: 206602997
Change-Id: I083aa6718bd67456bedd9444e9b78740c041f870
2021-12-17 00:18:57 +00:00
Issei Suzuki
bdc4e842cf Clean up windows which stuck in animatingExit state.
WM delays to destroy window surface if the window is running an exit
animation, and clean it up after the animation finishes. In case the
clean up process was not triggered, we do it before starting an app
transition.

Note that this is a safe guard for potential bugs. The surface shall
be destroyed as soon as an animation finishes, so the clean up should
have been done before an app transition starts.

Bug: 205335975
Test: atest AppTransitionControllerTest
Change-Id: I9c37ab9ebc57ef48827df25ecc52bf09101ad419
2021-11-24 12:54:13 +01:00
Hongwei Wang
0a53b766cb Allow auto-pip on launching new Task from TaskBar
Loosen the check on FLAG_RESUME_WHILE_PAUSING in
TaskFragment#startPausing for auto-enter-pip.

Fixed also the round corner radius calculation in WMShell component for
entering PiP transition.

Bug: 198227082
Bug: 202574512
Video: http://recall/-/aaaaaabFQoRHlzixHdtY/bEPWcJSn8iGbLLNg6cM0E3
Test: no auto-enter on quick switch and does on launching new Task,
      see video for details
Test: atest PinnedStackTests#testAutoPipOnLaunchingAnotherActivity
Change-Id: I53e62a5f6e663b2d6df8cd0aaa858ff01ef073e8
2021-11-18 10:50:29 -08:00
Charles Chen
082dec989c Choose TDA by DisplayAreaPolicy for WindowContext
Previously, WMS always associate TYPE_APPLICATION WindowContext with
the default TDA. This CL provides the capibility to select a TDA by
DisplayAreaPolicy.

Test: atest DisplayAreaPolicyBuilderTest
fixes: 185769955

Change-Id: Ie7cb686cd5d1da81ef618a3f1316dc3932a8272f
2021-10-27 09:57:41 +00:00
Issei Suzuki
3e469aec5a Add display sleep token information to winscope dump.
Change-Id: Ia25854feed3bb6b037d4510a6b5000d906d27313
Merged-In: Ia25854feed3bb6b037d4510a6b5000d906d27313
Bug: 198593156
Test: manual. capture winscope dump and see it.
2021-10-26 12:13:37 +02:00
Evan Rosky
c6d5abe414 Fix PiP Shell Transitions
PiP Shell Transitions needs to be more robust to pass CTS tests
reliably.

Some changes:

1. DELIVERED_TO_TOP intents don't create a transition since there is
   no change to the WM hierarchy. This way the app-launch transition
   won't conflict with activityRestartAttempt.

2. If PiP started an expand transition while an enter transition is
   ongoing, cancel the enter transition.
   a. Additionally, because PiP doesn't resize task until the enter
      transition finishes, the expand transition will actually be
      a no-op. If we see this pattern, also cancel the enter
      transition.

3. When taskVanished, make sure to call any pending finishCallback
   because it doesn't allow the running animator to properly finish.
   Transition systems require the finish callback to function
   properly.

4. Minimize the uses of finishTransition with a sync callback. We
   probably need to phase this out because it can conflict with
   subsequent startTransition calls (because only 1 sync is supported
   at a time).

Bug: 183993924
Test: atest PinnedStackTests
Change-Id: Ieb573032839a2f31b0bb371410484fc93a1714fa
2021-10-19 15:50:41 -07:00
Issei Suzuki
cd9c90750a Merge "Migrate WALLPAPER_LIGHT debug message to ProtoLog." into sc-v2-dev 2021-10-12 15:09:42 +00:00
Issei Suzuki
bde317e6b1 Migrate WALLPAPER_LIGHT debug message to ProtoLog.
Test: manual
Bug: 191438572
Bug: 202392340
Change-Id: Ibf538fce834715dc32741f4b52808f99020f741e
2021-10-12 09:38:58 +02:00
Chris Li
53e7502809 Don't override with TasmFragmentRemoteAnimation for wallpaper/non-app
We don't want to allow the client to animate for wallpaper or any
non-app windows.

Bug: 201482129
Bug: 196173550
Test: atest WmTests:AppTransitionControllerTest
      #testOverrideTaskFragmentAdapter_noOverrideWithWallpaper
Change-Id: Ic29db59fc9f9695df9c8ba3a6d812ad217cdd641
2021-10-12 10:03:29 +08:00
Chris Li
54d2b20371 Allow organizer to handle transition for non-embedded activity
We want to allow organizer to handle the transition in case like
launching split TaskFragments from a non-embedded activity.

Bug: 200496784
Test: atest WmTests:AppTransitionControllerTest
Test: test with demo app to launch split from non-embedded
Change-Id: Iaf1d07c8cf43fa773fede3c031855085147be263
2021-09-30 20:12:50 +08:00
Chris Li
abdb320b70 Merge "Don't start app transition when there is empty TaskFragment" into sc-v2-dev 2021-09-24 03:34:03 +00:00
Chris Li
c6ab0bb710 Don't start app transition when there is empty TaskFragment
TaskFragment can be empty for either 1. wait for new launch activity, or
2. last activity just removed.

For 1, we want to wait for the activity launch.
For 2, we want to wait for organizer to remove the TaskFragment.

Bug: 196173550
Test: atest WmTests:AppTransitionControllerTest
      #testTransitionGoodToGoForTaskFragments
Change-Id: I73ac239ef2e5a75d05af6f6ae97e3f2278ebb4c3
2021-09-23 21:53:55 +08:00
Vishnu Nair
d6f2c5882f WM: Handle primary display orientation when calculating the transform hint
Query the surface flinger property
ro.surface_flinger.primary_display_orientation to determine the
primary display's install orientation. If the window is on the
primary display, then update the transform hint passed on to the
client.

Bug: 196167822
Test: check initial buffer transforms on displays with a different
install orientation

Change-Id: Idf010cd6be73172ba708820f87046c3ba3cf8001
2021-09-22 17:06:10 +00:00
Evan Rosky
e02fc4cbba Don't let IME move to recents activity during recents transition
In shell transitions, recents opens on top, but in transient mode
(meaning it doesn't cause the other apps to pause). This means the
other apps should be running un-interrupted. This includes not
taking the IME away.

To handle this, adjust the IME logic so that transient-launching
activities are NOT canBeImeTarget.

Also fix a bug in isVisibleOrAdding where it was using
visibleRequested instead of visible (if you look at the change
history, !hiddenRequested was incorrectly replaced by
visibleRequested instead of visible).

Also fix a bug where a defer/continue of updateImeTarget was
updating the target even when an update was never requested while
it was deferred. This was causing it to be called prematurely
during activitystarter (where global lock is held).

Bug: 193565597
Test: atest ReOpenImeWindowTest SwitchImeWindowsFromGestureNavTest
Change-Id: Ic537d77c8b0e10e80444dd46d7b49e5a9bd63d6c
2021-09-07 11:33:50 -07:00
Naomi Musgrave
fcef782559 [MediaProjection] Do not start layer mirroring without a surface
An app may pass a null surface to MediaProjection#createVirtualDisplay,
and later set the surface on the VirtualDisplay. The display's state
will change from off to on when the surface is set.

When determining if layer mirroring should be started/updated in
DisplayContent, take the presence of the surface/display state
into account, to prevent the app from crashing.

Bug: 197863746
Test: atest WmTests:DisplayContentTests
Change-Id: I01af07fff681aab6fc8235c861375eb79118cbfe
2021-09-03 14:42:52 +01:00