Loading wifi/java/android/net/wifi/WifiConfigStore.java +11 −26 Original line number Diff line number Diff line Loading @@ -194,31 +194,6 @@ class WifiConfigStore { } } /** * Selects the specified network config for connection. This involves * addition/update of the specified config, updating the priority of * all the networks and enabling the given network while disabling others. * * Selecting a network will leave the other networks disabled and * a call to enableAllNetworks() needs to be issued upon a connection * or a failure event from supplicant * * @param config The configuration details in WifiConfiguration * @return the networkId now associated with the specified configuration */ int selectNetwork(WifiConfiguration config) { if (config != null) { NetworkUpdateResult result = addOrUpdateNetworkNative(config); int netId = result.getNetworkId(); if (netId != INVALID_NETWORK_ID) { selectNetwork(netId); } else { loge("Failed to update network " + config); } return netId; } return INVALID_NETWORK_ID; } /** * Selects the specified network for connection. This involves Loading @@ -230,8 +205,11 @@ class WifiConfigStore { * or a failure event from supplicant * * @param netId network to select for connection * @return false if the network id is invalid */ void selectNetwork(int netId) { boolean selectNetwork(int netId) { if (netId == INVALID_NETWORK_ID) return false; // Reset the priority of each network at start or if it goes too high. if (mLastPriority == -1 || mLastPriority > 1000000) { for(WifiConfiguration config : mConfiguredNetworks.values()) { Loading @@ -256,6 +234,7 @@ class WifiConfigStore { /* Avoid saving the config & sending a broadcast to prevent settings * from displaying a disabled list of networks */ return true; } /** Loading @@ -265,6 +244,12 @@ class WifiConfigStore { * @return network update result */ NetworkUpdateResult saveNetwork(WifiConfiguration config) { // A new network cannot have null SSID if (config == null || (config.networkId == INVALID_NETWORK_ID && config.SSID == null)) { return new NetworkUpdateResult(INVALID_NETWORK_ID); } boolean newNetwork = (config.networkId == INVALID_NETWORK_ID); NetworkUpdateResult result = addOrUpdateNetworkNative(config); int netId = result.getNetworkId(); Loading wifi/java/android/net/wifi/WifiStateMachine.java +16 −18 Original line number Diff line number Diff line Loading @@ -2849,35 +2849,33 @@ public class WifiStateMachine extends StateMachine { mWifiNative.reassociate(); break; case WifiManager.CONNECT_NETWORK: /* The connect message can contain a network id passed as arg1 on message or * or a config passed as obj on message. * For a new network, a config is passed to create and connect. * For an existing network, a network id is passed */ int netId = message.arg1; WifiConfiguration config = (WifiConfiguration) message.obj; /* We connect to a specific network by issuing a select * to the WifiConfigStore. This enables the network, * while disabling all other networks in the supplicant. * Disabling a connected network will cause a disconnection * from the network. A reconnectCommand() will then initiate * a connection to the enabled network. */ /* Save the network config */ if (config != null) { netId = mWifiConfigStore.selectNetwork(config); } else { mWifiConfigStore.selectNetwork(netId); NetworkUpdateResult result = mWifiConfigStore.saveNetwork(config); netId = result.getNetworkId(); } if (mWifiConfigStore.selectNetwork(netId) && mWifiNative.reconnect()) { /* The state tracker handles enabling networks upon completion/failure */ mSupplicantStateTracker.sendMessage(WifiManager.CONNECT_NETWORK); if (mWifiNative.reconnect()) { replyToMessage(message, WifiManager.CONNECT_NETWORK_SUCCEEDED); /* Expect a disconnection from the old connection */ transitionTo(mDisconnectingState); } else { loge("Failed to initiate connection"); loge("Failed to connect config: " + config + " netId: " + netId); replyToMessage(message, WifiManager.CONNECT_NETWORK_FAILED, WifiManager.ERROR); break; } /* Expect a disconnection from the old connection */ transitionTo(mDisconnectingState); break; case WifiManager.START_WPS: WpsInfo wpsInfo = (WpsInfo) message.obj; Loading Loading
wifi/java/android/net/wifi/WifiConfigStore.java +11 −26 Original line number Diff line number Diff line Loading @@ -194,31 +194,6 @@ class WifiConfigStore { } } /** * Selects the specified network config for connection. This involves * addition/update of the specified config, updating the priority of * all the networks and enabling the given network while disabling others. * * Selecting a network will leave the other networks disabled and * a call to enableAllNetworks() needs to be issued upon a connection * or a failure event from supplicant * * @param config The configuration details in WifiConfiguration * @return the networkId now associated with the specified configuration */ int selectNetwork(WifiConfiguration config) { if (config != null) { NetworkUpdateResult result = addOrUpdateNetworkNative(config); int netId = result.getNetworkId(); if (netId != INVALID_NETWORK_ID) { selectNetwork(netId); } else { loge("Failed to update network " + config); } return netId; } return INVALID_NETWORK_ID; } /** * Selects the specified network for connection. This involves Loading @@ -230,8 +205,11 @@ class WifiConfigStore { * or a failure event from supplicant * * @param netId network to select for connection * @return false if the network id is invalid */ void selectNetwork(int netId) { boolean selectNetwork(int netId) { if (netId == INVALID_NETWORK_ID) return false; // Reset the priority of each network at start or if it goes too high. if (mLastPriority == -1 || mLastPriority > 1000000) { for(WifiConfiguration config : mConfiguredNetworks.values()) { Loading @@ -256,6 +234,7 @@ class WifiConfigStore { /* Avoid saving the config & sending a broadcast to prevent settings * from displaying a disabled list of networks */ return true; } /** Loading @@ -265,6 +244,12 @@ class WifiConfigStore { * @return network update result */ NetworkUpdateResult saveNetwork(WifiConfiguration config) { // A new network cannot have null SSID if (config == null || (config.networkId == INVALID_NETWORK_ID && config.SSID == null)) { return new NetworkUpdateResult(INVALID_NETWORK_ID); } boolean newNetwork = (config.networkId == INVALID_NETWORK_ID); NetworkUpdateResult result = addOrUpdateNetworkNative(config); int netId = result.getNetworkId(); Loading
wifi/java/android/net/wifi/WifiStateMachine.java +16 −18 Original line number Diff line number Diff line Loading @@ -2849,35 +2849,33 @@ public class WifiStateMachine extends StateMachine { mWifiNative.reassociate(); break; case WifiManager.CONNECT_NETWORK: /* The connect message can contain a network id passed as arg1 on message or * or a config passed as obj on message. * For a new network, a config is passed to create and connect. * For an existing network, a network id is passed */ int netId = message.arg1; WifiConfiguration config = (WifiConfiguration) message.obj; /* We connect to a specific network by issuing a select * to the WifiConfigStore. This enables the network, * while disabling all other networks in the supplicant. * Disabling a connected network will cause a disconnection * from the network. A reconnectCommand() will then initiate * a connection to the enabled network. */ /* Save the network config */ if (config != null) { netId = mWifiConfigStore.selectNetwork(config); } else { mWifiConfigStore.selectNetwork(netId); NetworkUpdateResult result = mWifiConfigStore.saveNetwork(config); netId = result.getNetworkId(); } if (mWifiConfigStore.selectNetwork(netId) && mWifiNative.reconnect()) { /* The state tracker handles enabling networks upon completion/failure */ mSupplicantStateTracker.sendMessage(WifiManager.CONNECT_NETWORK); if (mWifiNative.reconnect()) { replyToMessage(message, WifiManager.CONNECT_NETWORK_SUCCEEDED); /* Expect a disconnection from the old connection */ transitionTo(mDisconnectingState); } else { loge("Failed to initiate connection"); loge("Failed to connect config: " + config + " netId: " + netId); replyToMessage(message, WifiManager.CONNECT_NETWORK_FAILED, WifiManager.ERROR); break; } /* Expect a disconnection from the old connection */ transitionTo(mDisconnectingState); break; case WifiManager.START_WPS: WpsInfo wpsInfo = (WpsInfo) message.obj; Loading