mirror of
https://github.com/Evolution-X-Devices/device_motorola_rtwo
synced 2026-01-27 13:35:15 +00:00
Revert "eqs: sensors: implement and enable UDFPS sensor"
This reverts commit b2dde636dd.
This commit is contained in:
@@ -278,7 +278,4 @@
|
|||||||
|
|
||||||
<!-- Type of the double tap sensor. Empty if double tap is not supported. -->
|
<!-- Type of the double tap sensor. Empty if double tap is not supported. -->
|
||||||
<string name="config_dozeDoubleTapSensorType" translatable="false">org.lineageos.sensor.dt2w</string>
|
<string name="config_dozeDoubleTapSensorType" translatable="false">org.lineageos.sensor.dt2w</string>
|
||||||
|
|
||||||
<!-- Type of the udfps long press sensor. Empty if long press is not supported. -->
|
|
||||||
<string name="config_dozeUdfpsLongPressSensorType" translatable="false">org.lineageos.sensor.udfps</string>
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <linux/input.h>
|
||||||
|
|
||||||
static bool readEvent(int fd, struct input_event *event) {
|
static bool readEvent(int fd, struct input_event *event) {
|
||||||
int rc;
|
int rc;
|
||||||
@@ -226,21 +227,24 @@ OneShotSensor::OneShotSensor(int32_t sensorHandle, ISensorsEventCallback* callba
|
|||||||
mSensorInfo.flags |= SensorFlagBits::ONE_SHOT_MODE;
|
mSensorInfo.flags |= SensorFlagBits::ONE_SHOT_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
InputEventOneShotSensor::InputEventOneShotSensor(
|
#define INPUT_DT2W_SENSOR_PATH "/dev/input/event10"
|
||||||
int32_t sensorHandle, ISensorsEventCallback* callback, const std::string& pollPath,
|
#define INPUT_TOUCHSCREEN_PATH "/dev/input/event11"
|
||||||
const std::string& enablePath, int enableValue, short keyValue, const std::string& name,
|
|
||||||
const std::string& typeAsString, SensorType type)
|
#define GESTURE_PATH "/sys/class/touchscreen/primary/gesture"
|
||||||
|
|
||||||
|
InputEventDT2WSensor::InputEventDT2WSensor(
|
||||||
|
int32_t sensorHandle, ISensorsEventCallback* callback)
|
||||||
: OneShotSensor(sensorHandle, callback) {
|
: OneShotSensor(sensorHandle, callback) {
|
||||||
mSensorInfo.name = name;
|
mSensorInfo.name = "DT2W sensor";
|
||||||
mSensorInfo.type = type;
|
mSensorInfo.type = static_cast<SensorType>(static_cast<int32_t>(SensorType::DEVICE_PRIVATE_BASE) + 1);
|
||||||
mSensorInfo.typeAsString = typeAsString;
|
mSensorInfo.typeAsString = "org.lineageos.sensor.dt2w";
|
||||||
mSensorInfo.maxRange = 2048.0f;
|
mSensorInfo.maxRange = 2048.0f;
|
||||||
mSensorInfo.resolution = 1.0f;
|
mSensorInfo.resolution = 1.0f;
|
||||||
mSensorInfo.power = 0;
|
mSensorInfo.power = 0;
|
||||||
mSensorInfo.flags |= SensorFlagBits::WAKE_UP;
|
mSensorInfo.flags |= SensorFlagBits::WAKE_UP;
|
||||||
|
|
||||||
std::ofstream mGestureEnable;
|
std::ofstream mGestureEnable;
|
||||||
mGestureEnable.open(enablePath);
|
mGestureEnable.open(GESTURE_PATH);
|
||||||
|
|
||||||
if(!mGestureEnable) {
|
if(!mGestureEnable) {
|
||||||
ALOGE("could not open gesture path");
|
ALOGE("could not open gesture path");
|
||||||
@@ -248,7 +252,7 @@ InputEventOneShotSensor::InputEventOneShotSensor(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mGestureEnable << enableValue << std::flush;
|
mGestureEnable << "49" << std::flush;
|
||||||
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
@@ -259,7 +263,7 @@ InputEventOneShotSensor::InputEventOneShotSensor(
|
|||||||
ALOGE("failed to open wait pipe: %d", rc);
|
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) {
|
if (mPollFds[0] < 0) {
|
||||||
ALOGE("failed to open poll fd: %d", mPollFds[0]);
|
ALOGE("failed to open poll fd: %d", mPollFds[0]);
|
||||||
}
|
}
|
||||||
@@ -278,17 +282,15 @@ InputEventOneShotSensor::InputEventOneShotSensor(
|
|||||||
.fd = mPollFds[0],
|
.fd = mPollFds[0],
|
||||||
.events = POLLIN,
|
.events = POLLIN,
|
||||||
};
|
};
|
||||||
|
|
||||||
mKeyValue = keyValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InputEventOneShotSensor::~InputEventOneShotSensor() {
|
InputEventDT2WSensor::~InputEventDT2WSensor() {
|
||||||
interruptPoll();
|
interruptPoll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputEventOneShotSensor::activate(bool enable) {
|
void InputEventDT2WSensor::activate(bool enable) {
|
||||||
std::lock_guard<std::mutex> lock(mRunMutex);
|
std::lock_guard<std::mutex> lock(mRunMutex);
|
||||||
ALOGE("Activated for key %d", mKeyValue);
|
|
||||||
if (mIsEnabled != enable) {
|
if (mIsEnabled != enable) {
|
||||||
mIsEnabled = enable;
|
mIsEnabled = enable;
|
||||||
interruptPoll();
|
interruptPoll();
|
||||||
@@ -296,12 +298,12 @@ void InputEventOneShotSensor::activate(bool enable) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputEventOneShotSensor::setOperationMode(OperationMode mode) {
|
void InputEventDT2WSensor::setOperationMode(OperationMode mode) {
|
||||||
Sensor::setOperationMode(mode);
|
Sensor::setOperationMode(mode);
|
||||||
interruptPoll();
|
interruptPoll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputEventOneShotSensor::run() {
|
void InputEventDT2WSensor::run() {
|
||||||
std::unique_lock<std::mutex> runLock(mRunMutex);
|
std::unique_lock<std::mutex> runLock(mRunMutex);
|
||||||
|
|
||||||
while (!mStopThread) {
|
while (!mStopThread) {
|
||||||
@@ -324,7 +326,7 @@ void InputEventOneShotSensor::run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if((mPolls[1].revents == mPolls[1].events) && readEvent(mPolls[1].fd, &event)) {
|
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;
|
mIsEnabled = false;
|
||||||
mCallback->postEvents(readEvents(), isWakeUpSensor());
|
mCallback->postEvents(readEvents(), isWakeUpSensor());
|
||||||
}
|
}
|
||||||
@@ -335,25 +337,21 @@ void InputEventOneShotSensor::run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputEventOneShotSensor::interruptPoll() {
|
void InputEventDT2WSensor::interruptPoll() {
|
||||||
if (mWaitPipeFd[1] < 0) return;
|
if (mWaitPipeFd[1] < 0) return;
|
||||||
|
|
||||||
char c = '1';
|
char c = '1';
|
||||||
write(mWaitPipeFd[1], &c, sizeof(c));
|
write(mWaitPipeFd[1], &c, sizeof(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputEventOneShotSensor::fillEventData(Event& event) {
|
std::vector<Event> InputEventDT2WSensor::readEvents() {
|
||||||
event.u.data[0] = 0;
|
|
||||||
event.u.data[1] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<Event> InputEventOneShotSensor::readEvents() {
|
|
||||||
std::vector<Event> events;
|
std::vector<Event> events;
|
||||||
Event event;
|
Event event;
|
||||||
event.sensorHandle = mSensorInfo.sensorHandle;
|
event.sensorHandle = mSensorInfo.sensorHandle;
|
||||||
event.sensorType = mSensorInfo.type;
|
event.sensorType = mSensorInfo.type;
|
||||||
event.timestamp = ::android::elapsedRealtimeNano();
|
event.timestamp = ::android::elapsedRealtimeNano();
|
||||||
fillEventData(event);
|
event.u.data[0] = 0;
|
||||||
|
event.u.data[1] = 0;
|
||||||
events.push_back(event);
|
events.push_back(event);
|
||||||
return events;
|
return events;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <linux/input.h>
|
|
||||||
|
|
||||||
using ::android::hardware::sensors::V1_0::OperationMode;
|
using ::android::hardware::sensors::V1_0::OperationMode;
|
||||||
using ::android::hardware::sensors::V1_0::Result;
|
using ::android::hardware::sensors::V1_0::Result;
|
||||||
@@ -93,18 +92,14 @@ class OneShotSensor : public Sensor {
|
|||||||
virtual Result flush() override { return Result::BAD_VALUE; }
|
virtual Result flush() override { return Result::BAD_VALUE; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class InputEventOneShotSensor : public OneShotSensor {
|
class InputEventDT2WSensor : public OneShotSensor {
|
||||||
public:
|
public:
|
||||||
InputEventOneShotSensor(int32_t sensorHandle, ISensorsEventCallback* callback,
|
InputEventDT2WSensor(int32_t sensorHandle, ISensorsEventCallback* callback);
|
||||||
const std::string& pollPath, const std::string& enablePath,
|
virtual ~InputEventDT2WSensor() override;
|
||||||
int enableValue, short keyValue, const std::string& name,
|
|
||||||
const std::string& typeAsString, SensorType type);
|
|
||||||
virtual ~InputEventOneShotSensor() override;
|
|
||||||
|
|
||||||
virtual void activate(bool enable) override;
|
virtual void activate(bool enable) override;
|
||||||
virtual void setOperationMode(OperationMode mode) override;
|
virtual void setOperationMode(OperationMode mode) override;
|
||||||
virtual std::vector<Event> readEvents() override;
|
virtual std::vector<Event> readEvents() override;
|
||||||
virtual void fillEventData(Event& event);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void run() override;
|
virtual void run() override;
|
||||||
@@ -117,31 +112,6 @@ class InputEventOneShotSensor : public OneShotSensor {
|
|||||||
struct pollfd mPolls[2];
|
struct pollfd mPolls[2];
|
||||||
int mWaitPipeFd[2];
|
int mWaitPipeFd[2];
|
||||||
int mPollFds[1];
|
int mPollFds[1];
|
||||||
short mKeyValue;
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::string kDoubleTapInputEventPath = "/dev/input/event10";
|
|
||||||
const std::string kGestureEnablePath = "/sys/class/touchscreen/primary/gesture";
|
|
||||||
|
|
||||||
const int kEnableDt2w = 49;
|
|
||||||
const int kEnableFodPressed = 17;
|
|
||||||
|
|
||||||
class InputEventDT2WSensor : public InputEventOneShotSensor {
|
|
||||||
public:
|
|
||||||
InputEventDT2WSensor(int32_t sensorHandle, ISensorsEventCallback* callback)
|
|
||||||
: InputEventOneShotSensor(
|
|
||||||
sensorHandle, callback, kDoubleTapInputEventPath,
|
|
||||||
kGestureEnablePath, kEnableDt2w, KEY_F4, "DT2W sensor",
|
|
||||||
"org.lineageos.sensor.dt2w", static_cast<SensorType>(static_cast<int32_t>(SensorType::DEVICE_PRIVATE_BASE) + 1)) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
class InputEventUdfpsSensor : public InputEventOneShotSensor {
|
|
||||||
public:
|
|
||||||
InputEventUdfpsSensor(int32_t sensorHandle, ISensorsEventCallback* callback)
|
|
||||||
: InputEventOneShotSensor(
|
|
||||||
sensorHandle, callback, kDoubleTapInputEventPath,
|
|
||||||
kGestureEnablePath, kEnableFodPressed, KEY_F2, "UDFPS sensor",
|
|
||||||
"org.lineageos.sensor.udfps", static_cast<SensorType>(static_cast<int32_t>(SensorType::DEVICE_PRIVATE_BASE) + 2)) {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace implementation
|
} // namespace implementation
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ using ::android::hardware::sensors::V2_0::implementation::ScopedWakelock;
|
|||||||
|
|
||||||
SensorsSubHal::SensorsSubHal() : mCallback(nullptr), mNextHandle(1) {
|
SensorsSubHal::SensorsSubHal() : mCallback(nullptr), mNextHandle(1) {
|
||||||
AddSensor<InputEventDT2WSensor>();
|
AddSensor<InputEventDT2WSensor>();
|
||||||
AddSensor<InputEventUdfpsSensor>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Return<void> SensorsSubHal::getSensorsList_2_1(ISensors::getSensorsList_2_1_cb _hidl_cb) {
|
Return<void> SensorsSubHal::getSensorsList_2_1(ISensors::getSensorsList_2_1_cb _hidl_cb) {
|
||||||
|
|||||||
Reference in New Issue
Block a user