diff options
author | Roshan Pius <rpius@google.com> | 2016-04-21 12:09:57 -0700 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2016-04-21 14:01:27 -0700 |
commit | ad36265b6efc83414daf7e38283826482dfb5045 (patch) | |
tree | 0f1fc443252d999a7d82b7e98514e72d662d3efc /service | |
parent | 985df17909a5703a86f3e665abc9dd964d9623d9 (diff) |
WifiConfigManager: Remove redundant code
Remove some redundant code in enableNetwork and move some the network
status updation from state machine to ConfigManager.
BUG: 28317135
Change-Id: I375af87bd971352d3066a150e046571f00de44fd
TEST: Compiles & unit-test passes
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiConfigManager.java | 29 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiStateMachine.java | 8 |
2 files changed, 14 insertions, 23 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java index 4820cc2f6..a13512f5c 100644 --- a/service/java/com/android/server/wifi/WifiConfigManager.java +++ b/service/java/com/android/server/wifi/WifiConfigManager.java @@ -1294,35 +1294,30 @@ public class WifiConfigManager { * API. The more powerful selectNetwork()/saveNetwork() is used by the * state machine for connecting to a network * - * @param netId network to be enabled + * @param config network to be enabled * @return {@code true} if it succeeds, {@code false} otherwise */ - boolean enableNetwork(int netId, boolean disableOthers, int uid) { - WifiConfiguration config = mConfiguredNetworks.getForCurrentUser(netId); + boolean enableNetwork(WifiConfiguration config, boolean disableOthers, int uid) { if (config == null) { return false; } + + updateNetworkSelectionStatus( + config, WifiConfiguration.NetworkSelectionStatus.NETWORK_SELECTION_ENABLE); + setLatestUserSelectedConfiguration(config); boolean ret = true; if (disableOthers) { - ret = selectNetworkWithoutBroadcast(netId); + ret = selectNetworkWithoutBroadcast(config.networkId); if (sVDBG) { - localLogNetwork("enableNetwork(disableOthers=true, uid=" + uid + ") ", netId); + localLogNetwork("enableNetwork(disableOthers=true, uid=" + uid + ") ", + config.networkId); } - updateLastConnectUid(getWifiConfiguration(netId), uid); - + updateLastConnectUid(config, uid); writeKnownNetworkHistory(); sendConfiguredNetworksChangedBroadcast(); } else { - if (sVDBG) localLogNetwork("enableNetwork(disableOthers=false) ", netId); - WifiConfiguration enabledNetwork; - synchronized (mConfiguredNetworks) { // !!! Useless synchronization! - enabledNetwork = mConfiguredNetworks.getForCurrentUser(netId); - } - // check just in case the network was removed by someone else. - if (enabledNetwork != null) { - sendConfiguredNetworksChangedBroadcast(enabledNetwork, - WifiManager.CHANGE_REASON_CONFIG_CHANGE); - } + if (sVDBG) localLogNetwork("enableNetwork(disableOthers=false) ", config.networkId); + sendConfiguredNetworksChangedBroadcast(config, WifiManager.CHANGE_REASON_CONFIG_CHANGE); } return ret; } diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index ce6a9f690..5e921c607 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -5503,7 +5503,6 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss replyToMessage(message, message.what, FAILURE); break; } - // disable other only means select this network, does not mean all other // networks need to be disabled if (disableOthers) { @@ -5514,11 +5513,8 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss // Cancel auto roam requests autoRoamSetBSSID(netId, "any"); - int uid = message.sendingUid; - mWifiConfigManager.updateNetworkSelectionStatus(config, - WifiConfiguration.NetworkSelectionStatus.NETWORK_SELECTION_ENABLE); - mWifiConfigManager.setLatestUserSelectedConfiguration(config); - ok = mWifiConfigManager.enableNetwork(netId, disableOthers, uid); + ok = mWifiConfigManager.enableNetwork( + config, disableOthers, message.sendingUid); if (!ok) { messageHandlingStatus = MESSAGE_HANDLING_STATUS_FAIL; } else if (disableOthers) { |