Loading include/gui/SensorEventQueue.h +13 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,18 @@ public: enum { MAX_RECEIVE_BUFFER_EVENT_COUNT = 256 }; /** * Typical sensor delay (sample period) in microseconds. */ // Fastest sampling, system will bound it to minDelay static constexpr int32_t SENSOR_DELAY_FASTEST = 0; // Typical sample period for game, 50Hz; static constexpr int32_t SENSOR_DELAY_GAME = 20000; // Typical sample period for UI, 15Hz static constexpr int32_t SENSOR_DELAY_UI = 66667; // Default sensor sample period static constexpr int32_t SENSOR_DELAY_NORMAL = 200000; SensorEventQueue(const sp<ISensorEventConnection>& connection); virtual ~SensorEventQueue(); virtual void onFirstRef(); Loading @@ -68,6 +80,7 @@ public: status_t wake() const; status_t enableSensor(Sensor const* sensor) const; status_t enableSensor(Sensor const* sensor, int32_t samplingPeriodUs) const; status_t disableSensor(Sensor const* sensor) const; status_t setEventRate(Sensor const* sensor, nsecs_t ns) const; Loading libs/gui/SensorEventQueue.cpp +7 −2 Original line number Diff line number Diff line Loading @@ -125,11 +125,16 @@ status_t SensorEventQueue::wake() const } status_t SensorEventQueue::enableSensor(Sensor const* sensor) const { return mSensorEventConnection->enableDisable(sensor->getHandle(), true, us2ns(200000), 0, false); return enableSensor(sensor, SENSOR_DELAY_NORMAL); } status_t SensorEventQueue::enableSensor(Sensor const* sensor, int32_t samplingPeriodUs) const { return mSensorEventConnection->enableDisable(sensor->getHandle(), true, us2ns(samplingPeriodUs), 0, 0); } status_t SensorEventQueue::disableSensor(Sensor const* sensor) const { return mSensorEventConnection->enableDisable(sensor->getHandle(), false, 0, 0, false); return mSensorEventConnection->enableDisable(sensor->getHandle(), false, 0, 0, 0); } status_t SensorEventQueue::enableSensor(int32_t handle, int32_t samplingPeriodUs, Loading Loading
include/gui/SensorEventQueue.h +13 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,18 @@ public: enum { MAX_RECEIVE_BUFFER_EVENT_COUNT = 256 }; /** * Typical sensor delay (sample period) in microseconds. */ // Fastest sampling, system will bound it to minDelay static constexpr int32_t SENSOR_DELAY_FASTEST = 0; // Typical sample period for game, 50Hz; static constexpr int32_t SENSOR_DELAY_GAME = 20000; // Typical sample period for UI, 15Hz static constexpr int32_t SENSOR_DELAY_UI = 66667; // Default sensor sample period static constexpr int32_t SENSOR_DELAY_NORMAL = 200000; SensorEventQueue(const sp<ISensorEventConnection>& connection); virtual ~SensorEventQueue(); virtual void onFirstRef(); Loading @@ -68,6 +80,7 @@ public: status_t wake() const; status_t enableSensor(Sensor const* sensor) const; status_t enableSensor(Sensor const* sensor, int32_t samplingPeriodUs) const; status_t disableSensor(Sensor const* sensor) const; status_t setEventRate(Sensor const* sensor, nsecs_t ns) const; Loading
libs/gui/SensorEventQueue.cpp +7 −2 Original line number Diff line number Diff line Loading @@ -125,11 +125,16 @@ status_t SensorEventQueue::wake() const } status_t SensorEventQueue::enableSensor(Sensor const* sensor) const { return mSensorEventConnection->enableDisable(sensor->getHandle(), true, us2ns(200000), 0, false); return enableSensor(sensor, SENSOR_DELAY_NORMAL); } status_t SensorEventQueue::enableSensor(Sensor const* sensor, int32_t samplingPeriodUs) const { return mSensorEventConnection->enableDisable(sensor->getHandle(), true, us2ns(samplingPeriodUs), 0, 0); } status_t SensorEventQueue::disableSensor(Sensor const* sensor) const { return mSensorEventConnection->enableDisable(sensor->getHandle(), false, 0, 0, false); return mSensorEventConnection->enableDisable(sensor->getHandle(), false, 0, 0, 0); } status_t SensorEventQueue::enableSensor(int32_t handle, int32_t samplingPeriodUs, Loading