简体   繁体   English

Android NFC卡仿真试图模拟一张卡

[英]Android NFC Card Emulation try to emulate a card

I'm trying to use NFC to emulate a card. 我正在尝试使用NFC来模拟卡片。

What I expect is that when I pass the phone on an NFC reader the reader reads the data (this data then I would modify in the future). 我期望的是,当我在NFC阅读器上通过手机时,阅读器会读取数据(这些数据将在未来修改)。

Passing the phone on the reader, for what I understand, the entry point should be in the Java class CardService.java . 将电话传递给阅读器,根据我的理解,入口点应该在Java类CardService.java But the method processCommandApdu is never called (I have tried to insert a breakpoint there and even a toast, but that code is never called). 但是方法processCommandApdu永远不会被调用(我试图在那里插入断点甚至是吐司,但是从不调用该代码)。

So at the moment the main thing that I can not understand is: Did I do something wrong? 所以目前我无法理解的主要问题是:我做错了吗? This thing can be done? 这件事可以做到吗?

In order for the method processCommandApdu() to be called for incoming APDU commands, the reader needs to select your application first. 为了调用processCommandApdu() APDU命令调用processCommandApdu()方法,读者需要先选择应用程序。 Selection is done using the SELECT (by AID / DF name) command according to ISO/IEC 8716-4: 根据ISO / IEC 8716-4使用SELECT(通过AID / DF名称)命令完成选择:

00 A4 04 00  <Lc>  <AID>  00

Where <Lc> is the length of <AID> and <AID> is the application identifier registered for your app. 其中<Lc><AID>的长度, <AID> <AID>是为您的应用注册的应用程序标识符。

The ISO/IEC 8716-4 application structure (ie application selection through a SELECT (by AID) command) is the only way Android allows to start interaction with an app over HCE. ISO / IEC 8716-4应用程序结构(即通过SELECT(通过AID)命令选择应用程序)是Android允许通过HCE开始与应用程序交互的唯一方式 Consequently, it's not possible to emulate cards (card applications) that use different mechanisms. 因此,它不可能模仿使用不同的机制卡(卡应用程序)。 (At least not without modifying the Android system itself; eg though a customized ROM or through Xposed.) (至少没有修改Android系统本身;例如,通过自定义ROM或通过Xposed。)

AIDs for the CardEmulation sample app are registered through a file named res/xml/aid_list.xml in the example project. CardEmulation示例应用程序的AID通过示例项目中名为res/xml/aid_list.xml的文件进行注册。 In this file you register AID groups, which in turn contain AID filter entries: 在此文件中,您注册AID组,而AID组又包含AID过滤器条目:

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

Therefore, the default AID that is registered in the example app is F222222222 . 因此,示例应用程序中注册的默认AID为F222222222 Hence, you can use the following SELECT (byte AID) command to select the application: 因此,您可以使用以下SELECT(字节AID)命令来选择应用程序:

00 A4 04 00  05  F2 22 22 22 22  00

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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