Respect the enforce flag for callback registration.

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
This commit is contained in:
Shan Huang
2022-08-09 00:39:07 +00:00
parent 7c09300459
commit d6c5d36d1c

View File

@@ -325,7 +325,8 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher {
public boolean checkApplicationCallbackRegistration(int priority,
OnBackInvokedCallback callback) {
if (!mApplicationCallBackEnabled
&& !(callback instanceof CompatOnBackInvokedCallback)) {
&& !(callback instanceof CompatOnBackInvokedCallback)
&& !ALWAYS_ENFORCE_PREDICTIVE_BACK) {
Log.w("OnBackInvokedCallback",
"OnBackInvokedCallback is not enabled for the application."
+ "\nSet 'android:enableOnBackInvokedCallback=\"true\"' in the"