diff options
-rw-r--r-- | service/java/com/android/server/wifi/WifiStateMachine.java | 14 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java | 27 |
2 files changed, 33 insertions, 8 deletions
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index ebe6c3d07..6e5da1716 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -5172,6 +5172,20 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss // TODO(b/31065385): Passpoint config management. replyToMessage(message, message.what, 0); break; + case CMD_ADD_OR_UPDATE_PASSPOINT_CONFIG: + PasspointConfiguration passpointConfig = (PasspointConfiguration) message.obj; + if (mPasspointManager.addOrUpdateProvider(passpointConfig)) { + String fqdn = passpointConfig.getHomeSp().getFqdn(); + if (isProviderOwnedNetwork(mTargetNetworkId, fqdn) + || isProviderOwnedNetwork(mLastNetworkId, fqdn)) { + logd("Disconnect from current network since its provider is updated"); + sendMessage(CMD_DISCONNECT); + } + replyToMessage(message, message.what, SUCCESS); + } else { + replyToMessage(message, message.what, FAILURE); + } + break; case CMD_REMOVE_PASSPOINT_CONFIG: String fqdn = (String) message.obj; if (mPasspointManager.removeProvider(fqdn)) { diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java index c901227e0..80e29c6b1 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java @@ -1166,23 +1166,34 @@ public class WifiStateMachineTest { */ @Test public void syncAddOrUpdatePasspointConfig() throws Exception { - when(mPasspointManager.addOrUpdateProvider(any(PasspointConfiguration.class))) - .thenReturn(true); + PasspointConfiguration config = new PasspointConfiguration(); + HomeSp homeSp = new HomeSp(); + homeSp.setFqdn("test.com"); + config.setHomeSp(homeSp); + + when(mPasspointManager.addOrUpdateProvider(config)).thenReturn(true); mLooper.startAutoDispatch(); - assertTrue(mWsm.syncAddOrUpdatePasspointConfig(mWsmAsyncChannel, - new PasspointConfiguration())); + assertTrue(mWsm.syncAddOrUpdatePasspointConfig(mWsmAsyncChannel, config)); mLooper.stopAutoDispatch(); reset(mPasspointManager); - when(mPasspointManager.addOrUpdateProvider(any(PasspointConfiguration.class))) - .thenReturn(false); + when(mPasspointManager.addOrUpdateProvider(config)).thenReturn(false); mLooper.startAutoDispatch(); - assertFalse(mWsm.syncAddOrUpdatePasspointConfig(mWsmAsyncChannel, - new PasspointConfiguration())); + assertFalse(mWsm.syncAddOrUpdatePasspointConfig(mWsmAsyncChannel, config)); mLooper.stopAutoDispatch(); } /** + * Verify that syncAddOrUpdatePasspointConfig will redirect calls to {@link PasspointManager} + * and returning the result that's returned from {@link PasspointManager} when in client mode. + */ + @Test + public void syncAddOrUpdatePasspointConfigInClientMode() throws Exception { + loadComponentsInStaMode(); + syncAddOrUpdatePasspointConfig(); + } + + /** * Verify that syncRemovePasspointConfig will redirect calls to {@link PasspointManager} * and returning the result that's returned from {@link PasspointManager}. */ |