Merge "Per API review, revert the API renaming CL." into nyc-dev am: 03d3f4a6cb

am: 0f19009fb7

* commit '0f19009fb7daa5e03c29f4c853e3798b4f38661e':
  BatteryStats: Allow for sample errors in wlan stats

Change-Id: I6e7becdf2427d847af56af3df959a61f5f31669e
This commit is contained in:
Derek Tan
2016-05-26 00:07:28 +00:00
committed by android-build-merger

View File

@@ -88,6 +88,9 @@ public final class BatteryStatsService extends IBatteryStats.Stub
*/ */
private static final long EXTERNAL_STATS_SYNC_TIMEOUT_MILLIS = 2000; 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; private static IBatteryStats sService;
final BatteryStatsImpl mStats; final BatteryStatsImpl mStats;
@@ -1338,32 +1341,33 @@ public final class BatteryStatsService extends IBatteryStats.Stub
} else { } else {
final long totalActiveTimeMs = txTimeMs + rxTimeMs; final long totalActiveTimeMs = txTimeMs + rxTimeMs;
long maxExpectedIdleTimeMs; long maxExpectedIdleTimeMs;
// Active time can never be greater than the total time, the stats received seem
// to be corrupt.
if (totalActiveTimeMs > timePeriodMs) { if (totalActiveTimeMs > timePeriodMs) {
maxExpectedIdleTimeMs = timePeriodMs; // Cap the max idle time at zero since the active time consumed the whole time
StringBuilder sb = new StringBuilder(); maxExpectedIdleTimeMs = 0;
sb.append("Total Active time "); if (totalActiveTimeMs > timePeriodMs + MAX_WIFI_STATS_SAMPLE_ERROR_MILLIS) {
TimeUtils.formatDuration(totalActiveTimeMs, sb); StringBuilder sb = new StringBuilder();
sb.append(" is longer than sample period "); sb.append("Total Active time ");
TimeUtils.formatDuration(timePeriodMs, sb); TimeUtils.formatDuration(totalActiveTimeMs, sb);
sb.append(".\n"); sb.append(" is longer than sample period ");
sb.append("Previous WiFi snapshot: ").append("idle="); TimeUtils.formatDuration(timePeriodMs, sb);
TimeUtils.formatDuration(lastIdleMs, sb); sb.append(".\n");
sb.append(" rx="); sb.append("Previous WiFi snapshot: ").append("idle=");
TimeUtils.formatDuration(lastRxMs, sb); TimeUtils.formatDuration(lastIdleMs, sb);
sb.append(" tx="); sb.append(" rx=");
TimeUtils.formatDuration(lastTxMs, sb); TimeUtils.formatDuration(lastRxMs, sb);
sb.append(" e=").append(lastEnergy); sb.append(" tx=");
sb.append("\n"); TimeUtils.formatDuration(lastTxMs, sb);
sb.append("Current WiFi snapshot: ").append("idle="); sb.append(" e=").append(lastEnergy);
TimeUtils.formatDuration(latest.mControllerIdleTimeMs, sb); sb.append("\n");
sb.append(" rx="); sb.append("Current WiFi snapshot: ").append("idle=");
TimeUtils.formatDuration(latest.mControllerRxTimeMs, sb); TimeUtils.formatDuration(latest.mControllerIdleTimeMs, sb);
sb.append(" tx="); sb.append(" rx=");
TimeUtils.formatDuration(latest.mControllerTxTimeMs, sb); TimeUtils.formatDuration(latest.mControllerRxTimeMs, sb);
sb.append(" e=").append(latest.mControllerEnergyUsed); sb.append(" tx=");
Slog.wtf(TAG, sb.toString()); TimeUtils.formatDuration(latest.mControllerTxTimeMs, sb);
sb.append(" e=").append(latest.mControllerEnergyUsed);
Slog.wtf(TAG, sb.toString());
}
} else { } else {
maxExpectedIdleTimeMs = timePeriodMs - totalActiveTimeMs; maxExpectedIdleTimeMs = timePeriodMs - totalActiveTimeMs;
} }