Merge "Fix NullPointerException in getAuthenticatorId when ID is missing"

This commit is contained in:
TreeHugger Robot
2021-01-16 02:54:35 +00:00
committed by Android (Google) Code Review
4 changed files with 18 additions and 2 deletions

View File

@@ -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

View File

@@ -682,7 +682,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

View File

@@ -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,

View File

@@ -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