summaryrefslogtreecommitdiff
path: root/core/java/android/window/WindowOnBackInvokedDispatcher.java
Commit message (Collapse)AuthorAgeFilesLines
* DO NOT MERGE Add logging for when IOnBackInvokedCallback is null.Shan Huang2023-04-041-0/+1
| | | | | | | | | | It should never be null. We had a bug where the IME callback can be unexpectedly GC-ed and jam back nav. This is to verify if we need its fix ag/21301891 in QPR as well. Bug: 274911901 Test: atest WindowOnBackInvokedDispatcherTest Change-Id: Ic2a576655ca16577ca35f3544f5b26d4a0db8f90
* Merge "DO NOT MERGE Prevent back navigation not working after activity ↵Arthur Hung2023-02-091-0/+21
|\ | | | | | | re-created" into tm-qpr-dev
| * DO NOT MERGE Prevent back navigation not working after activity re-createdArthur Hung2023-02-011-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When recreating the Activity, if the window is preserved, we would set the actual dispatcher from the preserved window to the new Activiy's proxy dispatcher, and expect the new callback could be re-registered in the recreating flow. This CL clears the old callbacks of the preserved dispatcher before it attach to the new proxy dispatcher, this could prevent it access the wrong top callback after other new callbacks have been unregistered. Also provide dump log for WindowOnBackInvokedDispatcher. Bug: 259500250 Test: atest BackNavigationTests Change-Id: Idc9a6a95f5669a009762570d7bc9acc2c538e4cb
* | DO NOT MERGE Let BackProgressAnimator could play cancel animationArthur Hung2023-01-111-5/+6
|/ | | | | | | | | | Add cancel and the cancel callback in BackProgressAnimator so it could animate to start position and invoke the callback after finished. Bug: 259608500 Test: atest BackAnimationControllerTest BackNavigationControllerTests Test: atest BackProgressAnimatorTest Change-Id: I94303ba530d155f4b264dafa21bd23185a6b44bd
* DO NOT MERGE Split BackEvent into an internal BackMotionEvent and public ↵Shan Huang2022-12-301-3/+5
| | | | | | | | | | | | | | | | | BackEvent. The constructor of BackEvent has diverged on QPR and master, which will create merge conflicts for all subsequent SysUI back animations to be added from QPR. This cherry-picks ag/20445076 minus the public API changes to solve this problem. Test: atest BackAnimationControllerTest Test: atest BackNavigationControllerTests Test: atest WindowOnBackInvokedDispatcherTest Test: atest TouchTrackerTest Test: m -j Bug: 238475284 Change-Id: Ib9100a9d667a9a17e8f357a1bfc3ee2b52ec17c7
* DO NOT MERGE Spring controlled back progress APIShan Huang2022-10-211-3/+10
| | | | | | | | | | | | | | This CL introduces BackProgressAnimator which runs in app's main thread. It receives target progress values from SysUI and drives the actual progress value passed to the app with a high stiffness, no bounce spring. Bug: 238475284 Test: atest WindowOnBackDispatcherTest Test: atest BackAnimationControllerTest Test: atest TouchTrackerTest Change-Id: Ib0d3ebe43929c405b10681000fb4e7ef8bccce34
* Respect the enforce flag for callback registration.Shan Huang2022-08-091-1/+2
| | | | | | | | | | | | | | | Predictive back infra respect the enforce flag everywhere else (e.g. for compat / default callback registrations), so we follow the same pattern here. This flag is a development only flag, so this CL should not affect droidfood or public builds. Test: `adb shell setprop persist.wm.debug.predictive_back_always_enforce 1`. Restart. Check apps can register callbacks without opting in (e.g. can swipe back to LS from bouncer) Change-Id: I7d5a85b37b50b11f6e4be28d022dd0e528a7d4fd
* Cancel back invoke when window focus has lostArthur Hung2022-07-281-22/+2
| | | | | | | | | | | | | | | | | | | | This reverts commit 0099ca8fab618dfeefe25cb4c2146b2831900ee5 and provide new mechanism. The back invoke target could lost focus during back navigation gesture. To prevent the non-focused window could still trigger back action cause some unexpected behavior, this CL will listen the focus change of current focused window and cancel back gesture when its focus has lost. Bug: 238050065 Bug: 239792909 Test: atest BackNavigationControllerTests Test: atest BackNavigationLegacyGestureTest BackNavigationLegacyTest Test: atest BackNavigationTests Test: atest WindowOnBackInvokedDispatcherTest BackNavigationTest Test: atset BackAnimationControllerTest Change-Id: I65eb19371020ce39977eeb2a2a80c7f08600aaec
* Ignore back invoke when window focus has lostArthur Hung2022-07-201-4/+22
| | | | | | | | | | | | | | 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
* Prevent callback registration when back flag is disabledVadim Caen2022-06-201-5/+58
| | | | | | | | | | | | | | | | 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 aa48dc3c2db92189055804878b88a51f0cf8e955)
* Disable debug loggingVadim Caen2022-05-251-5/+0
| | | | | | Bug: 227173606 Test: N/A Change-Id: Ia03f7b6e5d9dfb6e247fab4526d6293b3600d398
* Transfer IME callbacks when app's focused root view changes.Shan Huang2022-05-161-3/+4
| | | | | | | | | | | | | | | 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
* Migrate IME to handle back with OnBackInvokedDispatcher.Shan Huang2022-05-041-7/+30
| | | | | | | | | | | | | | 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
* Merge "Create OnBackInvokedCallbackInfo to wrap callback and its priority." ↵Shan Huang2022-04-081-3/+4
|\ | | | | | | into tm-dev
| * Create OnBackInvokedCallbackInfo to wrap callback and its priority.Shan Huang2022-04-071-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Merge "Split predictive back bitmask flags into a few boolean flags." into ↵Shan Huang2022-04-071-7/+8
|\ \ | |/ |/| | | tm-dev
| * Split predictive back bitmask flags into a few boolean flags.Shan Huang2022-03-291-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Merge "Split animation methods out of OnBackInvokedCallback" into tm-devVadim Caen2022-04-011-15/+16
|\ \
| * | Split animation methods out of OnBackInvokedCallbackVadim Caen2022-04-011-15/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Some cleanup logging and test for back navigationVadim Caen2022-04-011-1/+0
|/ / | | | | | | | | | | | | | | | | | | | | - Better logging - Remove method form OnBackInvokedDispatcher interface (but not the implementation) - Add test for ag/17211289 Bug: 222675481 Test: BackNavigationControllerTests#testUnregisterCallbacksWithSystemCallback Change-Id: I6a3ae30da7e29dddda116acd8fa0c9af4b9faa6e
* | Merge "Remove DISPATCH_BACK_INVOCATION_AHEAD_OF_TIME." into tm-devShan Huang2022-03-301-10/+8
|\|
| * Remove DISPATCH_BACK_INVOCATION_AHEAD_OF_TIME.Shan Huang2022-03-291-10/+8
| | | | | | | | | | | | | | | | | | 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
* | Remove callback before WindowState removalVadim Caen2022-03-251-3/+8
|/ | | | | | | | | | | | ViewRootImpl was removing the callback from the server after the windowState was removed, which was consistently failing resulting in an exception in the log. Now the removal is done before the ViewRootImpl's window removal Test: Manually check that the error is not appearing in the log Bug: 226089354 Change-Id: Ie9cb9940791b16d6ae1b243079794583c87b1a5c
* Change parameter order to make it SAM compatibleVadim Caen2022-03-171-1/+1
| | | | | | | | Move the callback as the last paramter to registerOnBackInvokedCallback Test: Existing Bug: 224562951 Change-Id: I8608a03b53baa04bedee81d2e86b2339abd6c594
* Revert "Turn off predictive back"Shan Huang2022-03-141-1/+1
| | | | | | | | | This reverts commit ad89a821450e9a61bd85225fbcf921f8ca51e94b. Reason for revert: b/222170518 was unrelated to gesture back, and is now fixed. Test: m -j. Test back behavior throughout system. Change-Id: Ia27c7ea97416831355e1949ec6874de570b52108
* Make OnBackInvoked callback a WeakReference.Bryce Lee2022-03-081-11/+35
| | | | | | | | | | | OnBackInvokedCallbackWrapper instances are sent to the WindowState over AIDL. This leads to Activity leak issues even if the reference is cleared in the remote side. This change makes the held reference weak So it is not retained. Test: verified leak no longer present through hprof Bug: 221285764 Change-Id: I1c529d27769e2426898776e47f37bdb7abe1f681
* Merge "Move OnBackInvokedCallback to window package." into tm-devVadim Caen2022-03-031-5/+3
|\
| * Move OnBackInvokedCallback to window package.Vadim Caen2022-03-021-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Originally, View was implementing onBackInvokedDisptacherOwner, but now only Activity and Dialog and since back event are related to the window, it makes sense to move them into the android.window package This follow up comment at: ag/c/platform/frameworks/base/+/16764116/comments/e131f3ef_e3e1d2e0 Test: atest BackNavigationTests Bug: 221401221 Change-Id: Ia2f26162beb6a41b6e162b31e599e882f8bf7320
* | Turn off predictive backShan Huang2022-03-021-1/+1
|/ | | | | | | Test: m -j. Test back in apps that opt-in, opt-out & sysUI Bug: 222170518 Change-Id: I97ae7769ff2e04eb7fb39c49e025b255cdba057f
* Fix Activity leaking form OnBackInvokedCallbackWrapperVadim Caen2022-02-251-25/+21
| | | | | | | | | | | - The callback was not removed on the server in the clear() method since mWindow and mWindowSession fields were cleared before - The wrapper class was not static, risking to leak it's outer class and its field. Test: com.android.launcher3.ui.widget.RequestPinItemTest#testPinWidgetWithConfig Fixes: 220385755 Change-Id: I3e5a81bf48c2272b1cb2b5a9f2ba940d0f794a6f
* Add enableOnBackInvokedCallaback manifest attributeVadim Caen2022-02-141-6/+20
| | | | | | | | | | 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
* Invoke callbacks based on back navigation type.Shan Huang2022-02-111-2/+2
| | | | | | | | | 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
* Merge "Create BackEvent interface for back navigation parameters."Shan Huang2022-02-101-2/+2
|\
| * Create BackEvent interface for back navigation parameters.Shan Huang2022-02-101-2/+2
| | | | | | | | | | | | Bug: b/210539672, b/195946584 Test: m -j Change-Id: I0264d0995aed8a73563bece0d15d2a9aac0ebf06
* | Avoid leaking Activity from OnBackInvokedCallback.Shan Huang2022-02-101-40/+39
|/ | | | | | | | | | | - Remove mTopCallback field - Cleanup compat and default callbacks - Remove the callback held by WindowState when the window is removed. Bug: 218328707 Test: atest packages/apps/Launcher3/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java Test: atest frameworks/base/core/tests/coretests/src/android/window/WindowOnBackInvokedDispatcherTest.java Change-Id: I38fd760a617500c874aef10bc8de165880837008
* Add compatibility back callbacks.Shan Huang2022-02-051-4/+40
| | | | | | | | | | | For pre-T apps, the default back callback dispatches KEYCODE_BACK to the application's root view. For T+ apps, the default KEYCODE_BACK listener invokes the registered OnBackInvokedCallback. Test: m -j Bug: 195946584 Change-Id: I62342b249e6cd6f8b036f7e950cc3f9754418ee4
* Implement OnBackInvokedDispatcherShan Huang2022-01-231-6/+132
| | | | | | | Bug:209867448 Test: mp core services sysuig. atest FrameworksCoreTests:WindowOnBackInvokedDispatcherTest Change-Id: Ib74250e93926854f07ebba6b9f680040aa98f9a4
* Provide OnBackInvokedDispatcher from Activity, View and DialogShan Huang2022-01-201-0/+75
Test: mp core sysuig services Bug: 195946584 Change-Id: Ia882ec621154ea1daa780c8976b900e4c8f44a7d