diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2017-08-22 03:29:15 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-08-22 03:29:15 +0000 |
commit | f6e0f26cc0823b628f887c651a906fa3ebbab070 (patch) | |
tree | 8c1dbd620ddb08df5e9393d0fb43dc1e61b51697 /service | |
parent | c2775146944350a720acbf33942a583540094246 (diff) | |
parent | d27716a747d9cf2d86153aa9ec1b55b663808b28 (diff) |
Merge "Update NETWORK_CONNECTION_EVENT netId after WPS" into oc-mr1-dev
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); } } |