From b5a8f62f9ff6667bbce349569659a84fbd826db0 Mon Sep 17 00:00:00 2001 From: Steven Liu Date: Thu, 30 Apr 2020 19:58:43 -0700 Subject: Add CarrierWifi metrics Updated-PDD: TRUE Bug: 145762500 Test: atest com.android.server.wifi Merged-In: I11a60c877cd0a7594a4a691207e89935f35fe22e Change-Id: Ifd03a0e6d15d777e632f000c07a666d1d5491d6c --- .../src/com/android/server/wifi/ClientModeImplTest.java | 9 ++++++++- .../src/com/android/server/wifi/WifiMetricsTest.java | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java index c3829be46..bb9db6d51 100644 --- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java @@ -997,6 +997,8 @@ public class ClientModeImplTest extends WifiBaseTest { @Test public void connect() throws Exception { triggerConnect(); + WifiConfiguration config = mWifiConfigManager.getConfiguredNetwork(FRAMEWORK_NETWORK_ID); + config.carrierId = CARRIER_ID_1; when(mWifiConfigManager.getScanDetailCacheForNetwork(FRAMEWORK_NETWORK_ID)) .thenReturn(mScanDetailCache); @@ -1045,6 +1047,7 @@ public class ClientModeImplTest extends WifiBaseTest { assertEquals("", mConnectedNetwork.enterpriseConfig.getAnonymousIdentity()); verify(mWifiStateTracker).updateState(eq(WifiStateTracker.CONNECTED)); assertEquals("ConnectedState", getCurrentState().getName()); + verify(mWifiMetrics).incrementNumOfCarrierWifiConnectionSuccess(); verify(mWifiLockManager).updateWifiClientConnected(true); verify(mWifiNative).getConnectionCapabilities(any()); verify(mThroughputPredictor).predictMaxTxThroughput(any()); @@ -1703,6 +1706,7 @@ public class ClientModeImplTest extends WifiBaseTest { WifiConfiguration config = new WifiConfiguration(); config.SSID = sSSID; config.getNetworkSelectionStatus().setHasEverConnected(false); + config.carrierId = CARRIER_ID_1; when(mWifiConfigManager.getConfiguredNetwork(anyInt())).thenReturn(config); mCmi.sendMessage(WifiMonitor.AUTHENTICATION_FAILURE_EVENT, @@ -1712,7 +1716,7 @@ public class ClientModeImplTest extends WifiBaseTest { verify(mWrongPasswordNotifier).onWrongPasswordError(eq(sSSID)); verify(mWifiConfigManager).updateNetworkSelectionStatus(anyInt(), eq(WifiConfiguration.NetworkSelectionStatus.DISABLED_BY_WRONG_PASSWORD)); - + verify(mWifiMetrics).incrementNumOfCarrierWifiConnectionAuthFailure(); assertEquals("DisconnectedState", getCurrentState().getName()); } @@ -3077,6 +3081,8 @@ public class ClientModeImplTest extends WifiBaseTest { @Test public void testAssociationRejectionUpdatesWatchdog() throws Exception { initializeAndAddNetworkAndVerifySuccess(); + WifiConfiguration config = mWifiConfigManager.getConfiguredNetwork(FRAMEWORK_NETWORK_ID); + config.carrierId = CARRIER_ID_1; mCmi.sendMessage(ClientModeImpl.CMD_START_CONNECT, 0, 0, sBSSID); mCmi.sendMessage(WifiMonitor.ASSOCIATION_REJECTION_EVENT, 0, 0, sBSSID); mLooper.dispatchAll(); @@ -3084,6 +3090,7 @@ public class ClientModeImplTest extends WifiBaseTest { anyString(), anyString(), anyInt()); verify(mBssidBlocklistMonitor).handleBssidConnectionFailure(sBSSID, sSSID, BssidBlocklistMonitor.REASON_ASSOCIATION_REJECTION, false); + verify(mWifiMetrics).incrementNumOfCarrierWifiConnectionNonAuthFailure(); } /** diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java index 67d0c82a7..fcaee0550 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java @@ -4975,4 +4975,21 @@ public class WifiMetricsTest extends WifiBaseTest { assertEquals(0, mWifiMetrics.startConnectionEvent(mTestWifiConfig, "TestNetwork", WifiMetricsProto.ConnectionEvent.ROAM_ENTERPRISE)); } + + @Test + public void testCarrierWifiConnectionEvent() throws Exception { + mWifiMetrics.incrementNumOfCarrierWifiConnectionSuccess(); + for (int i = 0; i < 2; i++) { + mWifiMetrics.incrementNumOfCarrierWifiConnectionAuthFailure(); + } + for (int i = 0; i < 3; i++) { + mWifiMetrics.incrementNumOfCarrierWifiConnectionNonAuthFailure(); + } + + dumpProtoAndDeserialize(); + + assertEquals(1, mDecodedProto.carrierWifiMetrics.numConnectionSuccess); + assertEquals(2, mDecodedProto.carrierWifiMetrics.numConnectionAuthFailure); + assertEquals(3, mDecodedProto.carrierWifiMetrics.numConnectionNonAuthFailure); + } } -- cgit v1.2.3