summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Johannes Gallmann <gallmann@google.com> 2025-03-05 10:27:42 -0800
committer Android (Google) Code Review <android-gerrit@google.com> 2025-03-05 10:27:42 -0800
commit23f87d67a93ca31ff9d802b606463180fa278cbf (patch)
treeaad529816c11e30b3fd6788e9fbddcebbda78d2d
parentd98e0c0743a731bd8d226b0deedac41627b7f26e (diff)
parent3db0392c347f9fb78cc07c43ae896287c9b9b595 (diff)
Merge "Fix back callback not cleared by RIV" into main
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java7
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/RemoteInputViewTest.java11
2 files changed, 7 insertions, 11 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java
index 2b0bf1a3d343..f1f2b88e9943 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java
@@ -461,6 +461,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
}
}
}
+ unregisterBackCallback();
if (logClose) {
mUiEventLogger.logWithInstanceId(
@@ -558,11 +559,6 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
@Override
public void onVisibilityAggregated(boolean isVisible) {
- if (isVisible) {
- registerBackCallback();
- } else {
- unregisterBackCallback();
- }
super.onVisibilityAggregated(isVisible);
mEditText.setEnabled(isVisible && !mSending);
}
@@ -623,6 +619,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
setAttachment(mEntry.remoteInputAttachment);
updateSendButton();
+ registerBackCallback();
}
public void onNotificationUpdateOrReset() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/RemoteInputViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/RemoteInputViewTest.java
index ffe7750dadfa..4a0445d5543a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/RemoteInputViewTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/RemoteInputViewTest.java
@@ -269,14 +269,14 @@ public class RemoteInputViewTest extends SysuiTestCase {
when(viewRoot.getOnBackInvokedDispatcher()).thenReturn(backInvokedDispatcher);
view.setViewRootImpl(viewRoot);
- /* verify that predictive back callback registered when RemoteInputView becomes visible */
- view.onVisibilityAggregated(true);
+ /* verify that predictive back callback registered when RemoteInputView gains focus */
+ view.focus();
verify(backInvokedDispatcher).registerOnBackInvokedCallback(
eq(OnBackInvokedDispatcher.PRIORITY_OVERLAY),
onBackInvokedCallbackCaptor.capture());
- /* verify that same callback unregistered when RemoteInputView becomes invisible */
- view.onVisibilityAggregated(false);
+ /* verify that same callback unregistered when RemoteInputView loses focus */
+ view.onDefocus(false, false, null);
verify(backInvokedDispatcher).unregisterOnBackInvokedCallback(
eq(onBackInvokedCallbackCaptor.getValue()));
}
@@ -299,13 +299,12 @@ public class RemoteInputViewTest extends SysuiTestCase {
view.onVisibilityAggregated(true);
view.setEditTextReferenceToSelf();
+ view.focus();
/* capture the callback during registration */
verify(backInvokedDispatcher).registerOnBackInvokedCallback(
eq(OnBackInvokedDispatcher.PRIORITY_OVERLAY),
onBackInvokedCallbackCaptor.capture());
- view.focus();
-
/* invoke the captured callback */
onBackInvokedCallbackCaptor.getValue().onBackInvoked();