Jelly Bean Sensor Framework

如果您要转载,请注明原创作者是蝈蝈

Frameworks

Below is a picture to show how sensor works in JB.

Each Application would create an EventListener to handle events from sensorHW. Below is a snap shot for EventListener, usually, onSensorChanged() and onAccuracyChanged() would be provided.

 

The Application registers the created EventListener to the SystemSensorManager which has a pooling thread and will invokes the callback functions in EventThread once read any event data from SensorEventQueue whose data is from SensorService.

SystemSensorManager enables the required sensor once registered with the EventListener. The control commands are sent to sensorService also through SensorEventQueue.

For the data flow, the sensorEventQueue holds a bitTube buffer; sensorSevice is responsible to write it with sensor event polled from sensorhal while systemSensorManager has a thread reads data from the bitTube buffer and invokes registered callbacks.

2.    Sensor Service

Sensor Service is an android service run in system_server.

Sensor Service has a fancy fusion instance which could generate virtual sensors event data. Once hardware not supplies such virtual sensors, Sensor Service uses its own virtual sensors. Those virtual sensors include Rotation vector, Gravity, Linear Acceleration, and Orientation. And to support those virtual sensors, hardware should at least provide Accelerator, Magnetic and Gyroscope sensors.

SensorDevice holds an internal class BatteryService. It is used to inform the BatteryService that how much time the sensor running. noteStartSensor() is called when enabling a sensor while noteStopSensor() is called when disabling a sensor.

3.    Control Flow sequence

Below is the control flow for register an event listener by applications.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值