Merge "[dynamic_sensor] correctly interpret HID data" am: dcbe8650b6 am: 69f047a046 am: 28bb4526f9 am: 9a2c8265c6

Original change: https://android-review.googlesource.com/c/platform/hardware/libhardware/+/2213197

Change-Id: I17592fb7e35a0fafc80ef668cbeac837c02b8b08
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot 2022-09-09 22:01:42 +00:00 committed by Automerger Merge Worker
commit 97675c486a
2 changed files with 8 additions and 3 deletions

View file

@ -1066,7 +1066,10 @@ bool HidRawSensor::getHeadTrackerEventData(const std::vector<uint8_t> &message,
bool HidRawSensor::getSensorEventData(const std::vector<uint8_t> &message,
sensors_event_t *event) {
for (const auto &rec : mTranslateTable) {
int64_t v = (message[rec.byteOffset + rec.byteSize - 1] & 0x80) ? -1 : 0;
int64_t v = 0;
if (rec.minValue < 0) {
v = (message[rec.byteOffset + rec.byteSize - 1] & 0x80) ? -1 : 0;
}
for (int i = static_cast<int>(rec.byteSize) - 1; i >= 0; --i) {
v = (v << 8) | message[rec.byteOffset + i]; // HID is little endian
}

View file

@ -154,9 +154,11 @@ private:
bool getReportFieldValue(const std::vector<uint8_t> &message,
ReportTranslateRecord* rec, ValueType* value) {
bool valid = true;
int64_t v;
int64_t v = 0;
if (rec->minValue < 0) {
v = (message[rec->byteOffset + rec->byteSize - 1] & 0x80) ? -1 : 0;
}
v = (message[rec->byteOffset + rec->byteSize - 1] & 0x80) ? -1 : 0;
for (int i = static_cast<int>(rec->byteSize) - 1; i >= 0; --i) {
v = (v << 8) | message[rec->byteOffset + i]; // HID is little endian
}