2424public interface Goldfinger {
2525
2626 /**
27- * Returns true if user has fingerprint hardware, false otherwise .
27+ * @deprecated Use {@link #hasFingerprintHardware(int)} instead .
2828 */
29+ @ Deprecated
2930 boolean hasFingerprintHardware ();
3031
3132 /**
32- * Returns true if user has enrolled fingerprint, false otherwise.
33+ * Returns true if user has fingerprint hardware, false otherwise.
34+ */
35+ boolean hasFingerprintHardware (int authenticators );
36+
37+ /**
38+ * @deprecated Use {@link #hasEnrolledFingerprint(int)} instead.
3339 */
40+ @ Deprecated
3441 boolean hasEnrolledFingerprint ();
3542
3643 /**
37- * @see BiometricManager#canAuthenticate()
44+ * Returns true if user has enrolled fingerprint, false otherwise.
45+ */
46+ boolean hasEnrolledFingerprint (int authenticators );
47+
48+ /**
49+ * @deprecated Use {@link #canAuthenticate(int)} instead.
3850 */
51+ @ Deprecated
3952 boolean canAuthenticate ();
4053
54+ /**
55+ * @see BiometricManager#canAuthenticate(int)
56+ */
57+ boolean canAuthenticate (int authenticators );
58+
4159 /**
4260 * Authenticate user via Fingerprint.
4361 * <p>
@@ -103,7 +121,6 @@ class Builder {
103121 @ Nullable private CipherCrypter cipherCrypter ;
104122 @ Nullable private MacCrypter macCrypter ;
105123 @ Nullable private SignatureCrypter signatureCrypter ;
106- @ NonNull private Mode mode = Mode .AUTHENTICATION ;
107124 @ Nullable private String key ;
108125 @ Nullable private String value ;
109126
@@ -210,6 +227,7 @@ class PromptParams {
210227 @ Nullable private final String title ;
211228 private final boolean confirmationRequired ;
212229 private final boolean deviceCredentialsAllowed ;
230+ private final int allowedAuthenticators ;
213231
214232 private PromptParams (
215233 @ NonNull Object dialogOwner ,
@@ -218,7 +236,8 @@ private PromptParams(
218236 @ Nullable String negativeButtonText ,
219237 @ Nullable String subtitle ,
220238 boolean confirmationRequired ,
221- boolean deviceCredentialsAllowed
239+ boolean deviceCredentialsAllowed ,
240+ int allowedAuthenticators
222241 ) {
223242 this .dialogOwner = dialogOwner ;
224243 this .title = title ;
@@ -227,24 +246,22 @@ private PromptParams(
227246 this .subtitle = subtitle ;
228247 this .confirmationRequired = confirmationRequired ;
229248 this .deviceCredentialsAllowed = deviceCredentialsAllowed ;
249+ this .allowedAuthenticators = allowedAuthenticators ;
230250 }
231251
232- public boolean confirmationRequired () {
233- return confirmationRequired ;
252+ @ NonNull
253+ public Object dialogOwner () {
254+ return dialogOwner ;
234255 }
235256
236257 @ Nullable
237- public String description () {
238- return description ;
239- }
240-
241- public boolean deviceCredentialsAllowed () {
242- return deviceCredentialsAllowed ;
258+ public String title () {
259+ return title ;
243260 }
244261
245- @ NonNull
246- public Object dialogOwner () {
247- return dialogOwner ;
262+ @ Nullable
263+ public String description () {
264+ return description ;
248265 }
249266
250267 @ Nullable
@@ -257,9 +274,16 @@ public String subtitle() {
257274 return subtitle ;
258275 }
259276
260- @ Nullable
261- public String title () {
262- return title ;
277+ public boolean confirmationRequired () {
278+ return confirmationRequired ;
279+ }
280+
281+ public boolean deviceCredentialsAllowed () {
282+ return deviceCredentialsAllowed ;
283+ }
284+
285+ public int allowedAuthenticators () {
286+ return allowedAuthenticators ;
263287 }
264288
265289 /**
@@ -274,26 +298,23 @@ BiometricPrompt.PromptInfo buildPromptInfo() {
274298 .setTitle (title )
275299 .setSubtitle (subtitle )
276300 .setDescription (description )
277- .setDeviceCredentialAllowed (deviceCredentialsAllowed )
301+ .setAllowedAuthenticators (allowedAuthenticators )
302+ .setNegativeButtonText (negativeButtonText )
278303 .setConfirmationRequired (confirmationRequired );
279304
280- if (!deviceCredentialsAllowed ) {
281- builder .setNegativeButtonText (negativeButtonText );
282- }
283305 return builder .build ();
284306 }
285307
286308 public static class Builder {
287309
288310 /* Dialog dialogOwner can be either Fragment or FragmentActivity */
289311 @ NonNull private Object dialogOwner ;
290- @ NonNull private Mode mode = Mode .AUTHENTICATION ;
291312 @ Nullable private String description ;
292313 @ Nullable private String negativeButtonText ;
293314 @ Nullable private String subtitle ;
294315 @ Nullable private String title ;
295316 private boolean confirmationRequired ;
296- private boolean deviceCredentialsAllowed ;
317+ private int allowedAuthenticators = BiometricManager . Authenticators . BIOMETRIC_WEAK ;
297318
298319 public Builder (@ NonNull FragmentActivity activity ) {
299320 this .dialogOwner = activity ;
@@ -305,50 +326,53 @@ public Builder(@NonNull Fragment fragment) {
305326
306327 @ NonNull
307328 public PromptParams build () {
329+ boolean deviceCredentialAllowed = (allowedAuthenticators & BiometricManager .Authenticators .DEVICE_CREDENTIAL ) != 0 ;
330+
308331 return new PromptParams (
309332 dialogOwner ,
310333 title ,
311334 description ,
312335 negativeButtonText ,
313336 subtitle ,
314337 confirmationRequired ,
315- deviceCredentialsAllowed
338+ deviceCredentialAllowed ,
339+ allowedAuthenticators
316340 );
317341 }
318342
319343 /**
320- * @see BiometricPrompt.PromptInfo.Builder#setConfirmationRequired
344+ * @see BiometricPrompt.PromptInfo.Builder#setTitle
321345 */
322346 @ NonNull
323- public Builder confirmationRequired ( boolean confirmationRequired ) {
324- this .confirmationRequired = confirmationRequired ;
347+ public Builder title ( @ NonNull String title ) {
348+ this .title = title ;
325349 return this ;
326350 }
327351
328352 /**
329- * @see BiometricPrompt.PromptInfo.Builder#setDescription
353+ * @see BiometricPrompt.PromptInfo.Builder#setTitle
330354 */
331355 @ NonNull
332- public Builder description ( @ Nullable String description ) {
333- this .description = description ;
356+ public Builder title ( @ StringRes int resId ) {
357+ this .title = getString ( resId ) ;
334358 return this ;
335359 }
336360
337361 /**
338362 * @see BiometricPrompt.PromptInfo.Builder#setDescription
339363 */
340364 @ NonNull
341- public Builder description (@ StringRes int resId ) {
342- this .description = getString ( resId ) ;
365+ public Builder description (@ Nullable String description ) {
366+ this .description = description ;
343367 return this ;
344368 }
345369
346370 /**
347- * @see BiometricPrompt.PromptInfo.Builder#setDeviceCredentialAllowed
371+ * @see BiometricPrompt.PromptInfo.Builder#setDescription
348372 */
349373 @ NonNull
350- public Builder deviceCredentialsAllowed ( boolean deviceCredentialsAllowed ) {
351- this .deviceCredentialsAllowed = deviceCredentialsAllowed ;
374+ public Builder description ( @ StringRes int resId ) {
375+ this .description = getString ( resId ) ;
352376 return this ;
353377 }
354378
@@ -389,20 +413,20 @@ public Builder subtitle(@StringRes int resId) {
389413 }
390414
391415 /**
392- * @see BiometricPrompt.PromptInfo.Builder#setTitle
416+ * @see BiometricPrompt.PromptInfo.Builder#setConfirmationRequired
393417 */
394418 @ NonNull
395- public Builder title ( @ NonNull String title ) {
396- this .title = title ;
419+ public Builder confirmationRequired ( boolean confirmationRequired ) {
420+ this .confirmationRequired = confirmationRequired ;
397421 return this ;
398422 }
399423
400424 /**
401- * @see BiometricPrompt.PromptInfo.Builder#setTitle
425+ * @see BiometricPrompt.PromptInfo.Builder#setAllowedAuthenticators(int)
402426 */
403427 @ NonNull
404- public Builder title ( @ StringRes int resId ) {
405- this .title = getString ( resId ) ;
428+ public Builder allowedAuthenticators ( int allowedAuthenticators ) {
429+ this .allowedAuthenticators = allowedAuthenticators ;
406430 return this ;
407431 }
408432
@@ -579,6 +603,11 @@ enum Reason {
579603 */
580604 NO_DEVICE_CREDENTIAL ,
581605
606+ /**
607+ * @see BiometricPrompt#ERROR_SECURITY_UPDATE_REQUIRED
608+ */
609+ SECURITY_UPDATE_REQUIRED ,
610+
582611 /**
583612 * Dispatched when Fingerprint authentication is initialized correctly and
584613 * just before actual authentication is started. Can be used to update UI if necessary.
0 commit comments