summaryrefslogtreecommitdiffstats
path: root/services/core
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2015-06-12 23:16:07 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-06-12 23:16:10 +0000
commita109cc1b6d08517ba0d9ee58bae65d3a6af739c1 (patch)
treea04eee454c8316966ba0fa32dca0369165145284 /services/core
parent4c9dafbfecf00ba3dca0c5de61d889676bfdc7af (diff)
parentf4013aa4f7f9ba0010840c20fd747b73880f3d74 (diff)
downloadframeworks_base-a109cc1b6d08517ba0d9ee58bae65d3a6af739c1.zip
frameworks_base-a109cc1b6d08517ba0d9ee58bae65d3a6af739c1.tar.gz
frameworks_base-a109cc1b6d08517ba0d9ee58bae65d3a6af739c1.tar.bz2
Merge "BatteryStats: Wifi energy data is sometimes wrong" into mnc-dev
Diffstat (limited to 'services/core')
-rw-r--r--services/core/java/com/android/server/am/BatteryStatsService.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/am/BatteryStatsService.java b/services/core/java/com/android/server/am/BatteryStatsService.java
index b97fa69..b56e326 100644
--- a/services/core/java/com/android/server/am/BatteryStatsService.java
+++ b/services/core/java/com/android/server/am/BatteryStatsService.java
@@ -1113,23 +1113,32 @@ public final class BatteryStatsService extends IBatteryStats.Stub
// correct delta from when we should start reading (aka when we are on battery).
WifiActivityEnergyInfo info = mWifiManager.reportActivityInfo();
if (info != null && info.isValid()) {
+ if (info.mControllerEnergyUsed < 0 || info.mControllerIdleTimeMs < 0 ||
+ info.mControllerRxTimeMs < 0 || info.mControllerTxTimeMs < 0) {
+ Slog.wtf(TAG, "Reported WiFi energy data is invalid: " + info);
+ return null;
+ }
+
// We will modify the last info object to be the delta, and store the new
// WifiActivityEnergyInfo object as our last one.
final WifiActivityEnergyInfo result = mLastInfo;
result.mTimestamp = info.getTimeStamp();
result.mStackState = info.getStackState();
+
+ // These times seem to be the most reliable.
result.mControllerTxTimeMs =
info.mControllerTxTimeMs - mLastInfo.mControllerTxTimeMs;
result.mControllerRxTimeMs =
info.mControllerRxTimeMs - mLastInfo.mControllerRxTimeMs;
- result.mControllerEnergyUsed =
- info.mControllerEnergyUsed - mLastInfo.mControllerEnergyUsed;
// WiFi calculates the idle time as a difference from the on time and the various
// Rx + Tx times. There seems to be some missing time there because this sometimes
// becomes negative. Just cap it at 0 and move on.
+ // b/21613534
result.mControllerIdleTimeMs =
Math.max(0, info.mControllerIdleTimeMs - mLastInfo.mControllerIdleTimeMs);
+ result.mControllerEnergyUsed =
+ Math.max(0, info.mControllerEnergyUsed - mLastInfo.mControllerEnergyUsed);
if (result.mControllerTxTimeMs < 0 ||
result.mControllerRxTimeMs < 0) {