From bac7430bc9de3779b078da596a2ef1badfc7fd54 Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Wed, 6 May 2020 08:31:40 -0700 Subject: SupplicantStaIfaceCallback: Refactor FILS connection event handling The new FILS param in onStateChanged() callback in V3 HAL version resulted in duplication of code in V10 & V13 HAL callback implementation. Refactor the code to remove this duplication. Changes: a) Remove the new FILS_NETWORK_CONNECTION_EVENT message and instead add a boolean in the regular NETWORK_CONNECTION_EVENT message to indicate whether the connection used FILS or not. b) Plumb the new filsHlpSent param from V13 callback all the way back to V10 callback. (cherry-picked from ag/11403532) Bug: 135503681 Bug: 159687884 Test: atest com.android.server.wifi Merged-In: I9a3694540e994c09a5268e0ae0b7722654a3384c Change-Id: I9a3694540e994c09a5268e0ae0b7722654a3384c --- .../src/com/android/server/wifi/ClientModeImplTest.java | 2 +- .../com/android/server/wifi/SupplicantStaIfaceHalTest.java | 8 ++++---- .../src/com/android/server/wifi/WifiMonitorTest.java | 11 ++++++----- 3 files changed, 11 insertions(+), 10 deletions(-) (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 fd1ef1718..d4af7ecac 100644 --- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java @@ -4986,7 +4986,7 @@ public class ClientModeImplTest extends WifiBaseTest { verify(mWifiMetrics, times(1)).incrementConnectRequestWithFilsAkmCount(); - mCmi.sendMessage(WifiMonitor.FILS_NETWORK_CONNECTION_EVENT, 0, 0, sBSSID); + mCmi.sendMessage(WifiMonitor.NETWORK_CONNECTION_EVENT, 0, 1, sBSSID); mLooper.dispatchAll(); verify(mWifiMetrics, times(1)).incrementL2ConnectionThroughFilsAuthCount(); diff --git a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java index 762691184..7e0c20faf 100644 --- a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java @@ -1010,7 +1010,7 @@ public class SupplicantStaIfaceHalTest extends WifiBaseTest { NativeUtil.decodeSsid(SUPPLICANT_SSID)); wifiMonitorInOrder.verify(mWifiMonitor).broadcastNetworkConnectionEvent( - eq(WLAN0_IFACE_NAME), eq(frameworkNetworkId), eq(BSSID)); + eq(WLAN0_IFACE_NAME), eq(frameworkNetworkId), eq(false), eq(BSSID)); wifiMonitorInOrder.verify(mWifiMonitor).broadcastSupplicantStateChangeEvent( eq(WLAN0_IFACE_NAME), eq(frameworkNetworkId), any(WifiSsid.class), eq(BSSID), eq(SupplicantState.COMPLETED)); @@ -2824,7 +2824,7 @@ public class SupplicantStaIfaceHalTest extends WifiBaseTest { NativeUtil.decodeSsid(SUPPLICANT_SSID), false); wifiMonitorInOrder.verify(mWifiMonitor).broadcastNetworkConnectionEvent( - eq(WLAN0_IFACE_NAME), eq(frameworkNetworkId), eq(BSSID)); + eq(WLAN0_IFACE_NAME), eq(frameworkNetworkId), eq(false), eq(BSSID)); wifiMonitorInOrder.verify(mWifiMonitor).broadcastSupplicantStateChangeEvent( eq(WLAN0_IFACE_NAME), eq(frameworkNetworkId), any(WifiSsid.class), eq(BSSID), eq(SupplicantState.COMPLETED)); @@ -2904,8 +2904,8 @@ public class SupplicantStaIfaceHalTest extends WifiBaseTest { NativeUtil.macAddressToByteArray(BSSID), SUPPLICANT_NETWORK_ID, NativeUtil.decodeSsid(SUPPLICANT_SSID), true); - wifiMonitorInOrder.verify(mWifiMonitor).broadcastFilsNetworkConnectionEvent( - eq(WLAN0_IFACE_NAME), eq(frameworkNetworkId), eq(BSSID)); + wifiMonitorInOrder.verify(mWifiMonitor).broadcastNetworkConnectionEvent( + eq(WLAN0_IFACE_NAME), eq(frameworkNetworkId), eq(true), eq(BSSID)); wifiMonitorInOrder.verify(mWifiMonitor).broadcastSupplicantStateChangeEvent( eq(WLAN0_IFACE_NAME), eq(frameworkNetworkId), any(WifiSsid.class), eq(BSSID), eq(SupplicantState.COMPLETED)); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java index 24bb968a5..c4acd73c2 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java @@ -423,13 +423,14 @@ public class WifiMonitorTest extends WifiBaseTest { WLAN_IFACE_NAME, WifiMonitor.NETWORK_CONNECTION_EVENT, mHandlerSpy); int networkId = NETWORK_ID; String bssid = BSSID; - mWifiMonitor.broadcastNetworkConnectionEvent(WLAN_IFACE_NAME, networkId, bssid); + mWifiMonitor.broadcastNetworkConnectionEvent(WLAN_IFACE_NAME, networkId, false, bssid); mLooper.dispatchAll(); ArgumentCaptor messageCaptor = ArgumentCaptor.forClass(Message.class); verify(mHandlerSpy).handleMessage(messageCaptor.capture()); assertEquals(WifiMonitor.NETWORK_CONNECTION_EVENT, messageCaptor.getValue().what); assertEquals(networkId, messageCaptor.getValue().arg1); + assertEquals(0, messageCaptor.getValue().arg2); assertEquals(bssid, (String) messageCaptor.getValue().obj); } @@ -607,17 +608,17 @@ public class WifiMonitorTest extends WifiBaseTest { @Test public void testBroadcastFilsNetworkConnectionEvent() { mWifiMonitor.registerHandler( - WLAN_IFACE_NAME, WifiMonitor.FILS_NETWORK_CONNECTION_EVENT, mHandlerSpy); + WLAN_IFACE_NAME, WifiMonitor.NETWORK_CONNECTION_EVENT, mHandlerSpy); int networkId = NETWORK_ID; String bssid = BSSID; - mWifiMonitor.broadcastFilsNetworkConnectionEvent(WLAN_IFACE_NAME, networkId, bssid); + mWifiMonitor.broadcastNetworkConnectionEvent(WLAN_IFACE_NAME, networkId, true, bssid); mLooper.dispatchAll(); ArgumentCaptor messageCaptor = ArgumentCaptor.forClass(Message.class); verify(mHandlerSpy).handleMessage(messageCaptor.capture()); - assertEquals(WifiMonitor.FILS_NETWORK_CONNECTION_EVENT, messageCaptor.getValue().what); + assertEquals(WifiMonitor.NETWORK_CONNECTION_EVENT, messageCaptor.getValue().what); assertEquals(networkId, messageCaptor.getValue().arg1); + assertEquals(1, messageCaptor.getValue().arg2); assertEquals(bssid, (String) messageCaptor.getValue().obj); } - } -- cgit v1.2.3