From d35cddaf72ba0d679143fa07e07df330c6893574 Mon Sep 17 00:00:00 2001 From: Peter Qiu Date: Wed, 24 May 2017 15:37:17 -0700 Subject: 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 --- .../android/server/wifi/WifiServiceImplTest.java | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'tests') 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()); + } } -- cgit v1.2.3