Android HCE开发配置AID响应关系总结
2015-02-28 16:21
387 查看
开发HCE功能必须使用到HostApduService,在使用HostApduService时需要配置HostApduService的对应AID,同一个手机可能安装多个HCE APP,或者同一个APP包含多个HostApduService,这时候就需要搞清楚配置的AID和对应的HostApduService之间的响应向后问题。
首先介绍一下关于HostApduService的AID配置问题,AID有两种模式:other和payment
第一种
下面我们来详细说明一下关于不同模式下的AID响应问题(前提:一个手机,手机上有A、B两个HCE APP,通过读卡器向手机发送APDU选择指令)
1、A和B的应用AID设置的都是payment模式,
只有手机当前选定的默认支付APP会响应,另外一个APP的AID选择指令是不会响应的。
2、A和B的应用AID设置的都是other模式,
当A和B的AID是相同的时候系统会弹出对话框,列出A和B,让用户选择。
如果A和B的AID不同,那么两个APP之间没有相互影响。
3、A和B的应用AID设置的分别是payment(A)和other(B)模式,
如果A和B的AID相同,那么只有A会响应选择指令。
如果A和B的AID不同,那么两者之间不会相互影响
最后将如何判断当前HCE应用是否是默认支付程序以及如何设置成默认支付程序的方法贡献给大家
首先介绍一下关于HostApduService的AID配置问题,AID有两种模式:other和payment
第一种
<host-apdu-service xmlns:android="http://schemas.android.com/apk/res/android" android:apduServiceBanner="@drawable/icon" android:description="@string/servicedesc" android:requireDeviceUnlock="false" > <!-- 可以通过指定多个aid-filter,来注册多个AID。 category可以指定为 other 或者 payment。 requireDeviceUnlock为false的时候,可以在锁屏状态下完成处理,为true的时候,则会要求用户解锁屏幕。 --> <aid-group android:category="other" android:description="@string/app_name" > <aid-filter android:name="@string/AID1" /> </aid-group> </host-apdu-service>第二种
<host-apdu-service xmlns:android="http://schemas.android.com/apk/res/android" android:apduServiceBanner="@drawable/alipay" android:description="@string/servicedesc" android:requireDeviceUnlock="false" > <!-- 可以通过指定多个aid-filter,来注册多个AID。 category可以指定为 other 或者 payment。 requireDeviceUnlock为false的时候,可以在锁屏状态下完成处理,为true的时候,则会要求用户解锁屏幕 --> <aid-group android:category="payment" android:description="@string/app_name" > <aid-filter android:name="@string/AID2" /> </aid-group> </host-apdu-service>
下面我们来详细说明一下关于不同模式下的AID响应问题(前提:一个手机,手机上有A、B两个HCE APP,通过读卡器向手机发送APDU选择指令)
1、A和B的应用AID设置的都是payment模式,
只有手机当前选定的默认支付APP会响应,另外一个APP的AID选择指令是不会响应的。
2、A和B的应用AID设置的都是other模式,
当A和B的AID是相同的时候系统会弹出对话框,列出A和B,让用户选择。
如果A和B的AID不同,那么两个APP之间没有相互影响。
3、A和B的应用AID设置的分别是payment(A)和other(B)模式,
如果A和B的AID相同,那么只有A会响应选择指令。
如果A和B的AID不同,那么两者之间不会相互影响
最后将如何判断当前HCE应用是否是默认支付程序以及如何设置成默认支付程序的方法贡献给大家
private void checkIsDefaultApp() { CardEmulation cardEmulationManager = CardEmulation.getInstance(NfcAdapter.getDefaultAdapter(this)); ComponentName paymentServiceComponent = new ComponentName(getApplicationContext(), CardMangerService.class.getCanonicalName()); if (!cardEmulationManager.isDefaultServiceForCategory(paymentServiceComponent, CardEmulation.CATEGORY_PAYMENT)) { Intent intent = new Intent(CardEmulation.ACTION_CHANGE_DEFAULT); intent.putExtra(CardEmulation.EXTRA_CATEGORY,CardEmulation.CATEGORY_PAYMENT); intent.putExtra(CardEmulation.EXTRA_SERVICE_COMPONENT,paymentServiceComponent); startActivityForResult(intent, 0); L.d("TAG","当前应用不是默认支付,需手动设置"); } else { L.d("TAG","当前应用是系统默认支付程序"); } }
相关文章推荐
- Android开发环境配置_总结
- android 开发配置及jni使用总结
- Android开发中Launcher3常见默认配置修改方法总结
- Android学习总结之开发工具AndroidStudio的安装与配置
- android开发环境配置及HelloWorld总结
- Android源码开发配置总结
- React Native for Android on Windows 配置开发安装总结
- 【嗨兴科技】Android 3.0.1 图解配置NDK开发环境以及Hello Word To JNI方法总结
- Linux(Centos)配置android开发环境总结
- Winform开发框架之客户关系管理系统(CRM)的开发总结系列3-客户分类和配置管理实现
- 自己泣血总结:Myeclipse8.5-Android开发环境配置(经测试成功)
- Android开发环境配置的个人总结,也许对某些RP像我一样低的童鞋有帮助
- Android开发常用的gradle配置总结
- 【SSI开发总结.7】Struts+Spring+Ibatis环境配置(二)
- RedHat Linux下的jdk1.5+tomcat+eclipse+myeclipse+mysql开发环境配置的经验总结