diff options
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiStateMachine.java | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index ce9c09432..b2eaad564 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -6774,7 +6774,11 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss // Ignore intermediate success, wait for full connection break; case WifiMonitor.NETWORK_CONNECTION_EVENT: - if (loadNetworksFromSupplicantAfterWps()) { + Pair<Boolean, Integer> loadResult = loadNetworksFromSupplicantAfterWps(); + boolean success = loadResult.first; + int netId = loadResult.second; + if (success) { + message.arg1 = netId; replyToMessage(mSourceMessage, WifiManager.WPS_COMPLETED); } else { replyToMessage(mSourceMessage, WifiManager.WPS_FAILED, @@ -6870,13 +6874,17 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss /** * Load network config from wpa_supplicant after WPS is complete. + * @return a boolean (true if load was successful) and integer (Network Id of currently + * connected network, can be {@link WifiConfiguration#INVALID_NETWORK_ID} despite + * successful loading, if multiple networks in supplicant) pair. */ - private boolean loadNetworksFromSupplicantAfterWps() { + private Pair<Boolean, Integer> loadNetworksFromSupplicantAfterWps() { Map<String, WifiConfiguration> configs = new HashMap<>(); SparseArray<Map<String, String>> extras = new SparseArray<>(); + int netId = WifiConfiguration.INVALID_NETWORK_ID; if (!mWifiNative.migrateNetworksFromSupplicant(configs, extras)) { loge("Failed to load networks from wpa_supplicant after Wps"); - return false; + return Pair.create(false, WifiConfiguration.INVALID_NETWORK_ID); } for (Map.Entry<String, WifiConfiguration> entry : configs.entrySet()) { WifiConfiguration config = entry.getValue(); @@ -6887,15 +6895,17 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss config, mSourceMessage.sendingUid); if (!result.isSuccess()) { loge("Failed to add network after WPS: " + entry.getValue()); - return false; + return Pair.create(false, WifiConfiguration.INVALID_NETWORK_ID); } if (!mWifiConfigManager.enableNetwork( result.getNetworkId(), true, mSourceMessage.sendingUid)) { - loge("Failed to enable network after WPS: " + entry.getValue()); - return false; + Log.wtf(TAG, "Failed to enable network after WPS: " + entry.getValue()); + return Pair.create(false, WifiConfiguration.INVALID_NETWORK_ID); } + netId = result.getNetworkId(); } - return true; + return Pair.create(true, + configs.size() == 1 ? netId : WifiConfiguration.INVALID_NETWORK_ID); } } |