From 8ec05512be4951a9b90e71030e49291dd7104249 Mon Sep 17 00:00:00 2001 From: Shan Huang Date: Fri, 16 Dec 2022 16:14:30 -0800 Subject: [PATCH] Allow IME to register callbacks with negative priorities. It's perfectly valid to register system callbacks (which have negative priority) from the IME process from framework code, once it is opted in. We should still reject negative priority for registration through public APIs though. Will follow up separately in b/262930093. Test: atest android.view.inputmethod.cts.KeyboardVisibilityControlTest#testHideImeAfterBackPressed_legacyAppMigratedIme Fixes: 262727745 Change-Id: Ie13c738d0d4a10f4265fbf116ff7b4206d3bfc62 --- core/java/android/window/ImeOnBackInvokedDispatcher.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/java/android/window/ImeOnBackInvokedDispatcher.java b/core/java/android/window/ImeOnBackInvokedDispatcher.java index 14f52282b3aa0..9152e7837b828 100644 --- a/core/java/android/window/ImeOnBackInvokedDispatcher.java +++ b/core/java/android/window/ImeOnBackInvokedDispatcher.java @@ -123,7 +123,7 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc private void receive( int resultCode, Bundle resultData, - @NonNull OnBackInvokedDispatcher receivingDispatcher) { + @NonNull WindowOnBackInvokedDispatcher receivingDispatcher) { final int callbackId = resultData.getInt(RESULT_KEY_ID); if (resultCode == RESULT_CODE_REGISTER) { int priority = resultData.getInt(RESULT_KEY_PRIORITY); @@ -140,11 +140,11 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc @NonNull IOnBackInvokedCallback iCallback, @OnBackInvokedDispatcher.Priority int priority, int callbackId, - @NonNull OnBackInvokedDispatcher receivingDispatcher) { + @NonNull WindowOnBackInvokedDispatcher receivingDispatcher) { final ImeOnBackInvokedCallback imeCallback = new ImeOnBackInvokedCallback(iCallback, callbackId, priority); mImeCallbacks.add(imeCallback); - receivingDispatcher.registerOnBackInvokedCallback(priority, imeCallback); + receivingDispatcher.registerOnBackInvokedCallbackUnchecked(imeCallback, priority); } private void unregisterReceivedCallback(