summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Arthur Ishiguro <arthuri@google.com> 2021-12-26 18:40:16 +0000
committer Arthur Ishiguro <arthuri@google.com> 2021-12-26 18:40:56 +0000
commit39e04c65ded1c43bbe0e39325bde03db21428619 (patch)
tree15321631261371d534f81c69f541fb980ce16d74
parentffef668d287be9691ec6082f532c02439a9e3204 (diff)
Reorganize sensors resolution logic
Bug: 195593357 Test: Load on device Change-Id: Iad2642ad06bbe315332d47abb1ee4f8108d8ef58
-rw-r--r--services/sensorservice/HidlSensorHalWrapper.cpp21
-rw-r--r--services/sensorservice/HidlSensorHalWrapper.h3
-rw-r--r--services/sensorservice/SensorDevice.cpp8
3 files changed, 8 insertions, 24 deletions
diff --git a/services/sensorservice/HidlSensorHalWrapper.cpp b/services/sensorservice/HidlSensorHalWrapper.cpp
index a488eab3d5..31652adaa5 100644
--- a/services/sensorservice/HidlSensorHalWrapper.cpp
+++ b/services/sensorservice/HidlSensorHalWrapper.cpp
@@ -216,9 +216,6 @@ ssize_t HidlSensorHalWrapper::pollFmq(sensors_event_t* buffer, size_t maxNumEven
for (size_t i = 0; i < eventsToRead; i++) {
convertToSensorEvent(mEventBuffer[i], &buffer[i]);
- android::SensorDeviceUtils::quantizeSensorEventValues(&buffer[i],
- getResolutionForSensor(
- buffer[i].sensor));
}
eventsRead = eventsToRead;
} else {
@@ -538,25 +535,7 @@ void HidlSensorHalWrapper::convertToSensorEventsAndQuantize(
for (size_t i = 0; i < src.size(); ++i) {
android::hardware::sensors::V2_1::implementation::convertToSensorEvent(src[i], &dst[i]);
- android::SensorDeviceUtils::quantizeSensorEventValues(&dst[i],
- getResolutionForSensor(
- dst[i].sensor));
}
}
-float HidlSensorHalWrapper::getResolutionForSensor(int sensorHandle) {
- for (size_t i = 0; i < mSensorList.size(); i++) {
- if (sensorHandle == mSensorList[i].handle) {
- return mSensorList[i].resolution;
- }
- }
-
- auto it = mConnectedDynamicSensors.find(sensorHandle);
- if (it != mConnectedDynamicSensors.end()) {
- return it->second.resolution;
- }
-
- return 0;
-}
-
} // namespace android
diff --git a/services/sensorservice/HidlSensorHalWrapper.h b/services/sensorservice/HidlSensorHalWrapper.h
index 030247fc12..2a3a4f4bae 100644
--- a/services/sensorservice/HidlSensorHalWrapper.h
+++ b/services/sensorservice/HidlSensorHalWrapper.h
@@ -124,7 +124,6 @@ public:
private:
sp<::android::hardware::sensors::V2_1::implementation::ISensorsWrapperBase> mSensors;
sp<::android::hardware::sensors::V2_1::ISensorsCallback> mCallback;
- std::vector<sensor_t> mSensorList;
std::unordered_map<int32_t, sensor_t> mConnectedDynamicSensors;
std::mutex mDynamicSensorsMutex;
@@ -167,8 +166,6 @@ private:
typedef hardware::MessageQueue<uint32_t, hardware::kSynchronizedReadWrite> WakeLockQueue;
std::unique_ptr<WakeLockQueue> mWakeLockQueue;
- float getResolutionForSensor(int sensorHandle);
-
hardware::EventFlag* mEventQueueFlag;
hardware::EventFlag* mWakeLockQueueFlag;
diff --git a/services/sensorservice/SensorDevice.cpp b/services/sensorservice/SensorDevice.cpp
index 84a1076b14..ee63735921 100644
--- a/services/sensorservice/SensorDevice.cpp
+++ b/services/sensorservice/SensorDevice.cpp
@@ -349,6 +349,14 @@ ssize_t SensorDevice::poll(sensors_event_t* buffer, size_t count) {
ALOGE("Must support polling or FMQ");
eventsRead = -1;
}
+
+ if (eventsRead > 0) {
+ for (ssize_t i = 0; i < eventsRead; i++) {
+ float resolution = getResolutionForSensor(buffer[i].sensor);
+ android::SensorDeviceUtils::quantizeSensorEventValues(&buffer[i], resolution);
+ }
+ }
+
return eventsRead;
}