diff options
author | Jong Wook Kim <jongwook@google.com> | 2018-08-08 15:03:31 -0700 |
---|---|---|
committer | Jong Wook Kim <jongwook@google.com> | 2018-08-08 15:15:19 -0700 |
commit | c3b4bcfb325898a9d753d5dae8aeaa8817999296 (patch) | |
tree | d2737ba6b9e7ccd978b4b644c58d7590208ae7a9 /tests | |
parent | 78f3b4a5f2b9032fcc16df9067883f9f88b01035 (diff) |
Log when wifi is turned on/off in metrics
Generate a StaEvent whenever wifi is enabled/disabled.
Bug: 112193991
Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Test: Turn wifi on/off from settings
Test: adb shell dumpsys wifi | grep -A10 StaEventList
Change-Id: I9ed97ed38e7529a6977bbf1a6004530f2af10a2e
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java | 10 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java | 14 |
2 files changed, 20 insertions, 4 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java index 4b04694d6..15acff41a 100644 --- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java @@ -94,6 +94,7 @@ import com.android.internal.util.StateMachine; import com.android.server.wifi.hotspot2.NetworkDetail; import com.android.server.wifi.hotspot2.PasspointManager; import com.android.server.wifi.hotspot2.PasspointProvisioningTestUtil; +import com.android.server.wifi.nano.WifiMetricsProto; import com.android.server.wifi.nano.WifiMetricsProto.StaEvent; import com.android.server.wifi.p2p.WifiP2pServiceImpl; import com.android.server.wifi.util.WifiPermissionsUtil; @@ -1828,6 +1829,7 @@ public class ClientModeImplTest { public void testWifiInfoCleanedUpEnteringExitingConnectModeState() throws Exception { InOrder inOrder = inOrder(mWifiConnectivityManager); InOrder inOrderSarMgr = inOrder(mSarManager); + InOrder inOrderMetrics = inOrder(mWifiMetrics); Log.i(TAG, mCmi.getCurrentState().getName()); String initialBSSID = "aa:bb:cc:dd:ee:ff"; WifiInfo wifiInfo = mCmi.getWifiInfo(); @@ -1839,6 +1841,9 @@ public class ClientModeImplTest { assertEquals(WifiManager.WIFI_STATE_ENABLED, mCmi.syncGetWifiState()); inOrder.verify(mWifiConnectivityManager).setWifiEnabled(eq(true)); inOrderSarMgr.verify(mSarManager).setClientWifiState(WifiManager.WIFI_STATE_ENABLED); + inOrderMetrics.verify(mWifiMetrics) + .setWifiState(WifiMetricsProto.WifiLog.WIFI_DISCONNECTED); + inOrderMetrics.verify(mWifiMetrics).logStaEvent(StaEvent.TYPE_WIFI_ENABLED); assertNull(wifiInfo.getBSSID()); // Send a SUPPLICANT_STATE_CHANGE_EVENT, verify WifiInfo is updated @@ -1859,6 +1864,8 @@ public class ClientModeImplTest { assertEquals(WifiManager.WIFI_STATE_DISABLED, mCmi.syncGetWifiState()); inOrder.verify(mWifiConnectivityManager).setWifiEnabled(eq(false)); inOrderSarMgr.verify(mSarManager).setClientWifiState(WifiManager.WIFI_STATE_DISABLED); + inOrderMetrics.verify(mWifiMetrics).setWifiState(WifiMetricsProto.WifiLog.WIFI_DISABLED); + inOrderMetrics.verify(mWifiMetrics).logStaEvent(StaEvent.TYPE_WIFI_DISABLED); assertNull(wifiInfo.getBSSID()); assertEquals(SupplicantState.DISCONNECTED, wifiInfo.getSupplicantState()); @@ -1880,6 +1887,9 @@ public class ClientModeImplTest { assertEquals(WifiManager.WIFI_STATE_ENABLED, mCmi.syncGetWifiState()); inOrder.verify(mWifiConnectivityManager).setWifiEnabled(eq(true)); inOrderSarMgr.verify(mSarManager).setClientWifiState(WifiManager.WIFI_STATE_ENABLED); + inOrderMetrics.verify(mWifiMetrics) + .setWifiState(WifiMetricsProto.WifiLog.WIFI_DISCONNECTED); + inOrderMetrics.verify(mWifiMetrics).logStaEvent(StaEvent.TYPE_WIFI_ENABLED); assertEquals("DisconnectedState", getCurrentState().getName()); assertEquals(SupplicantState.DISCONNECTED, wifiInfo.getSupplicantState()); assertNull(wifiInfo.getBSSID()); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java index bca0cab06..b3127e1ea 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java @@ -49,13 +49,13 @@ import com.android.server.wifi.hotspot2.PasspointMatch; import com.android.server.wifi.hotspot2.PasspointProvider; import com.android.server.wifi.nano.WifiMetricsProto; import com.android.server.wifi.nano.WifiMetricsProto.ConnectToNetworkNotificationAndActionCount; +import com.android.server.wifi.nano.WifiMetricsProto.PasspointProfileTypeCount; import com.android.server.wifi.nano.WifiMetricsProto.PnoScanMetrics; import com.android.server.wifi.nano.WifiMetricsProto.SoftApConnectedClientsEvent; import com.android.server.wifi.nano.WifiMetricsProto.StaEvent; import com.android.server.wifi.nano.WifiMetricsProto.WifiIsUnusableEvent; import com.android.server.wifi.nano.WifiMetricsProto.WifiRadioUsage; import com.android.server.wifi.nano.WifiMetricsProto.WpsMetrics; -import com.android.server.wifi.nano.WifiMetricsProto.PasspointProfileTypeCount; import com.android.server.wifi.rtt.RttMetrics; import org.junit.Before; @@ -1469,7 +1469,7 @@ public class WifiMetricsTest { private static final int ASSOC_TIMEOUT = 1; private static final int LOCAL_GEN = 1; private static final int AUTH_FAILURE_REASON = WifiManager.ERROR_AUTH_FAILURE_WRONG_PSWD; - private static final int NUM_TEST_STA_EVENTS = 16; + private static final int NUM_TEST_STA_EVENTS = 18; private static final String sSSID = "\"SomeTestSsid\""; private static final WifiSsid sWifiSsid = WifiSsid.createFromAsciiEncoded(sSSID); private static final String sBSSID = "01:02:03:04:05:06"; @@ -1519,7 +1519,9 @@ public class WifiMetricsTest { {StaEvent.TYPE_NETWORK_AGENT_VALID_NETWORK, 0, 0}, {StaEvent.TYPE_FRAMEWORK_DISCONNECT, StaEvent.DISCONNECT_API, 0}, {StaEvent.TYPE_SCORE_BREACH, 0, 0}, - {StaEvent.TYPE_MAC_CHANGE, 0, 1} + {StaEvent.TYPE_MAC_CHANGE, 0, 1}, + {StaEvent.TYPE_WIFI_ENABLED, 0, 0}, + {StaEvent.TYPE_WIFI_DISABLED, 0, 0} }; // Values used to generate the StaEvent log calls from WifiMonitor // <type>, <reason>, <status>, <local_gen>, @@ -1556,7 +1558,11 @@ public class WifiMetricsTest { {StaEvent.TYPE_SCORE_BREACH, -1, -1, 0, /**/ 0, 0, 0, 0}, /**/ {StaEvent.TYPE_MAC_CHANGE, -1, -1, 0, - /**/ 0, 0, 0, 1} /**/ + /**/ 0, 0, 0, 1}, /**/ + {StaEvent.TYPE_WIFI_ENABLED, -1, -1, 0, + /**/ 0, 0, 0, 0}, /**/ + {StaEvent.TYPE_WIFI_DISABLED, -1, -1, 0, + /**/ 0, 0, 0, 0} /**/ }; /** |