SensorService fixes.
i) Add more debug stats (acks needed, acks received)
ii) Comment out write failure message.
Change-Id: Iac892a66530849a2dd023d6f5628cd070a79537d
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp
index bee5062..84d3b0f 100644
--- a/services/sensorservice/SensorService.cpp
+++ b/services/sensorservice/SensorService.cpp
@@ -924,6 +924,7 @@
}
#if DEBUG_CONNECTIONS
mEventsReceived = mEventsSentFromCache = mEventsSent = 0;
+ mTotalAcksNeeded = mTotalAcksReceived = 0;
#endif
}
@@ -960,12 +961,15 @@
mCacheSize,
mMaxCacheSize);
#if DEBUG_CONNECTIONS
- result.appendFormat("\t events recvd: %d | sent %d | cache %d | dropped %d\n",
+ result.appendFormat("\t events recvd: %d | sent %d | cache %d | dropped %d |"
+ " total_acks_needed %d | total_acks_recvd %d\n",
mEventsReceived,
mEventsSent,
mEventsSentFromCache,
- mEventsReceived - (mEventsSentFromCache
- mEventsSent + mCacheSize));
+ mEventsReceived - (mEventsSentFromCache +
+ mEventsSent + mCacheSize),
+ mTotalAcksNeeded,
+ mTotalAcksReceived);
#endif
}
@@ -1125,6 +1129,9 @@
if (index_wake_up_event >= 0) {
scratch[index_wake_up_event].flags |= WAKE_UP_SENSOR_EVENT_NEEDS_ACK;
++mWakeLockRefCount;
+#if DEBUG_CONNECTIONS
+ ++mTotalAcksNeeded;
+#endif
}
// NOTE: ASensorEvent and sensors_event_t are the same type.
@@ -1136,6 +1143,9 @@
// If there was a wake_up sensor_event, reset the flag.
scratch[index_wake_up_event].flags &= ~WAKE_UP_SENSOR_EVENT_NEEDS_ACK;
--mWakeLockRefCount;
+#if DEBUG_CONNECTIONS
+ --mTotalAcksNeeded;
+#endif
}
if (mEventCache == NULL) {
mMaxCacheSize = computeMaxCacheSizeLocked();
@@ -1214,6 +1224,9 @@
mEventCache[index_wake_up_event + numEventsSent].flags |=
WAKE_UP_SENSOR_EVENT_NEEDS_ACK;
++mWakeLockRefCount;
+#if DEBUG_CONNECTIONS
+ ++mTotalAcksNeeded;
+#endif
}
ssize_t size = SensorEventQueue::write(mChannel,
@@ -1225,6 +1238,9 @@
mEventCache[index_wake_up_event + numEventsSent].flags &=
~WAKE_UP_SENSOR_EVENT_NEEDS_ACK;
--mWakeLockRefCount;
+#if DEBUG_CONNECTIONS
+ --mTotalAcksNeeded;
+#endif
}
memmove(mEventCache, &mEventCache[numEventsSent],
(mCacheSize - numEventsSent) * sizeof(sensors_event_t));
@@ -1333,6 +1349,9 @@
{
Mutex::Autolock _l(mConnectionLock);
--mWakeLockRefCount;
+#if DEBUG_CONNECTIONS
+ ++mTotalAcksReceived;
+#endif
}
// Check if wakelock can be released by sensorservice. mConnectionLock needs to be released
// here as checkWakeLockState() will need it.
@@ -1380,7 +1399,7 @@
if (fifoWakeUpSensors + fifoNonWakeUpSensors == 0) {
// It is extremely unlikely that there is a write failure in non batch mode. Return a cache
// size that is equal to that of the batch mode.
- ALOGI("Write failure in non-batch mode");
+ // ALOGW("Write failure in non-batch mode");
return MAX_SOCKET_BUFFER_SIZE_BATCHED/sizeof(sensors_event_t);
}
return fifoWakeUpSensors + fifoNonWakeUpSensors;