Loading libs/battery/MultiStateCounter.h +12 −4 Original line number Diff line number Diff line Loading @@ -31,6 +31,8 @@ namespace android { namespace battery { #define REPORTED_INVALID_TIMESTAMP_DELTA_MS 60000 typedef uint16_t state_t; template <class T> Loading Loading @@ -171,8 +173,12 @@ void MultiStateCounter<T>::setState(state_t state, time_t timestamp) { if (timestamp >= lastStateChangeTimestamp) { states[currentState].timeInStateSinceUpdate += timestamp - lastStateChangeTimestamp; } else { ALOGE("setState is called with an earlier timestamp: %lu, previous timestamp: %lu\n", if (timestamp < lastStateChangeTimestamp - REPORTED_INVALID_TIMESTAMP_DELTA_MS) { ALOGE("setState is called with an earlier timestamp: %lu, " "previous timestamp: %lu\n", (unsigned long)timestamp, (unsigned long)lastStateChangeTimestamp); } // The accumulated durations have become unreliable. For example, if the timestamp // sequence was 1000, 2000, 1000, 3000, if we accumulated the positive deltas, // we would get 4000, which is greater than (last - first). This could lead to Loading Loading @@ -232,8 +238,10 @@ const T& MultiStateCounter<T>::updateValue(const T& value, time_t timestamp) { } } } else if (timestamp < lastUpdateTimestamp) { if (timestamp < lastUpdateTimestamp - REPORTED_INVALID_TIMESTAMP_DELTA_MS) { ALOGE("updateValue is called with an earlier timestamp: %lu, previous: %lu\n", (unsigned long)timestamp, (unsigned long)lastUpdateTimestamp); } for (int i = 0; i < stateCount; i++) { states[i].timeInStateSinceUpdate = 0; Loading Loading
libs/battery/MultiStateCounter.h +12 −4 Original line number Diff line number Diff line Loading @@ -31,6 +31,8 @@ namespace android { namespace battery { #define REPORTED_INVALID_TIMESTAMP_DELTA_MS 60000 typedef uint16_t state_t; template <class T> Loading Loading @@ -171,8 +173,12 @@ void MultiStateCounter<T>::setState(state_t state, time_t timestamp) { if (timestamp >= lastStateChangeTimestamp) { states[currentState].timeInStateSinceUpdate += timestamp - lastStateChangeTimestamp; } else { ALOGE("setState is called with an earlier timestamp: %lu, previous timestamp: %lu\n", if (timestamp < lastStateChangeTimestamp - REPORTED_INVALID_TIMESTAMP_DELTA_MS) { ALOGE("setState is called with an earlier timestamp: %lu, " "previous timestamp: %lu\n", (unsigned long)timestamp, (unsigned long)lastStateChangeTimestamp); } // The accumulated durations have become unreliable. For example, if the timestamp // sequence was 1000, 2000, 1000, 3000, if we accumulated the positive deltas, // we would get 4000, which is greater than (last - first). This could lead to Loading Loading @@ -232,8 +238,10 @@ const T& MultiStateCounter<T>::updateValue(const T& value, time_t timestamp) { } } } else if (timestamp < lastUpdateTimestamp) { if (timestamp < lastUpdateTimestamp - REPORTED_INVALID_TIMESTAMP_DELTA_MS) { ALOGE("updateValue is called with an earlier timestamp: %lu, previous: %lu\n", (unsigned long)timestamp, (unsigned long)lastUpdateTimestamp); } for (int i = 0; i < stateCount; i++) { states[i].timeInStateSinceUpdate = 0; Loading