1
0
mirror of https://github.com/yurisieucuti/treble_evolution.git synced 2024-11-24 10:56:22 +00:00
treble_evolution/patches/trebledroid/platform_hardware_interfaces/0002-Fix-light-sensor-crash-on-Xiaomi-13.patch
2024-03-10 06:48:11 +00:00

37 lines
1.5 KiB
Diff

From 5fcd965b22998e72d7cc8100bdf5be657cf91ba0 Mon Sep 17 00:00:00 2001
From: Andy CrossGate Yan <GeForce8800Ultra@gmail.com>
Date: Tue, 18 Apr 2023 23:48:15 +0000
Subject: [PATCH 2/3] Fix light sensor crash on Xiaomi 13
SensorService expects a scalar, but Xiaomi HAL returns a pose6DOF vector encapsulation
Thanks @phhusson for the analysis
Change-Id: Ie358321d5328d01541f455d6af86944ff413c9c9
---
sensors/aidl/convert/convert.cpp | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/sensors/aidl/convert/convert.cpp b/sensors/aidl/convert/convert.cpp
index 2dc7a177a..be3833dfa 100644
--- a/sensors/aidl/convert/convert.cpp
+++ b/sensors/aidl/convert/convert.cpp
@@ -162,7 +162,14 @@ void convertToSensorEvent(const Event& src, sensors_event_t* dst) {
case SensorType::MOTION_DETECT:
case SensorType::HEART_BEAT:
case SensorType::LOW_LATENCY_OFFBODY_DETECT: {
- dst->data[0] = src.payload.get<Event::EventPayload::scalar>();
+ if (src.payload.getTag() == Event::EventPayload::pose6DOF) {
+ auto d = src.payload.get<Event::EventPayload::pose6DOF>();
+ auto dstr = ::android::internal::ToString(d);
+ // ALOGE("Received 6DOF for expected scalar %s", dstr.c_str());
+ dst->data[0] = d.values[0];
+ } else {
+ dst->data[0] = src.payload.get<Event::EventPayload::scalar>();
+ }
break;
}
--
2.25.1