sensors: Implement udfps long press sensor
Change-Id: I49773535f47c538b1ff210245109dd63c18d32cb
This commit is contained in:
parent
b5ae2b09f2
commit
4b8b52d599
@ -361,6 +361,40 @@ bool SysfsPollingOneShotSensor::readFd(const int fd) {
|
|||||||
return readBool(fd, true /* seek */);
|
return readBool(fd, true /* seek */);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UdfpsSensor::fillEventData(Event& event) {
|
||||||
|
event.u.data[0] = mScreenX;
|
||||||
|
event.u.data[1] = mScreenY;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UdfpsSensor::readFd(const int fd) {
|
||||||
|
char buffer[512];
|
||||||
|
int state = 0;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = lseek(fd, 0, SEEK_SET);
|
||||||
|
if (rc < 0) {
|
||||||
|
ALOGE("failed to seek: %d", rc);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
rc = read(fd, &buffer, sizeof(buffer));
|
||||||
|
if (rc < 0) {
|
||||||
|
ALOGE("failed to read state: %d", rc);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
rc = sscanf(buffer, "%d,%d,%d", &mScreenX, &mScreenY, &state);
|
||||||
|
if (rc == 1) {
|
||||||
|
// If fod_press_status contains only one value,
|
||||||
|
// assume that just reports the state
|
||||||
|
state = mScreenX;
|
||||||
|
mScreenX = 0;
|
||||||
|
mScreenY = 0;
|
||||||
|
} else if (rc < 3) {
|
||||||
|
ALOGE("failed to parse fp state: %d", rc);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return state > 0;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace implementation
|
} // namespace implementation
|
||||||
} // namespace subhal
|
} // namespace subhal
|
||||||
} // namespace V2_1
|
} // namespace V2_1
|
||||||
|
@ -143,6 +143,23 @@ class SingleTapSensor : public SysfsPollingOneShotSensor {
|
|||||||
2)) {}
|
2)) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class UdfpsSensor : public SysfsPollingOneShotSensor {
|
||||||
|
public:
|
||||||
|
UdfpsSensor(int32_t sensorHandle, ISensorsEventCallback* callback)
|
||||||
|
: SysfsPollingOneShotSensor(
|
||||||
|
sensorHandle, callback, "/sys/class/touch/touch_dev/fod_press_status",
|
||||||
|
"/sys/class/touch/touch_dev/fod_longpress_gesture_enabled", "UDFPS Sensor",
|
||||||
|
"org.lineageos.sensor.udfps",
|
||||||
|
static_cast<SensorType>(static_cast<int32_t>(SensorType::DEVICE_PRIVATE_BASE) +
|
||||||
|
3)) {}
|
||||||
|
virtual void fillEventData(Event& event);
|
||||||
|
virtual bool readFd(const int fd);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int mScreenX;
|
||||||
|
int mScreenY;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace implementation
|
} // namespace implementation
|
||||||
} // namespace subhal
|
} // namespace subhal
|
||||||
} // namespace V2_1
|
} // namespace V2_1
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "SensorsSubHal.h"
|
#include "SensorsSubHal.h"
|
||||||
|
|
||||||
#include <android/hardware/sensors/2.1/types.h>
|
#include <android/hardware/sensors/2.1/types.h>
|
||||||
|
#include <cutils/properties.h>
|
||||||
#include <log/log.h>
|
#include <log/log.h>
|
||||||
|
|
||||||
using ::android::hardware::sensors::V2_1::implementation::ISensorsSubHal;
|
using ::android::hardware::sensors::V2_1::implementation::ISensorsSubHal;
|
||||||
@ -39,6 +40,9 @@ SensorsSubHal::SensorsSubHal() : mCallback(nullptr), mNextHandle(1) {
|
|||||||
if (property_get_bool("ro.vendor.sensors.xiaomi.single_tap", false)) {
|
if (property_get_bool("ro.vendor.sensors.xiaomi.single_tap", false)) {
|
||||||
AddSensor<SingleTapSensor>();
|
AddSensor<SingleTapSensor>();
|
||||||
}
|
}
|
||||||
|
if (property_get_bool("ro.vendor.sensors.xiaomi.udfps", false)) {
|
||||||
|
AddSensor<UdfpsSensor>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user