mirror of
https://github.com/Evolution-X-Devices/device_motorola_rtwo
synced 2026-01-27 13:35:15 +00:00
eqs: sensors: Create sysfs polling one shot sensor
Change-Id: Ie78d7729201836bacd65a57f76e22adb61159192
This commit is contained in:
@@ -17,8 +17,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <android/hardware/sensors/2.1/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <poll.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <condition_variable>
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
@@ -88,6 +92,34 @@ class OneShotSensor : public Sensor {
|
||||
virtual Result flush() override { return Result::BAD_VALUE; }
|
||||
};
|
||||
|
||||
class SysfsPollingOneShotSensor : public OneShotSensor {
|
||||
public:
|
||||
SysfsPollingOneShotSensor(int32_t sensorHandle, ISensorsEventCallback* callback,
|
||||
const std::string& pollPath, const std::string& enablePath,
|
||||
const std::string& name, const std::string& typeAsString,
|
||||
SensorType type);
|
||||
virtual ~SysfsPollingOneShotSensor() override;
|
||||
|
||||
virtual void activate(bool enable) override;
|
||||
virtual void activate(bool enable, bool notify, bool lock);
|
||||
virtual void writeEnable(bool enable);
|
||||
virtual void setOperationMode(OperationMode mode) override;
|
||||
virtual std::vector<Event> readEvents() override;
|
||||
virtual void fillEventData(Event& event);
|
||||
|
||||
protected:
|
||||
virtual void run() override;
|
||||
|
||||
std::ofstream mEnableStream;
|
||||
|
||||
private:
|
||||
void interruptPoll();
|
||||
|
||||
struct pollfd mPolls[2];
|
||||
int mWaitPipeFd[2];
|
||||
int mPollFd;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace subhal
|
||||
} // namespace V2_1
|
||||
|
||||
Reference in New Issue
Block a user