1. Sensor HAL层接口
Google为Sensor提供统一的HAL接口,Android中Sensor的HAL接口定义在:hardware/libhardware/include/hardware/sensors.h。包含:
- sensor type 宏定义;
- sensor模块结构体定义struct sensors_module_t扩展于struct hw_module_t;
- sensor 数据结构体定义sensors_event_t。
- sensor设备结构体sensor_poll_device_t, 扩展于struct hw_device_t
poll函数用来获取底层数据,调用时将被阻塞定义如下:int(*poll) (para list...)。控制设备打开/关闭结构体定义如下:
2. Sensor HAL实现--打开设备流程图
Refs: http://blog.chinaunix.net/uid-26997997-id-3485501.html