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

Commit 20987e7f authored by Joshua McCloskey's avatar Joshua McCloskey Committed by Joshua Mccloskey
Browse files

Cleaned up side fps logic

Test: atest FingerprintAuthenticationClientTest
Test: manual.
Fixes: 252888293
Change-Id: I6a872757ecb6294b55536bea75919bb53db52603
Merged-In: I6a872757ecb6294b55536bea75919bb53db52603
parent 9a0ed1af
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -3553,9 +3553,9 @@
         config_sidefpsSkipWaitForPowerVendorAcquireMessage -->
    <integer name="config_sidefpsSkipWaitForPowerAcquireMessage">6</integer>

    <!-- This vendor acquired message that will cause the sidefpsKgPowerPress window to be skipped.
         config_sidefpsSkipWaitForPowerOnFingerUp must be true and
         config_sidefpsSkipWaitForPowerAcquireMessage must be BIOMETRIC_ACQUIRED_VENDOR == 6. -->
    <!-- This vendor acquired message will cause the sidefpsKgPowerPress window to be skipped
         when config_sidefpsSkipWaitForPowerAcquireMessage == 6 (VENDOR) and the vendor acquire
         message equals this constant -->
    <integer name="config_sidefpsSkipWaitForPowerVendorAcquireMessage">2</integer>

    <!-- This config is used to force VoiceInteractionService to start on certain low ram devices.
+1 −2
Original line number Diff line number Diff line
@@ -265,8 +265,7 @@ class FingerprintAuthenticationClient extends AuthenticationClient<AidlSession>
            final boolean acquireMessageMatch = acquiredInfo == mSkipWaitForPowerAcquireMessage;
            final boolean vendorMessageMatch = vendorCode == mSkipWaitForPowerVendorAcquireMessage;
            final boolean ignorePowerPress =
                    (acquireMessageMatch && !shouldLookForVendor) || (shouldLookForVendor
                            && acquireMessageMatch && vendorMessageMatch);
                    acquireMessageMatch && (!shouldLookForVendor || vendorMessageMatch);

            if (ignorePowerPress) {
                Slog.d(TAG, "(sideFPS) onFingerUp");
+47 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import android.hardware.biometrics.common.OperationContext;
import android.hardware.biometrics.fingerprint.ISession;
import android.hardware.biometrics.fingerprint.PointerContext;
import android.hardware.fingerprint.Fingerprint;
import android.hardware.fingerprint.FingerprintManager;
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
import android.hardware.fingerprint.ISidefpsController;
import android.hardware.fingerprint.IUdfpsOverlayController;
@@ -422,6 +423,52 @@ public class FingerprintAuthenticationClientTest {
        verify(mCallback).onClientFinished(any(), eq(true));
    }

    @Test
    public void sideFingerprintSkipsWindowIfVendorMessageMatch() throws Exception {
        when(mSensorProps.isAnySidefpsType()).thenReturn(true);
        final int vendorAcquireMessage = 1234;

        mContext.getOrCreateTestableResources().addOverride(
                R.integer.config_sidefpsSkipWaitForPowerAcquireMessage,
                FingerprintManager.FINGERPRINT_ACQUIRED_VENDOR);
        mContext.getOrCreateTestableResources().addOverride(
                R.integer.config_sidefpsSkipWaitForPowerVendorAcquireMessage,
                vendorAcquireMessage);

        final FingerprintAuthenticationClient client = createClient(1);
        client.start(mCallback);
        mLooper.dispatchAll();
        client.onAuthenticated(new Fingerprint("friendly", 4 /* fingerId */, 5 /* deviceId */),
                true /* authenticated */, new ArrayList<>());
        client.onAcquired(FingerprintManager.FINGERPRINT_ACQUIRED_VENDOR, vendorAcquireMessage);
        mLooper.dispatchAll();

        verify(mCallback).onClientFinished(any(), eq(true));
    }

    @Test
    public void sideFingerprintDoesNotSkipWindowOnVendorErrorMismatch() throws Exception {
        when(mSensorProps.isAnySidefpsType()).thenReturn(true);
        final int vendorAcquireMessage = 1234;

        mContext.getOrCreateTestableResources().addOverride(
                R.integer.config_sidefpsSkipWaitForPowerAcquireMessage,
                FingerprintManager.FINGERPRINT_ACQUIRED_VENDOR);
        mContext.getOrCreateTestableResources().addOverride(
                R.integer.config_sidefpsSkipWaitForPowerVendorAcquireMessage,
                vendorAcquireMessage);

        final FingerprintAuthenticationClient client = createClient(1);
        client.start(mCallback);
        mLooper.dispatchAll();
        client.onAuthenticated(new Fingerprint("friendly", 4 /* fingerId */, 5 /* deviceId */),
                true /* authenticated */, new ArrayList<>());
        client.onAcquired(FingerprintManager.FINGERPRINT_ACQUIRED_VENDOR, 1);
        mLooper.dispatchAll();

        verify(mCallback, never()).onClientFinished(any(), anyBoolean());
    }

    @Test
    public void sideFingerprintSendsAuthIfFingerUp() throws Exception {
        when(mSensorProps.isAnySidefpsType()).thenReturn(true);