Android BiometricAuthenticator.AuthenticationResult mUserId 和多个用户

Android BiometricAuthenticator.AuthenticationResult mUserId and multiple users

在 Android,我想通过生物识别来区分哪个用户正在使用我的应用程序。 我不想直接访问他们的原始指纹数据或面部识别。

我只是假设可能不止一个用户在使用 phone。 有什么办法可以告诉我是哪一个? 我正在寻找一个唯一的用户 ID,而不是图片或类似的东西。 "User1 is using the fingerprint sensor" 之类的答案就足够了;我的应用程序不需要知道用户的指纹扫描或他们的电子邮件。我只想区分User1和User2。

例如:android 用户可以在其指纹传感器上设置多个手指。当我的应用程序调用 BiometricPrompt 时,我能以某种方式告诉扫描了哪个手指号码吗? (手指 1?手指 2 等...)

当 运行 在调试器中时,我看到 result 有一个 mUserId 字段,但它始终为 0。

new BiometricPrompt.AuthenticationCallback() {
                            @Override
                            public void onAuthenticationSucceeded(BiometricPrompt.AuthenticationResult result) {
                                // Can I write something here to figure out which user is using this phone?

这可能吗?如果不是,那么 mUserId 有什么用?

当前 API 不支持您尝试执行的操作。它实质上为您提供了 Yes/No 问题 "Is the currently scanned fingerprint/face/iris enrolled on this device?" 的答案。就是这样。

then what is mUserId for?

我很确定它指的是当前进程的UID,即标识应用程序内核级应用程序沙箱的唯一值。

无论如何,getUserIdBiometricAuthenticator.AuthenticationResult 源代码中被注释为 @hide,这意味着应用程序不应使用它。如果你查看 the BiometricPrompt source code,你会发现他们在构造 AuthenticationResult.

时总是将字段设置为 0