summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);
}