mirror of
https://github.com/Evolution-X-Devices/device_motorola_rtwo
synced 2026-01-27 18:07:35 +00:00
Revert "eqs: sensors: Create input event polling one shot sensor"
This reverts commit 19f1c1d6f0.
This commit is contained in:
@@ -53,6 +53,11 @@ endif
|
|||||||
BOARD_MOT_DP_GROUP_SIZE := 11806965760 # ( BOARD_SUPER_PARTITION_SIZE - 4MB )
|
BOARD_MOT_DP_GROUP_SIZE := 11806965760 # ( BOARD_SUPER_PARTITION_SIZE - 4MB )
|
||||||
BOARD_SUPER_PARTITION_SIZE := 11811160064
|
BOARD_SUPER_PARTITION_SIZE := 11811160064
|
||||||
|
|
||||||
|
# Power
|
||||||
|
TARGET_TAP_TO_WAKE_NODE := "/sys/class/touchscreen/primary/gesture"
|
||||||
|
TARGET_TAP_TO_WAKE_NODE_ENABLE := "49"
|
||||||
|
TARGET_TAP_TO_WAKE_NODE_DISABLE := "48"
|
||||||
|
|
||||||
# Properties
|
# Properties
|
||||||
TARGET_PRODUCT_PROP += $(DEVICE_PATH)/product.prop
|
TARGET_PRODUCT_PROP += $(DEVICE_PATH)/product.prop
|
||||||
TARGET_SYSTEM_PROP += $(DEVICE_PATH)/system.prop
|
TARGET_SYSTEM_PROP += $(DEVICE_PATH)/system.prop
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ PRODUCT_PACKAGES += \
|
|||||||
|
|
||||||
# Sensors
|
# Sensors
|
||||||
PRODUCT_PACKAGES += \
|
PRODUCT_PACKAGES += \
|
||||||
sensors.eqs
|
sensors.dubai
|
||||||
|
|
||||||
PRODUCT_COPY_FILES += \
|
PRODUCT_COPY_FILES += \
|
||||||
$(LOCAL_PATH)/sensors/android.hardware.sensors@2.1-service-multihal.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/android.hardware.sensors@2.1-service-multihal.rc \
|
$(LOCAL_PATH)/sensors/android.hardware.sensors@2.1-service-multihal.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/android.hardware.sensors@2.1-service-multihal.rc \
|
||||||
|
|||||||
@@ -276,6 +276,6 @@
|
|||||||
<!-- How long it takes for the HW to start illuminating after the illumination is requested. -->
|
<!-- How long it takes for the HW to start illuminating after the illumination is requested. -->
|
||||||
<integer name="config_udfps_illumination_transition_ms">32</integer>
|
<integer name="config_udfps_illumination_transition_ms">32</integer>
|
||||||
|
|
||||||
<!-- Type of the double tap sensor. Empty if double tap is not supported. -->
|
<!-- Whether device supports double tap to wake -->
|
||||||
<string name="config_dozeDoubleTapSensorType" translatable="false">org.lineageos.sensor.dt2w</string>
|
<bool name="config_supportDoubleTapWake">true</bool>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
cc_library_shared {
|
cc_library_shared {
|
||||||
name: "sensors.eqs",
|
name: "sensors.dubai",
|
||||||
defaults: ["hidl_defaults"],
|
defaults: ["hidl_defaults"],
|
||||||
srcs: [
|
srcs: [
|
||||||
"Sensor.cpp",
|
"Sensor.cpp",
|
||||||
@@ -16,7 +16,6 @@ cc_library_shared {
|
|||||||
"android.hardware.sensors@2.0",
|
"android.hardware.sensors@2.0",
|
||||||
"android.hardware.sensors@2.0-ScopedWakelock",
|
"android.hardware.sensors@2.0-ScopedWakelock",
|
||||||
"android.hardware.sensors@2.1",
|
"android.hardware.sensors@2.1",
|
||||||
"libc",
|
|
||||||
"libcutils",
|
"libcutils",
|
||||||
"libfmq",
|
"libfmq",
|
||||||
"libhardware",
|
"libhardware",
|
||||||
@@ -30,7 +29,7 @@ cc_library_shared {
|
|||||||
"android.hardware.sensors@2.X-multihal",
|
"android.hardware.sensors@2.X-multihal",
|
||||||
],
|
],
|
||||||
cflags: [
|
cflags: [
|
||||||
"-DLOG_TAG=\"sensors.eqs\"",
|
"-DLOG_TAG=\"sensors.dubai\"",
|
||||||
],
|
],
|
||||||
vendor: true,
|
vendor: true,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,44 +17,9 @@
|
|||||||
#include "Sensor.h"
|
#include "Sensor.h"
|
||||||
|
|
||||||
#include <hardware/sensors.h>
|
#include <hardware/sensors.h>
|
||||||
#include <log/log.h>
|
|
||||||
#include <utils/SystemClock.h>
|
#include <utils/SystemClock.h>
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <linux/input.h>
|
|
||||||
|
|
||||||
static bool readEvent(int fd, struct input_event *event) {
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
rc = read(fd, event, sizeof(struct input_event));
|
|
||||||
if (rc != sizeof(struct input_event)) {
|
|
||||||
ALOGE("failed to read event from fd, err: %d", rc);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool readBool(int fd, bool seek) {
|
|
||||||
char c;
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
if (seek) {
|
|
||||||
rc = lseek(fd, 0, SEEK_SET);
|
|
||||||
if (rc) {
|
|
||||||
ALOGE("failed to seek: %d", rc);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = read(fd, &c, sizeof(c));
|
|
||||||
if (rc != 1) {
|
|
||||||
ALOGE("failed to read bool: %d", rc);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return c != '0';
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
namespace hardware {
|
namespace hardware {
|
||||||
@@ -226,171 +191,6 @@ OneShotSensor::OneShotSensor(int32_t sensorHandle, ISensorsEventCallback* callba
|
|||||||
mSensorInfo.flags |= SensorFlagBits::ONE_SHOT_MODE;
|
mSensorInfo.flags |= SensorFlagBits::ONE_SHOT_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#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 = "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(GESTURE_PATH);
|
|
||||||
|
|
||||||
if(!mGestureEnable) {
|
|
||||||
ALOGE("could not open gesture path");
|
|
||||||
mStopThread = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mGestureEnable << "49" << std::flush;
|
|
||||||
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
rc = pipe(mWaitPipeFd);
|
|
||||||
if (rc < 0) {
|
|
||||||
mWaitPipeFd[0] = -1;
|
|
||||||
mWaitPipeFd[1] = -1;
|
|
||||||
ALOGE("failed to open wait pipe: %d", rc);
|
|
||||||
}
|
|
||||||
|
|
||||||
mPollFds[0] = open(INPUT_DT2W_SENSOR_PATH, O_RDONLY | O_NONBLOCK);
|
|
||||||
if (mPollFds[0] < 0) {
|
|
||||||
ALOGE("failed to open poll fd: %d", mPollFds[0]);
|
|
||||||
}
|
|
||||||
mPollFds[1] = open(INPUT_TOUCHSCREEN_PATH, O_RDONLY | O_NONBLOCK);
|
|
||||||
if (mPollFds[1] < 0) {
|
|
||||||
ALOGE("failed to open poll fd: %d", mPollFds[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mWaitPipeFd[0] < 0 || mWaitPipeFd[1] < 0 || mPollFds[0] < 0 || mPollFds[1] < 0) {
|
|
||||||
mStopThread = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mPolls[0] = {
|
|
||||||
.fd = mWaitPipeFd[0],
|
|
||||||
.events = POLLIN,
|
|
||||||
};
|
|
||||||
|
|
||||||
mPolls[1] = {
|
|
||||||
.fd = mPollFds[0],
|
|
||||||
.events = POLLIN,
|
|
||||||
};
|
|
||||||
|
|
||||||
mPolls[2] = {
|
|
||||||
.fd = mPollFds[1],
|
|
||||||
.events = POLLIN,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
InputEventDT2WSensor::~InputEventDT2WSensor() {
|
|
||||||
interruptPoll();
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputEventDT2WSensor::activate(bool enable) {
|
|
||||||
std::lock_guard<std::mutex> lock(mRunMutex);
|
|
||||||
|
|
||||||
if (mIsEnabled != enable) {
|
|
||||||
mIsEnabled = enable;
|
|
||||||
|
|
||||||
interruptPoll();
|
|
||||||
mWaitCV.notify_all();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputEventDT2WSensor::setOperationMode(OperationMode mode) {
|
|
||||||
Sensor::setOperationMode(mode);
|
|
||||||
interruptPoll();
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputEventDT2WSensor::run() {
|
|
||||||
std::unique_lock<std::mutex> runLock(mRunMutex);
|
|
||||||
|
|
||||||
long old_time = 0;
|
|
||||||
long new_time = 0;
|
|
||||||
|
|
||||||
int old_x = 0;
|
|
||||||
int new_x = 0;
|
|
||||||
int old_y = 0;
|
|
||||||
int new_y = 0;
|
|
||||||
|
|
||||||
while (!mStopThread) {
|
|
||||||
if (!mIsEnabled || mMode == OperationMode::DATA_INJECTION) {
|
|
||||||
mWaitCV.wait(runLock, [&] {
|
|
||||||
return ((mIsEnabled && mMode == OperationMode::NORMAL) || mStopThread);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// Cannot hold lock while polling.
|
|
||||||
runLock.unlock();
|
|
||||||
int rc = poll(mPolls, 3, -1);
|
|
||||||
runLock.lock();
|
|
||||||
|
|
||||||
struct input_event event;
|
|
||||||
|
|
||||||
if (rc < 0) {
|
|
||||||
ALOGE("failed to poll: %d", rc);
|
|
||||||
mStopThread = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if((mPolls[1].revents == mPolls[1].events) && readEvent(mPolls[1].fd, &event)) {
|
|
||||||
if(event.type == EV_KEY && event.value == 1 && event.code == KEY_F4) {
|
|
||||||
mIsEnabled = false;
|
|
||||||
mCallback->postEvents(readEvents(), isWakeUpSensor());
|
|
||||||
}
|
|
||||||
} else if((mPolls[2].revents == mPolls[2].events) && readEvent(mPolls[2].fd, &event)) {
|
|
||||||
if(event.type == EV_KEY && event.value == 1) { // Touchscreen down/up
|
|
||||||
old_time = new_time;
|
|
||||||
new_time = event.time.tv_sec * 1000000 + event.time.tv_usec;
|
|
||||||
if((new_time - old_time < 200000) && // 200ms
|
|
||||||
(abs(sqrt(pow(old_x, 2) + pow(old_y, 2)) - sqrt(pow(new_x, 2) + pow(new_y, 2))) < 500)) {
|
|
||||||
mIsEnabled = false;
|
|
||||||
mCallback->postEvents(readEvents(), isWakeUpSensor());
|
|
||||||
}
|
|
||||||
} else if(event.type == EV_ABS) { // send order: touch pos x -> touch y -> down/up
|
|
||||||
if(event.code == ABS_MT_POSITION_X) {
|
|
||||||
old_x = new_x;
|
|
||||||
new_x = event.value;
|
|
||||||
} else if (event.code == ABS_MT_POSITION_Y) {
|
|
||||||
old_y = new_y;
|
|
||||||
new_y = event.value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (mPolls[0].revents == mPolls[0].events) {
|
|
||||||
readBool(mWaitPipeFd[0], false /* seek */);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputEventDT2WSensor::interruptPoll() {
|
|
||||||
if (mWaitPipeFd[1] < 0) return;
|
|
||||||
|
|
||||||
char c = '1';
|
|
||||||
write(mWaitPipeFd[1], &c, sizeof(c));
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<Event> InputEventDT2WSensor::readEvents() {
|
|
||||||
std::vector<Event> events;
|
|
||||||
Event event;
|
|
||||||
event.sensorHandle = mSensorInfo.sensorHandle;
|
|
||||||
event.sensorType = mSensorInfo.type;
|
|
||||||
event.timestamp = ::android::elapsedRealtimeNano();
|
|
||||||
event.u.data[0] = 0;
|
|
||||||
event.u.data[1] = 0;
|
|
||||||
events.push_back(event);
|
|
||||||
return events;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace implementation
|
} // namespace implementation
|
||||||
} // namespace subhal
|
} // namespace subhal
|
||||||
} // namespace V2_1
|
} // namespace V2_1
|
||||||
|
|||||||
@@ -17,12 +17,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <android/hardware/sensors/2.1/types.h>
|
#include <android/hardware/sensors/2.1/types.h>
|
||||||
#include <fcntl.h>
|
|
||||||
#include <poll.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <fstream>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
@@ -92,31 +88,6 @@ class OneShotSensor : public Sensor {
|
|||||||
virtual Result flush() override { return Result::BAD_VALUE; }
|
virtual Result flush() override { return Result::BAD_VALUE; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class InputEventDT2WSensor : public OneShotSensor {
|
|
||||||
public:
|
|
||||||
InputEventDT2WSensor(int32_t sensorHandle, ISensorsEventCallback* callback);
|
|
||||||
virtual ~InputEventDT2WSensor() 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 mGestureEnable;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void interruptPoll();
|
|
||||||
|
|
||||||
struct pollfd mPolls[3];
|
|
||||||
int mWaitPipeFd[2];
|
|
||||||
int mPollFds[2];
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace implementation
|
} // namespace implementation
|
||||||
} // namespace subhal
|
} // namespace subhal
|
||||||
} // namespace V2_1
|
} // namespace V2_1
|
||||||
|
|||||||
@@ -32,9 +32,7 @@ namespace implementation {
|
|||||||
using ::android::hardware::Void;
|
using ::android::hardware::Void;
|
||||||
using ::android::hardware::sensors::V2_0::implementation::ScopedWakelock;
|
using ::android::hardware::sensors::V2_0::implementation::ScopedWakelock;
|
||||||
|
|
||||||
SensorsSubHal::SensorsSubHal() : mCallback(nullptr), mNextHandle(1) {
|
SensorsSubHal::SensorsSubHal() : mCallback(nullptr), mNextHandle(1) {}
|
||||||
AddSensor<InputEventDT2WSensor>();
|
|
||||||
}
|
|
||||||
|
|
||||||
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) {
|
||||||
std::vector<SensorInfo> sensors;
|
std::vector<SensorInfo> sensors;
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
sensors.ssc.so
|
sensors.ssc.so
|
||||||
sensors.moto.so
|
sensors.moto.so
|
||||||
sensors.eqs.so
|
sensors.dubai.so
|
||||||
|
|||||||
Reference in New Issue
Block a user