Kể từ ngày 27 tháng 3 năm 2025, bạn nên sử dụng android-latest-release
thay vì aosp-main
để xây dựng và đóng góp cho AOSP. Để biết thêm thông tin, hãy xem phần Thay đổi đối với AOSP.
NFC
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Trang này mô tả cách kiểm soát NFC trên thiết bị Cuttlefish bằng tính năng NFC Cuttlefish. NFC được hỗ trợ trên các thiết bị Cuttlefish chạy Android 15 trở lên.
Sử dụng Casimir
Tính năng NFC của Cuttlefish sử dụng Casimir, một công cụ mô phỏng thiết bị NFC bên ngoài, hỗ trợ chèn byte APDU để mô phỏng thẻ máy chủ. Casimir được triển khai trong /platform/system/nfc/tools/casimir/
.
Khi chạy Cuttlefish, Casimir cũng sẽ được chạy theo mặc định. Để kiểm soát Casimir, hãy sử dụng dịch vụ CasimirControlService
.
CasimirControlService
Bạn có thể sử dụng dịch vụ CasimirControlService
thông qua API REST hoặc giao diện dòng lệnh. Để biết thông tin chi tiết, hãy xem bài viết Cuttlefish: Kiểm soát môi trường.
Bảng sau đây mô tả phương thức trong CasimirControlService
. Để biết thêm thông tin, hãy xem casimir_control.proto
.
Phương thức |
Mô tả |
SendApdu
|
Gửi các byte APDU (chuỗi thập lục phân) bằng NFC-A và ISO-DEP. Phản hồi được trả về dưới dạng chuỗi thập lục phân. |
Sau đây là lệnh mẫu và phản hồi đơn giản để gửi hai byte APDU, [0x00, 0x11, 0x22]
và [0x33, 0x44, 0x55]
.
Lệnh
cvd env call CasimirControlService SendApdu '{apdu_hex_strings: ["001122", "334455"]}'
Phản hồi đơn giản
Rpc succeeded with OK status
{
"responseHexStrings": [
"9000",
"9000",
]
}
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-07-27 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-27 UTC."],[],[],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 }"]]