History log of /frameworks/base/core/tests/coretests/src/com/android/internal/os/MockBatteryStatsImpl.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
0719c6af4442e1be5de766582398b8e6efb7b180 24-Apr-2018 Sudheer Shanka <sudheersai@google.com> Schedule external stats sync on battery level change with a delay

and fix locking in scheduleCpuStatsSyncDueToWakelockChange().

Bug: 74146897
Test: atest cts/hostsidetests/incident/src/com/android/server/cts/BatteryStatsValidationTest.java
Test: atest core/tests/coretests/src/com/android/internal/os/BatteryStatsTests.java
Change-Id: I2891dfb8a0aedf429232f45e26deab93c738506e
/frameworks/base/core/tests/coretests/src/com/android/internal/os/MockBatteryStatsImpl.java
234d1828ca4a706676ad6f3fa0629959c74297c7 14-Mar-2018 Mike Ma <yanmin@google.com> Resolve STATSD and batterystats race condition

Both STATSD and batterystats need to read uid cpu info. However, uid cpu
stats needs to be cleared from time to time to conserve memory. To
resolve this race condition, only batterystats will remove uid stats,
both from readers and from the kernel, also with a delay, so that STATSD
can access such info before it is removed.

Refactored readers to reuse some common code. Also removed string reader
from KernelUidCpuFreqTimeReader completely since binary reader has been
working fine for a while.

Change-Id: I209bdcec642e1a29a44b566ce98ebbfaaacb4e6a
Fixes: 72172569
Test: BatteryStatsCpuTimesTest
Test: KernelUidCpuActiveTimeReaderTest
Test: KernelUidCpuClusterTimeReaderTest
Test: KernelUidCpuFreqTimeReaderTest
/frameworks/base/core/tests/coretests/src/com/android/internal/os/MockBatteryStatsImpl.java
c20379e6ec8057f8566ba05f74e527e5c081d033 15-Feb-2018 Sudheer Shanka <sudheersai@google.com> Read per-uid cpu times less often.

Schedule the read with a delay and ignore any
proc state changes during this delay duration.

Bug: 73437192
Test: atest com.android.internal.os.BatteryStatsTests
Change-Id: Ica6ec3f16ed911091e79102a2a62210edcaddf94
/frameworks/base/core/tests/coretests/src/com/android/internal/os/MockBatteryStatsImpl.java
c57729adaef25a48775d981836ae2e3484495a1f 10-Feb-2018 Sudheer Shanka <sudheersai@google.com> Update BatteryStats cpustats collection to be asynchronous.

- Collect cpu times info asynchronously when the screen state changes.
- Remove the redundant cpu collection during the battery state handling.
- Fix BatteryStatsNoteTest failing because of http://b/70808931

Bug: 70563832
Bug: 69054238
Test: atest hostsidetests/incident/src/com/android/server/cts/BatteryStatsValidationTest.java
Test: atest core/tests/coretests/src/com/android/internal/os/BatteryStatsTests.java
Test: atest core/tests/coretests/src/com/android/internal/os/BstatsCpuTimesValidationTest.java
Change-Id: Ic6441d45f94dc0703b8adc03cb8d3ab5f877626d
/frameworks/base/core/tests/coretests/src/com/android/internal/os/MockBatteryStatsImpl.java
efa0fe6b3e10f944773509f53a30f23f40d7f963 05-Feb-2018 Narayan Kamath <narayan@google.com> BatteryStatsNoteTest: Fix GPS related tests.

Bug: N/A
Test: BatteryStatsTests
Change-Id: Icadf17a3839d96559f824e45babdbf794a92456c
/frameworks/base/core/tests/coretests/src/com/android/internal/os/MockBatteryStatsImpl.java
3d422c37b7f2caf364febc556e17b43c40c56be6 25-Oct-2017 Mike Ma <yanmin@google.com> Add cluster&active cost to cpu power

Add logic to read per UID cluster and active CPU time from the kernel in
BatteryStatsImpl, store them in BatteryStats.Uid, then use these data to
calculate CPU power more accurately in CpuPowerCalculator.

