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

Commit ace85513 authored by Matt Pietal's avatar Matt Pietal
Browse files

[DO NOT MERGE] Fix intent launch from notification

When tapped some notifications, especially work profile ones, were not
launching correctly. The action after bouncer dismiss was being
cleared by an onVisibilityChanged callback before the authentication
path had a chance to complete and start the intent.

Also add more tracing

Fixes: 227354876
Test: manually, atest StatusBarKeyguardViewManagerTest
Change-Id: I6f3e28a44827a87cc08c7b3685bb9bf1c54ce8e3
parent 331f163d
Loading
Loading
Loading
Loading
+51 −40
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.content.Context;
import android.content.res.ColorStateList;
import android.hardware.biometrics.BiometricSourceType;
import android.os.Handler;
import android.os.Trace;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.Log;
@@ -164,6 +165,10 @@ public class KeyguardBouncer {
            // In split system user mode, we never unlock system user.
            return;
        }

        try {
            Trace.beginSection("KeyguardBouncer#show");

            ensureView();
            mIsScrimmed = isScrimmed;

@@ -177,8 +182,8 @@ public class KeyguardBouncer {
            }

            if (resetSecuritySelection) {
            // showPrimarySecurityScreen() updates the current security method. This is needed in
            // case we are already showing and the current security method changed.
                // showPrimarySecurityScreen() updates the current security method. This is needed
                // in case we are already showing and the current security method changed.
                showPrimarySecurityScreen();
            }

@@ -191,15 +196,16 @@ public class KeyguardBouncer {
                UserManager.isSplitSystemUser() && activeUserId == UserHandle.USER_SYSTEM;
            final boolean allowDismissKeyguard = !isSystemUser && activeUserId == keyguardUserId;

        // If allowed, try to dismiss the Keyguard. If no security auth (password/pin/pattern) is
        // set, this will dismiss the whole Keyguard. Otherwise, show the bouncer.
            // If allowed, try to dismiss the Keyguard. If no security auth (password/pin/pattern)
            // is set, this will dismiss the whole Keyguard. Otherwise, show the bouncer.
            if (allowDismissKeyguard && mKeyguardViewController.dismiss(activeUserId)) {
                return;
            }

            // This condition may indicate an error on Android, so log it.
            if (!allowDismissKeyguard) {
            Log.w(TAG, "User can't dismiss keyguard: " + activeUserId + " != " + keyguardUserId);
                Log.w(TAG, "User can't dismiss keyguard: " + activeUserId + " != "
                        + keyguardUserId);
            }

            mShowingSoon = true;
@@ -216,6 +222,9 @@ public class KeyguardBouncer {

            mCallback.onBouncerVisiblityChanged(true /* shown */);
            dispatchStartingToShow();
        } finally {
            Trace.endSection();
        }
    }

    public boolean isScrimmed() {
@@ -317,6 +326,7 @@ public class KeyguardBouncer {
    }

    public void hide(boolean destroyView) {
        Trace.beginSection("KeyguardBouncer#hide");
        if (isShowing()) {
            SysUiStatsLog.write(SysUiStatsLog.KEYGUARD_BOUNCER_STATE_CHANGED,
                    SysUiStatsLog.KEYGUARD_BOUNCER_STATE_CHANGED__STATE__HIDDEN);
@@ -338,6 +348,7 @@ public class KeyguardBouncer {
            // be slow because of AM lock contention during unlocking. We can delay it a bit.
            mHandler.postDelayed(mRemoveViewRunnable, 50);
        }
        Trace.endSection();
    }

    /**
+41 −32
Original line number Diff line number Diff line
@@ -164,7 +164,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
        @Override
        public void onVisibilityChanged(boolean isVisible) {
            if (!isVisible) {
                cancelPostAuthActions();
                mCentralSurfaces.setBouncerHiddenFraction(KeyguardBouncer.EXPANSION_HIDDEN);
            }
            if (mAlternateAuthInterceptor != null) {
@@ -502,9 +501,12 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
    public void dismissWithAction(OnDismissAction r, Runnable cancelAction,
            boolean afterKeyguardGone, String message) {
        if (mShowing) {
            try {
                Trace.beginSection("StatusBarKeyguardViewManager#dismissWithAction");
                cancelPendingWakeupAction();
                // If we're dozing, this needs to be delayed until after we wake up - unless we're
            // wake-and-unlocking, because there dozing will last until the end of the transition.
                // wake-and-unlocking, because there dozing will last until the end of the
                // transition.
                if (mDozing && !isWakeAndUnlocking()) {
                    mPendingWakeupAction = new DismissWithActionRequest(
                            r, cancelAction, afterKeyguardGone, message);
@@ -515,30 +517,37 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
                mKeyguardGoneCancelAction = cancelAction;
                mDismissActionWillAnimateOnKeyguard = r != null && r.willRunAnimationOnKeyguard();

            // If there is an an alternate auth interceptor (like the UDFPS), show that one instead
            // of the bouncer.
                // If there is an an alternate auth interceptor (like the UDFPS), show that one
                // instead of the bouncer.
                if (shouldShowAltAuth()) {
                    if (!afterKeyguardGone) {
                    mBouncer.setDismissAction(mAfterKeyguardGoneAction, mKeyguardGoneCancelAction);
                        mBouncer.setDismissAction(mAfterKeyguardGoneAction,
                                mKeyguardGoneCancelAction);
                        mAfterKeyguardGoneAction = null;
                        mKeyguardGoneCancelAction = null;
                    }

                updateAlternateAuthShowing(mAlternateAuthInterceptor.showAlternateAuthBouncer());
                    updateAlternateAuthShowing(
                            mAlternateAuthInterceptor.showAlternateAuthBouncer());
                    return;
                }

                if (afterKeyguardGone) {
                // we'll handle the dismiss action after keyguard is gone, so just show the bouncer
                    // we'll handle the dismiss action after keyguard is gone, so just show the
                    // bouncer
                    mBouncer.show(false /* resetSecuritySelection */);
                } else {
                    // after authentication success, run dismiss action with the option to defer
                    // hiding the keyguard based on the return value of the OnDismissAction
                mBouncer.showWithDismissAction(mAfterKeyguardGoneAction, mKeyguardGoneCancelAction);
                    mBouncer.showWithDismissAction(mAfterKeyguardGoneAction,
                            mKeyguardGoneCancelAction);
                    // bouncer will handle the dismiss action, so we no longer need to track it here
                    mAfterKeyguardGoneAction = null;
                    mKeyguardGoneCancelAction = null;
                }
            } finally {
                Trace.endSection();
            }
        }
        updateStates();
    }