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

Commit 1c5fee63 authored by Ilya Matyukhin's avatar Ilya Matyukhin
Browse files

Fix NullPointerException in getAuthenticatorId when ID is missing

Bug: 177640218
Test: atest Fingerprint21Test
Test: atest Face10Test
Change-Id: Idcb9fd1612c66600b9ef97ae31ff16c6a3f29222
parent 41903dfe
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -482,7 +482,7 @@ public class Face10 implements IHwBinder.DeathRecipient, ServiceProvider {

    @Override
    public long getAuthenticatorId(int sensorId, int userId) {
        return mAuthenticatorIds.get(userId);
        return mAuthenticatorIds.getOrDefault(userId, 0L);
    }

    @Override
+1 −1
Original line number Diff line number Diff line
@@ -681,7 +681,7 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider

    @Override
    public long getAuthenticatorId(int sensorId, int userId) {
        return mAuthenticatorIds.get(userId);
        return mAuthenticatorIds.getOrDefault(userId, 0L);
    }

    @Override
+8 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.server.biometrics.sensors.face.hidl;

import static junit.framework.Assert.assertEquals;

import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@@ -75,6 +77,12 @@ public class Face10Test {
        mBinder = new Binder();
    }

    @Test
    public void getAuthenticatorId_doesNotCrashWhenIdNotFound() {
        assertEquals(0, mFace10.getAuthenticatorId(0 /* sensorId */, 111 /* userId */));
        waitForIdle();
    }

    @Test
    public void scheduleRevokeChallenge_doesNotCrash() {
        mFace10.scheduleRevokeChallenge(0 /* sensorId */, 0 /* userId */, mBinder, TAG,
+8 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.server.biometrics.sensors.fingerprint.hidl;

import static junit.framework.Assert.assertEquals;

import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -84,6 +86,12 @@ public class Fingerprint21Test {
                mHalResultController);
    }

    @Test
    public void getAuthenticatorId_doesNotCrashWhenIdNotFound() {
        assertEquals(0, mFingerprint21.getAuthenticatorId(0 /* sensorId */, 111 /* userId */));
        waitForIdle();
    }

    @Test
    public void halServiceDied_resetsScheduler() {
        // It's difficult to test the linkToDeath --> serviceDied path, so let's just invoke