diff options
author | Peter Qiu <zqiu@google.com> | 2017-05-24 15:37:17 -0700 |
---|---|---|
committer | Peter Qiu <zqiu@google.com> | 2017-05-31 16:03:12 +0000 |
commit | d35cddaf72ba0d679143fa07e07df330c6893574 (patch) | |
tree | 8781250b0d0772d0838e61dbb90486c9cc64792f /tests | |
parent | 78156cd914c78f7bd427b85d4b5ebf338d8166c3 (diff) |
Add support for installing Passpoint profile via overloaded API
In N and earlier, WifiManager#addNetwork was used for adding/installing
Passpoint profiles. In O, we've refactored the Passpoint support
and provided dedicated APIs. In order to be backward compatible
with existing apps, we need to continue support installing Passpoint
profile using WifiManager#addNetwork.
Bug: 62142779
Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Test: Manually update WifiInstaller to use WifiManager#addNetwork
to install Passpoint profile, and verify it works.
Change-Id: I4a91273dccef5521c2bbca2a83e2ff08ce109a14
Merged-In: I4a91273dccef5521c2bbca2a83e2ff08ce109a14
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java index 0c608d9ea..48e16a880 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java @@ -60,8 +60,10 @@ import android.content.res.Resources; import android.net.IpConfiguration; import android.net.wifi.ScanSettings; import android.net.wifi.WifiConfiguration; +import android.net.wifi.WifiEnterpriseConfig; import android.net.wifi.WifiManager; import android.net.wifi.WifiManager.LocalOnlyHotspotCallback; +import android.net.wifi.hotspot2.PasspointConfiguration; import android.os.Handler; import android.os.HandlerThread; import android.os.IBinder; @@ -1450,4 +1452,29 @@ public class WifiServiceImplTest { public void testStopWatchLocalOnlyHotspotNotSupported() { mWifiServiceImpl.stopWatchLocalOnlyHotspot(); } + + /** + * Verify that the call to addOrUpdateNetwork for installing Passpoint profile is redirected + * to the Passpoint specific API addOrUpdatePasspointConfiguration. + */ + @Test + public void testAddPasspointProfileViaAddNetwork() throws Exception { + WifiConfiguration config = WifiConfigurationTestUtil.createPasspointNetwork(); + config.enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.TLS); + when(mResources.getBoolean(com.android.internal.R.bool.config_wifi_hotspot2_enabled)) + .thenReturn(true); + + when(mWifiStateMachine.syncAddOrUpdatePasspointConfig(any(), + any(PasspointConfiguration.class), anyInt())).thenReturn(true); + assertEquals(0, mWifiServiceImpl.addOrUpdateNetwork(config)); + verify(mWifiStateMachine).syncAddOrUpdatePasspointConfig(any(), + any(PasspointConfiguration.class), anyInt()); + reset(mWifiStateMachine); + + when(mWifiStateMachine.syncAddOrUpdatePasspointConfig(any(), + any(PasspointConfiguration.class), anyInt())).thenReturn(false); + assertEquals(-1, mWifiServiceImpl.addOrUpdateNetwork(config)); + verify(mWifiStateMachine).syncAddOrUpdatePasspointConfig(any(), + any(PasspointConfiguration.class), anyInt()); + } } |