summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMingguang Xu <mingguangxu@google.com>2019-03-22 17:08:57 -0700
committerMingguang Xu <mingguangxu@google.com>2019-03-26 16:25:36 -0700
commit83ca5f56f59f919845ce38768dfa2ad29ea6ac65 (patch)
tree1a2bf17d3f3850edf17b5f54a7a7da7daadd4fc9
parent67ea084b08b7155fd760f3e8853ff4d4a0dcd3f9 (diff)
Wifi usability: A couple of tweaks to Wifi usability data collection
1. Change the range of Wifi usability score from [0,60] to [0,100]: Usability score represents the estimated probability of Wifi usability so it is more convenient to use the range of [0,100] for metric collection purpose (no action is taken). 2. Capture up to 40 samples (equivalently 2 mins) per dataset. 2-min usability stats can provide more information on how Wifi networks gradually become unusable. 3. The minimum gap between two events is checked based on the event time, which is the timestamp of the last entry in the ring buffer. Note that the timestamp of the first entry cannot represent the time when event happens. Bug: 113262380 Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh Change-Id: Ib775fd4b73d04956c53d76a8a4b905851764dcab Signed-off-by: Mingguang Xu <mingguangxu@google.com>
-rw-r--r--service/java/com/android/server/wifi/WifiMetrics.java14
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java28
2 files changed, 26 insertions, 16 deletions
diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java
index ccfdbc029..bbcc283d0 100644
--- a/service/java/com/android/server/wifi/WifiMetrics.java
+++ b/service/java/com/android/server/wifi/WifiMetrics.java
@@ -124,7 +124,7 @@ public class WifiMetrics {
private static final int MIN_WIFI_SCORE = 0;
private static final int MAX_WIFI_SCORE = NetworkAgent.WIFI_BASE_SCORE;
private static final int MIN_WIFI_USABILITY_SCORE = 0; // inclusive
- private static final int MAX_WIFI_USABILITY_SCORE = 60; // inclusive
+ private static final int MAX_WIFI_USABILITY_SCORE = 100; // inclusive
@VisibleForTesting
static final int LOW_WIFI_SCORE = 50; // Mobile data score
@VisibleForTesting
@@ -151,7 +151,7 @@ public class WifiMetrics {
private static final int WIFI_IS_UNUSABLE_EVENT_METRICS_ENABLED_DEFAULT = 1; // 1 = true
private static final int WIFI_LINK_SPEED_METRICS_ENABLED_DEFAULT = 1; // 1 = true
// Max number of WifiUsabilityStatsEntry elements to store in the ringbuffer.
- public static final int MAX_WIFI_USABILITY_STATS_ENTRIES_LIST_SIZE = 20;
+ public static final int MAX_WIFI_USABILITY_STATS_ENTRIES_LIST_SIZE = 40;
// Max number of WifiUsabilityStats elements to store for each type.
public static final int MAX_WIFI_USABILITY_STATS_LIST_SIZE_PER_TYPE = 10;
// Max number of WifiUsabilityStats per labeled type to upload to server
@@ -4352,9 +4352,10 @@ public class WifiMetrics {
// Only add a good event if at least |MIN_WIFI_GOOD_USABILITY_STATS_PERIOD_MS|
// has passed.
if (mWifiUsabilityStatsListGood.isEmpty()
- || mWifiUsabilityStatsListGood.getLast().stats[0].timeStampMs
+ || mWifiUsabilityStatsListGood.getLast().stats[mWifiUsabilityStatsListGood
+ .getLast().stats.length - 1].timeStampMs
+ MIN_WIFI_GOOD_USABILITY_STATS_PERIOD_MS
- < mWifiUsabilityStatsEntriesList.get(0).timeStampMs) {
+ < mWifiUsabilityStatsEntriesList.getLast().timeStampMs) {
while (mWifiUsabilityStatsListGood.size()
>= MAX_WIFI_USABILITY_STATS_LIST_SIZE_PER_TYPE) {
mWifiUsabilityStatsListGood.remove(
@@ -4367,9 +4368,10 @@ public class WifiMetrics {
// Only add a bad event if at least |MIN_DATA_STALL_WAIT_MS|
// has passed.
if (mWifiUsabilityStatsListBad.isEmpty()
- || (mWifiUsabilityStatsListBad.getLast().stats[0].timeStampMs
+ || (mWifiUsabilityStatsListBad.getLast().stats[mWifiUsabilityStatsListBad
+ .getLast().stats.length - 1].timeStampMs
+ MIN_DATA_STALL_WAIT_MS
- < mWifiUsabilityStatsEntriesList.get(0).timeStampMs)) {
+ < mWifiUsabilityStatsEntriesList.getLast().timeStampMs)) {
while (mWifiUsabilityStatsListBad.size()
>= MAX_WIFI_USABILITY_STATS_LIST_SIZE_PER_TYPE) {
mWifiUsabilityStatsListBad.remove(
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
index dda7fa8f2..8d095679c 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
@@ -2863,17 +2863,21 @@ public class WifiMetricsTest {
WifiLinkLayerStats stats3 = new WifiLinkLayerStats();
WifiLinkLayerStats stats4 = new WifiLinkLayerStats();
- stats4.timeStampInMs = stats3.timeStampInMs - 1 + WifiMetrics.MIN_DATA_STALL_WAIT_MS;
- for (int i = 0; i < WifiMetrics.MAX_WIFI_USABILITY_STATS_ENTRIES_LIST_SIZE - 2; i++) {
+ for (int i = 0; i < WifiMetrics.MAX_WIFI_USABILITY_STATS_ENTRIES_LIST_SIZE - 1; i++) {
mWifiMetrics.updateWifiUsabilityStatsEntries(info, stats3);
stats3 = nextRandomStats(stats3);
}
- addBadWifiUsabilityStats(stats3);
- for (int i = 0; i < WifiMetrics.MAX_WIFI_USABILITY_STATS_ENTRIES_LIST_SIZE - 2; i++) {
+ mWifiMetrics.updateWifiUsabilityStatsEntries(info, stats3);
+ mWifiMetrics.addToWifiUsabilityStatsList(WifiUsabilityStats.LABEL_BAD,
+ WifiUsabilityStats.TYPE_DATA_STALL_BAD_TX);
+ for (int i = 0; i < WifiMetrics.MAX_WIFI_USABILITY_STATS_ENTRIES_LIST_SIZE - 1; i++) {
mWifiMetrics.updateWifiUsabilityStatsEntries(info, stats4);
stats4 = nextRandomStats(stats4);
}
- addBadWifiUsabilityStats(stats4);
+ stats4.timeStampInMs = stats3.timeStampInMs - 1 + WifiMetrics.MIN_DATA_STALL_WAIT_MS;
+ mWifiMetrics.updateWifiUsabilityStatsEntries(info, stats4);
+ mWifiMetrics.addToWifiUsabilityStatsList(WifiUsabilityStats.LABEL_BAD,
+ WifiUsabilityStats.TYPE_DATA_STALL_BAD_TX);
dumpProtoAndDeserialize();
assertEquals(2, mDecodedProto.wifiUsabilityStatsList.length);
}
@@ -2898,17 +2902,21 @@ public class WifiMetricsTest {
WifiLinkLayerStats stats3 = new WifiLinkLayerStats();
WifiLinkLayerStats stats4 = new WifiLinkLayerStats();
- stats4.timeStampInMs = stats3.timeStampInMs + 1 + WifiMetrics.MIN_DATA_STALL_WAIT_MS;
- for (int i = 0; i < WifiMetrics.MAX_WIFI_USABILITY_STATS_ENTRIES_LIST_SIZE - 2; i++) {
+ for (int i = 0; i < WifiMetrics.MAX_WIFI_USABILITY_STATS_ENTRIES_LIST_SIZE - 1; i++) {
mWifiMetrics.updateWifiUsabilityStatsEntries(info, stats3);
stats3 = nextRandomStats(stats3);
}
- addBadWifiUsabilityStats(stats3);
- for (int i = 0; i < WifiMetrics.MAX_WIFI_USABILITY_STATS_ENTRIES_LIST_SIZE - 2; i++) {
+ mWifiMetrics.updateWifiUsabilityStatsEntries(info, stats3);
+ mWifiMetrics.addToWifiUsabilityStatsList(WifiUsabilityStats.LABEL_BAD,
+ WifiUsabilityStats.TYPE_DATA_STALL_BAD_TX);
+ for (int i = 0; i < WifiMetrics.MAX_WIFI_USABILITY_STATS_ENTRIES_LIST_SIZE - 1; i++) {
mWifiMetrics.updateWifiUsabilityStatsEntries(info, stats4);
stats4 = nextRandomStats(stats4);
}
- addBadWifiUsabilityStats(stats4);
+ stats4.timeStampInMs = stats3.timeStampInMs + 1 + WifiMetrics.MIN_DATA_STALL_WAIT_MS;
+ mWifiMetrics.updateWifiUsabilityStatsEntries(info, stats4);
+ mWifiMetrics.addToWifiUsabilityStatsList(WifiUsabilityStats.LABEL_BAD,
+ WifiUsabilityStats.TYPE_DATA_STALL_BAD_TX);
dumpProtoAndDeserialize();
assertEquals(4, mDecodedProto.wifiUsabilityStatsList.length);
}