来自后台的生物识别提示?

问题描述 投票:0回答:0

我正在尝试从后台启动生物识别提示。基本上我向 AOSP 的 SystemUi 添加了一段代码,任何应用程序都可以向 SystemUi 发出请求以显示此生物识别覆盖。但现在我正在从 FingerprintManager 迁移到 androidx.biometrics 包,我遇到的问题是它不想从 systemUi 发出生物识别提示。 这是日志的输出:

05-14 21:40:12.166  1722  1722 W AuthController: Task stack changed, current client: com.android.systemui
05-14 21:40:12.171  1722  1722 E AuthController: Evicting client due to: org.example.app

基本上它是检查 clientPackage 是否等于 topPackage 然后它自动取消提示。

这是违规的方法:

    private void cancelIfOwnerIsNotInForeground() {
        mExecution.assertIsMainThread();
        if (mCurrentDialog != null) {
            try {
                final String clientPackage = mCurrentDialog.getOpPackageName();
                Log.w(TAG, "Task stack changed, current client: " + clientPackage);
                final List<ActivityManager.RunningTaskInfo> runningTasks =
                        mActivityTaskManager.getTasks(1);
                if (!runningTasks.isEmpty()) {
                    final String topPackage = runningTasks.get(0).topActivity.getPackageName();
                    if (!topPackage.contentEquals(clientPackage)
                            && !Utils.isSystem(mContext, clientPackage)) {
                        Log.e(TAG, "Evicting client due to: " + topPackage);
                        mCurrentDialog.dismissWithoutCallback(true /* animate */);
                        mCurrentDialog = null;

                        for (Callback cb : mCallbacks) {
                            cb.onBiometricPromptDismissed();
                        }

                        if (mReceiver != null) {
                            mReceiver.onDialogDismissed(
                                    BiometricPrompt.DISMISSED_REASON_USER_CANCEL,
                                    null /* credentialAttestation */);
                            mReceiver = null;
                        }
                    }
                }
            } catch (RemoteException e) {
                Log.e(TAG, "Remote exception", e);
            }
        }
    }

如果 systemUi 正在调用它,我怎样才能使该功能不会自动取消,并且指纹仍然有效?因为我试图只添加一个 if currentClient is "com.android.systemui" 然后返回。然后它不再自动取消,但我不能使用生物提示,因为当我触摸屏幕内传感器时它什么都不做。

提前致谢!

java android android-source android-biometric-prompt android-biometric
© www.soinside.com 2019 - 2024. All rights reserved.