自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
NFC
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
本頁說明如何使用 Cuttlefish NFC 功能,在 Cuttlefish 裝置上控制 NFC。搭載 Android 15 以上版本的 Cuttlefish 裝置支援 NFC。
使用 Casimir
Cuttlefish NFC 功能會使用 Casimir,這是外部 NFC 裝置模擬工具,可為主機卡模擬功能注入 APDU 位元組。Casimir 已在 /platform/system/nfc/tools/casimir/
中實作。
啟動 Cuttlefish 時,系統會預設啟動 Casimir。如要控制 Casimir,請使用 CasimirControlService
服務。
CasimirControlService
您可以透過 REST API 或指令列介面使用 CasimirControlService
服務。詳情請參閱「Cuttlefish:環境控制」。
下表說明 CasimirControlService
中的這個方法。詳情請參閱 casimir_control.proto
。
方法 |
說明 |
SendApdu
|
透過 NFC-A 和 ISO-DEP 傳送 APDU 位元組 (十六進位字串)。回應會以十六進位字串的形式傳回。 |
以下是傳送兩個 APDU 位元組 [0x00, 0x11, 0x22]
和 [0x33, 0x44, 0x55]
的範例指令和簡化回應。
指令
cvd env call CasimirControlService SendApdu '{apdu_hex_strings: ["001122", "334455"]}'
簡化回覆
Rpc succeeded with OK status
{
"responseHexStrings": [
"9000",
"9000",
]
}
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# NFC\n\nThis page describes how to control NFC on a Cuttlefish device using the\nCuttlefish NFC feature. NFC is supported on Cuttlefish devices running\nAndroid 15 or higher.\n\nUse Casimir\n-----------\n\nThe Cuttlefish NFC feature uses Casimir, an external NFC device simulation tool,\nwhich supports injecting APDU bytes for host card emulation. Casimir is\nimplemented in\n[`/platform/system/nfc/tools/casimir/`](https://cs.android.com/android/platform/superproject/+/android-latest-release:packages/modules/Nfc/libnfc-nci/tools/casimir/).\n\nWhen launching Cuttlefish, Casimir is also launched by default. To\ncontrol Casimir, use the `CasimirControlService` service.\n\n### CasimirControlService\n\nYou can use the `CasimirControlService` service through the REST API or the\ncommand line interface. For details, see\n[Cuttlefish: Environment Control](/docs/setup/create/cuttlefish-control-environment).\n\nThe following table describes the method in `CasimirControlService`. For\nmore information, see\n[`casimir_control.proto`](https://cs.android.com/android/platform/superproject/+/android-latest-release:device/google/cuttlefish/host/commands/casimir_control_server/casimir_control.proto).\n\n| Method | Description |\n|------------|-------------------------------------------------------------------------------------------------|\n| `SendApdu` | Sends APDU bytes (hex strings) with NFC-A and ISO-DEP. The response is returned as hex strings. |\n\nThe following is an example command and a simplified response for sending two\nAPDU bytes, `[0x00, 0x11, 0x22]` and `[0x33, 0x44, 0x55]`.\n\n- Command\n\n cvd env call CasimirControlService SendApdu '{apdu_hex_strings: [\"001122\", \"334455\"]}'\n\n- Simplified response\n\n Rpc succeeded with OK status\n {\n \"responseHexStrings\": [\n \"9000\",\n \"9000\",\n ]\n }"]]