Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e433e9b5 authored by Milo Sredkov's avatar Milo Sredkov
Browse files

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
parent dc617e0f
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -23,7 +23,9 @@ import com.android.keyguard.KeyguardHostView.OnDismissAction;

/** 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);
}
+2 −3
Original line number Diff line number Diff line
@@ -40,14 +40,13 @@ public class KeyguardDismissUtil implements KeyguardDismissHandler {
     * <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);
    }
}
+8 −2
Original line number Diff line number Diff line
@@ -1326,8 +1326,7 @@ public class StatusBar extends SystemUI implements DemoMode,

        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 @@ public class StatusBar extends SystemUI implements DemoMode,
        }
    }

    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);
    }
+1 −2
Original line number Diff line number Diff line
@@ -183,8 +183,7 @@ public class SmartReplyView extends ViewGroup {
        };

        b.setOnClickListener(view -> {
            mKeyguardDismissUtil.dismissKeyguardThenExecute(
                    action, null /* cancelAction */, false /* afterKeyguardGone */);
            mKeyguardDismissUtil.executeWhenUnlocked(action);
        });

        b.setAccessibilityDelegate(new AccessibilityDelegate() {
+3 −10
Original line number Diff line number Diff line
@@ -87,8 +87,7 @@ public class SmartReplyViewTest extends SysuiTestCase {
        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 @@ public class SmartReplyViewTest extends SysuiTestCase {

    @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 @@ public class SmartReplyViewTest extends SysuiTestCase {
    @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();