I am working on application that joins functionalities from SecureElement and HCE (HostCardEmulation) and processes APDU commands from external source.
Based on the availability of SecureElement I would like to decide if all APDUs are processed from NfcController to SecureElement (default option if SecureElement present) and if not present I would like HCE to take care of the APDU processing.
And here is my question, is such case possible ?
According to https://developer.android.com/guide/topics/connectivity/nfc/hce.html I assume that it is possible only if aids for SecureElement and HCE are different. Otherwise if screen is on I will have to choose myself which service use (HostApduService or OffHostApduService) or android will use the foreground service to handle the APDUs if screen is off.
What in case if I have the same AID for both channels ? Anyone had such case ?
I ended up using dynamic aid registration -> https://developer.android.com/reference/android/nfc/cardemulation/CardEmulation.html#registerAidsForService(android.content.ComponentName,%20java.lang.String,%20java.util.List)
So I am able to decide which Controller to use in a runtime.