简体   繁体   中英

Is it possible to change Android <host-apdu-service> attribute android:requireDeviceUnlock at runtime?

The Android NFC HCE HostApduService is configured through apduservice.xml which contains:

<host-apdu-service xmlns:android="http://schemas.android.com/apk/res/android"
    android:description="@string/servicedesc"
    android:requireDeviceUnlock="true" >

    <aid-group
        android:category="other"
        android:description="@string/aiddescription" >
        <aid-filter android:name="F0010203040506" />
    </aid-group>

</host-apdu-service>

I want to make requireDeviceUnlock a user configurable setting at runtime. I suspect that I can force reloading the XML file by restarting the service with:

stopService(new Intent(this, MyHostApduService.class));
startService(new Intent(this, MyHostApduService.class));

But how can I change the setting within the XML file at runtime?

I was actually looking at implementing this same functionality, ie making it, user preference to require device unlock or not.

However looking at the api

https://developer.android.com/reference/android/nfc/cardemulation/HostApduService.html

At this point in time, there seems to be no eligible call to change the "requireDeviceUnlock" value set within an applications apduservice.xml file.

Hopefully this will change in the future.

You could however set it to false, and then within your apduservice implementation check a sharedpreference setting to see what the user has specified and then accept/deny your process from there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM