Extend the time between WiFi energy samples

With bursty WiFi traffic, we end up sampling the WiFi controller's
energy data quite a lot. Extend the timeout so that we sample
once there has been no activity for 15 seconds.

Note: Once the WiFi radio goes down after being active, it can come back and be
active in less than 15 seconds, which means we may sample twice quickly.

Bug:21478443
Change-Id: I99081b664f8a33fef734bc55eef4d33ac297e83a
This commit is contained in:
Adam Lesinski
2015-06-23 13:42:53 -07:00
parent a0f5c76ffd
commit 06f46cb320
2 changed files with 6 additions and 2 deletions

View File

@@ -1559,7 +1559,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
NetworkCapabilities.TRANSPORT_WIFI)) {
timeout = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.DATA_ACTIVITY_TIMEOUT_WIFI,
5);
15);
type = ConnectivityManager.TYPE_WIFI;
} else {
// do not track any other networks

View File

@@ -38,6 +38,7 @@ import android.os.ServiceManager;
import android.os.SystemClock;
import android.os.UserHandle;
import android.os.WorkSource;
import android.telephony.DataConnectionRealTimeInfo;
import android.telephony.SignalStrength;
import android.telephony.TelephonyManager;
import android.util.Slog;
@@ -629,7 +630,10 @@ public final class BatteryStatsService extends IBatteryStats.Stub
// Collect data now for the past activity.
synchronized (mStats) {
if (mStats.isOnBattery()) {
mHandler.scheduleWifiSync("wifi-data");
final String type = (powerState == DataConnectionRealTimeInfo.DC_POWER_STATE_HIGH ||
powerState == DataConnectionRealTimeInfo.DC_POWER_STATE_MEDIUM) ? "active"
: "inactive";
mHandler.scheduleWifiSync("wifi-data: " + type);
}
mStats.noteWifiRadioPowerState(powerState, tsNanos);
}