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

Commit 135c4760 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "BatteryStats: Allow for sample errors in wlan stats" into nyc-dev

parents 03d3f4a6 2078d349
Loading
Loading
Loading
Loading
+29 −25
Original line number Diff line number Diff line
@@ -88,6 +88,9 @@ public final class BatteryStatsService extends IBatteryStats.Stub
     */
    private static final long EXTERNAL_STATS_SYNC_TIMEOUT_MILLIS = 2000;

    // There is some accuracy error in wifi reports so allow some slop in the results.
    private static final long MAX_WIFI_STATS_SAMPLE_ERROR_MILLIS = 750;

    private static IBatteryStats sService;

    final BatteryStatsImpl mStats;
@@ -1338,10 +1341,10 @@ public final class BatteryStatsService extends IBatteryStats.Stub
        } else {
            final long totalActiveTimeMs = txTimeMs + rxTimeMs;
            long maxExpectedIdleTimeMs;
            // Active time can never be greater than the total time, the stats received seem
            // to be corrupt.
            if (totalActiveTimeMs > timePeriodMs) {
                maxExpectedIdleTimeMs = timePeriodMs;
                // Cap the max idle time at zero since the active time consumed the whole time
                maxExpectedIdleTimeMs = 0;
                if (totalActiveTimeMs > timePeriodMs + MAX_WIFI_STATS_SAMPLE_ERROR_MILLIS) {
                    StringBuilder sb = new StringBuilder();
                    sb.append("Total Active time ");
                    TimeUtils.formatDuration(totalActiveTimeMs, sb);
@@ -1364,6 +1367,7 @@ public final class BatteryStatsService extends IBatteryStats.Stub
                    TimeUtils.formatDuration(latest.mControllerTxTimeMs, sb);
                    sb.append(" e=").append(latest.mControllerEnergyUsed);
                    Slog.wtf(TAG, sb.toString());
                }
            } else {
                maxExpectedIdleTimeMs = timePeriodMs - totalActiveTimeMs;
            }