diff options
| author | Dmitri Plotnikov <dplotnikov@google.com> | 2021-04-02 18:03:21 -0700 |
|---|---|---|
| committer | Dmitri Plotnikov <dplotnikov@google.com> | 2021-04-13 21:59:26 -0700 |
| commit | 9e19e96ad0c0443750adf976ad9f36f485dba675 (patch) | |
| tree | e169b9dad6d3225befdadeabc488edb585cbce90 /core/java/android/os/PowerComponents.java | |
| parent | 177de2ed552274965ba152c6f9942ab7c63b272a (diff) | |
Remove POWER_COMPONENT_USAGE and TIME_COMPONENT_USAGE
... and use specific power components, such as POWER_COMPONENT_SCREEN
Bug: 184397335
Test: atest FrameworksCoreTests:com.android.internal.os.BatteryStatsTests
Test: mp :BatteryStatsViewer && adb shell am start -n com.android.frameworks.core.batterystatsviewer/.BatteryStatsViewerActivity
Change-Id: I551b2d37d2da77e21e622961f5290b55fb24da61
Diffstat (limited to 'core/java/android/os/PowerComponents.java')
| -rw-r--r-- | core/java/android/os/PowerComponents.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/core/java/android/os/PowerComponents.java b/core/java/android/os/PowerComponents.java index 2fea4acf3876..a0a41f4d6630 100644 --- a/core/java/android/os/PowerComponents.java +++ b/core/java/android/os/PowerComponents.java @@ -192,6 +192,19 @@ class PowerComponents { } /** + * Returns the largest usage duration among all time components. + */ + public long getMaxComponentUsageDurationMillis() { + long max = 0; + for (int i = mTimeComponentsMs.length - 1; i >= 0; i--) { + if (mTimeComponentsMs[i] > max) { + max = mTimeComponentsMs[i]; + } + } + return max; + } + + /** * Builder for PowerComponents. */ static final class Builder { @@ -312,10 +325,10 @@ class PowerComponents { } public void addPowerAndDuration(Builder other) { - for (int i = 0; i < mPowerComponentsMah.length; i++) { + for (int i = mPowerComponentsMah.length - 1; i >= 0; i--) { mPowerComponentsMah[i] += other.mPowerComponentsMah[i]; } - for (int i = 0; i < mTimeComponentsMs.length; i++) { + for (int i = mTimeComponentsMs.length - 1; i >= 0; i--) { mTimeComponentsMs[i] += other.mTimeComponentsMs[i]; } } |
