Skip to content

Instantly share code, notes, and snippets.

@OleksandrKucherenko
Created February 7, 2020 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OleksandrKucherenko/f71a81b0420b3306c03ddc3051b2e73f to your computer and use it in GitHub Desktop.
Save OleksandrKucherenko/f71a81b0420b3306c03ddc3051b2e73f to your computer and use it in GitHub Desktop.
@Test
@Config(sdk = Build.VERSION_CODES.P)
public void testFingerprintConfigured_api28() throws Exception {
// GIVEN:
// API28 android version
// for api24+ system feature should be enabled
// fingerprints are configured
ReactApplicationContext context = getRNContext();
shadowOf(context.getPackageManager()).setSystemFeature(PackageManager.FEATURE_FINGERPRINT, true);
// set that hardware is available
FingerprintManager fm = (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
shadowOf(fm).setIsHardwareDetected(true);
shadowOf(fm).setDefaultFingerprints(5); // 5 fingerprints are available
// WHEN: verify availability
final int result = BiometricManager.from(context).canAuthenticate();
final KeychainModule module = new KeychainModule(context);
final boolean isFingerprintWorking = module.isFingerprintAuthAvailable();
// THEN: biometrics works
assertThat(result, is(BiometricManager.BIOMETRIC_SUCCESS));
assertThat(isFingerprintWorking, is(true));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment