Keep the notification shade open for smart replies
Currently when the user taps on a smart reply button from a locked
screen, we ask for a pattern/password and then close the notification
shade. This is inconsistent with the unlocked case and with how inline
replies are handled.
Set mLeaveOpenOnKeyguardHide to true when handling smart reply clicks.
Also simplify and rename the method in KeyguardDismissHandler to make
this new behaviour clearer.
Bug: 77841506
Test: Tap on a smart reply from the lockscreen, then unlock.
Change-Id: If1dab2a4b0d93a512c27e6d8a870289f64c7b63d
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardDismissHandler.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardDismissHandler.java
index 759a0d1..76ddca4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardDismissHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardDismissHandler.java
@@ -23,7 +23,9 @@
/** Executes actions that require the screen to be unlocked. */
public interface KeyguardDismissHandler {
- /** Executes an action that requres the screen to be unlocked. */
- void dismissKeyguardThenExecute(
- OnDismissAction action, @Nullable Runnable cancelAction, boolean afterKeyguardGone);
+ /**
+ * Executes an action that requres the screen to be unlocked, showing the keyguard if
+ * necessary. Does not close the notification shade (in case it was open).
+ */
+ void executeWhenUnlocked(OnDismissAction action);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardDismissUtil.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardDismissUtil.java
index c38b0b6..d676692 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardDismissUtil.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardDismissUtil.java
@@ -40,14 +40,13 @@
* <p>Must be called after {@link #setDismissHandler}.
*/
@Override
- public void dismissKeyguardThenExecute(
- OnDismissAction action, Runnable cancelAction, boolean afterKeyguardGone) {
+ public void executeWhenUnlocked(OnDismissAction action) {
KeyguardDismissHandler dismissHandler = mDismissHandler;
if (dismissHandler == null) {
Log.wtf(TAG, "KeyguardDismissHandler not set.");
action.onDismiss();
return;
}
- dismissHandler.dismissKeyguardThenExecute(action, cancelAction, afterKeyguardGone);
+ dismissHandler.executeWhenUnlocked(action);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index 57a3556..5f07599 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -1326,8 +1326,7 @@
mKeyguardViewMediatorCallback = keyguardViewMediator.getViewMediatorCallback();
mLightBarController.setFingerprintUnlockController(mFingerprintUnlockController);
- Dependency.get(KeyguardDismissUtil.class).setDismissHandler(
- this::dismissKeyguardThenExecute);
+ Dependency.get(KeyguardDismissUtil.class).setDismissHandler(this::executeWhenUnlocked);
Trace.endSection();
}
@@ -3088,6 +3087,13 @@
}
}
+ private void executeWhenUnlocked(OnDismissAction action) {
+ if (mStatusBarKeyguardViewManager.isShowing()) {
+ mLeaveOpenOnKeyguardHide = true;
+ }
+ dismissKeyguardThenExecute(action, null /* cancelAction */, false /* afterKeyguardGone */);
+ }
+
protected void dismissKeyguardThenExecute(OnDismissAction action, boolean afterKeyguardGone) {
dismissKeyguardThenExecute(action, null /* cancelRunnable */, afterKeyguardGone);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java
index b4fa2e8..351868d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java
@@ -183,8 +183,7 @@
};
b.setOnClickListener(view -> {
- mKeyguardDismissUtil.dismissKeyguardThenExecute(
- action, null /* cancelAction */, false /* afterKeyguardGone */);
+ mKeyguardDismissUtil.executeWhenUnlocked(action);
});
b.setAccessibilityDelegate(new AccessibilityDelegate() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SmartReplyViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SmartReplyViewTest.java
index 99c06e6..f3d79fd 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SmartReplyViewTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SmartReplyViewTest.java
@@ -87,8 +87,7 @@
MockitoAnnotations.initMocks(this);
mReceiver = new BlockingQueueIntentReceiver();
mContext.registerReceiver(mReceiver, new IntentFilter(TEST_ACTION));
- mDependency.get(KeyguardDismissUtil.class).setDismissHandler(
- (action, cancelAction, afterKeyguardGone) -> action.onDismiss());
+ mDependency.get(KeyguardDismissUtil.class).setDismissHandler(action -> action.onDismiss());
mContainer = new View(mContext, null);
mView = SmartReplyView.inflate(mContext, null);
@@ -130,12 +129,7 @@
@Test
public void testSendSmartReply_keyguardCancelled() throws InterruptedException {
- mDependency.get(KeyguardDismissUtil.class).setDismissHandler(
- (action, cancelAction, afterKeyguardGone) -> {
- if (cancelAction != null) {
- cancelAction.run();
- }
- });
+ mDependency.get(KeyguardDismissUtil.class).setDismissHandler(action -> {});
setRepliesFromRemoteInput(TEST_CHOICES);
mView.getChildAt(2).performClick();
@@ -146,8 +140,7 @@
@Test
public void testSendSmartReply_waitsForKeyguard() throws InterruptedException {
AtomicReference<OnDismissAction> actionRef = new AtomicReference<>();
- mDependency.get(KeyguardDismissUtil.class).setDismissHandler(
- (action, cancelAction, afterKeyguardGone) -> actionRef.set(action));
+ mDependency.get(KeyguardDismissUtil.class).setDismissHandler(actionRef::set);
setRepliesFromRemoteInput(TEST_CHOICES);
mView.getChildAt(2).performClick();