diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-03-06 03:10:30 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-03-06 03:10:30 +0000 |
commit | ec6f56e58897cac4d1093c9cacbccb545d3113ed (patch) | |
tree | 02d3dbb05ff51e9cdfe1aefdf07ca66ce3d5b44c /service | |
parent | b8cdd8b9c4399281a81e18abe93246081dffc97f (diff) | |
parent | b073c41572f8763239f27677c03a2225fa38dc3b (diff) |
Merge "Bug fix WifiChannelUtilization and WifiDataStall." into rvc-dev
Diffstat (limited to 'service')
3 files changed, 37 insertions, 5 deletions
diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java index 88eab4e33..f13983898 100644 --- a/service/java/com/android/server/wifi/ClientModeImpl.java +++ b/service/java/com/android/server/wifi/ClientModeImpl.java @@ -2714,6 +2714,7 @@ public class ClientModeImpl extends StateMachine { mLastSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; mLastSimBasedConnectionCarrierName = null; mWifiScoreCard.resetConnectionState(); + mWifiDataStall.reset(); updateL2KeyAndGroupHint(); } @@ -3671,6 +3672,7 @@ public class ClientModeImpl extends StateMachine { mWifiMetrics.logStaEvent(StaEvent.TYPE_WIFI_ENABLED); mWifiScoreCard.noteSupplicantStateChanged(mWifiInfo); mWifiHealthMonitor.setWifiEnabled(true); + mWifiDataStall.init(); } @Override @@ -3693,6 +3695,7 @@ public class ClientModeImpl extends StateMachine { mWifiInfo.setSupplicantState(SupplicantState.DISCONNECTED); mWifiScoreCard.noteSupplicantStateChanged(mWifiInfo); mWifiHealthMonitor.setWifiEnabled(false); + mWifiDataStall.reset(); stopClientMode(); } diff --git a/service/java/com/android/server/wifi/WifiChannelUtilization.java b/service/java/com/android/server/wifi/WifiChannelUtilization.java index a1ea7ea4f..2149e253f 100644 --- a/service/java/com/android/server/wifi/WifiChannelUtilization.java +++ b/service/java/com/android/server/wifi/WifiChannelUtilization.java @@ -53,7 +53,7 @@ public class WifiChannelUtilization { // The number of chanStatsMap readings saved in cache // where each reading corresponds to one link layer stats update. @VisibleForTesting - static final int CHANNEL_STATS_CACHE_SIZE = 3; + static final int CHANNEL_STATS_CACHE_SIZE = 5; private final Clock mClock; private @DeviceMobilityState int mDeviceMobilityState = DEVICE_MOBILITY_STATE_UNKNOWN; private int mCacheUpdateIntervalMinMs = DEFAULT_CACHE_UPDATE_INTERVAL_MIN_MS; @@ -78,6 +78,8 @@ public class WifiChannelUtilization { public void init(WifiLinkLayerStats wifiLinkLayerStats) { mChannelUtilizationMap.clear(); mChannelStatsMapCache.clear(); + mDeviceMobilityState = DEVICE_MOBILITY_STATE_UNKNOWN; + mLastChannelStatsMapMobilityState = DEVICE_MOBILITY_STATE_UNKNOWN; for (int i = 0; i < (CHANNEL_STATS_CACHE_SIZE - 1); ++i) { mChannelStatsMapCache.addFirst(new SparseArray<>()); } @@ -220,7 +222,7 @@ public class WifiChannelUtilization { private int calculateUtilizationRatio(int radioOnTimeDiff, int busyTimeDiff) { int maxRange = BssLoad.MAX_CHANNEL_UTILIZATION - BssLoad.MIN_CHANNEL_UTILIZATION; - if (radioOnTimeDiff > 0) { + if (radioOnTimeDiff > 0 && busyTimeDiff <= radioOnTimeDiff) { return (busyTimeDiff * maxRange / radioOnTimeDiff + BssLoad.MIN_CHANNEL_UTILIZATION); } else { return BssLoad.INVALID; diff --git a/service/java/com/android/server/wifi/WifiDataStall.java b/service/java/com/android/server/wifi/WifiDataStall.java index cce6c6528..11591bd58 100644 --- a/service/java/com/android/server/wifi/WifiDataStall.java +++ b/service/java/com/android/server/wifi/WifiDataStall.java @@ -53,7 +53,7 @@ public class WifiDataStall { public static final int DEFAULT_CCA_LEVEL_2G = CHANNEL_UTILIZATION_SCALE * 16 / 100; public static final int DEFAULT_CCA_LEVEL_ABOVE_2G = CHANNEL_UTILIZATION_SCALE * 6 / 100; // Minimum time interval in ms between two link layer stats cache updates - private static final int LLSTATS_CACHE_UPDATE_INTERVAL_MIN_MS = 6 * 1000; + private static final int LLSTATS_CACHE_UPDATE_INTERVAL_MIN_MS = 30_000; // Maximum time margin between two link layer stats for connection duration update public static final int MAX_TIME_MARGIN_LAST_TWO_POLLS_MS = 200; @@ -90,7 +90,6 @@ public class WifiDataStall { mContext = context; mClock = clock; mWifiChannelUtilization = wifiChannelUtilization; - mWifiChannelUtilization.init(null); mWifiChannelUtilization.setCacheUpdateIntervalMs(LLSTATS_CACHE_UPDATE_INTERVAL_MIN_MS); mThroughputPredictor = throughputPredictor; mPhoneStateListener = new PhoneStateListener(new HandlerExecutor(handler)) { @@ -110,6 +109,30 @@ public class WifiDataStall { } /** + * initialization after wifi is enabled + */ + public void init() { + mWifiChannelUtilization.init(null); + reset(); + } + + /** + * Reset internal variables + */ + public void reset() { + mLastTxBytes = 0; + mLastRxBytes = 0; + mLastFrequency = -1; + mLastBssid = null; + mDataStallStartTimeMs = -1; + mDataStallTx = false; + mDataStallRx = false; + mIsThroughputSufficient = true; + mTxTputKbps = INVALID_THROUGHPUT; + mRxTputKbps = INVALID_THROUGHPUT; + } + + /** * Set ConnectionCapabilities after each association and roaming */ public void setConnectionCapabilities(WifiNative.ConnectionCapabilities capabilities) { @@ -243,7 +266,7 @@ public class WifiDataStall { boolean isTxTrafficHigh = (totalTxDelta * 1000) > (mDeviceConfigFacade.getTxPktPerSecondThr() * timeDeltaLastTwoPollsMs); boolean isRxTrafficHigh = (rxSuccessDelta * 1000) - > (mDeviceConfigFacade.getTxPktPerSecondThr() * timeDeltaLastTwoPollsMs); + > (mDeviceConfigFacade.getRxPktPerSecondThr() * timeDeltaLastTwoPollsMs); if (timeDeltaLastTwoPollsMs < 0 || txSuccessDelta < 0 || txRetriesDelta < 0 @@ -284,6 +307,8 @@ public class WifiDataStall { * (CHANNEL_UTILIZATION_SCALE - ccaLevel) / CHANNEL_UTILIZATION_SCALE); } isTxTputLow = mTxTputKbps < mDeviceConfigFacade.getDataStallTxTputThrKbps(); + } else { + mTxTputKbps = INVALID_THROUGHPUT; } if (rxLinkSpeedMbps > 0) { @@ -293,6 +318,8 @@ public class WifiDataStall { * (CHANNEL_UTILIZATION_SCALE - ccaLevel) / CHANNEL_UTILIZATION_SCALE); } isRxTputLow = mRxTputKbps < mDeviceConfigFacade.getDataStallRxTputThrKbps(); + } else { + mRxTputKbps = INVALID_THROUGHPUT; } mIsThroughputSufficient = isThroughputSufficientInternal(mTxTputKbps, mRxTputKbps, |