sm8350-common: sensors: standardize xiaomi pickup sensor
* use standard sensor type * ignore non-wakeup sensor variant * ignore events that do not properly match a pickup
This commit is contained in:
parent
b6d092bc8b
commit
b7bca78611
@ -81,6 +81,25 @@ int64_t msFromNs(int64_t nanos) {
|
||||
return nanos / nanosecondsInAMillsecond;
|
||||
}
|
||||
|
||||
bool patchXiaomiPickupSensor(V2_1::SensorInfo& sensor) {
|
||||
if (sensor.typeAsString != "xiaomi.sensor.pickup") {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Implement only the wake-up version of this sensor.
|
||||
*/
|
||||
if (!(sensor.flags & V1_0::SensorFlagBits::WAKE_UP)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
sensor.type = V2_1::SensorType::PICK_UP_GESTURE;
|
||||
sensor.typeAsString = SENSOR_STRING_TYPE_PICK_UP_GESTURE;
|
||||
sensor.maxRange = 1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
HalProxy::HalProxy() {
|
||||
const char* kMultiHalConfigFile = "/vendor/etc/sensors/hals.conf";
|
||||
initializeSubHalListFromConfigFile(kMultiHalConfigFile);
|
||||
@ -480,6 +499,11 @@ void HalProxy::initializeSensorList() {
|
||||
ALOGV("Loaded sensor: %s", sensor.name.c_str());
|
||||
sensor.sensorHandle = setSubHalIndex(sensor.sensorHandle, subHalIndex);
|
||||
setDirectChannelFlags(&sensor, mSubHalList[subHalIndex]);
|
||||
bool keep = patchXiaomiPickupSensor(sensor);
|
||||
if (!keep) {
|
||||
continue;
|
||||
}
|
||||
|
||||
mSensors[sensor.sensorHandle] = sensor;
|
||||
}
|
||||
}
|
||||
|
@ -68,11 +68,17 @@ std::vector<V2_1::Event> HalProxyCallbackBase::processEvents(const std::vector<V
|
||||
std::vector<V2_1::Event> eventsOut;
|
||||
for (V2_1::Event event : events) {
|
||||
event.sensorHandle = setSubHalIndex(event.sensorHandle, mSubHalIndex);
|
||||
eventsOut.push_back(event);
|
||||
const V2_1::SensorInfo& sensor = mCallback->getSensorInfo(event.sensorHandle);
|
||||
|
||||
if (sensor.type == V2_1::SensorType::PICK_UP_GESTURE
|
||||
&& event.u.scalar != 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((sensor.flags & V1_0::SensorFlagBits::WAKE_UP) != 0) {
|
||||
(*numWakeupEvents)++;
|
||||
}
|
||||
eventsOut.push_back(event);
|
||||
}
|
||||
return eventsOut;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user