Sensor本地封装类SensorDevice
SensorDevice是在本地代码中SensorService对Sensor设备的抽象类型封装,它封装了传感器硬件的硬件操作,该类继承了Singleton类,通过getInstance方法获得单例模式设备操作对象:
@frameworks/base/services/sensorservice/SensorDevice.h
class SensorDevice : public Singleton<SensorDevice> {
friend class Singleton<SensorDevice>;
struct sensors_poll_device_t* mSensorDevice;
struct sensors_module_t* mSensorModule;
mutable Mutex mLock; // protect mActivationCount[].rates
// fixed-size array after construction
struct Info {
Info() : delay(0) { }
KeyedVector<void*, nsecs_t> rates;
nsecs_t delay;
status_t setDelayForIdent(void* ident, int64_t ns);
nsecs_t selectDelay();
};
DefaultKeyedVector<int, Info> mActivationCount;
SensorDevice();
public:
ssize_t getSensorList(sensor_t const** list);
status_t initCheck() const;
ssize_t p