Hello! Need to make the thing: if my app is default for HCE answer and for some reason "the card is not ready", then APDU exchange should not start. The reason is that PoS terminal aborts current operation, and salesman need to restart financial operation -- the bad UX :-/
As HCE tech is based on NFC and NfcAdapter should be in PASSIVE mode to run HCE session, I've found some workaround for my issue -- if one switches NfcAdapter to ACTIVE mode, then HCE session wouldn't start at all. So, salesman needs not to re-start financial operation, and user is able to unlock device or do some other staff to make his emulated card "ready-to-pay". Yet, I've not found how to detect if there is an NFC reader near. Looking my device log I've seen that NFC adapter changes its state from IDLE to OPEN. NfcAdapter.ACTION_ADAPTER_STATE_CHANGED event occurs only on enabling and disabling NFC. Do anyone knows is it possible to detect this state change? Or, maybe there is some other way to say that current NFC session need to be restarted later? Thanks in advance! ---------------------------------------------------------- Some logs from my device when NFC is on and adapter is in PASSIVE mode -- device is near an NFC reader: ---------------------------------------------------------- 12-19 16:55:25.667 9166-8260/? D/USERIAL_LINUX: my_read: return 27(0x1b) bytes, errno=11 count=280, n=1, timeout=-1 12-19 16:55:25.667 9166-8260/? D/USERIAL_LINUX: userial_read_thread(): enqueued p_buf=0xef329260, count=1, length=27 12-19 16:55:25.667 9166-8260/? D/USERIAL_LINUX: my_read: enter, pbuf=ef329f4c, len = 280 12-19 16:55:25.667 9166-8250/? I/BrcmNci: -- 12-19 16:55:25.668 9166-8250/? I/BrcmNci: RECV NCI Type:NTF Name: RF_ACTIVATE(0x5) PBF:No/Last Param Len: 23/23 f:0x0 12-19 16:55:25.668 9166-8250/? I/BrcmNci: RF Disc ID : 1 (0x01) 12-19 16:55:25.668 9166-8250/? I/BrcmNci: Interface Type : Frame (1/0x01) 12-19 16:55:25.668 9166-8250/? I/BrcmNci: SelectedProtocol : T2T (2/0x02) 12-19 16:55:25.668 9166-8250/? I/BrcmNci: DetTechNMode : POLL_A_PASSIVE (0/0x00) 12-19 16:55:25.668 9166-8250/? I/BrcmNci: Buff Size : 255 (0xff) 12-19 16:55:25.668 9166-8250/? I/BrcmNci: Num Buffs : 1 (0x01) 12-19 16:55:25.668 9166-8250/? I/BrcmNci: Tech Param Len : 12 (0x0c) 12-19 16:55:25.668 9166-8250/? I/BrcmNci: SENS_RES : 44 00 12-19 16:55:25.668 9166-8250/? I/BrcmNci: NFCID1 : 04 85 7e 3a 5f 36 80 12-19 16:55:25.668 9166-8250/? I/BrcmNci: SEL_RES : 08 12-19 16:55:25.668 9166-8250/? I/BrcmNci: DataTechNMode : POLL_A_PASSIVE (0/0x00) 12-19 16:55:25.668 9166-8250/? I/BrcmNci: TxBitRate : 106kbit/s (0/0x00) 12-19 16:55:25.668 9166-8250/? I/BrcmNci: RxBitRate : 106kbit/s (0/0x00) 12-19 16:55:25.668 9166-8250/? I/BrcmNci: Actv Param Len : 0/0x00 12-19 16:55:25.668 9166-8250/? D/BrcmNci: Raw NCI Packet: 12-19 16:55:25.668 9166-8250/? D/BrcmNci: 0000: 61 05 17 01 01 02 00 ff 01 0c 44 00 07 04 85 7e a.........D....~ 12-19 16:55:25.668 9166-8250/? D/BrcmNci: 0010: 3a 5f 36 80 01 08 00 00 00 00 :_6....... 12-19 16:55:25.668 9166-8250/? I/BrcmNci: -- 12-19 16:55:25.668 9166-8250/? I/NfcNciHal: nfc_hal_nci_preproc_rx_nci_msg() 12-19 16:55:25.668 9166-8250/? I/NfcNciHal: nfc_hal_dm_power_mode_execute () event = 1 12-19 16:55:25.669 9166-8250/? I/NfcNciHal: nfc_hal_dm_set_nfc_wake () ASSERT 12-19 16:55:25.669 9166-8250/? D/USERIAL_LINUX: UPIO_Set: ioctl, state=0 12-19 16:55:25.669 9166-8250/? D/USERIAL_LINUX: UPIO_Set: ioctl, old state=1, insert delay for 20 ms 12-19 16:55:25.669 9166-8250/? D/NfcNciHal: BroadcomHalDataCallback: enter; len=26 12-19 16:55:25.669 9166-8250/? D/NfcAdaptation: NfcAdaptation::HalDeviceContextDataCallback: len=26 12-19 16:55:25.669 9166-8249/? I/BrcmNfcNfa: NFC received ntf gid:1 ======================================== 12-19 16:55:25.669 9166-8249/? I/BrcmNfcNfa: nfc_set_state 4 (IDLE)->5 (OPEN) ======================================== 12-19 16:55:25.669 9166-8249/? I/BrcmNfcNfa: nfc_ncif_proc_activate:23 0, mode:0x00 12-19 16:55:25.669 9166-8249/? I/BrcmNfcNfa: nfa_dm_disc_discovery_cback (): event:0x4004 12-19 16:55:25.669 9166-8249/? I/BrcmNfcNfa: nfa_dm_disc_sm_execute (): state: DISCOVERY (1), event: ACTIVATED_NTF(5) disc_flags: 0x1 12-19 16:55:25.669 9166-8249/? I/BrcmNfcNfa: nfa_dm_disc_new_state (): old_state: DISCOVERY (1), new_state: POLL_ACTIVE (4) disc_flags: 0x1 12-19 16:55:25.669 9166-8249/? I/BrcmNfcNfa: nfa_dm_disc_notify_activation (): tech_n_mode:0x0, proto:0x2 12-19 16:55:25.669 9166-8249/? I/BrcmNfcNfa: nfa_dm_disc_get_disc_mask (): tech_n_mode:0x0, protocol:0x2, disc_mask:0x2 12-19 16:55:25.669 9166-8249/? I/BrcmNfcNfa: activated_protocol:0x2, activated_handle: 0x1 12-19 16:55:25.669 9166-8249/? I/BrcmNfcNfa: nfa_dm_poll_disc_cback (): event:0x01 12-19 16:55:25.670 9166-8249/? I/BrcmNfcNfa: nfa_rw_handle_event event: NFA_RW_ACTIVATE_NTF_EVT (0x601), flags: 00000001 12-19 16:55:25.670 9166-8249/? I/BrcmNfcNfa: nfa_rw_activate_ntf 12-19 16:55:25.670 9166-8249/? I/BrcmNfcNfa: nfa_dm_notify_activation_status (): status:0x0 12-19 16:55:25.670 9166-8249/? D/BrcmNfcJni: nfaConnectionCallback: event= 5 12-19 16:55:25.670 9166-8249/? D/BrcmNfcJni: nfaConnectionCallback: NFA_ACTIVATED_EVT: gIsSelectingRfInterface=0, sIsDisabling=0 12-19 16:55:25.670 9166-8249/? D/BrcmNfcJni: NfcTag::setActivationState: state=2 12-19 16:55:25.670 9166-8249/? D/BrcmNfcJni: pn544InteropIsBusy: 0 12-19 16:55:25.670 9166-8249/? D/BrcmNfcJni: NfcTag::IsSameKovio: enter 12-19 16:55:25.670 9166-8249/? D/BrcmNfcJni: NfcTag::discoverTechnologies (activation): enter 12-19 16:55:25.670 9166-8249/? D/BrcmNfcJni: NfcTag::discoverTechnologies (activation): index=0; tech=1; handle=1; nfc type=2 12-19 16:55:25.670 9166-8249/? D/BrcmNfcJni: NfcTag::discoverTechnologies (activation): exit 12-19 16:55:25.670 9166-8249/? D/BrcmNfcJni: NfcTag::createNativeNfcTag: enter 12-19 16:55:25.673 9166-8249/? D/BrcmNfcJni: NfcTag::fillNativeNfcTagMembers1 12-19 16:55:25.673 9166-8249/? D/BrcmNfcJni: NfcTag::fillNativeNfcTagMembers2 12-19 16:55:25.673 9166-8249/? D/BrcmNfcJni: NfcTag::fillNativeNfcTagMembers3: index=0; rf tech params mode=0 12-19 16:55:25.673 9166-8249/? D/BrcmNfcJni: NfcTag::fillNativeNfcTagMembers3: tech A 12-19 16:55:25.673 9166-8249/? D/BrcmNfcJni: NfcTag::fillNativeNfcTagMembers4: index=0 12-19 16:55:25.673 9166-8249/? D/BrcmNfcJni: NfcTag::fillNativeNfcTagMembers4: T2T; tech A 12-19 16:55:25.673 9166-8249/? D/BrcmNfcJni: NfcTag::fillNativeNfcTagMembers5: tech A 12-19 16:55:25.673 9166-8249/? D/BrcmNfcJni: NfcTag::createNativeNfcTag: try notify nfc service 12-19 16:55:25.673 9166-8249/? D/BrcmNfcJni: NfcTag::createNativeNfcTag: exit ---------------------------------------------------------- -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. To post to this group, send email to android-developers@googlegroups.com. Visit this group at https://groups.google.com/group/android-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/7b5c3712-1dd6-42be-a514-154e97a9704b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.