diff options
author | Kai Shi <kaishi@google.com> | 2019-07-19 09:40:55 -0700 |
---|---|---|
committer | Kai Shi <kaishi@google.com> | 2019-07-22 13:40:13 -0700 |
commit | fa0ca0bc40a1a7ba0c3701384a756d29ef54c38f (patch) | |
tree | 3e7fd7d1dd703cbea553d9648f81f8e8fbc3e884 /service | |
parent | 4a900f532c60f039103ac32320b63c18fd98741e (diff) |
Wifi: add per-band Tx and Rx speed histogram in WifiMetrics and add
rxLinkSpeed in logLinkMetrics() of WifiScoreReport
Bug: 137886569
Test: unit test with frameworks/opt/net/wifi/tests/wifitests/runtest.sh and manual test
Change-Id: Id57ad91e84cd68de558b21d568037bfc5a250966
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiMetrics.java | 96 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiScoreReport.java | 11 |
2 files changed, 102 insertions, 5 deletions
diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java index a62ad379c..c0b04d34c 100644 --- a/service/java/com/android/server/wifi/WifiMetrics.java +++ b/service/java/com/android/server/wifi/WifiMetrics.java @@ -180,6 +180,11 @@ public class WifiMetrics { // Maximum time that a score breaching low event stays valid. public static final int VALIDITY_PERIOD_OF_SCORE_BREACH_LOW_MS = 90 * 1000; // 1.5 minutes + public static final int BAND_2G_MAX_FREQ_MHZ = 2484; + public static final int BAND_5G_LOW_MAX_FREQ_MHZ = 5240; + public static final int BAND_5G_MID_MAX_FREQ_MHZ = 5720; + public static final int BAND_5G_HIGH_MAX_FREQ_MHZ = 5865; + private Clock mClock; private boolean mScreenOn; private int mWifiState; @@ -216,6 +221,7 @@ public class WifiMetrics { private LinkedList<StaEventWithTime> mStaEventList = new LinkedList<>(); private int mLastPollRssi = -127; private int mLastPollLinkSpeed = -1; + private int mLastPollRxLinkSpeed = -1; private int mLastPollFreq = -1; private int mLastScore = -1; @@ -254,6 +260,16 @@ public class WifiMetrics { private final SparseIntArray mRssiDeltaCounts = new SparseIntArray(); /** Mapping of link speed values to LinkSpeedCount objects. */ private final SparseArray<LinkSpeedCount> mLinkSpeedCounts = new SparseArray<>(); + + private final IntCounter mTxLinkSpeedCount2g = new IntCounter(); + private final IntCounter mTxLinkSpeedCount5gLow = new IntCounter(); + private final IntCounter mTxLinkSpeedCount5gMid = new IntCounter(); + private final IntCounter mTxLinkSpeedCount5gHigh = new IntCounter(); + private final IntCounter mRxLinkSpeedCount2g = new IntCounter(); + private final IntCounter mRxLinkSpeedCount5gLow = new IntCounter(); + private final IntCounter mRxLinkSpeedCount5gMid = new IntCounter(); + private final IntCounter mRxLinkSpeedCount5gHigh = new IntCounter(); + /** RSSI of the scan result for the last connection event*/ private int mScanResultRssi = 0; /** Boot-relative timestamp when the last candidate scanresult was received, used to calculate @@ -1527,6 +1543,9 @@ public class WifiMetrics { mLastPollFreq = wifiInfo.getFrequency(); incrementRssiPollRssiCount(mLastPollFreq, mLastPollRssi); incrementLinkSpeedCount(mLastPollLinkSpeed, mLastPollRssi); + mLastPollRxLinkSpeed = wifiInfo.getRxLinkSpeedMbps(); + incrementTxLinkSpeedBandCount(mLastPollLinkSpeed, mLastPollFreq); + incrementRxLinkSpeedBandCount(mLastPollRxLinkSpeed, mLastPollFreq); } /** @@ -1596,6 +1615,56 @@ public class WifiMetrics { } /** + * Increment occurrence count of Tx link speed for operating sub-band + * Ignores link speed values that are lower than MIN_LINK_SPEED_MBPS + * @param txLinkSpeed PHY layer Tx link speed in Mbps + * @param frequency Channel frequency of beacon frames in MHz + */ + @VisibleForTesting + public void incrementTxLinkSpeedBandCount(int txLinkSpeed, int frequency) { + if (!(mLinkSpeedCountsLogging + && txLinkSpeed >= MIN_LINK_SPEED_MBPS)) { + return; + } + synchronized (mLock) { + if (frequency <= BAND_2G_MAX_FREQ_MHZ) { + mTxLinkSpeedCount2g.increment(txLinkSpeed); + } else if (frequency <= BAND_5G_LOW_MAX_FREQ_MHZ) { + mTxLinkSpeedCount5gLow.increment(txLinkSpeed); + } else if (frequency <= BAND_5G_MID_MAX_FREQ_MHZ) { + mTxLinkSpeedCount5gMid.increment(txLinkSpeed); + } else { + mTxLinkSpeedCount5gHigh.increment(txLinkSpeed); + } + } + } + + /** + * Increment occurrence count of Rx link speed for operating sub-band + * Ignores link speed values that are lower than MIN_LINK_SPEED_MBPS + * @param rxLinkSpeed PHY layer Tx link speed in Mbps + * @param frequency Channel frequency of beacon frames in MHz + */ + @VisibleForTesting + public void incrementRxLinkSpeedBandCount(int rxLinkSpeed, int frequency) { + if (!(mLinkSpeedCountsLogging + && rxLinkSpeed >= MIN_LINK_SPEED_MBPS)) { + return; + } + synchronized (mLock) { + if (frequency <= BAND_2G_MAX_FREQ_MHZ) { + mRxLinkSpeedCount2g.increment(rxLinkSpeed); + } else if (frequency <= BAND_5G_LOW_MAX_FREQ_MHZ) { + mRxLinkSpeedCount5gLow.increment(rxLinkSpeed); + } else if (frequency <= BAND_5G_MID_MAX_FREQ_MHZ) { + mRxLinkSpeedCount5gMid.increment(rxLinkSpeed); + } else { + mRxLinkSpeedCount5gHigh.increment(rxLinkSpeed); + } + } + } + + /** * Increment count of Watchdog successes. */ public void incrementNumLastResortWatchdogSuccesses() { @@ -2793,6 +2862,15 @@ public class WifiMetrics { + mWifiLogProto.numAddOrUpdateNetworkCalls); pw.println("mWifiLogProto.numEnableNetworkCalls=" + mWifiLogProto.numEnableNetworkCalls); + + pw.println("mWifiLogProto.txLinkSpeedCount2g=" + mTxLinkSpeedCount2g); + pw.println("mWifiLogProto.txLinkSpeedCount5gLow=" + mTxLinkSpeedCount5gLow); + pw.println("mWifiLogProto.txLinkSpeedCount5gMid=" + mTxLinkSpeedCount5gMid); + pw.println("mWifiLogProto.txLinkSpeedCount5gHigh=" + mTxLinkSpeedCount5gHigh); + pw.println("mWifiLogProto.rxLinkSpeedCount2g=" + mRxLinkSpeedCount2g); + pw.println("mWifiLogProto.rxLinkSpeedCount5gLow=" + mRxLinkSpeedCount5gLow); + pw.println("mWifiLogProto.rxLinkSpeedCount5gMid=" + mRxLinkSpeedCount5gMid); + pw.println("mWifiLogProto.rxLinkSpeedCount5gHigh=" + mRxLinkSpeedCount5gHigh); } } } @@ -3337,6 +3415,15 @@ public class WifiMetrics { entry.count = count; return entry; }); + // 'G' is due to that 1st Letter after _ becomes capital during protobuff compilation + mWifiLogProto.txLinkSpeedCount2G = mTxLinkSpeedCount2g.toProto(); + mWifiLogProto.txLinkSpeedCount5GLow = mTxLinkSpeedCount5gLow.toProto(); + mWifiLogProto.txLinkSpeedCount5GMid = mTxLinkSpeedCount5gMid.toProto(); + mWifiLogProto.txLinkSpeedCount5GHigh = mTxLinkSpeedCount5gHigh.toProto(); + mWifiLogProto.rxLinkSpeedCount2G = mRxLinkSpeedCount2g.toProto(); + mWifiLogProto.rxLinkSpeedCount5GLow = mRxLinkSpeedCount5gLow.toProto(); + mWifiLogProto.rxLinkSpeedCount5GMid = mRxLinkSpeedCount5gMid.toProto(); + mWifiLogProto.rxLinkSpeedCount5GHigh = mRxLinkSpeedCount5gHigh.toProto(); } } @@ -3440,6 +3527,14 @@ public class WifiMetrics { mRssiPollCountsMap.clear(); mRssiDeltaCounts.clear(); mLinkSpeedCounts.clear(); + mTxLinkSpeedCount2g.clear(); + mTxLinkSpeedCount5gLow.clear(); + mTxLinkSpeedCount5gMid.clear(); + mTxLinkSpeedCount5gHigh.clear(); + mRxLinkSpeedCount2g.clear(); + mRxLinkSpeedCount5gLow.clear(); + mRxLinkSpeedCount5gMid.clear(); + mRxLinkSpeedCount5gHigh.clear(); mWifiAlertReasonCounts.clear(); mWifiScoreCounts.clear(); mWifiUsabilityScoreCounts.clear(); @@ -3681,6 +3776,7 @@ public class WifiMetrics { mLastPollRssi = -127; mLastPollFreq = -1; mLastPollLinkSpeed = -1; + mLastPollRxLinkSpeed = -1; mLastScore = -1; mLastWifiUsabilityScore = -1; mLastPredictionHorizonSec = -1; diff --git a/service/java/com/android/server/wifi/WifiScoreReport.java b/service/java/com/android/server/wifi/WifiScoreReport.java index 70a749b92..33cc15058 100644 --- a/service/java/com/android/server/wifi/WifiScoreReport.java +++ b/service/java/com/android/server/wifi/WifiScoreReport.java @@ -249,7 +249,8 @@ public class WifiScoreReport { double filteredRssi = mVelocityBasedConnectedScore.getFilteredRssi(); double rssiThreshold = mVelocityBasedConnectedScore.getAdjustedRssiThreshold(); int freq = wifiInfo.getFrequency(); - int linkSpeed = wifiInfo.getLinkSpeed(); + int txLinkSpeed = wifiInfo.getLinkSpeed(); + int rxLinkSpeed = wifiInfo.getRxLinkSpeedMbps(); double txSuccessRate = wifiInfo.txSuccessRate; double txRetriesRate = wifiInfo.txRetriesRate; double txBadRate = wifiInfo.txBadRate; @@ -258,9 +259,9 @@ public class WifiScoreReport { try { String timestamp = new SimpleDateFormat("MM-dd HH:mm:ss.SSS").format(new Date(now)); s = String.format(Locale.US, // Use US to avoid comma/decimal confusion - "%s,%d,%d,%.1f,%.1f,%.1f,%d,%d,%.2f,%.2f,%.2f,%.2f,%d,%d,%d,%d,%d", + "%s,%d,%d,%.1f,%.1f,%.1f,%d,%d,%d,%.2f,%.2f,%.2f,%.2f,%d,%d,%d,%d,%d", timestamp, mSessionNumber, netId, - rssi, filteredRssi, rssiThreshold, freq, linkSpeed, + rssi, filteredRssi, rssiThreshold, freq, txLinkSpeed, rxLinkSpeed, txSuccessRate, txRetriesRate, txBadRate, rxSuccessRate, mNudYes, mNudCount, s1, s2, score); @@ -292,8 +293,8 @@ public class WifiScoreReport { synchronized (mLinkMetricsHistory) { history = new LinkedList<>(mLinkMetricsHistory); } - pw.println("time,session,netid,rssi,filtered_rssi,rssi_threshold," - + "freq,linkspeed,tx_good,tx_retry,tx_bad,rx_pps,nudrq,nuds,s1,s2,score"); + pw.println("time,session,netid,rssi,filtered_rssi,rssi_threshold, freq,txLinkSpeed," + + "rxLinkSpeed,tx_good,tx_retry,tx_bad,rx_pps,nudrq,nuds,s1,s2,score"); for (String line : history) { pw.println(line); } |