summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxshu <xshu@google.com>2020-01-09 15:01:00 -0800
committerxshu <xshu@google.com>2020-01-09 15:31:59 -0800
commit229a8457010009e748408d85773479edae01da9c (patch)
tree2caafd169b469a5153cc9c80434a92240f427b31
parent6632bbc1fb548fa613fdeaef3bf18ae08a8e8a47 (diff)
Metrics: number of IP renewal failures
Counts the number of times IP provisioning failure occurs in ConnectedState. Bug: 147448863 Test: atest FrameworksWifiTests Change-Id: I4274bba5a82036d1b61affbfd027bba9371955aa
-rw-r--r--service/java/com/android/server/wifi/ClientModeImpl.java4
-rw-r--r--service/java/com/android/server/wifi/WifiMetrics.java11
-rw-r--r--service/proto/src/metrics.proto3
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java15
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java5
5 files changed, 38 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java
index 8957f21fe..4f7fcf0ef 100644
--- a/service/java/com/android/server/wifi/ClientModeImpl.java
+++ b/service/java/com/android/server/wifi/ClientModeImpl.java
@@ -5158,6 +5158,10 @@ public class ClientModeImpl extends StateMachine {
break;
}
break;
+ case CMD_IP_CONFIGURATION_LOST:
+ mWifiMetrics.incrementIpRenewalFailure();
+ handleStatus = NOT_HANDLED;
+ break;
default:
handleStatus = NOT_HANDLED;
break;
diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java
index 1a0a13d35..f93a5cc9d 100644
--- a/service/java/com/android/server/wifi/WifiMetrics.java
+++ b/service/java/com/android/server/wifi/WifiMetrics.java
@@ -2853,6 +2853,8 @@ public class WifiMetrics {
pw.println("mWifiLogProto.rxLinkSpeedCount5gLow=" + mRxLinkSpeedCount5gLow);
pw.println("mWifiLogProto.rxLinkSpeedCount5gMid=" + mRxLinkSpeedCount5gMid);
pw.println("mWifiLogProto.rxLinkSpeedCount5gHigh=" + mRxLinkSpeedCount5gHigh);
+ pw.println("mWifiLogProto.numIpRenewalFailure="
+ + mWifiLogProto.numIpRenewalFailure);
}
}
}
@@ -5112,6 +5114,15 @@ public class WifiMetrics {
}
/**
+ * Increment number of IP renewal failures.
+ */
+ public void incrementIpRenewalFailure() {
+ synchronized (mLock) {
+ mWifiLogProto.numIpRenewalFailure++;
+ }
+ }
+
+ /**
* Sets the duration for evaluating Wifi condition to trigger a data stall
*/
public void setDataStallDurationMs(int duration) {
diff --git a/service/proto/src/metrics.proto b/service/proto/src/metrics.proto
index aa0b38e22..60dd432c4 100644
--- a/service/proto/src/metrics.proto
+++ b/service/proto/src/metrics.proto
@@ -573,6 +573,9 @@ message WifiLog {
// Histogram of Rx link speed at 5G high band
repeated Int32Count rx_link_speed_count_5g_high = 156;
+
+ // Count of IP renewal failures.
+ optional int32 num_ip_renewal_failure = 157;
}
// Information that gets logged for every WiFi connection.
diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
index cf893f494..4394c87b4 100644
--- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
@@ -1551,6 +1551,8 @@ public class ClientModeImplTest extends WifiBaseTest {
mLooper.dispatchAll();
assertEquals("DisconnectingState", getCurrentState().getName());
+ // Verify this is not counted as a IP renewal failure
+ verify(mWifiMetrics, never()).incrementIpRenewalFailure();
// Verifies that WifiLastResortWatchdog be notified
// by DHCP failure
verify(mWifiLastResortWatchdog, times(2)).noteConnectionFailureAndTriggerIfNeeded(
@@ -1564,6 +1566,19 @@ public class ClientModeImplTest extends WifiBaseTest {
}
/**
+ * Verify that a IP renewal failure is logged when IP provisioning fail in the
+ * ConnectedState.
+ */
+ @Test
+ public void testDhcpRenewalMetrics() throws Exception {
+ connect();
+ injectDhcpFailure();
+ mLooper.dispatchAll();
+
+ verify(mWifiMetrics).incrementIpRenewalFailure();
+ }
+
+ /**
* Verify that the network selection status will be updated with DISABLED_AUTHENTICATION_FAILURE
* when wrong password authentication failure is detected and the network had been
* connected previously.
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
index d63ace814..497e1f59a 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
@@ -410,6 +410,7 @@ public class WifiMetricsTest extends WifiBaseTest {
private static final int NUM_ONESHOT_SCAN_REQUESTS_WITH_DFS_CHANNELS = 4;
private static final int NUM_ADD_OR_UPDATE_NETWORK_CALLS = 5;
private static final int NUM_ENABLE_NETWORK_CALLS = 6;
+ private static final long NUM_IP_RENEWAL_FAILURE = 7;
/** Number of notifications per "Connect to Network" notification type. */
private static final int[] NUM_CONNECT_TO_NETWORK_NOTIFICATIONS = {0, 10, 20, 30, 40};
@@ -869,6 +870,9 @@ public class WifiMetricsTest extends WifiBaseTest {
for (int i = 0; i < NUM_ENABLE_NETWORK_CALLS; i++) {
mWifiMetrics.incrementNumEnableNetworkCalls();
}
+ for (int i = 0; i < NUM_IP_RENEWAL_FAILURE; i++) {
+ mWifiMetrics.incrementIpRenewalFailure();
+ }
mWifiMetrics.setWatchdogSuccessTimeDurationMs(NUM_WATCHDOG_SUCCESS_DURATION_MS);
mResources.setBoolean(R.bool.config_wifi_connected_mac_randomization_supported,
@@ -1208,6 +1212,7 @@ public class WifiMetricsTest extends WifiBaseTest {
mDecodedProto.numOneshotHasDfsChannelScans);
assertEquals(NUM_ADD_OR_UPDATE_NETWORK_CALLS, mDecodedProto.numAddOrUpdateNetworkCalls);
assertEquals(NUM_ENABLE_NETWORK_CALLS, mDecodedProto.numEnableNetworkCalls);
+ assertEquals(NUM_IP_RENEWAL_FAILURE, mDecodedProto.numIpRenewalFailure);
}
/**