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

Commit d794fa6c authored by Aaron Liu's avatar Aaron Liu
Browse files

Fix bugs revolving around user switching.

When switching users in the bouncer, we do no invoke
startAppearAnimation. Additionally, the theme color change was delayed
for roughly 3 seconds after the user switch completes, which reinflates
the bouncer view.

In order to handle this case, I've moved some logic from
startAppearAnimation to onViewAttached. Additionally, when the user
switch occurs, we opt to reinflate the bouncer. When the color changes,
we do not reinflate the view. Although the view will not adopt the new
theme changes, it will change when we leave the bouncer and enter again.

Fixes: 292255597
Fixes: 294035459
Fixes: 292123727
Test: switch users from auto confirmation pin to pin and then back.
Test: switch users from locked out pattern to pin and then back.
Test: switch users from password to pin and then back.
Change-Id: I5b851598c09a0587dd241838b4af256b6c533aaa
parent 0ccfa0d2
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -102,6 +102,12 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
        super.onViewAttached();
        mView.setKeyDownListener(mKeyDownListener);
        mEmergencyButtonController.setEmergencyButtonCallback(mEmergencyButtonCallback);
        // if the user is currently locked out, enforce it.
        long deadline = mLockPatternUtils.getLockoutAttemptDeadline(
                KeyguardUpdateMonitor.getCurrentUser());
        if (shouldLockout(deadline)) {
            handleAttemptLockout(deadline);
        }
    }

    @Override
@@ -278,12 +284,6 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
    @Override
    public void onResume(int reason) {
        mResumed = true;
        // if the user is currently locked out, enforce it.
        long deadline = mLockPatternUtils.getLockoutAttemptDeadline(
                KeyguardUpdateMonitor.getCurrentUser());
        if (shouldLockout(deadline)) {
            handleAttemptLockout(deadline);
        }
    }

    @Override
+9 −9
Original line number Diff line number Diff line
@@ -30,13 +30,13 @@ import com.android.internal.util.LatencyTracker;
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
import com.android.systemui.R;
import com.android.systemui.bouncer.domain.interactor.BouncerMessageInteractor;
import com.android.systemui.bouncer.ui.BouncerMessageView;
import com.android.systemui.bouncer.ui.binder.BouncerMessageViewBinder;
import com.android.systemui.classifier.FalsingCollector;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.flags.Flags;
import com.android.systemui.bouncer.domain.interactor.BouncerMessageInteractor;
import com.android.systemui.bouncer.ui.BouncerMessageView;
import com.android.systemui.bouncer.ui.binder.BouncerMessageViewBinder;
import com.android.systemui.log.BouncerLogger;
import com.android.systemui.statusbar.policy.DevicePostureController;
import com.android.systemui.util.ViewController;
@@ -95,6 +95,12 @@ public abstract class KeyguardInputViewController<T extends KeyguardInputView>
    @CallSuper
    protected void onViewAttached() {
        updateMessageAreaVisibility();
        if (TextUtils.isEmpty(mMessageAreaController.getMessage())
                && getInitialMessageResId() != 0) {
            mMessageAreaController.setMessage(
                    mView.getResources().getString(getInitialMessageResId()),
                    /* animate= */ false);
        }
    }

    private void updateMessageAreaVisibility() {
@@ -147,12 +153,6 @@ public abstract class KeyguardInputViewController<T extends KeyguardInputView>
    }

    public void startAppearAnimation() {
        if (TextUtils.isEmpty(mMessageAreaController.getMessage())
                && getInitialMessageResId() != 0) {
            mMessageAreaController.setMessage(
                    mView.getResources().getString(getInitialMessageResId()),
                    /* animate= */ false);
        }
        mView.startAppearAnimation();
    }

+6 −6
Original line number Diff line number Diff line
@@ -238,6 +238,12 @@ public class KeyguardPatternViewController
        }
        mView.onDevicePostureChanged(mPostureController.getDevicePosture());
        mPostureController.addCallback(mPostureCallback);
        // if the user is currently locked out, enforce it.
        long deadline = mLockPatternUtils.getLockoutAttemptDeadline(
                KeyguardUpdateMonitor.getCurrentUser());
        if (deadline != 0) {
            handleAttemptLockout(deadline);
        }
    }

    @Override
@@ -268,12 +274,6 @@ public class KeyguardPatternViewController
    @Override
    public void onResume(int reason) {
        super.onResume(reason);
        // if the user is currently locked out, enforce it.
        long deadline = mLockPatternUtils.getLockoutAttemptDeadline(
                KeyguardUpdateMonitor.getCurrentUser());
        if (deadline != 0) {
            handleAttemptLockout(deadline);
        }
    }

    @Override
+4 −4
Original line number Diff line number Diff line
@@ -79,6 +79,10 @@ public class KeyguardPinViewController
        mPasswordEntry.setUserActivityListener(this::onUserInput);
        mView.onDevicePostureChanged(mPostureController.getDevicePosture());
        mPostureController.addCallback(mPostureCallback);
        if (mFeatureFlags.isEnabled(Flags.AUTO_PIN_CONFIRMATION)) {
            mPasswordEntry.setUsePinShapes(true);
            updateAutoConfirmationState();
        }
    }

    protected void onUserInput() {
@@ -100,10 +104,6 @@ public class KeyguardPinViewController

    @Override
    public void startAppearAnimation() {
        if (mFeatureFlags.isEnabled(Flags.AUTO_PIN_CONFIRMATION)) {
            mPasswordEntry.setUsePinShapes(true);
            updateAutoConfirmationState();
        }
        super.startAppearAnimation();
    }

+13 −3
Original line number Diff line number Diff line
@@ -145,8 +145,19 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
    private int mLastOrientation;

    private SecurityMode mCurrentSecurityMode = SecurityMode.Invalid;
    private int mCurrentUser = UserHandle.USER_NULL;
    private UserSwitcherController.UserSwitchCallback mUserSwitchCallback =
            () -> showPrimarySecurityScreen(false);
            new UserSwitcherController.UserSwitchCallback() {
        @Override
        public void onUserSwitched() {
            if (mCurrentUser == KeyguardUpdateMonitor.getCurrentUser()) {
                return;
            }
            mCurrentUser = KeyguardUpdateMonitor.getCurrentUser();
            showPrimarySecurityScreen(false);
            reinflateViewFlipper((l) -> {});
        }
    };

    @VisibleForTesting
    final Gefingerpoken mGlobalTouchListener = new Gefingerpoken() {
@@ -338,7 +349,6 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
                @Override
                public void onThemeChanged() {
                    reloadColors();
                    reset();
                }

                @Override
@@ -1156,7 +1166,7 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
    }

    private void reloadColors() {
        reinflateViewFlipper(controller -> mView.reloadColors());
        mView.reloadColors();
    }

    /** Handles density or font scale changes. */
Loading