summaryrefslogtreecommitdiff
path: root/core/java/android/window/ProxyOnBackInvokedDispatcher.java
Commit message (Collapse)AuthorAgeFilesLines
* DO NOT MERGE Prevent back navigation not working after activity re-createdArthur Hung2023-02-011-10/+1
| | | | | | | | | | | | | | | | | 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
* Inject back key events if no focus window found.wilsonshih2022-07-291-1/+1
| | | | | | | | | | | | | | | | | | | | If user applied a back gesture but core cannot find a focus window, inject back key event, so that event can dispatch to client once it gain focus window. And since the gesture was happened, treat it as onBackPressed. And if device is playing recents animation but the focus window is point to live tile, we can also inject back key because Home/Recents activity shall not have the same behavior as normal app. Bug: 237629607 Test: cross test that back gesture can finish recents with legacy/shell transition on Nexus/3rd launcher. Test: test on BackTestApp for both 3btn mode and gesture mode. Test: atest AnrTests BackNavigationLegacyGestureTest Test: atest OnBackInvokedDispatcherTest KeyboardVisibilityControlTest BackInvokedOnWidgetTest BackNavigationTests BackNavigationControllerTests Change-Id: If754e66ea7c1c4ec313c45d17d7f6c10bfc2c465
* Prevent callback registration when back flag is disabledVadim Caen2022-06-201-4/+8
| | | | | | | | | | | | | | | | 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)
* Transfer the actual dispatcher when the window is preservedVadim Caen2022-05-251-2/+15
| | | | | | | | | | | | | | | | 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
* Migrate IME to handle back with OnBackInvokedDispatcher.Shan Huang2022-05-041-0/+16
| | | | | | | | | | | | | | 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
* Remove OnBackInvokedDispatcherOwner interface.Shan Huang2022-04-011-32/+24
| | | | | | | | Test: m -j update-api. Build and flash and test back behavior throughout the system. Bug: 227500290 Change-Id: Ibdb13d02e044741d05d99f1cad96e43dc0129fe4
* Some cleanup logging and test for back navigationVadim Caen2022-04-011-1/+1
| | | | | | | | | | | - Better logging - Remove method form OnBackInvokedDispatcher interface (but not the implementation) - Add test for ag/17211289 Bug: 222675481 Test: BackNavigationControllerTests#testUnregisterCallbacksWithSystemCallback Change-Id: I6a3ae30da7e29dddda116acd8fa0c9af4b9faa6e
* Improve startBackNavigation stabilityVadim Caen2022-03-241-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | - 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
* Change parameter order to make it SAM compatibleVadim Caen2022-03-171-4/+4
| | | | | | | | Move the callback as the last paramter to registerOnBackInvokedCallback Test: Existing Bug: 224562951 Change-Id: I8608a03b53baa04bedee81d2e86b2339abd6c594
* Move OnBackInvokedCallback to window package.Vadim Caen2022-03-021-3/+0
| | | | | | | | | | | | | 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
* Fix callbacks not being unregistered from ProxyDispatcherVadim Caen2022-02-241-0/+4
| | | | | | Test: Manual Bug: N/A Change-Id: I1caae0fe212ca7915d6d689183e615e9c421dbfa
* Add compatibility back callbacks.Shan Huang2022-02-051-10/+27
| | | | | | | | | | | 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
* Save the OnBackInvokedCallback in WindowStateVadim Caen2022-02-021-0/+162
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