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

Commit cd2fcae0 authored by Kevin Chyn's avatar Kevin Chyn Committed by Automerger Merge Worker
Browse files

10/n: Always send feedback if capacitive (or unknown) sensor am: 7f2031b6 am: e7091599

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15377751

Change-Id: I8f5d2dd56611f29692ac2faa7602ee4d35cbba64
parents 3b35d60b e7091599
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import android.os.Handler;
import android.os.Looper;
import android.util.Slog;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.server.biometrics.sensors.BiometricScheduler.SensorType;
import com.android.server.biometrics.sensors.fingerprint.Udfps;
@@ -239,6 +238,11 @@ public class CoexCoordinator {

                    removeAndFinishAllFaceFromQueue();

                    callback.sendHapticFeedback();
                    callback.sendAuthenticationResult(true /* addAuthTokenIfStrong */);
                    callback.handleLifecycleAfterAuth();
                } else {
                    // Capacitive fingerprint sensor (or other)
                    callback.sendHapticFeedback();
                    callback.sendAuthenticationResult(true /* addAuthTokenIfStrong */);
                    callback.handleLifecycleAfterAuth();
+44 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.server.biometrics.sensors;

import static com.android.server.biometrics.sensors.BiometricScheduler.SENSOR_TYPE_FACE;
import static com.android.server.biometrics.sensors.BiometricScheduler.SENSOR_TYPE_FP_OTHER;
import static com.android.server.biometrics.sensors.BiometricScheduler.SENSOR_TYPE_UDFPS;

import static junit.framework.Assert.assertEquals;
@@ -326,6 +327,49 @@ public class CoexCoordinatorTest {
        verify(mCallback, never()).sendHapticFeedback();
    }

    @Test
    public void testKeyguard_capacitiveAccepted_whenFaceScanning() {
        mCoexCoordinator.reset();

        AuthenticationClient<?> faceClient = mock(AuthenticationClient.class);
        when(faceClient.isKeyguard()).thenReturn(true);
        when(faceClient.getState()).thenReturn(AuthenticationClient.STATE_STARTED);

        AuthenticationClient<?> fpClient = mock(AuthenticationClient.class);
        when(fpClient.getState()).thenReturn(AuthenticationClient.STATE_STARTED);
        when(fpClient.isKeyguard()).thenReturn(true);

        mCoexCoordinator.addAuthenticationClient(SENSOR_TYPE_FACE, faceClient);
        mCoexCoordinator.addAuthenticationClient(SENSOR_TYPE_FP_OTHER, fpClient);

        mCoexCoordinator.onAuthenticationSucceeded(0 /* currentTimeMillis */, fpClient, mCallback);
        verify(mCallback).sendHapticFeedback();
        verify(mCallback).sendAuthenticationResult(eq(true) /* addAuthTokenIfStrong */);
        verify(mCallback).handleLifecycleAfterAuth();
    }

    @Test
    public void testKeyguard_capacitiveRejected_whenFaceScanning() {
        mCoexCoordinator.reset();

        AuthenticationClient<?> faceClient = mock(AuthenticationClient.class);
        when(faceClient.isKeyguard()).thenReturn(true);
        when(faceClient.getState()).thenReturn(AuthenticationClient.STATE_STARTED);

        AuthenticationClient<?> fpClient = mock(AuthenticationClient.class);
        when(fpClient.getState()).thenReturn(AuthenticationClient.STATE_STARTED);
        when(fpClient.isKeyguard()).thenReturn(true);

        mCoexCoordinator.addAuthenticationClient(SENSOR_TYPE_FACE, faceClient);
        mCoexCoordinator.addAuthenticationClient(SENSOR_TYPE_FP_OTHER, fpClient);

        mCoexCoordinator.onAuthenticationRejected(0 /* currentTimeMillis */, fpClient,
                LockoutTracker.LOCKOUT_NONE, mCallback);
        verify(mCallback).sendHapticFeedback();
        verify(mCallback).sendAuthenticationResult(eq(false) /* addAuthTokenIfStrong */);
        verify(mCallback).handleLifecycleAfterAuth();
    }

    @Test
    public void testNonKeyguard_rejectAndNotLockedOut() {
        mCoexCoordinator.reset();