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

Commit 7d6c291d authored by Chandru S's avatar Chandru S Committed by Android (Google) Code Review
Browse files

Merge "Prevent face auth from running again after a successful unlock when...

Merge "Prevent face auth from running again after a successful unlock when assistant is active." into tm-qpr-dev
parents 7160f840 fd3b0b92
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -1537,6 +1537,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    @VisibleForTesting
    void setAssistantVisible(boolean assistantVisible) {
        mAssistantVisible = assistantVisible;
        mLogger.logAssistantVisible(mAssistantVisible);
        updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE,
                FACE_AUTH_UPDATED_ASSISTANT_VISIBILITY_CHANGED);
        if (mAssistantVisible) {
@@ -2678,7 +2679,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab

    private boolean shouldListenForFaceAssistant() {
        BiometricAuthenticated face = mUserFaceAuthenticated.get(getCurrentUser());
        return mAssistantVisible && mKeyguardOccluded
        return mAssistantVisible
                // There can be intermediate states where mKeyguardShowing is false but
                // mKeyguardOccluded is true, we don't want to run face auth in such a scenario.
                && (mKeyguardShowing && mKeyguardOccluded)
                && !(face != null && face.mAuthenticated)
                && !mUserHasTrust.get(getCurrentUser(), false);
    }
@@ -3679,6 +3683,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                if (info == null) {
                    return;
                }
                mLogger.logTaskStackChangedForAssistant(info.visible);
                mHandler.sendMessage(mHandler.obtainMessage(MSG_ASSISTANT_STACK_CHANGED,
                        info.visible));
            } catch (RemoteException e) {
+16 −0
Original line number Diff line number Diff line
@@ -431,4 +431,20 @@ class KeyguardUpdateMonitorLogger @Inject constructor(
            str1 = PowerManager.wakeReasonToString(pmWakeReason)
        }, { "Skip updating face listening state on wakeup from $str1"})
    }

    fun logTaskStackChangedForAssistant(assistantVisible: Boolean) {
        logBuffer.log(TAG, VERBOSE, {
            bool1 = assistantVisible
        }, {
            "TaskStackChanged for ACTIVITY_TYPE_ASSISTANT, assistant visible: $bool1"
        })
    }

    fun logAssistantVisible(assistantVisible: Boolean) {
        logBuffer.log(TAG, VERBOSE, {
            bool1 = assistantVisible
        }, {
            "Updating mAssistantVisible to new value: $bool1"
        })
    }
}
+13 −1
Original line number Diff line number Diff line
@@ -95,7 +95,6 @@ import android.os.PowerManager;
import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
import android.service.dreams.IDreamManager;
import android.service.trust.TrustAgentService;
import android.telephony.ServiceState;
@@ -833,6 +832,19 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
        verify(mFaceManager).authenticate(any(), any(), any(), any(), anyInt(), anyBoolean());
    }

    @Test
    public void doesNotTryToAuthenticateWhenKeyguardIsNotShowingButOccluded_whenAssistant() {
        mKeyguardUpdateMonitor.setKeyguardShowing(false, true);
        mKeyguardUpdateMonitor.setAssistantVisible(true);

        verify(mFaceManager, never()).authenticate(any(),
                any(),
                any(),
                any(),
                anyInt(),
                anyBoolean());
    }

    @Test
    public void testTriesToAuthenticate_whenTrustOnAgentKeyguard_ifBypass() {
        mKeyguardUpdateMonitor.dispatchStartedWakingUp(PowerManager.WAKE_REASON_POWER_BUTTON);