summaryrefslogtreecommitdiffstats
path: root/tests/wifitests/src/com/android/server/wifi/hotspot2
diff options
context:
space:
mode:
authorEcco Park <eccopark@google.com>2018-12-27 16:13:07 -0800
committerEcco Park <eccopark@google.com>2019-01-07 13:19:48 -0800
commit12bf6dc320343cbe051aae0e65c6b92f1584da08 (patch)
treeb770ed36e5eaf809579fd8a212ab46947ddf820d /tests/wifitests/src/com/android/server/wifi/hotspot2
parente52bfec84a81968b6005b66b9d96f6a737c4bbd0 (diff)
downloadandroid_frameworks_opt_net_wifi-12bf6dc320343cbe051aae0e65c6b92f1584da08.tar.gz
android_frameworks_opt_net_wifi-12bf6dc320343cbe051aae0e65c6b92f1584da08.tar.bz2
android_frameworks_opt_net_wifi-12bf6dc320343cbe051aae0e65c6b92f1584da08.zip
passpoint-r2: fixes OSU network connection problem
Test Scenario: 1) Connected to any AP 2) Click OSU on UI to start Provisioning flow Expected result: Open up the OSU login window Actual result: Got disconnection for the AP immediately and connected to previous AP. There are two root causes for this disconection. 1) remove ephemeral network in removeAllEphemeralOrPasspointConfiguredNetworks() API on wifi stateMachine at any disconnect event. => currently OSU AP is configured as ephemeral network in the connect of OsuNetworkConnection not to save the config. => When previous AP is diconnected, it causes to disconnect ongoing connection of OSU-AP. Solution: removeAllEphemeralOrPasspointConfiguredNetworks only when wifi become disable. 2) receive connect and disconnect event for previous AP. OsuNetworkcallback receives the connect and disconnect event for previous AP. It causes Passpoint State to move to next state and failed to connect OSU server. Eventually it causes to disconnect OSU AP. Solution: only receive the connect and disconnect event for OSU-AP. Bug: 121223278 Test:./frameworks/opt/net/wifi/tests/wifitests/runtests.sh Test: tested with R2 AP under the test scenario. Change-Id: I77a9a36e14aed9f73773d7a06eb212604fde11fe Signed-off-by: Ecco Park <eccopark@google.com>
Diffstat (limited to 'tests/wifitests/src/com/android/server/wifi/hotspot2')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/hotspot2/OsuNetworkConnectionTest.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/OsuNetworkConnectionTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/OsuNetworkConnectionTest.java
index 5fb0cc0a4..65ab8588a 100644
--- a/tests/wifitests/src/com/android/server/wifi/hotspot2/OsuNetworkConnectionTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/OsuNetworkConnectionTest.java
@@ -92,6 +92,7 @@ public class OsuNetworkConnectionTest {
when(mWifiManager.isWifiEnabled()).thenReturn(true);
when(mWifiManager.enableNetwork(TEST_NETWORK_ID, true)).thenReturn(true);
when(mWifiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(TEST_NETWORK_ID);
+ when(mWifiManager.getConnectionInfo()).thenReturn(mWifiInfo);
when(mWifiInfo.getNetworkId()).thenReturn(TEST_NETWORK_ID);
mLooper = new TestLooper();
mHandler = new Handler(mLooper.getLooper());
@@ -216,6 +217,7 @@ public class OsuNetworkConnectionTest {
verify(mConnectivityManager).requestNetwork(any(NetworkRequest.class),
networkCallbackCaptor.capture(), any(Handler.class), anyInt());
ConnectivityManager.NetworkCallback callback = networkCallbackCaptor.getValue();
+ callback.onAvailable(mCurrentNetwork);
callback.onLinkPropertiesChanged(mCurrentNetwork, createProvisionedLinkProperties());
verify(mNetworkCallbacks).onConnected(mCurrentNetwork);
@@ -230,6 +232,28 @@ public class OsuNetworkConnectionTest {
}
/**
+ * Verifies that onConnected callback are never invoked when onLinkPropertiesChanged is invoked
+ * without onAvailable of NetworkCallback.
+ */
+ @Test
+ public void verifyNetworkCallbackWithoutOnAvailable() {
+ mNetworkConnection.init(mHandler);
+
+ mNetworkConnection.setEventCallback(mNetworkCallbacks);
+ assertEquals(true, mNetworkConnection.connect(TEST_SSID, TEST_NAI));
+
+ ArgumentCaptor<ConnectivityManager.NetworkCallback> networkCallbackCaptor =
+ ArgumentCaptor.forClass(ConnectivityManager.NetworkCallback.class);
+ verify(mConnectivityManager).requestNetwork(any(NetworkRequest.class),
+ networkCallbackCaptor.capture(), any(Handler.class), anyInt());
+ ConnectivityManager.NetworkCallback callback = networkCallbackCaptor.getValue();
+
+ callback.onLinkPropertiesChanged(mCurrentNetwork, createProvisionedLinkProperties());
+
+ verify(mNetworkCallbacks, never()).onConnected(mCurrentNetwork);
+ }
+
+ /**
* Verifies that network state callbacks are invoked when the network callbacks
* are received and when WifiManager has successfully requested connection to the OSU AP.
* If IP connectivity is not provisioned, do not invoke onConnected callback.
@@ -292,6 +316,7 @@ public class OsuNetworkConnectionTest {
WifiConfiguration wifiConfiguration = wifiConfigurationCaptor.getValue();
assertTrue(wifiConfiguration.isNoInternetAccessExpected());
assertTrue(wifiConfiguration.isEphemeral());
+ assertTrue(wifiConfiguration.osu);
ArgumentCaptor<NetworkRequest> networkRequestCaptor = ArgumentCaptor.forClass(
NetworkRequest.class);