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

Commit fd3b0b92 authored by Chandru S's avatar Chandru S
Browse files

Prevent face auth from running again after a successful unlock when assistant is active.

Fixes: 264952680
Test: atest KeyguardUpdateMonitorTest
Test: manually,
  1. Enable face & fp unlock
  2. Enable AoD
  3. Enable assistant with voice trigger
  4. Hold phone in front of your face
  5. Go to AoD by pressing the power button
  6. Trigger assistant by saying "Ok Google"
  7. Assistant should open up on lockscreen.
  8. Say "setup an alarm"
  9. Face unlock should be triggered and device should be unlocked in the bg with keyguard being dismissed.
  10. Specify the time for the alarm verbally
  11. Once the alarm is set, tap the alarm on the assistant window
  12. Face unlock should not be triggered momentarily while assistant is dismissed.

Change-Id: Ie3eefc17bc81b2057f318ad53159f5c9b823721b
parent f7347b49
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);