属性 android:requireDeviceUnlock 未执行其功能

Attribute android:requireDeviceUnlock does not perform its function

这是我在 HCE 应用程序中的文件 apduservice.xml:

<?xml version="1.0" encoding="utf-8"?>

<host-apdu-service xmlns:android="http://schemas.android.com/apk/res/android"
                   android:requireDeviceUnlock="false">
    <aid-group android:category="other">
        <aid-filter android:name="00000000000401"/>
    </aid-group>
</host-apdu-service>

我还尝试更改此文件中的属性 android:requireDeviceUnlock,如下所示:

android:requireDeviceUnlock="true"

并尝试运行没有此属性的应用程序

<host-apdu-service xmlns:android="http://schemas.android.com/apk/res/android">
        <aid-group android:category="other">
            <aid-filter android:name="F0405400400337"/>
        </aid-group>
    </host-apdu-service>

但没有任何改变。我的应用程序仅在显示器解锁时工作,并且当显示器熄灭时,我的 processCommandApdu 方法没有命令。

来自文档:

The requireDeviceUnlock attribute can be used to specify that the device must be unlocked before this service can be invoked to handle APDUs.

HCE services can function from the lock-screen however: this is controlled by the android:requireDeviceUnlock attribute in the tag of your HCE service. By default, device unlock is not required, and your service will be invoked even if the device is locked.

If you set the android:requireDeviceUnlock attribute to "true" for your HCE service, Android will prompt the user to unlock the device when you tap an NFC reader that selects an AID that is resolved to your service. After unlocking, Android will show a dialog prompting the user to tap again to complete the transaction. This is necessary because the user may have moved the device away from the NFC reader in order to unlock it.

我做错了什么?请帮助我!

Android HCE 服务仅在您的屏幕实际打开时才有效。

From the HostApduService Documentation:

Current Android implementations turn the NFC controller and the application processor off completely when the screen of the device is turned off. HCE services will therefore not work when the screen is off. HCE services can function from the lock-screen however: this is controlled by the android:requireDeviceUnlock attribute in the tag of your HCE service. By default, device unlock is not required, and your service will be invoked even if the device is locked.

android:requireDevice 属性仅在屏幕 开启 并且您的 ApduService 收到命令时才要求锁屏。此外,用户必须设置锁屏。

希望对您有所帮助