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

Commit 199d469f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix NullPointerException in getAuthenticatorId when ID is missing"

parents 83d14224 1c5fee63
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -482,7 +482,7 @@ public class Face10 implements IHwBinder.DeathRecipient, ServiceProvider {


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


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


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


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


package com.android.server.biometrics.sensors.face.hidl;
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.verify;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.when;


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


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

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


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


import static junit.framework.Assert.assertEquals;

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


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

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