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

Commit 1e0084bb authored by Wenhui Yang's avatar Wenhui Yang
Browse files

Fix ServiceNotFoundException when face/fp feature not available

Fixes: 310154334
Fixes: 262239736
Test: atest AuthenticationStatsCollectorTest
Change-Id: Ibf2efa884e7b0aeec8af34edf049100a26c8a05d
parent da3e9759
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -54,8 +54,8 @@ public class AuthenticationStatsCollector {

    @NonNull private final Context mContext;
    @NonNull private final PackageManager mPackageManager;
    @NonNull private final FaceManager mFaceManager;
    @NonNull private final FingerprintManager mFingerprintManager;
    @Nullable private final FaceManager mFaceManager;
    @Nullable private final FingerprintManager mFingerprintManager;

    private final boolean mEnabled;
    private final float mThreshold;
@@ -197,11 +197,11 @@ public class AuthenticationStatsCollector {
    }

    private boolean hasEnrolledFace(int userId) {
        return mFaceManager.hasEnrolledTemplates(userId);
        return mFaceManager != null && mFaceManager.hasEnrolledTemplates(userId);
    }

    private boolean hasEnrolledFingerprint(int userId) {
        return mFingerprintManager.hasEnrolledTemplates(userId);
        return mFingerprintManager != null && mFingerprintManager.hasEnrolledTemplates(userId);
    }

    /**
+1 −0
Original line number Diff line number Diff line
@@ -271,6 +271,7 @@ public class AuthenticationStatsCollectorTest {
                .thenReturn(true);
        when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FACE)).thenReturn(false);
        when(mFingerprintManager.hasEnrolledTemplates(anyInt())).thenReturn(true);
        when(mContext.getSystemService(Context.FACE_SERVICE)).thenReturn(null);

        mAuthenticationStatsCollector.authenticate(USER_ID_1, false /* authenticated */);