Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 941d98fe authored by Bookatz's avatar Bookatz
Browse files

Wakelock durations are 0 instead of -1 if unused

Previously, wakelock max/current/total durations were initialized to -1,
instead of 0. So if, e.g., an app held a full wakelock but not a partial
wakelock, then the partial wakelock would return -1 for these data. This
cl changes that to be 0. The value will only be -1 if the data is not
tracked (as is currently the case for full and window wakelocks), in
which case if the wakelock was held, -1 will be given to signify the
lack of tracking.

Test: manually confirm 0 instead of -1 in batterystats dump.
Change-Id: I934022294ba5adafb2e4d9a5be1dc20aab045cb0
parent 506a8183
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -2756,9 +2756,9 @@ public abstract class BatteryStats implements Parcelable {
            long elapsedRealtimeUs, String name, int which, String linePrefix) {
        long totalTimeMicros = 0;
        int count = 0;
        long max = -1;
        long current = -1;
        long totalDuration = -1;
        long max = 0;
        long current = 0;
        long totalDuration = 0;
        if (timer != null) {
            totalTimeMicros = timer.getTotalTimeLocked(elapsedRealtimeUs, which);
            count = timer.getCountLocked(which);