diff options
author | Roshan Pius <rpius@google.com> | 2018-03-22 09:28:06 -0700 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2018-03-22 09:37:13 -0700 |
commit | b195838541edf2597659b217291079c52623d85c (patch) | |
tree | c5bd01328226ee15f88cd361ad7862ae1573f534 | |
parent | ee4e4d484fc699eea1492538b68c125782e57883 (diff) |
WifiMetrics: Send a different error code for assoc timeout
Note: This and all the other connection failure codes should be moved to the
proto file.
Bug: 34280407
Test: Unit tests
Change-Id: I1d8842475b3cadb15abebe60c612f685b7397ae0
3 files changed, 29 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java index 992182686..f899ac105 100644 --- a/service/java/com/android/server/wifi/WifiMetrics.java +++ b/service/java/com/android/server/wifi/WifiMetrics.java @@ -281,6 +281,8 @@ public class WifiMetrics { public static final int FAILURE_ROAM_TIMEOUT = 9; // DHCP failure public static final int FAILURE_DHCP = 10; + // ASSOCIATION_TIMED_OUT + public static final int FAILURE_ASSOCIATION_TIMED_OUT = 11; RouterFingerPrint mRouterFingerPrint; private long mRealStartTime; @@ -369,6 +371,10 @@ public class WifiMetrics { break; case FAILURE_DHCP: sb.append("DHCP"); + break; + case FAILURE_ASSOCIATION_TIMED_OUT: + sb.append("ASSOCIATION_TIMED_OUT"); + break; default: sb.append("UNKNOWN"); break; diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index 38c2cd428..4bcb8d2e1 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -4305,7 +4305,9 @@ public class WifiStateMachine extends StateMachine { mSupplicantStateTracker.sendMessage(WifiMonitor.ASSOCIATION_REJECTION_EVENT); // If rejection occurred while Metrics is tracking a ConnnectionEvent, end it. reportConnectionAttemptEnd( - WifiMetrics.ConnectionEvent.FAILURE_ASSOCIATION_REJECTION, + timedOut + ? WifiMetrics.ConnectionEvent.FAILURE_ASSOCIATION_TIMED_OUT + : WifiMetrics.ConnectionEvent.FAILURE_ASSOCIATION_REJECTION, WifiMetricsProto.ConnectionEvent.HLF_NONE); mWifiInjector.getWifiLastResortWatchdog() .noteConnectionFailureAndTriggerIfNeeded( diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java index d823f5a50..9f93e495f 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java @@ -977,6 +977,26 @@ public class WifiMetricsTest { } /** + * Test that WifiMetrics is serializing/deserializing association time out events. + */ + @Test + public void testMetricsAssociationTimedOut() throws Exception { + mWifiMetrics.startConnectionEvent(null, "RED", + WifiMetricsProto.ConnectionEvent.ROAM_NONE); + mWifiMetrics.endConnectionEvent( + WifiMetrics.ConnectionEvent.FAILURE_ASSOCIATION_TIMED_OUT, + WifiMetricsProto.ConnectionEvent.HLF_NONE); + + //Dump proto and deserialize + //This should clear all the metrics in mWifiMetrics, + dumpProtoAndDeserialize(); + //Check there is only 1 connection events + assertEquals(mDecodedProto.connectionEvent.length, 1); + assertEquals(mDecodedProto.connectionEvent[0].level2FailureCode, + WifiMetrics.ConnectionEvent.FAILURE_ASSOCIATION_TIMED_OUT); + } + + /** * Test that WifiMetrics is being cleared after dumping via proto */ @Test |