From c4ad341e844e88a34be7ed4c3c9509fb72608b37 Mon Sep 17 00:00:00 2001 From: Ningyuan Wang Date: Mon, 1 May 2017 17:28:36 -0700 Subject: Abort scan before connection In the past, supplicant would abort any ongoing scan before issuing a connection or roaming request. For Android O we issue scans using wificond, so supplicant doesn't know about ongoing scan issued by wificond. As a result, we may have regression that connection request may be delayed because device is waiting for ongoing scan to finish. This patch adds back the logic at framework level, fixing the potential regression. Bug: 37743832 Test: compile, unit tests, integration test, manual test Change-Id: I556c7561d39a9d0b91399d5b3348256bcf0943c8 --- .../com/android/server/wifi/WifiNativeTest.java | 26 ++++++++++++++++++++++ .../android/server/wifi/WificondControlTest.java | 11 +++++++++ 2 files changed, 37 insertions(+) (limited to 'tests') diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java index 281c47a07..9447e4d25 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java @@ -28,6 +28,7 @@ import static org.mockito.Mockito.when; import android.net.wifi.IApInterface; import android.net.wifi.IClientInterface; +import android.net.wifi.WifiConfiguration; import android.test.suitebuilder.annotation.SmallTest; import org.junit.Before; @@ -614,4 +615,29 @@ public class WifiNativeTest { mWifiNative.stopPnoScan(); verify(mWificondControl).stopPnoScan(); } + + /** + * Verifies that connectToNetwork() calls underlying WificondControl and SupplicantStaIfaceHal. + */ + @Test + public void testConnectToNetwork() throws Exception { + WifiConfiguration config = mock(WifiConfiguration.class); + mWifiNative.connectToNetwork(config); + // connectToNetwork() should abort ongoing scan before connection. + verify(mWificondControl).abortScan(); + verify(mStaIfaceHal).connectToNetwork(config); + } + + /** + * Verifies that roamToNetwork() calls underlying WificondControl and SupplicantStaIfaceHal. + */ + @Test + public void testRoamToNetwork() throws Exception { + WifiConfiguration config = mock(WifiConfiguration.class); + mWifiNative.roamToNetwork(config); + // roamToNetwork() should abort ongoing scan before connection. + verify(mWificondControl).abortScan(); + verify(mStaIfaceHal).roamToNetwork(config); + } + } diff --git a/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java b/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java index 6d26c9b39..261733144 100644 --- a/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java @@ -596,6 +596,17 @@ public class WificondControlTest { verify(mWifiMonitor).broadcastPnoScanResultEvent(any(String.class)); } + /** + * Verifies that abortScan() calls underlying wificond. + */ + @Test + public void testAbortScan() throws Exception { + IWifiScannerImpl scanner = setupClientInterfaceAndCreateMockWificondScanner(); + + mWificondControl.abortScan(); + verify(scanner).abortScan(); + } + /** * Helper method: create a mock IClientInterface which mocks all neccessary operations. * Returns a mock IClientInterface. -- cgit v1.2.3