{"id":1589,"date":"2015-08-07T03:45:08","date_gmt":"2015-08-06T19:45:08","guid":{"rendered":"\/wp\/?p=1589"},"modified":"2019-07-05T01:17:12","modified_gmt":"2019-07-04T17:17:12","slug":"android-hce","status":"publish","type":"post","link":"https:\/\/tixbay.net\/?p=1589","title":{"rendered":"Android HCE"},"content":{"rendered":"<p><a title=\"\u5f15\u7528\" href=\"http:\/\/www.bkjia.com\/Androidjc\/961971.html\" target=\"_blank\" rel=\"noopener\">\u5f15\u7528<\/a><\/p>\n<p>\u5f00\u53d1HCE\u529f\u80fd\u5fc5\u987b\u4f7f\u7528\u5230HostApduService\uff0c\u5728\u4f7f\u7528HostApduService\u65f6\u9700\u8981\u914d\u7f6eHostApduService\u7684\u5bf9\u5e94AID\uff0c\u540c\u4e00\u4e2a\u624b\u673a\u53ef\u80fd\u5b89\u88c5\u591a\u4e2aHCE APP\uff0c\u6216\u8005\u540c\u4e00\u4e2aAPP\u5305\u542b\u591a\u4e2aHostApduService,\u8fd9\u65f6\u5019\u5c31\u9700\u8981\u641e\u6e05\u695a\u914d\u7f6e\u7684AID\u548c\u5bf9\u5e94\u7684HostApduService\u4e4b\u95f4\u7684\u54cd\u5e94\u5411\u540e\u95ee\u9898\u3002<br \/>\n\u9996\u5148\u4ecb\u7ecd\u4e00\u4e0b\u5173\u4e8eHostApduService\u7684AID\u914d\u7f6e\u95ee\u9898\uff0cAID\u6709\u4e24\u79cd\u6a21\u5f0f\uff1aother\u548cpayment<\/p>\n<p>\u7b2c\u4e00\u79cd<\/p>\n<pre>          \u53ef\u4ee5\u901a\u8fc7\u6307\u5b9a\u591a\u4e2aaid-filter\uff0c\u6765\u6ce8\u518c\u591a\u4e2aAID\u3002\n          category\u53ef\u4ee5\u6307\u5b9a\u4e3a other \u6216\u8005 payment\u3002\n          requireDeviceUnlock\u4e3afalse\u7684\u65f6\u5019\uff0c\u53ef\u4ee5\u5728\u9501\u5c4f\u72b6\u6001\u4e0b\u5b8c\u6210\u5904\u7406\uff0c\u4e3atrue\u7684\u65f6\u5019\uff0c\u5219\u4f1a\u8981\u6c42\u7528\u6237\u89e3\u9501\u5c4f\u5e55\u3002\n<\/pre>\n<p>\u7b2c\u4e8c\u79cd<\/p>\n<pre> \n          \u53ef\u4ee5\u901a\u8fc7\u6307\u5b9a\u591a\u4e2aaid-filter\uff0c\u6765\u6ce8\u518c\u591a\u4e2aAID\u3002\n          category\u53ef\u4ee5\u6307\u5b9a\u4e3a other \u6216\u8005 payment\u3002\n          requireDeviceUnlock\u4e3afalse\u7684\u65f6\u5019\uff0c\u53ef\u4ee5\u5728\u9501\u5c4f\u72b6\u6001\u4e0b\u5b8c\u6210\u5904\u7406\uff0c\u4e3atrue\u7684\u65f6\u5019\uff0c\u5219\u4f1a\u8981\u6c42\u7528\u6237\u89e3\u9501\u5c4f\u5e55\n<\/pre>\n<p>\u4e0b\u9762\u6211\u4eec\u6765\u8be6\u7ec6\u8bf4\u660e\u4e00\u4e0b\u5173\u4e8e\u4e0d\u540c\u6a21\u5f0f\u4e0b\u7684AID\u54cd\u5e94\u95ee\u9898\uff08\u524d\u63d0\uff1a\u4e00\u4e2a\u624b\u673a\uff0c\u624b\u673a\u4e0a\u6709A\u3001B\u4e24\u4e2aHCE APP\uff0c\u901a\u8fc7\u8bfb\u5361\u5668\u5411\u624b\u673a\u53d1\u9001APDU\u9009\u62e9\u6307\u4ee4\uff09<\/p>\n<p>1\u3001A\u548cB\u7684\u5e94\u7528AID\u8bbe\u7f6e\u7684\u90fd\u662fpayment\u6a21\u5f0f\uff0c<\/p>\n<p>\u53ea\u6709\u624b\u673a\u5f53\u524d\u9009\u5b9a\u7684\u9ed8\u8ba4\u652f\u4ed8APP\u4f1a\u54cd\u5e94\uff0c\u53e6\u5916\u4e00\u4e2aAPP\u7684AID\u9009\u62e9\u6307\u4ee4\u662f\u4e0d\u4f1a\u54cd\u5e94\u7684\u3002<\/p>\n<p>2\u3001A\u548cB\u7684\u5e94\u7528AID\u8bbe\u7f6e\u7684\u90fd\u662fother\u6a21\u5f0f\uff0c<\/p>\n<p>\u5f53A\u548cB\u7684AID\u662f\u76f8\u540c\u7684\u65f6\u5019\u7cfb\u7edf\u4f1a\u5f39\u51fa\u5bf9\u8bdd\u6846\uff0c\u5217\u51faA\u548cB\uff0c\u8ba9\u7528\u6237\u9009\u62e9\u3002<\/p>\n<p>\u5982\u679cA\u548cB\u7684AID\u4e0d\u540c\uff0c\u90a3\u4e48\u4e24\u4e2aAPP\u4e4b\u95f4\u6ca1\u6709\u76f8\u4e92\u5f71\u54cd\u3002<\/p>\n<p>3\u3001A\u548cB\u7684\u5e94\u7528AID\u8bbe\u7f6e\u7684\u5206\u522b\u662fpayment\uff08A\uff09\u548cother\uff08B\uff09\u6a21\u5f0f\uff0c<\/p>\n<p>\u5982\u679cA\u548cB\u7684AID\u76f8\u540c\uff0c\u90a3\u4e48\u53ea\u6709A\u4f1a\u54cd\u5e94\u9009\u62e9\u6307\u4ee4\u3002<\/p>\n<p>\u5982\u679cA\u548cB\u7684AID\u4e0d\u540c\uff0c\u90a3\u4e48\u4e24\u8005\u4e4b\u95f4\u4e0d\u4f1a\u76f8\u4e92\u5f71\u54cd<\/p>\n<p>\u6700\u540e\u5c06\u5982\u4f55\u5224\u65ad\u5f53\u524dHCE\u5e94\u7528\u662f\u5426\u662f\u9ed8\u8ba4\u652f\u4ed8\u7a0b\u5e8f\u4ee5\u53ca\u5982\u4f55\u8bbe\u7f6e\u6210\u9ed8\u8ba4\u652f\u4ed8\u7a0b\u5e8f\u7684\u65b9\u6cd5\u8d21\u732e\u7ed9\u5927\u5bb6<\/p>\n<p>private void checkIsDefaultApp() {<br \/>\nCardEmulation cardEmulationManager = CardEmulation.getInstance(NfcAdapter.getDefaultAdapter(this));<br \/>\nComponentName paymentServiceComponent = new ComponentName(getApplicationContext(), CardMangerService.class.getCanonicalName());<br \/>\nif (!cardEmulationManager.isDefaultServiceForCategory(paymentServiceComponent, CardEmulation.CATEGORY_PAYMENT)) {<br \/>\nIntent intent = new Intent(CardEmulation.ACTION_CHANGE_DEFAULT);<br \/>\nintent.putExtra(CardEmulation.EXTRA_CATEGORY,CardEmulation.CATEGORY_PAYMENT);<br \/>\nintent.putExtra(CardEmulation.EXTRA_SERVICE_COMPONENT,paymentServiceComponent);<br \/>\nstartActivityForResult(intent, 0);<br \/>\nL.d(&#8220;TAG&#8221;,&#8221;\u5f53\u524d\u5e94\u7528\u4e0d\u662f\u9ed8\u8ba4\u652f\u4ed8\uff0c\u9700\u624b\u52a8\u8bbe\u7f6e&#8221;);<br \/>\n} else {<br \/>\nL.d(&#8220;TAG&#8221;,&#8221;\u5f53\u524d\u5e94\u7528\u662f\u7cfb\u7edf\u9ed8\u8ba4\u652f\u4ed8\u7a0b\u5e8f&#8221;);<br \/>\n}<br \/>\n}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f15\u7528 \u5f00\u53d1HCE\u529f\u80fd\u5fc5\u987b\u4f7f\u7528\u5230HostApduService\uff0c\u5728\u4f7f\u7528HostAp &hellip;<\/p>\n<p class=\"read-more\"><a href=\"https:\/\/tixbay.net\/?p=1589\">\u7ee7\u7eed\u9605\u8bfb &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1589","post","type-post","status-publish","format-standard","hentry","category-moo"],"_links":{"self":[{"href":"https:\/\/tixbay.net\/index.php?rest_route=\/wp\/v2\/posts\/1589","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tixbay.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tixbay.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tixbay.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tixbay.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1589"}],"version-history":[{"count":5,"href":"https:\/\/tixbay.net\/index.php?rest_route=\/wp\/v2\/posts\/1589\/revisions"}],"predecessor-version":[{"id":2177,"href":"https:\/\/tixbay.net\/index.php?rest_route=\/wp\/v2\/posts\/1589\/revisions\/2177"}],"wp:attachment":[{"href":"https:\/\/tixbay.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1589"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tixbay.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1589"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tixbay.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1589"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}