From d6c5d36d1c41c2849cf8f37b40d6f3b93805abcd Mon Sep 17 00:00:00 2001 From: Shan Huang Date: Tue, 9 Aug 2022 00:39:07 +0000 Subject: [PATCH] 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 --- core/java/android/window/WindowOnBackInvokedDispatcher.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/java/android/window/WindowOnBackInvokedDispatcher.java b/core/java/android/window/WindowOnBackInvokedDispatcher.java index 1d396be6b4789..0730f3ddf8ac1 100644 --- a/core/java/android/window/WindowOnBackInvokedDispatcher.java +++ b/core/java/android/window/WindowOnBackInvokedDispatcher.java @@ -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"