Change-Id: I06a84d2bba8b97445466b310f15092614ff3477f
Bug: 67752294
Test: PowerProfileTest
Test: KernelUidCpuActiveTimeReaderTest
Test: KernelUidCpuClusterTimeReaderTest
Test: BatteryStatsCpuTimesTest
/frameworks/base/core/tests/coretests/src/com/android/internal/os/MockBatteryStatsImpl.java
5c19b897ddb89481c5981195d2470f6ce5de4b1c 06-Jan-2018 Sudheer Shanka <sudheersai@google.com> Add a global setting to turn on/off the proc state cpu times tracking.

Bug: 66953194
Test: atest core/tests/coretests/src/com/android/internal/os/BatteryStatsTests.java
Test: atest hostsidetests/incident/src/com/android/server/cts/BatteryStatsValidationTest.java
Test: atest core/tests/coretests/src/com/android/internal/os/BstatsCpuTimesValidationTest.java
Change-Id: Id26476ad77c95994f358d8bd59b6c2e6513c4c54
/frameworks/base/core/tests/coretests/src/com/android/internal/os/MockBatteryStatsImpl.java
65e919ae8c299fe06613b67b534d085909306354 09-Jan-2018 Sudheer Shanka <sudheersai@google.com> Merge "Attribute procstate cpu times to correct battery/screen on/off buckets."
695cf72f26638f051d356abcb4acdc0c1fe3918d 21-Dec-2017 Narayan Kamath <narayan@google.com> Support chained attribution for alarm related WorkSources.

.. those passed down via the AlarmManager.set() variant that takes
a WorkSource. This required a minor re-arrangement of code in
the ActivityManager. We now treat WorkSources as opaque in the
AlarmManager and simply push them down to the AM (and eventually
to BatteryStats) where they are picked apart.

Test: BatteryStatsNoteTest, AlarmManagerTest
Bug: 62390666
Change-Id: I118f1a1d16aafa41b4f401f1a6a3ba4d2d5eca8f
/frameworks/base/core/tests/coretests/src/com/android/internal/os/MockBatteryStatsImpl.java
e544d1622091eb9d47e958d60e117c19b137d0d9 29-Dec-2017 Sudheer Shanka <sudheersai@google.com> Attribute procstate cpu times to correct battery/screen on/off buckets.

- Remove redundant 'mPluggedCounts' data from LongSamplingCounterArray
- Update relevant tests

Bug: 66953194
Test: atest core/tests/coretests/src/com/android/internal/os/BatteryStatsTests.java
Test: atest hostsidetests/incident/src/com/android/server/cts/BatteryStatsValidationTest.java
Test: atest core/tests/coretests/src/com/android/internal/os/BstatsCpuTimesValidationTest.java
Change-Id: I1f32eef0d4a0fe3b6124c07d016cf0ff8967b956
/frameworks/base/core/tests/coretests/src/com/android/internal/os/MockBatteryStatsImpl.java
b2f83c16d6669456b237970327ebb9c92a4789f0 14-Nov-2017 Sudheer Shanka <sudheersai@google.com> Update BatteryStatsImpl to track per-procstate cpu times.

BatteryStatsImpl will track this data by reading from
/proc/uid/<uid>/time_in_state whenever process state changes
and will include this data as part of batterystats dump.

Bug: 66953194
Test: atest core/tests/coretests/src/com/android/internal/os/BatteryStatsTests.java
Test: atest hostsidetests/incident/src/com/android/server/cts/BatteryStatsValidationTest.java
Test: atest core/tests/coretests/src/com/android/internal/os/BstatsCpuTimesValidationTest.java

Change-Id: Ibb3e07f518aaf7eea2a00bb95b95dc5f7e09552e
/frameworks/base/core/tests/coretests/src/com/android/internal/os/MockBatteryStatsImpl.java
c2f518a9dd4b625e52e2c424f288fb5d4d430b45 20-Sep-2017 Mike Ma <yanmin@google.com> Add AOD metrics in batterystats

Fixes: 64899521
Test: manual - flash build, reset batteryStats, use device > 1 hr
with alternating pattern between screen on/off/AOD. Dump stats, check
all screen related stats look normal, esp. record matches actual time
spent in each screen state. In raw bugreport:
Search "amount discharged" for % discharge;
Search "Screen on/off/doze discharge" for mAh discharge;
Search "time on battery" for up/real time in each state.

