Sensor: expose sensor UUID to privileged clients
Allow privileged clients (system server and audio server)
to access the UUID of dynamic sensors.
For other clients, the UUID is replaced by the existing
obfuscated sensor ID.
Bug: 210803914
Test: make
Change-Id: I496ac59504da4e8d98310663c047cb3c0a2abad6
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp
index 9bc7b8e..517d383 100644
--- a/services/sensorservice/SensorService.cpp
+++ b/services/sensorservice/SensorService.cpp
@@ -1254,6 +1254,11 @@
for (auto &sensor : sensorList) {
int32_t id = getIdFromUuid(sensor.getUuid());
sensor.setId(id);
+ // The sensor UUID must always be anonymized here for non privileged clients.
+ // There is no other checks after this point before returning to client process.
+ if (!isAudioServerOrSystemServerUid(IPCThreadState::self()->getCallingUid())) {
+ sensor.anonymizeUuid();
+ }
}
}
diff --git a/services/sensorservice/SensorService.h b/services/sensorservice/SensorService.h
index 9b6d01a..b009829 100644
--- a/services/sensorservice/SensorService.h
+++ b/services/sensorservice/SensorService.h
@@ -26,6 +26,7 @@
#include <binder/IUidObserver.h>
#include <cutils/compiler.h>
#include <cutils/multiuser.h>
+#include <private/android_filesystem_config.h>
#include <sensor/ISensorServer.h>
#include <sensor/ISensorEventConnection.h>
#include <sensor/Sensor.h>
@@ -447,6 +448,10 @@
// Removes the capped rate on active direct connections (when the mic toggle is flipped to off)
void uncapRates(userid_t userId);
+ static inline bool isAudioServerOrSystemServerUid(uid_t uid) {
+ return multiuser_get_app_id(uid) == AID_SYSTEM || uid == AID_AUDIOSERVER;
+ }
+
static uint8_t sHmacGlobalKey[128];
static bool sHmacGlobalKeyIsValid;