diff options
| author | Bookatz <bookatz@google.com> | 2017-07-11 16:49:17 -0700 |
|---|---|---|
| committer | Andre Eisenbach <eisenbach@google.com> | 2017-07-21 21:46:01 +0000 |
| commit | 94c5a313d7313a9a88abdf4267af43b87deb0dd2 (patch) | |
| tree | 95df59b443c809ad645d748943d4acc62edf120e /core/java | |
| parent | cdcbbeccb76cd28daf8e18af7acc71f79ba0fc81 (diff) | |
Batterystats handles nested unoptimized ble scans
When a ble scan starts, it tells batterystats whether that scan is
unoptimized. When the scan stops, batterystats is not informed of
whether the stopped scan was unoptimized. Because the ble scan call
could not be nested (couldn't call start twice without stopping first),
this was fine, but now nesting is possible, so batterystats needs to
know whether the stopped ble scan is unoptimized.
Bug: 63456783
Test: runtest -x frameworks/base/core/tests/coretests/src/com/android/internal/os/BatteryStatsTests.java
Test: no new errors when run cts-dev -m CtsIncidentHostTestCases -t com.android.server.cts.BatteryStatsValidationTest#testUnoptimizedBleScans
Change-Id: Ia73f294cf1807ddaf20f1c0bcc28add001cac78c
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/com/android/internal/app/IBatteryStats.aidl | 2 | ||||
| -rw-r--r-- | core/java/com/android/internal/os/BatteryStatsImpl.java | 15 |
2 files changed, 7 insertions, 10 deletions
diff --git a/core/java/com/android/internal/app/IBatteryStats.aidl b/core/java/com/android/internal/app/IBatteryStats.aidl index 04f7c76c8e74..a44fd675a709 100644 --- a/core/java/com/android/internal/app/IBatteryStats.aidl +++ b/core/java/com/android/internal/app/IBatteryStats.aidl @@ -130,7 +130,7 @@ interface IBatteryStats { long getAwakeTimePlugged(); void noteBleScanStarted(in WorkSource ws, boolean isUnoptimized); - void noteBleScanStopped(in WorkSource ws); + void noteBleScanStopped(in WorkSource ws, boolean isUnoptimized); void noteResetBleScan(); void noteBleScanResults(in WorkSource ws, int numNewResults); diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java index 2363f6820da4..ccfeadb10c42 100644 --- a/core/java/com/android/internal/os/BatteryStatsImpl.java +++ b/core/java/com/android/internal/os/BatteryStatsImpl.java @@ -4852,7 +4852,7 @@ public class BatteryStatsImpl extends BatteryStats { } } - private void noteBluetoothScanStoppedLocked(int uid) { + private void noteBluetoothScanStoppedLocked(int uid, boolean isUnoptimized) { uid = mapUid(uid); final long elapsedRealtime = mClocks.elapsedRealtime(); final long uptime = mClocks.uptimeMillis(); @@ -4864,13 +4864,13 @@ public class BatteryStatsImpl extends BatteryStats { addHistoryRecordLocked(elapsedRealtime, uptime); mBluetoothScanTimer.stopRunningLocked(elapsedRealtime); } - getUidStatsLocked(uid).noteBluetoothScanStoppedLocked(elapsedRealtime); + getUidStatsLocked(uid).noteBluetoothScanStoppedLocked(elapsedRealtime, isUnoptimized); } - public void noteBluetoothScanStoppedFromSourceLocked(WorkSource ws) { + public void noteBluetoothScanStoppedFromSourceLocked(WorkSource ws, boolean isUnoptimized) { final int N = ws.size(); for (int i = 0; i < N; i++) { - noteBluetoothScanStoppedLocked(ws.get(i)); + noteBluetoothScanStoppedLocked(ws.get(i), isUnoptimized); } } @@ -6121,14 +6121,11 @@ public class BatteryStatsImpl extends BatteryStats { } } - public void noteBluetoothScanStoppedLocked(long elapsedRealtimeMs) { + public void noteBluetoothScanStoppedLocked(long elapsedRealtimeMs, boolean isUnoptimized) { if (mBluetoothScanTimer != null) { mBluetoothScanTimer.stopRunningLocked(elapsedRealtimeMs); } - // In the ble code, a scan cannot change types and nested starts are not possible. - // So if an unoptimizedScan is running, it is now being stopped. - if (mBluetoothUnoptimizedScanTimer != null - && mBluetoothUnoptimizedScanTimer.isRunningLocked()) { + if (isUnoptimized && mBluetoothUnoptimizedScanTimer != null) { mBluetoothUnoptimizedScanTimer.stopRunningLocked(elapsedRealtimeMs); } } |
