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

Commit fdfd2d3b authored by Kevin Chyn's avatar Kevin Chyn
Browse files

Only control fingerprint from primary KeyguardUpdateMonitor

KeyguardUpdateMonitor is user-aware, yet there are multiple instances
(one per user). Only the first/primary KeyguardUpdateMonitor should control
Fingerprint behavior.

Bug: 123695809

Test: Fingerprint in multi-user works as expected now
Change-Id: I6a7c2529b0ba7dd6b87fa0d96205e5c582db0e92
parent cef5e0e7
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -196,6 +196,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
    private static KeyguardUpdateMonitor sInstance;

    private final Context mContext;
    private final boolean mIsPrimaryUser;
    HashMap<Integer, SimData> mSimDatas = new HashMap<Integer, SimData>();
    HashMap<Integer, ServiceState> mServiceStates = new HashMap<Integer, ServiceState>();

@@ -1530,6 +1531,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {

        ActivityManagerWrapper.getInstance().registerTaskStackListener(mTaskStackListener);
        mUserManager = context.getSystemService(UserManager.class);
        mIsPrimaryUser = mUserManager.isPrimaryUser();
        mDevicePolicyManager = context.getSystemService(DevicePolicyManager.class);
        mLogoutEnabled = mDevicePolicyManager.isLogoutEnabled();
        updateAirplaneModeState();
@@ -1608,21 +1610,26 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
    }

    private boolean shouldListenForFingerprint() {
        return (mKeyguardIsVisible || !mDeviceInteractive ||
        // Only listen if this KeyguardUpdateMonitor belongs to the primary user. There is an
        // instance of KeyguardUpdateMonitor for each user but KeyguardUpdateMonitor is user-aware.
        final boolean shouldListen = (mKeyguardIsVisible || !mDeviceInteractive ||
                (mBouncer && !mKeyguardGoingAway) || mGoingToSleep ||
                shouldListenForFingerprintAssistant() || (mKeyguardOccluded && mIsDreaming))
                && !mSwitchingUser && !isFingerprintDisabled(getCurrentUser())
                && !mKeyguardGoingAway && !mFingerprintLockedOut;
                && !mKeyguardGoingAway && !mFingerprintLockedOut && mIsPrimaryUser;
        return shouldListen;
    }

    private boolean shouldListenForFace() {
        final boolean awakeKeyguard = mKeyguardIsVisible && mDeviceInteractive && !mGoingToSleep;
        final int user = getCurrentUser();

        // Only listen if this KeyguardUpdateMonitor belongs to the primary user. There is an
        // instance of KeyguardUpdateMonitor for each user but KeyguardUpdateMonitor is user-aware.
        return (mBouncer || mAuthInterruptActive || awakeKeyguard || shouldListenForFaceAssistant())
                && !mSwitchingUser && !getUserCanSkipBouncer(user) && !isFaceDisabled(user)
                && !mKeyguardGoingAway && !mFaceLockedOut && mFaceSettingEnabledForUser
                && mUserManager.isUserUnlocked(user);
                && mUserManager.isUserUnlocked(user)
                && mIsPrimaryUser;
    }


+1 −0
Original line number Diff line number Diff line
@@ -106,6 +106,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
        when(mFaceManager.hasEnrolledTemplates()).thenReturn(true);
        when(mFaceManager.hasEnrolledTemplates(anyInt())).thenReturn(true);
        when(mUserManager.isUserUnlocked(anyInt())).thenReturn(true);
        when(mUserManager.isPrimaryUser()).thenReturn(true);
        when(mStrongAuthTracker.isUnlockingWithBiometricAllowed()).thenReturn(true);
        context.addMockSystemService(TrustManager.class, mTrustManager);
        context.addMockSystemService(FingerprintManager.class, mFingerprintManager);