Add a retry mechanism to potentially allow recovery from HIDL failures.
Retry a few times to see if HIDL failures persist.
Add some logging to track failures.
Bug: 36088202
Test: Ensure sensors stream normally after change.
Change-Id: I194eaffd455ba782fff041f03ef89da384e3a901
diff --git a/services/sensorservice/SensorDevice.h b/services/sensorservice/SensorDevice.h
index 03552f6..410531b 100644
--- a/services/sensorservice/SensorDevice.h
+++ b/services/sensorservice/SensorDevice.h
@@ -31,6 +31,8 @@
#include "android/hardware/sensors/1.0/ISensors.h"
+#include "RingBuffer.h"
+
// ---------------------------------------------------------------------------
namespace android {
@@ -41,6 +43,33 @@
class SensorDevice : public Singleton<SensorDevice>, public Dumpable {
public:
+
+ class HidlTransportErrorLog {
+ public:
+
+ HidlTransportErrorLog() {
+ mTs = 0;
+ mCount = 0;
+ }
+
+ HidlTransportErrorLog(time_t ts, int count) {
+ mTs = ts;
+ mCount = count;
+ }
+
+ String8 toString() const {
+ String8 result;
+ struct tm *timeInfo = localtime(&mTs);
+ result.appendFormat("%02d:%02d:%02d :: %d", timeInfo->tm_hour, timeInfo->tm_min,
+ timeInfo->tm_sec, mCount);
+ return result;
+ }
+
+ private:
+ time_t mTs; // timestamp of the error
+ int mCount; // number of transport errors observed
+ };
+
ssize_t getSensorList(sensor_t const** list);
void handleDynamicSensorConnection(int handle, bool connected);
@@ -125,6 +154,10 @@
};
DefaultKeyedVector<int, Info> mActivationCount;
+ // Keep track of any hidl transport failures
+ SensorServiceUtil::RingBuffer<HidlTransportErrorLog> mHidlTransportErrors;
+ int mTotalHidlTransportErrors;
+
// Use this vector to determine which client is activated or deactivated.
SortedVector<void *> mDisabledClients;
SensorDevice();