summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Shi <kaishi@google.com>2019-07-25 13:27:21 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-07-25 13:27:21 -0700
commit9b065309d83d47b5bcead8e6bc65869a79c3eead (patch)
tree44817f41fe2962e9dd6c70e1864e620797c8d8b1
parentf272b21563525d7c21735df8202a6e90e43f5b77 (diff)
parent1c65961bc213d53fbb49566bd71770fdafd22643 (diff)
Merge "Wifi: add per-band Tx and Rx speed histogram in WifiMetrics and add rxLinkSpeed in logLinkMetrics() of WifiScoreReport" into qt-r1-dev
am: 1c65961bc2 Change-Id: I7392c2844d85bb74cdd3c365686ed793e827d7d4
-rw-r--r--service/java/com/android/server/wifi/WifiMetrics.java96
-rw-r--r--service/java/com/android/server/wifi/WifiScoreReport.java11
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java55
3 files changed, 157 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);
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
index e45906a85..7e086d4ce 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
@@ -2577,6 +2577,45 @@ public class WifiMetricsTest {
}
/**
+ * Verify that Tx and Rx per-band LinkSpeedCounts are correctly logged in metrics
+ */
+ @Test
+ public void testTxRxLinkSpeedBandCounts() throws Exception {
+ when(mFacade.getIntegerSetting(eq(mContext),
+ eq(Settings.Global.WIFI_LINK_SPEED_METRICS_ENABLED), anyInt())).thenReturn(1);
+ mWifiMetrics.loadSettings();
+ for (int i = 0; i < NUM_LINK_SPEED_LEVELS_TO_INCREMENT; i++) {
+ for (int j = 0; j <= i; j++) {
+ mWifiMetrics.incrementTxLinkSpeedBandCount(
+ WifiMetrics.MIN_LINK_SPEED_MBPS + i, RSSI_POLL_FREQUENCY);
+ mWifiMetrics.incrementRxLinkSpeedBandCount(
+ WifiMetrics.MIN_LINK_SPEED_MBPS + i + 1, RSSI_POLL_FREQUENCY);
+ }
+ }
+ dumpProtoAndDeserialize();
+ assertEquals(0, mDecodedProto.txLinkSpeedCount2G.length);
+ assertEquals(0, mDecodedProto.rxLinkSpeedCount2G.length);
+ assertEquals(NUM_LINK_SPEED_LEVELS_TO_INCREMENT,
+ mDecodedProto.txLinkSpeedCount5GLow.length);
+ assertEquals(NUM_LINK_SPEED_LEVELS_TO_INCREMENT,
+ mDecodedProto.rxLinkSpeedCount5GLow.length);
+ assertEquals(0, mDecodedProto.txLinkSpeedCount5GMid.length);
+ assertEquals(0, mDecodedProto.rxLinkSpeedCount5GMid.length);
+ assertEquals(0, mDecodedProto.txLinkSpeedCount5GHigh.length);
+ assertEquals(0, mDecodedProto.rxLinkSpeedCount5GHigh.length);
+ for (int i = 0; i < NUM_LINK_SPEED_LEVELS_TO_INCREMENT; i++) {
+ assertEquals("Incorrect Tx link speed", WifiMetrics.MIN_LINK_SPEED_MBPS + i,
+ mDecodedProto.txLinkSpeedCount5GLow[i].key);
+ assertEquals("Incorrect Rx link speed", WifiMetrics.MIN_LINK_SPEED_MBPS + i + 1,
+ mDecodedProto.rxLinkSpeedCount5GLow[i].key);
+ assertEquals("Incorrect count of Tx link speed",
+ i + 1, mDecodedProto.txLinkSpeedCount5GLow[i].count);
+ assertEquals("Incorrect count of Rx link speed",
+ i + 1, mDecodedProto.rxLinkSpeedCount5GLow[i].count);
+ }
+ }
+
+ /**
* Verify that LinkSpeedCounts is not logged when disabled in settings
*/
@Test
@@ -2588,11 +2627,19 @@ public class WifiMetricsTest {
for (int j = 0; j <= i; j++) {
mWifiMetrics.incrementLinkSpeedCount(
WifiMetrics.MIN_LINK_SPEED_MBPS + i, TEST_RSSI_LEVEL);
+ mWifiMetrics.incrementTxLinkSpeedBandCount(
+ WifiMetrics.MIN_LINK_SPEED_MBPS - i, RSSI_POLL_FREQUENCY);
+ mWifiMetrics.incrementRxLinkSpeedBandCount(
+ WifiMetrics.MIN_LINK_SPEED_MBPS - i, RSSI_POLL_FREQUENCY);
}
}
dumpProtoAndDeserialize();
assertEquals("LinkSpeedCounts should not be logged when disabled in settings",
0, mDecodedProto.linkSpeedCounts.length);
+ assertEquals("Tx LinkSpeedCounts should not be logged when disabled in settings",
+ 0, mDecodedProto.txLinkSpeedCount5GLow.length);
+ assertEquals("Rx LinkSpeedCounts should not be logged when disabled in settings",
+ 0, mDecodedProto.rxLinkSpeedCount5GLow.length);
}
/**
@@ -2608,6 +2655,10 @@ public class WifiMetricsTest {
for (int i = 1; i < NUM_OUT_OF_BOUND_ENTRIES; i++) {
mWifiMetrics.incrementLinkSpeedCount(
WifiMetrics.MIN_LINK_SPEED_MBPS - i, MIN_RSSI_LEVEL);
+ mWifiMetrics.incrementTxLinkSpeedBandCount(
+ WifiMetrics.MIN_LINK_SPEED_MBPS - i, RSSI_POLL_FREQUENCY);
+ mWifiMetrics.incrementRxLinkSpeedBandCount(
+ WifiMetrics.MIN_LINK_SPEED_MBPS - i, RSSI_POLL_FREQUENCY);
}
for (int i = 1; i < NUM_OUT_OF_BOUND_ENTRIES; i++) {
mWifiMetrics.incrementLinkSpeedCount(
@@ -2620,6 +2671,10 @@ public class WifiMetricsTest {
dumpProtoAndDeserialize();
assertEquals("LinkSpeedCounts should not be logged for out of bound values",
0, mDecodedProto.linkSpeedCounts.length);
+ assertEquals("Tx LinkSpeedCounts should not be logged for out of bound values",
+ 0, mDecodedProto.txLinkSpeedCount5GLow.length);
+ assertEquals("Rx LinkSpeedCounts should not be logged for out of bound values",
+ 0, mDecodedProto.rxLinkSpeedCount5GLow.length);
}
private int nextRandInt() {