Add BLE results counter to batterystats
Batterystats provides an API to count the number of BLE scan results.
Bug: 37720787
Test: runtest -x frameworks/base/core/tests/coretests/src/com/android/internal/os/BatteryStatsTests.java
Change-Id: Idcb7494b39e88dcbfbb3da1ebe90b8a2f8f4d55c
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java
index 235f24c..21b68ea 100644
--- a/core/java/android/os/BatteryStats.java
+++ b/core/java/android/os/BatteryStats.java
@@ -513,6 +513,7 @@
public abstract Timer getForegroundActivityTimer();
public abstract Timer getBluetoothScanTimer();
public abstract Timer getBluetoothScanBackgroundTimer();
+ public abstract Counter getBluetoothScanResultCounter();
// Note: the following times are disjoint. They can be added together to find the
// total time a uid has had any processes running at all.
@@ -3347,8 +3348,10 @@
final long actualTime = bleTimer.getTotalDurationMsLocked(rawRealtimeMs);
final long actualTimeBg = bleTimerBg != null ?
bleTimerBg.getTotalDurationMsLocked(rawRealtimeMs) : 0;
+ final int resultCount = u.getBluetoothScanResultCounter() != null ?
+ u.getBluetoothScanResultCounter().getCountLocked(which) : 0;
dumpLine(pw, uid, category, BLUETOOTH_MISC_DATA, totalTime, count,
- countBg, actualTime, actualTimeBg);
+ countBg, actualTime, actualTimeBg, resultCount);
}
}
@@ -4500,6 +4503,8 @@
final long actualTimeMs = bleTimer.getTotalDurationMsLocked(rawRealtimeMs);
final long actualTimeMsBg = bleTimerBg != null ?
bleTimerBg.getTotalDurationMsLocked(rawRealtimeMs) : 0;
+ final int resultCount = u.getBluetoothScanResultCounter() != null ?
+ u.getBluetoothScanResultCounter().getCountLocked(which) : 0;
sb.setLength(0);
sb.append(prefix);
@@ -4524,6 +4529,8 @@
sb.append(countBg);
sb.append(" times)");
}
+ sb.append("; Results count ");
+ sb.append(resultCount);
pw.println(sb.toString());
uidActivity = true;
}