mirror of
https://github.com/Evolution-X-Devices/device_motorola_rtwo
synced 2026-01-27 18:07:35 +00:00
Revert "eqs: sensors: implement and enable UDFPS sensor"
This reverts commit b2dde636dd.
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <chrono>
|
||||
#include <cmath>
|
||||
#include <linux/input.h>
|
||||
|
||||
static bool readEvent(int fd, struct input_event *event) {
|
||||
int rc;
|
||||
@@ -226,21 +227,24 @@ OneShotSensor::OneShotSensor(int32_t sensorHandle, ISensorsEventCallback* callba
|
||||
mSensorInfo.flags |= SensorFlagBits::ONE_SHOT_MODE;
|
||||
}
|
||||
|
||||
InputEventOneShotSensor::InputEventOneShotSensor(
|
||||
int32_t sensorHandle, ISensorsEventCallback* callback, const std::string& pollPath,
|
||||
const std::string& enablePath, int enableValue, short keyValue, const std::string& name,
|
||||
const std::string& typeAsString, SensorType type)
|
||||
#define INPUT_DT2W_SENSOR_PATH "/dev/input/event10"
|
||||
#define INPUT_TOUCHSCREEN_PATH "/dev/input/event11"
|
||||
|
||||
#define GESTURE_PATH "/sys/class/touchscreen/primary/gesture"
|
||||
|
||||
InputEventDT2WSensor::InputEventDT2WSensor(
|
||||
int32_t sensorHandle, ISensorsEventCallback* callback)
|
||||
: OneShotSensor(sensorHandle, callback) {
|
||||
mSensorInfo.name = name;
|
||||
mSensorInfo.type = type;
|
||||
mSensorInfo.typeAsString = typeAsString;
|
||||
mSensorInfo.name = "DT2W sensor";
|
||||
mSensorInfo.type = static_cast<SensorType>(static_cast<int32_t>(SensorType::DEVICE_PRIVATE_BASE) + 1);
|
||||
mSensorInfo.typeAsString = "org.lineageos.sensor.dt2w";
|
||||
mSensorInfo.maxRange = 2048.0f;
|
||||
mSensorInfo.resolution = 1.0f;
|
||||
mSensorInfo.power = 0;
|
||||
mSensorInfo.flags |= SensorFlagBits::WAKE_UP;
|
||||
|
||||
std::ofstream mGestureEnable;
|
||||
mGestureEnable.open(enablePath);
|
||||
mGestureEnable.open(GESTURE_PATH);
|
||||
|
||||
if(!mGestureEnable) {
|
||||
ALOGE("could not open gesture path");
|
||||
@@ -248,7 +252,7 @@ InputEventOneShotSensor::InputEventOneShotSensor(
|
||||
return;
|
||||
}
|
||||
|
||||
mGestureEnable << enableValue << std::flush;
|
||||
mGestureEnable << "49" << std::flush;
|
||||
|
||||
int rc;
|
||||
|
||||
@@ -259,7 +263,7 @@ InputEventOneShotSensor::InputEventOneShotSensor(
|
||||
ALOGE("failed to open wait pipe: %d", rc);
|
||||
}
|
||||
|
||||
mPollFds[0] = open(pollPath.c_str(), O_RDONLY | O_NONBLOCK);
|
||||
mPollFds[0] = open(INPUT_DT2W_SENSOR_PATH, O_RDONLY | O_NONBLOCK);
|
||||
if (mPollFds[0] < 0) {
|
||||
ALOGE("failed to open poll fd: %d", mPollFds[0]);
|
||||
}
|
||||
@@ -278,17 +282,15 @@ InputEventOneShotSensor::InputEventOneShotSensor(
|
||||
.fd = mPollFds[0],
|
||||
.events = POLLIN,
|
||||
};
|
||||
|
||||
mKeyValue = keyValue;
|
||||
}
|
||||
|
||||
InputEventOneShotSensor::~InputEventOneShotSensor() {
|
||||
InputEventDT2WSensor::~InputEventDT2WSensor() {
|
||||
interruptPoll();
|
||||
}
|
||||
|
||||
void InputEventOneShotSensor::activate(bool enable) {
|
||||
void InputEventDT2WSensor::activate(bool enable) {
|
||||
std::lock_guard<std::mutex> lock(mRunMutex);
|
||||
ALOGE("Activated for key %d", mKeyValue);
|
||||
|
||||
if (mIsEnabled != enable) {
|
||||
mIsEnabled = enable;
|
||||
interruptPoll();
|
||||
@@ -296,12 +298,12 @@ void InputEventOneShotSensor::activate(bool enable) {
|
||||
}
|
||||
}
|
||||
|
||||
void InputEventOneShotSensor::setOperationMode(OperationMode mode) {
|
||||
void InputEventDT2WSensor::setOperationMode(OperationMode mode) {
|
||||
Sensor::setOperationMode(mode);
|
||||
interruptPoll();
|
||||
}
|
||||
|
||||
void InputEventOneShotSensor::run() {
|
||||
void InputEventDT2WSensor::run() {
|
||||
std::unique_lock<std::mutex> runLock(mRunMutex);
|
||||
|
||||
while (!mStopThread) {
|
||||
@@ -324,7 +326,7 @@ void InputEventOneShotSensor::run() {
|
||||
}
|
||||
|
||||
if((mPolls[1].revents == mPolls[1].events) && readEvent(mPolls[1].fd, &event)) {
|
||||
if(event.type == EV_KEY && event.value == 1 && event.code == mKeyValue) {
|
||||
if(event.type == EV_KEY && event.value == 1 && event.code == KEY_F4) {
|
||||
mIsEnabled = false;
|
||||
mCallback->postEvents(readEvents(), isWakeUpSensor());
|
||||
}
|
||||
@@ -335,25 +337,21 @@ void InputEventOneShotSensor::run() {
|
||||
}
|
||||
}
|
||||
|
||||
void InputEventOneShotSensor::interruptPoll() {
|
||||
void InputEventDT2WSensor::interruptPoll() {
|
||||
if (mWaitPipeFd[1] < 0) return;
|
||||
|
||||
char c = '1';
|
||||
write(mWaitPipeFd[1], &c, sizeof(c));
|
||||
}
|
||||
|
||||
void InputEventOneShotSensor::fillEventData(Event& event) {
|
||||
event.u.data[0] = 0;
|
||||
event.u.data[1] = 0;
|
||||
}
|
||||
|
||||
std::vector<Event> InputEventOneShotSensor::readEvents() {
|
||||
std::vector<Event> InputEventDT2WSensor::readEvents() {
|
||||
std::vector<Event> events;
|
||||
Event event;
|
||||
event.sensorHandle = mSensorInfo.sensorHandle;
|
||||
event.sensorType = mSensorInfo.type;
|
||||
event.timestamp = ::android::elapsedRealtimeNano();
|
||||
fillEventData(event);
|
||||
event.u.data[0] = 0;
|
||||
event.u.data[1] = 0;
|
||||
events.push_back(event);
|
||||
return events;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user