Merge "Fix NullPointerException in getAuthenticatorId when ID is missing"
This commit is contained in:
committed by
Android (Google) Code Review
commit
199d469f12
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user