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

Commit 2f3bf138 authored by Peng Xu's avatar Peng Xu
Browse files

Define typical sensor sample rate in native code

Porting typical sensor sample rate (e.g. SENSOR_DELAY_UI)
defined in Java API to native code.

Change-Id: I8b59216415bc952b4e953ca6e8058beb1dd3c645
parent 8e48e0aa
Loading
Loading
Loading
Loading
+13 −0
Original line number Original line Diff line number Diff line
@@ -53,6 +53,18 @@ public:


    enum { MAX_RECEIVE_BUFFER_EVENT_COUNT = 256 };
    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);
    SensorEventQueue(const sp<ISensorEventConnection>& connection);
    virtual ~SensorEventQueue();
    virtual ~SensorEventQueue();
    virtual void onFirstRef();
    virtual void onFirstRef();
@@ -68,6 +80,7 @@ public:
    status_t wake() const;
    status_t wake() const;


    status_t enableSensor(Sensor const* sensor) 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 disableSensor(Sensor const* sensor) const;
    status_t setEventRate(Sensor const* sensor, nsecs_t ns) const;
    status_t setEventRate(Sensor const* sensor, nsecs_t ns) const;


+7 −2
Original line number Original line Diff line number Diff line
@@ -125,11 +125,16 @@ status_t SensorEventQueue::wake() const
}
}


status_t SensorEventQueue::enableSensor(Sensor const* sensor) 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 {
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,
status_t SensorEventQueue::enableSensor(int32_t handle, int32_t samplingPeriodUs,