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

Commit d17b3506 authored by Selim Cinek's avatar Selim Cinek
Browse files

Fixed a few bugs with remoteInput

Because of our refactoring, we would crash whenever the
user clicked on reply while pulsing and not bypassing.
Also, the user would be sent to the shade when replying
from the bypass hun or smart replying, which is wrong.
Last, the logic wasn't working when the user didn't
have security.

Fixes: 67475697
Fixes: 135958017
Test: receive HUN on AOD and other surfaces, observe normal behavior
Change-Id: I68163ccfaa2dc2d998b2d68b29168e369670fb17
parent 2e4f32be
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.statusbar.NotificationVisibility;
import com.android.systemui.Dumpable;
import com.android.systemui.R;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.notification.NotificationEntryListener;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
@@ -121,6 +122,7 @@ public class NotificationRemoteInputManager implements Dumpable {
    protected final Context mContext;
    private final UserManager mUserManager;
    private final KeyguardManager mKeyguardManager;
    private final StatusBarStateController mStatusBarStateController;

    protected RemoteInputController mRemoteInputController;
    protected NotificationLifetimeExtender.NotificationSafeToRemoveCallback
@@ -259,6 +261,7 @@ public class NotificationRemoteInputManager implements Dumpable {
            SmartReplyController smartReplyController,
            NotificationEntryManager notificationEntryManager,
            Lazy<ShadeController> shadeController,
            StatusBarStateController statusBarStateController,
            @Named(MAIN_HANDLER_NAME) Handler mainHandler) {
        mContext = context;
        mLockscreenUserManager = lockscreenUserManager;
@@ -271,6 +274,7 @@ public class NotificationRemoteInputManager implements Dumpable {
        mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
        addLifetimeExtenders();
        mKeyguardManager = context.getSystemService(KeyguardManager.class);
        mStatusBarStateController = statusBarStateController;

        notificationEntryManager.addNotificationEntryListener(new NotificationEntryListener() {
            @Override
@@ -380,7 +384,10 @@ public class NotificationRemoteInputManager implements Dumpable {

        if (!mLockscreenUserManager.shouldAllowLockscreenRemoteInput()) {
            final int userId = pendingIntent.getCreatorUserHandle().getIdentifier();
            if (mLockscreenUserManager.isLockscreenPublicMode(userId)) {
            if (mLockscreenUserManager.isLockscreenPublicMode(userId)
                    || mStatusBarStateController.getState() == StatusBarState.KEYGUARD) {
                // Even if we don't have security we should go through this flow, otherwise we won't
                // go to the shade
                mCallback.onLockedRemoteInput(row, view);
                return true;
            }
@@ -391,6 +398,11 @@ public class NotificationRemoteInputManager implements Dumpable {
            }
        }

        if (!riv.isAttachedToWindow()) {
            // the remoteInput isn't attached to the window anymore :/ Let's focus on the expanded
            // one instead if it's available
            riv = null;
        }
        if (riv == null) {
            riv = findRemoteInputView(row.getPrivateLayout().getExpandedChild());
            if (riv == null) {
@@ -405,6 +417,10 @@ public class NotificationRemoteInputManager implements Dumpable {
            return true;
        }

        if (!riv.isAttachedToWindow()) {
            // if we still didn't find a view that is attached, let's abort.
            return false;
        }
        int width = view.getWidth();
        if (view instanceof TextView) {
            // Center the reveal on the text which might be off-center from the TextView
+2 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ public interface KeyguardDismissHandler {
    /**
     * 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).
     * @param requiresShadeOpen does the shade need to be forced open when hiding the keyguard?
     */
    void executeWhenUnlocked(OnDismissAction action);
    void executeWhenUnlocked(OnDismissAction action, boolean requiresShadeOpen);
}
+5 −3
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ public class KeyguardDismissUtil implements KeyguardDismissHandler {
    public KeyguardDismissUtil() {
    }

    /** Sets the actual {@link DismissHandler} implementation. */
    /** Sets the actual {@link KeyguardDismissHandler} implementation. */
    public void setDismissHandler(KeyguardDismissHandler dismissHandler) {
        mDismissHandler = dismissHandler;
    }
@@ -46,15 +46,17 @@ public class KeyguardDismissUtil implements KeyguardDismissHandler {
     * Executes an action that requires the screen to be unlocked.
     *
     * <p>Must be called after {@link #setDismissHandler}.
     *
     * @param requiresShadeOpen does the shade need to be forced open when hiding the keyguard?
     */
    @Override
    public void executeWhenUnlocked(OnDismissAction action) {
    public void executeWhenUnlocked(OnDismissAction action, boolean requiresShadeOpen) {
        KeyguardDismissHandler dismissHandler = mDismissHandler;
        if (dismissHandler == null) {
            Log.wtf(TAG, "KeyguardDismissHandler not set.");
            action.onDismiss();
            return;
        }
        dismissHandler.executeWhenUnlocked(action);
        dismissHandler.executeWhenUnlocked(action, requiresShadeOpen);
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -2618,8 +2618,8 @@ public class StatusBar extends SystemUI implements DemoMode,
        }
    }

    private void executeWhenUnlocked(OnDismissAction action) {
        if (mStatusBarKeyguardViewManager.isShowing()) {
    private void executeWhenUnlocked(OnDismissAction action, boolean requiresShadeOpen) {
        if (mStatusBarKeyguardViewManager.isShowing() && requiresShadeOpen) {
            mStatusBarStateController.setLeaveOpenOnKeyguardHide(true);
        }
        dismissKeyguardThenExecute(action, null /* cancelAction */, false /* afterKeyguardGone */);
+8 −3
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import com.android.systemui.statusbar.SysuiStatusBarStateController;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.policy.KeyguardMonitor;
import com.android.systemui.statusbar.policy.RemoteInputView;

import javax.inject.Inject;
import javax.inject.Singleton;
@@ -93,9 +94,11 @@ public class StatusBarRemoteInputCallback implements Callback, Callbacks,

    @Override
    public void onStateChanged(int state) {
        if (state == StatusBarState.SHADE && mStatusBarStateController.leaveOpenOnKeyguardHide()) {
        boolean hasPendingRemoteInput = mPendingRemoteInputView != null;
        if (state == StatusBarState.SHADE
                && (mStatusBarStateController.leaveOpenOnKeyguardHide() || hasPendingRemoteInput)) {
            if (!mStatusBarStateController.isKeyguardRequested()) {
                if (mPendingRemoteInputView != null) {
                if (hasPendingRemoteInput) {
                    mMainHandler.post(mPendingRemoteInputView::callOnClick);
                }
                mPendingRemoteInputView = null;
@@ -105,7 +108,9 @@ public class StatusBarRemoteInputCallback implements Callback, Callbacks,

    @Override
    public void onLockedRemoteInput(ExpandableNotificationRow row, View clicked) {
        if (!row.isPinned()) {
            mStatusBarStateController.setLeaveOpenOnKeyguardHide(true);
        }
        mShadeController.showBouncer(true /* scrimmed */);
        mPendingRemoteInputView = clicked;
    }
Loading