wifi: Remove logging duration from idle and active time calculation.

Wifi link layer stats aggregate the stats from multiple radios.
So on wifi chips with multiple radio support, active time and idle time
can go beyond logging duration(mainly in concurrent operation like
wifi sta + wifi tethering mode on). With this approach we can longer
assume that wifi activity time or idle time cannot go beyond the
logging duration. So removed the logging duration parameter in
computing the final idle time.

Bug: 36176141
Test: Manual - Verified the aggregation logic by logging the stats

Change-Id: I620047fb4ee363484c3d1d8e775bb6e582c1886a
diff --git a/services/core/java/com/android/server/am/BatteryExternalStatsWorker.java b/services/core/java/com/android/server/am/BatteryExternalStatsWorker.java
index 692b3f1..b6010d9 100644
--- a/services/core/java/com/android/server/am/BatteryExternalStatsWorker.java
+++ b/services/core/java/com/android/server/am/BatteryExternalStatsWorker.java
@@ -33,7 +33,6 @@
 import android.telephony.TelephonyManager;
 import android.util.IntArray;
 import android.util.Slog;
-import android.util.TimeUtils;
 
 import com.android.internal.annotations.GuardedBy;
 import com.android.internal.os.BatteryStatsImpl;
@@ -607,49 +606,11 @@
             }
             wasReset = true;
         } else {
-            final long totalActiveTimeMs = txTimeMs + rxTimeMs;
-            long maxExpectedIdleTimeMs;
-            if (totalActiveTimeMs > 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);
-                    sb.append(" is longer than sample period ");
-                    TimeUtils.formatDuration(timePeriodMs, sb);
-                    sb.append(".\n");
-                    sb.append("Previous WiFi snapshot: ").append("idle=");
-                    TimeUtils.formatDuration(lastIdleMs, sb);
-                    sb.append(" rx=");
-                    TimeUtils.formatDuration(lastRxMs, sb);
-                    sb.append(" tx=");
-                    TimeUtils.formatDuration(lastTxMs, sb);
-                    sb.append(" e=").append(lastEnergy);
-                    sb.append("\n");
-                    sb.append("Current WiFi snapshot: ").append("idle=");
-                    TimeUtils.formatDuration(latest.getControllerIdleDurationMillis(), sb);
-                    sb.append(" rx=");
-                    TimeUtils.formatDuration(latest.getControllerRxDurationMillis(), sb);
-                    sb.append(" tx=");
-                    TimeUtils.formatDuration(latest.getControllerTxDurationMillis(), sb);
-                    sb.append(" e=").append(latest.getControllerEnergyUsedMicroJoules());
-                    Slog.wtf(TAG, sb.toString());
-                }
-            } else {
-                maxExpectedIdleTimeMs = timePeriodMs - totalActiveTimeMs;
-            }
             // These times seem to be the most reliable.
             deltaControllerTxDurationMillis = txTimeMs;
             deltaControllerRxDurationMillis = rxTimeMs;
             deltaControllerScanDurationMillis = scanTimeMs;
-            // WiFi calculates the idle time as a difference from the on time and the various
-            // Rx + Tx times. There seems to be some missing time there because this sometimes
-            // becomes negative. Just cap it at 0 and ensure that it is less than the expected idle
-            // time from the difference in timestamps.
-            // b/21613534
-            deltaControllerIdleDurationMillis =
-                    Math.min(maxExpectedIdleTimeMs, Math.max(0, idleTimeMs));
+            deltaControllerIdleDurationMillis = idleTimeMs;
             deltaControllerEnergyUsedMicroJoules =
                     Math.max(0, latest.getControllerEnergyUsedMicroJoules() - lastEnergy);
             wasReset = false;