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

Commit 4c9ace51 authored by Adam Lesinski's avatar Adam Lesinski
Browse files

BatteryStats: Compensate for accuracy issues when reporting WiFi energy data issues with Slog.wtf

In practice I've seen the reported time spent in all WiFi energy states ~20 milliseconds larger
than the time between samples, which seems reasonable.

This will reduce false positives in APR.

Bug:22774068
Change-Id: Ibf33c9826586c8a1b70449b9a609cb51bdfc08b8
parent 71bfb270
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1261,9 +1261,11 @@ public final class BatteryStatsService extends IBatteryStats.Stub
                    Slog.v(TAG, "WiFi energy data was reset, new WiFi energy data is " + result);
                }

                // There is some accuracy error in reports so allow 30 milliseconds of error.
                final long SAMPLE_ERROR_MILLIS = 30;
                final long totalTimeMs = result.mControllerIdleTimeMs + result.mControllerRxTimeMs +
                        result.mControllerTxTimeMs;
                if (totalTimeMs > timePeriodMs) {
                if (totalTimeMs > timePeriodMs + SAMPLE_ERROR_MILLIS) {
                    StringBuilder sb = new StringBuilder();
                    sb.append("Total time ");
                    TimeUtils.formatDuration(totalTimeMs, sb);