ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ข้อมูลอ้างอิงเกี่ยวกับโครงสร้าง hw_device_t
#include <
hardware.h
>
โครงสร้างข้อมูลอุปกรณ์ทุกรายการต้องขึ้นต้นด้วย
hw_device_t
ตามด้วยเมธอดและแอตทริบิวต์สาธารณะเฉพาะโมดูล
คําจํากัดความที่บรรทัด
167
ของไฟล์
hardware.h
.
การอ้างอิงถึงโมดูลที่อุปกรณ์นี้อยู่
คําจํากัดความที่บรรทัด
190
ของไฟล์
hardware.h
.
ระยะห่างที่สงวนไว้สำหรับการใช้งานในอนาคต
คําจํากัดความที่บรรทัด
196
ของไฟล์
hardware.h
.
ต้องเริ่มต้นค่าแท็กเป็น HARDWARE_DEVICE_TAG
คําจํากัดความที่บรรทัด
169
ของไฟล์
hardware.h
.
เวอร์ชันของ Device API สำหรับโมดูลที่เฉพาะเจาะจง ผู้ใช้โมดูลที่ดึงข้อมูลจะใช้ค่านี้เพื่อจัดการการติดตั้งใช้งานอุปกรณ์ต่างๆ
ผู้ใช้โมดูลมีหน้าที่ตรวจสอบช่อง module_api_version และเวอร์ชันอุปกรณ์เพื่อให้มั่นใจว่าผู้ใช้สามารถสื่อสารกับการติดตั้งใช้งานโมดูลที่เฉพาะเจาะจงได้
โมดูลเดียวรองรับอุปกรณ์หลายเครื่องที่มีเวอร์ชันต่างกันได้ ซึ่งอาจมีประโยชน์เมื่ออินเทอร์เฟซของอุปกรณ์มีการเปลี่ยนแปลงในลักษณะที่เข้ากันไม่ได้ แต่ยังคงต้องรองรับการติดตั้งใช้งานเวอร์ชันเก่าไปพร้อมๆ กัน ตัวอย่างหนึ่งคือ Camera 2.0 API
ผู้ใช้โมดูลจะตีความช่องนี้ และอินเทอร์เฟซ HAL จะไม่สนใจ
คําจํากัดความที่บรรทัด
187
ของไฟล์
hardware.h
.
เอกสารประกอบสำหรับโครงสร้างนี้สร้างขึ้นจากไฟล์ต่อไปนี้
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 UTC
[[["เข้าใจง่าย","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 UTC"],[],[],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)"]]