Test: Added two unit tests for note AOD screen state
Change-Id: I7193a36751124dd380818b2b665303c0f0d8c984
/frameworks/base/core/tests/coretests/src/com/android/internal/os/MockBatteryStatsImpl.java
3838323df6b10f63b1d7aed71fa663c7f118570c 25-Jul-2017 Sudheer Shanka <sudheersai@google.com> Refactor BatteryStatsImpl.updateCpuTimeLocked.

Bug: 62240247
Test: bit FrameworksCoreTests:com.android.internal.os.BatteryStatsTests
Change-Id: I666c44ef9cb4e0720564b161da0ff1c94f15d5b9
/frameworks/base/core/tests/coretests/src/com/android/internal/os/MockBatteryStatsImpl.java
c8c44960c0051dacac0a6cb6c65ddfafc9d1cb84 11-May-2017 Bookatz <bookatz@google.com> Cumulative wakelock time per uid

Currently, the time for each partial wakelock was tracked. If one
wants the total time that a uid held partial wakelocks (over all of its
wakelocks), they could sum over all the uid's partial wakelock
totalTimes, but this would underestimate the value because totalTimes
are pooled amongst all uids. Alternatively, they could sum over all the
uid's partial wakelock totalDurations, but this would overestimate the
value because totalDurations are not pooled within the uid (so there
will be double-counting if two wakelocks are held simultaneously). This
cl adds a new timer that specifically tracks the actual total time that
the uid spent holding wakelocks, and also provides the ability to see
how much time the uid was in the background when doing so.

Bug: 38198272
Test: runtest -x frameworks/base/core/tests/coretests/src/com/android/internal/os/BatteryStatsTests.java

Change-Id: I20ea3546338c44ffdf06859bc840d9059fb18321
/frameworks/base/core/tests/coretests/src/com/android/internal/os/MockBatteryStatsImpl.java
867c0d72af63b67cd0abce8a0f40e94e04193aa6 08-Mar-2017 Bookatz <bookatz@google.com> Collect background stats: bluetooth, wifi, sensors

Added background times and counts for an app's bluetooth scans, wifi
scans, and sensor usage. Note that the original times for these three
are pooled (i.e. represent the blame apportioned to an app for using
these, rather than the actual time an app used these). Since background
times are not pooled, and are therefore incomparable to the original
times, an extra time, to represent the actual time, had to also be added
in the form of 'total duration' to which background times can be
compared.

Note that this total duration is now a feature of all DurationTimers and
can be used, e.g., to track actual wakelock time (not just
apportioned wakelock times). The total duration is the time used since
reset, and does not give other 'which' times (such as 'since
unplugged').

Bug: 35679958
Bug: 35677312
Bug: 35673525
Test: runtest -x
frameworks/base/core/tests/coretests/src/com/android/internal/os/BatteryStatsTests.java

Change-Id: I4b6943f76517cf5cc9420684857a5592cc7495be
/frameworks/base/core/tests/coretests/src/com/android/internal/os/MockBatteryStatsImpl.java
ab9ad195d1e873f7569dec45c4e627a4e8ba67e4 06-Dec-2016 Amith Yamasani <yamasani@google.com> Track background sensor usage

Keep an additional counter for background access
of sensors. Increment the count when sensor is
accessed while process is in the background state.

Bug: 33553631
Test: runtest -x frameworks/base/core/tests/coretests/src/com/android/internal/os/BatteryStatsSensorTest.java
Change-Id: I87d7dbdaf4c34aa9dd9c7e13134d8f5f759f4e2b
/frameworks/base/core/tests/coretests/src/com/android/internal/os/MockBatteryStatsImpl.java
abded113bde548734600dc1b6e4ce2e94f48e32e 09-Feb-2016 Joe Onorato <joeo@google.com> Add unit tests for BatteryStatsImpl.

- Add a Clocks interface to wrap SystemClock.uptimeMillis and
SystemClock.elapsedRealtime.
- Make the inner classes static so they can be created independently,
which meant passing explicit pointers to the BatteryStatsImpl and
the Uid objects in a lot of places.
- Make several fields protected so they can be accessed by the tests (they are
still @hidden)
- Add a test suite for the battery stats.
- Add the tests

Change-Id: I4e45afedc64f7050985c28a7eb4f5c1ddbaa63fa
/frameworks/base/core/tests/coretests/src/com/android/internal/os/MockBatteryStatsImpl.java