diff options
author | Ningyuan Wang <nywang@google.com> | 2017-03-23 21:21:58 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-03-23 21:21:58 +0000 |
commit | ce0bec30360b3f6559342d8c77175fcb4768a044 (patch) | |
tree | 7da2c003f5ce7fc2f385250bf30197e01b9c4b3e /service | |
parent | dc59be4e200b9739a3a114360743f7d021e4f758 (diff) | |
parent | 5fc64fc1daeb4a60cdcd124728ec93d351caf218 (diff) |
Do not initialize connection upon SAVE_NEWORK am: 1316bfba02 am: 0ae1655c95
am: 5fc64fc1da
Change-Id: Ic7d961ca07765eb2c1d6d2a82aab1eb4cbe54e24
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiServiceImpl.java | 57 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiStateMachine.java | 14 |
2 files changed, 37 insertions, 34 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index cef91f97a..303af02db 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -201,42 +201,45 @@ public class WifiServiceImpl extends IWifiManager.Stub { ac.connect(mContext, this, msg.replyTo); break; } - /* Client commands are forwarded to state machine */ - case WifiManager.CONNECT_NETWORK: - case WifiManager.SAVE_NETWORK: { + case WifiManager.CONNECT_NETWORK: { WifiConfiguration config = (WifiConfiguration) msg.obj; int networkId = msg.arg1; - if (msg.what == WifiManager.SAVE_NETWORK) { - Slog.d("WiFiServiceImpl ", "SAVE" - + " nid=" + Integer.toString(networkId) - + " uid=" + msg.sendingUid - + " name=" - + mContext.getPackageManager().getNameForUid(msg.sendingUid)); - } - if (msg.what == WifiManager.CONNECT_NETWORK) { - Slog.d("WiFiServiceImpl ", "CONNECT " - + " nid=" + Integer.toString(networkId) - + " uid=" + msg.sendingUid - + " name=" - + mContext.getPackageManager().getNameForUid(msg.sendingUid)); - } - + Slog.d("WiFiServiceImpl ", "CONNECT " + + " nid=" + Integer.toString(networkId) + + " uid=" + msg.sendingUid + + " name=" + + mContext.getPackageManager().getNameForUid(msg.sendingUid)); if (config != null && isValid(config)) { - if (DBG) Slog.d(TAG, "Connect with config" + config); + if (DBG) Slog.d(TAG, "Connect with config " + config); + /* Command is forwarded to state machine */ mWifiStateMachine.sendMessage(Message.obtain(msg)); } else if (config == null && networkId != WifiConfiguration.INVALID_NETWORK_ID) { - if (DBG) Slog.d(TAG, "Connect with networkId" + networkId); + if (DBG) Slog.d(TAG, "Connect with networkId " + networkId); mWifiStateMachine.sendMessage(Message.obtain(msg)); } else { Slog.e(TAG, "ClientHandler.handleMessage ignoring invalid msg=" + msg); - if (msg.what == WifiManager.CONNECT_NETWORK) { - replyFailed(msg, WifiManager.CONNECT_NETWORK_FAILED, - WifiManager.INVALID_ARGS); - } else { - replyFailed(msg, WifiManager.SAVE_NETWORK_FAILED, - WifiManager.INVALID_ARGS); - } + replyFailed(msg, WifiManager.CONNECT_NETWORK_FAILED, + WifiManager.INVALID_ARGS); + } + break; + } + case WifiManager.SAVE_NETWORK: { + WifiConfiguration config = (WifiConfiguration) msg.obj; + int networkId = msg.arg1; + Slog.d("WiFiServiceImpl ", "SAVE" + + " nid=" + Integer.toString(networkId) + + " uid=" + msg.sendingUid + + " name=" + + mContext.getPackageManager().getNameForUid(msg.sendingUid)); + if (config != null && isValid(config)) { + if (DBG) Slog.d(TAG, "Save network with config " + config); + /* Command is forwarded to state machine */ + mWifiStateMachine.sendMessage(Message.obtain(msg)); + } else { + Slog.e(TAG, "ClientHandler.handleMessage ignoring invalid msg=" + msg); + replyFailed(msg, WifiManager.SAVE_NETWORK_FAILED, + WifiManager.INVALID_ARGS); } break; } diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index e015c3ad3..898a9ca76 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -5119,13 +5119,13 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss mIpManager.setHttpProxy( getCurrentWifiConfiguration().getHttpProxy()); } - } else { - if (!connectToUserSelectNetwork(netId, message.sendingUid)) { - messageHandlingStatus = MESSAGE_HANDLING_STATUS_FAIL; - replyToMessage(message, WifiManager.SAVE_NETWORK_FAILED, - WifiManager.NOT_AUTHORIZED); - break; - } + } else if (!mWifiConfigManager.enableNetwork(result.getNetworkId(), + false, message.sendingUid)) { + loge("ENABLE_NETWORK config=" + config + " failed"); + messageHandlingStatus = MESSAGE_HANDLING_STATUS_FAIL; + replyToMessage(message, WifiManager.SAVE_NETWORK_FAILED, + WifiManager.ERROR); + break; } broadcastWifiCredentialChanged(WifiManager.WIFI_CREDENTIAL_SAVED, config); replyToMessage(message, WifiManager.SAVE_NETWORK_SUCCEEDED); |