安卓:14443 A型卡HCE [英] Android: HCE of 14443 type A card

查看:290
本文介绍了安卓:14443 A型卡HCE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图开发(HCE中的模式是Android 4.4.2)是采用Android NFC智能卡的应用程序。我读过指导如何在Android 4.4 HCE。我用的是Android 4.4 SDK沿例子。但是,如果尝试读取从另一个Android NFC设备与NFC读写应用HCE-模拟的智能卡(Android 4.3的),我只看到这些日志:

I'm trying to develop an application that uses Android NFC as smart card (Android 4.4.2 in HCE mode). I've read the guide about HCE on Android 4.4. I used the example along with the Android 4.4 SDK. But if try to read the HCE-emulated smart card from another Android NFC device (Android 4.3) with an NFC reader application, I see only these logs:

03-31 17:02:21.151: I/NFC-HCI(600): I'm P2P Active Initiator @ 424 kb/s
03-31 17:02:21.159: D/NFCJNI(600): Discovered P2P Target
03-31 17:02:21.159: D/NfcService(600): LLCP Activation message
03-31 17:02:21.183: I/NFC-HCI(600): I'm P2P Active Initiator @ 424 kb/s
03-31 17:02:21.190: I/NFCJNI(600): LLCP Link activated (LTO=150, MIU=128, OPTION=0x00, WKS=0x13)
03-31 17:02:21.190: I/NfcP2pLinkManager(600): LLCP activated
03-31 17:02:21.190: D/NfcP2pLinkManager(600): onP2pInRange()
[...]
03-31 17:02:22.144: I/NFCJNI(600): LLCP Link deactivated
03-31 17:02:22.144: D/NfcService(600): LLCP Link Deactivated message. Restart polling loop.
03-31 17:02:22.144: I/NfcP2pLinkManager(600): LLCP deactivated.
03-31 17:02:22.144: D/NfcP2pLinkManager(600): Debounce timeout
03-31 17:02:22.151: D/NfcP2pLinkManager(600): onP2pOutOfRange()

如果我尝试,而是读一个真正的智能卡,它按预期工作,我能够读取卡:

If I try, instead, to read a real smart card, it works as expected and I'm able to read the card:

TagID (hex): c4 2a 29 c8
TagID (dec): 3291097544
Technologies: MifareClassic, NfcA,NdefFormatable
Mifare Classic type: Classic
Mifare size: 1024 btes
Mifare sectors: 16
Mifare blocks: 64

我读过此​​线程,但我在这方面的知识对于极少数。

I've read this thread but my knowledge in this regard are very few.

推荐答案

答案很简单:你正在尝试做的是不可能的。

Simple answer: what you are trying to do is not possible.

这里的问题是两个Android设备将在对等网络模式默认通信(即使一个或两个设备的支持主机卡模拟)。一旦Android设备在对等网络模式成功通信,也不会尝试在读/写模式进行通信。因此,在与阅读器应用程序设备将无法检测到其他设备的HCE-模拟的一卡通。

The problem here is that two Android devices will communicate in peer-to-peer mode by default (even if one or both devices support host card emulation). Once an Android device successfully communicates in peer-to-peer mode, it won't try to communicate in reader/writer mode. Consequently, your device with the reader app won't detect the HCE-emulated "card" of the other device.

为了允许在Android HCE-仿真卡是与阅读器应用程序的第二装置可见,该第二设备将需要禁用其对等网络模式能力并只在读/写器模式是活动的。这是你refereing到(<一个线程href=\"http://stackoverflow.com/questions/20821701/android-how-to-change-nfc-protocol-priority\">Android :如何更改NFC协议优先)进来通过使用阅读器模式API的更具体的 enableReaderMode 方法 NfcAdapter? 与标志 FLAG_READER_NFC_A FLAG_READER_NFC_B (可选择 FLAG_READER_SKIP_NDEF_CHECK ),可以强制(读者侧!)Android设备只作用在读/写模式,并禁止对等网络模式:

In order to permit the Android HCE-emulated card to be visible to the second device with the reader app, that second device would need to disable its peer-to-peer mode capabilities and be active only in reader/writer mode. That's were the thread you were refereing to (Android : How to change NFC protocol priority?) comes in. By using the reader mode API, more specifically the enableReaderMode method of the NfcAdapter with the flags FLAG_READER_NFC_A, FLAG_READER_NFC_B (and optionally FLAG_READER_SKIP_NDEF_CHECK), you can force the (reader side!!!) Android device to act only in reader/writer mode and to disable peer-to-peer mode:

NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this);
nfcAdapter.enableReaderMode(this, new NfcAdapter.ReaderCallback() {
    public void onTagDiscovered(Tag tag) {
        // TODO: access tag...
    }
},
NfcAdapter.FLAG_READER_NFC_A | NfcAdapter.FLAG_READER_NFC_B | NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK, null);

不幸的是,这个API仅适用于Android 4.4及更高版本。所以与Android 4.3的设备,你也没办法禁止对等网络模式,因此不能与沟通Android的HCE一卡通。

Unfortunately, this API is only available on Android 4.4 and later. So with an Android 4.3 device, you have no means to disable peer-to-peer mode and therefore can't communicate with an Android HCE "card".

这篇关于安卓:14443 A型卡HCE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