自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
hw_device_t 結構體參考資料
#include <
hardware.h
>
每個裝置資料結構都必須以
hw_device_t
開頭,後面接著模組專屬的公開方法和屬性。
定義位於檔案
hardware.h
的
167
行。
模組專屬裝置 API 的版本。衍生模組使用者會使用這個值來管理不同的裝置實作方式。
模組使用者必須檢查 module_api_version 和 device version 欄位,確保使用者能夠與特定模組實作項目通訊。
一個模組可支援多個不同版本的裝置。當裝置介面以不相容的方式變更,但仍需要同時支援舊版實作項目時,這項功能就很實用。其中一個例子就是 Camera 2.0 API。
這個欄位會由模組使用者解讀,並由 HAL 介面本身忽略。
定義位於檔案
hardware.h
的
187
行。
這個結構體的說明文件是由下列檔案產生:
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。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,["# Android Hardware Abstraction Layer: hw_device_t Struct Reference\n\nhw_device_t Struct Reference\n============================\n\n[Data Fields](#pub-attribs) \nhw_device_t Struct Reference \n\n`\n#include \u003c\n`[hardware.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)`\n\u003e\n`\n\n|-------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|\n| Data Fields ----------- ||\n| uint32_t | [tag](/reference/hal/structhw__device__t#a1c50fcd1195659821729f52af8f3bb7d) |\n| ||\n| uint32_t | [version](/reference/hal/structhw__device__t#acd99bb05ca015e7d74448acb1deba7ca) |\n| ||\n| struct [hw_module_t](/reference/hal/structhw__module__t) \\* | [module](/reference/hal/structhw__device__t#a0566f4bbaaf67d861130a279b9fe6e53) |\n| ||\n| uint32_t | [reserved](/reference/hal/structhw__device__t#a364fd3526fe030c97b47b0e71b31e199) \\[12\\] |\n| ||\n| int(\\* | [close](/reference/hal/structhw__device__t#a5fb45cbb01844ab66f2a7fef565928c8) )(struct [hw_device_t](/reference/hal/structhw__device__t) \\*device) |\n| ||\n\n\nDetailed Description\n--------------------\n\n\nEvery device data structure must begin with\n[hw_device_t](/reference/hal/structhw__device__t)\nfollowed by module specific public methods and attributes.\n\n\nDefinition at line\n[167](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\nof file\n[hardware.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\n.\n\nField Documentation\n-------------------\n\n\n|----------------------------------------------------------------------------------|\n| int(\\* close)(struct [hw_device_t](/reference/hal/structhw__device__t) \\*device) |\n\n\nClose this device\n\n\nDefinition at line\n[200](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\nof file\n[hardware.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\n.\n\n|--------------------------------------------------------------------|\n| struct [hw_module_t](/reference/hal/structhw__module__t) \\* module |\n\n\nreference to the module this device belongs to\n\n\nDefinition at line\n[190](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\nof file\n[hardware.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\n.\n\n|-------------------------|\n| uint32_t reserved\\[12\\] |\n\n\npadding reserved for future use\n\n\nDefinition at line\n[196](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\nof file\n[hardware.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\n.\n\n|--------------|\n| uint32_t tag |\n\n\ntag must be initialized to HARDWARE_DEVICE_TAG\n\n\nDefinition at line\n[169](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\nof file\n[hardware.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\n.\n\n|------------------|\n| uint32_t version |\n\n\nVersion of the module-specific device API. This value is used by the derived-module user to manage different device implementations.\n\n\nThe module user is responsible for checking the module_api_version and device version fields to ensure that the user is capable of communicating with the specific module implementation.\n\n\nOne module can support multiple devices with different versions. This can be useful when a device interface changes in an incompatible way but it is still necessary to support older implementations at the same time. One such example is the Camera 2.0 API.\n\n\nThis field is interpreted by the module user and is ignored by the HAL interface itself.\n\n\nDefinition at line\n[187](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\nof file\n[hardware.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)\n.\n\n*** ** * ** ***\n\nThe documentation for this struct was generated from the following file:\n\n- hardware/libhardware/include/hardware/ [hardware.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hardware.h)"]]