diff options
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 669eff65f..66605971c 100644 --- a/service/java/com/android/server/wifi/WifiMetrics.java +++ b/service/java/com/android/server/wifi/WifiMetrics.java @@ -287,6 +287,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; @@ -375,6 +377,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 e2345e9b1..41371c6e1 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 07737b281..c31ecb03d 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java @@ -1047,6 +1047,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 |