Add HAL Bypass Data Injection mode to Sensor Service
Add a new mode, HAL_BYPASS_REPLAY_DATA_INJECTION, which behaves similar
to Replay Data Injection with the difference that injected sensor data
is not injected into the HAL but simply passed back up to clients in
the platform.
Also, while I was in there, hook up the remaining bits and bobs to get
Replay Data Injection working and accessible from APIs in
SystemSensorManager in the platform.
Bug: 287257057
Test: manual
Change-Id: I9fc33a8bf5b67c02483089f849ba7ff0346d8097
(cherry picked from commit b0df44e2a6a40fb70a6e98a1e4e629945995a5f6)
diff --git a/services/sensorservice/SensorService.h b/services/sensorservice/SensorService.h
index bf43101..b643f6b 100644
--- a/services/sensorservice/SensorService.h
+++ b/services/sensorservice/SensorService.h
@@ -122,6 +122,11 @@
// delivered to all requesting apps rather than just the package allowed to inject data.
// This mode is only allowed to be used on development builds.
REPLAY_DATA_INJECTION = 3,
+ // Like REPLAY_DATA_INJECTION but injected data is not sent into the HAL. It is stored in a
+ // buffer in SensorDevice and played back to SensorService when SensorDevice::poll() is
+ // called. This is useful for playing back sensor data on the platform without relying on
+ // the HAL to support data injection.
+ HAL_BYPASS_REPLAY_DATA_INJECTION = 4,
// State Transitions supported.
// RESTRICTED <--- NORMAL ---> DATA_INJECTION/REPLAY_DATA_INJECTION
@@ -389,6 +394,8 @@
const String8& packageName,
int requestedMode, const String16& opPackageName, const String16& attributionTag);
virtual int isDataInjectionEnabled();
+ virtual int isReplayDataInjectionEnabled();
+ virtual int isHalBypassReplayDataInjectionEnabled();
virtual sp<ISensorEventConnection> createSensorDirectConnection(const String16& opPackageName,
int deviceId, uint32_t size, int32_t type, int32_t format,
const native_handle *resource);
@@ -507,6 +514,8 @@
// Removes the capped rate on active direct connections (when the mic toggle is flipped to off)
void uncapRates();
+ bool isInjectionMode(int mode);
+
static inline bool isAudioServerOrSystemServerUid(uid_t uid) {
return multiuser_get_app_id(uid) == AID_SYSTEM || uid == AID_AUDIOSERVER;
}