1

​ Hi, I am trying to implement HostService for communication with a payment terminal, however, my HostService is never started, when I try to perform payment on a terminal with NFC. I use Huawei Watch 3 and PAX terminal for testing.

Code in AbilitySlice

nfcController = NfcController.getInstance(getContext());
emulation = CardEmulation.getInstance(nfcController);


List<String> aidList = Collections.singletonList("MY_AID");
emulation.registerAids(getElementName(), CardEmulation.CATEGORY_PAYMENT, aidList);

Ability service = new CardService();     // my host service
emulation.registerForegroundPreferred(service, ability.getElementName()) // returns true

Code in Host Service

@Override
public byte[] handleRemoteCommand(byte[] cmd, IntentParams params) {
    HiLog.info(LABEL_LOG, "handleRemoteCommand" );
    return new byte[] {(byte)0x90, 0x00};
    }

Code in config.json

"abilities": [ ....     
{
        "name": "com.xxx.xxx.NFCService",
        "icon": "$media:icon",
        "description": "$string:nfcservice_description",
        "type": "service"
      }


....

    "reqPermissions": [
      {
        "name": "ohos.permission.NFC_CARD_EMULATION",
        "usedScene": {
          "ability": [
            "com.xxx.xxx.slice.MainAbilitySlice",
            "com.xxx.xxx.CardService"
          ],
          "when": "always"
        }
      },

​Do you see any problem here? Thanks!

EDIT*****

By the time, I found out, that the return code of the card is "6999, applet selection failed". Is there a problem, with how I assign my AID?

Maros Zelo
  • 53
  • 7

0 Answers0