自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
sensors_module_t 結構體參考資料
#include <
sensors.h
>
每個硬體模組都必須有名為 HAL_MODULE_INFO_SYM 的資料結構,且此資料結構的欄位必須以
hw_module_t
開頭,後面接著模組專屬資訊。
定義位於檔案
sensors.h
的第
1149
行。
列舉所有可用的感應器。清單會以「list」格式傳回。
-
退貨
-
清單中的感應器數量
定義位於檔案
sensors.h
的 1156 行。
int(* set_operation_mode)(unsigned int mode)
|
將模組置於特定模式。定義下列模式:
0 - 正常運作。模組的預設狀態。1 - 回送模式。在這個模式中,感應器服務會為支援的感應器注入資料。
-
退貨
-
成功時為 0 - 如果系統不支援要求的模式,則為 -EINVAL - 如果系統不允許作業,則為 -EPERM
定義位於檔案
sensors.h
的
1169
行。
這個結構體的說明文件是由下列檔案產生:
-
hardware/libhardware/include/hardware/
sensors.h
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。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: sensors_module_t Struct Reference\n\nsensors_module_t Struct Reference\n=================================\n\n[Data Fields](#pub-attribs) \nsensors_module_t Struct Reference \n\n`\n#include \u003c\n`[sensors.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/sensors.h)`\n\u003e\n`\n\n|----------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Data Fields ----------- ||\n| struct [hw_module_t](/reference/hal/structhw__module__t) | [common](/reference/hal/structsensors__module__t#a71ea01183b3998cad6a2301a37a42fc7) |\n| ||\n| int(\\* | [get_sensors_list](/reference/hal/structsensors__module__t#aa9546f8477ee959716aa78e849a2c51b) )(struct [sensors_module_t](/reference/hal/structsensors__module__t) \\*module, struct [sensor_t](/reference/hal/structsensor__t) const \\*\\*list) |\n| ||\n| int(\\* | [set_operation_mode](/reference/hal/structsensors__module__t#a495cc50ac138223c6f32006810c1a8ca) )(unsigned int mode) |\n| ||\n\n\nDetailed Description\n--------------------\n\n\nEvery hardware module must have a data structure named HAL_MODULE_INFO_SYM and the fields of this data structure must begin with\n[hw_module_t](/reference/hal/structhw__module__t)\nfollowed by module specific information.\n\n\nDefinition at line\n[1149](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/sensors.h)\nof file\n[sensors.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/sensors.h)\n.\n\nField Documentation\n-------------------\n\n\n|-----------------------------------------------------------------|\n| struct [hw_module_t](/reference/hal/structhw__module__t) common |\n\n\nDefinition at line\n[1150](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/sensors.h)\nof file\n[sensors.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/sensors.h)\n.\n\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| int(\\* get_sensors_list)(struct [sensors_module_t](/reference/hal/structsensors__module__t) \\*module, struct [sensor_t](/reference/hal/structsensor__t) const \\*\\*list) |\n\n\nEnumerate all available sensors. The list is returned in \"list\".\n\n\nReturns\n:\n number of sensors in the list\n\n\nDefinition at line\n[1156](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/sensors.h)\nof file\n[sensors.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/sensors.h)\n.\n\n|-----------------------------------------------|\n| int(\\* set_operation_mode)(unsigned int mode) |\n\n\nPlace the module in a specific mode. The following modes are defined\n\n\n0 - Normal operation. Default state of the module. 1 - Loopback mode. Data is injected for the supported sensors by the sensor service in this mode.\n\n\nReturns\n:\n 0 on success -EINVAL if requested mode is not supported -EPERM if operation is not allowed\n\n\nDefinition at line\n[1169](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/sensors.h)\nof file\n[sensors.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/sensors.h)\n.\n\n*** ** * ** ***\n\nThe documentation for this struct was generated from the following file:\n\n- hardware/libhardware/include/hardware/ [sensors.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/sensors.h)"]]