自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
nfc_tag_device 结构体参考文档
#include <
nfc_tag.h
>
初始化 NFC 标签。
驱动程序必须:
-
将静态锁定字节设置为只读
-
配置 capability 容器以停用写入权限,例如:0xE1 0x10 <size> 0x0F
在调用
setContent()
之前,系统会调用此函数一次。
成功时返回 0,错误时返回 -errno。
定义位于文件
nfc_tag.h
的
65 行
。
int(* setContent)(const struct
nfc_tag_device
*dev, const uint8_t *data, size_t len)
|
设置 NFC 标签内容。
驱动程序必须从第 4 个分块的字节 0 开始,在标签的数据区域中写入 <data>,并将数据区域的其余部分设为零。
成功时返回 0,失败时返回 -errno。
定义位于文件
nfc_tag.h
的
75 行
。
此结构体的文档是根据以下文件生成的:
-
hardware/libhardware/include/hardware/
nfc_tag.h
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):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"]],["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Android Hardware Abstraction Layer: nfc_tag_device Struct Reference\n\nnfc_tag_device Struct Reference\n===============================\n\n[Data Fields](#pub-attribs) \nnfc_tag_device Struct Reference \n\n`\n#include \u003c\n`[nfc_tag.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/nfc_tag.h)`\n\u003e\n`\n\n|----------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Data Fields ----------- ||\n| struct [hw_device_t](/reference/hal/structhw__device__t) | [common](/reference/hal/structnfc__tag__device#a86a0ca82dd3f02023e259b8b5e155dbe) |\n| ||\n| int(\\* | [init](/reference/hal/structnfc__tag__device#ae5eddc2663eab28a5880c1c3ece3c2cd) )(const struct [nfc_tag_device](/reference/hal/structnfc__tag__device) \\*dev) |\n| ||\n| int(\\* | [setContent](/reference/hal/structnfc__tag__device#a33335a1531a79b11436d1272d2ec696b) )(const struct [nfc_tag_device](/reference/hal/structnfc__tag__device) \\*dev, const uint8_t \\*data, size_t len) |\n| ||\n| int(\\* | [getMemorySize](/reference/hal/structnfc__tag__device#a93d3375699112cf6216b01be934f26d1) )(const struct [nfc_tag_device](/reference/hal/structnfc__tag__device) \\*dev) |\n| ||\n\n\nDetailed Description\n--------------------\n\n\nDefinition at line\n[44](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/nfc_tag.h)\nof file\n[nfc_tag.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/nfc_tag.h)\n.\n\nField Documentation\n-------------------\n\n\n|-----------------------------------------------------------------|\n| struct [hw_device_t](/reference/hal/structhw__device__t) common |\n\n\nCommon methods of the NFC tag device. This\n*must*\nbe the first member of nfc_tag_device_t as users of this structure will cast a\n[hw_device_t](/reference/hal/structhw__device__t)\nto nfc_tag_device_t pointer in contexts where it's known the\n[hw_device_t](/reference/hal/structhw__device__t)\nreferences a nfc_tag_device_t.\n\n\nDefinition at line\n[51](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/nfc_tag.h)\nof file\n[nfc_tag.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/nfc_tag.h)\n.\n\n|---------------------------------------------------------------------------------------------------|\n| int(\\* getMemorySize)(const struct [nfc_tag_device](/reference/hal/structnfc__tag__device) \\*dev) |\n\n\nReturns the memory size of the data area.\n\n\nDefinition at line\n[80](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/nfc_tag.h)\nof file\n[nfc_tag.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/nfc_tag.h)\n.\n\n|------------------------------------------------------------------------------------------|\n| int(\\* init)(const struct [nfc_tag_device](/reference/hal/structnfc__tag__device) \\*dev) |\n\n\nInitialize the NFC tag.\n\n\nThe driver must:\n\n- Set the static lock bytes to read only\n- Configure the Capability Container to disable write acess eg: 0xE1 0x10 \\\u003csize\\\u003e 0x0F\n\n\nThis function is called once before any calls to\n[setContent()](/reference/hal/structnfc__tag__device#a33335a1531a79b11436d1272d2ec696b)\n.\n\n\nReturn 0 on success or -errno on error.\n\n\nDefinition at line\n[65](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/nfc_tag.h)\nof file\n[nfc_tag.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/nfc_tag.h)\n.\n\n|----------------------------------------------------------------------------------------------------------------------------------|\n| int(\\* setContent)(const struct [nfc_tag_device](/reference/hal/structnfc__tag__device) \\*dev, const uint8_t \\*data, size_t len) |\n\n\nSet the NFC tag content.\n\n\nThe driver must write \\\u003cdata\\\u003e in the data area of the tag starting at byte 0 of block 4 and zero the rest of the data area.\n\n\nReturns 0 on success or -errno on error.\n\n\nDefinition at line\n[75](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/nfc_tag.h)\nof file\n[nfc_tag.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/nfc_tag.h)\n.\n\n*** ** * ** ***\n\nThe documentation for this struct was generated from the following file:\n\n- hardware/libhardware/include/hardware/ [nfc_tag.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/nfc_tag.h)"]]