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

Commit 0ed268b1 authored by Chenjie Yu's avatar Chenjie Yu
Browse files

similar to the samplers in batterystats, when we do diff,

if the value is not monotically increasing, we should take
the absolute value as the diff.

Test: unit tested
Change-Id: Idd8a248b4092b1863eb8e50539f8f14b3ac9af9e
parent 5e1f8546
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -285,8 +285,15 @@ void ValueMetricProducer::onMatchedLogEventInternalLocked(
            interval.start = value;
            interval.startUpdated = true;
        } else {
            // Generally we expect value to be monotonically increasing.
            // If not, there was a reset event. We take the absolute value as
            // diff in this case.
            if (interval.startUpdated) {
                if (value > interval.start) {
                    interval.sum += (value - interval.start);
                } else {
                    interval.sum += value;
                }
                interval.startUpdated = false;
            } else {
                VLOG("No start for matching end %ld", value);