Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 133887e6 authored by Peng Xu's avatar Peng Xu Committed by android-build-merger
Browse files

Merge "Define typical sensor sample rate in native code" into nyc-dev am: a84b43c9

am: f6fce6b9

* commit 'f6fce6b9':
  Define typical sensor sample rate in native code
parents 6a506441 f6fce6b9
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -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();
@@ -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;

+7 −2
Original line number Diff line number Diff line
@@ -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,