summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2017-03-30 08:17:37 -0700
committerRoshan Pius <rpius@google.com>2017-04-03 08:20:27 -0700
commitdc5eab67d9ca3e0453318071746e76b5d16990d6 (patch)
tree73b9d2f76df3f4ca42568b281df012c7de97d441 /service
parent31eb1e8997a0ee98df33f6d8b3b907e0fcb070ed (diff)
WSM: Support add/update/enable network in any state
WifiConfigManager can support network addition/updation as soon as the config store is read at bootup. So, add support for it in WSM. ENABLE_NETWORK handling is duplicated because when wifi is off, we don't want to trigger a connection request (when disableOthers is true). Bug: 36773940 Test: Unit tests. Change-Id: Ib4089e45e61062e1043329b2b77d1d19579cb3c0
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiConfigManager.java4
-rw-r--r--service/java/com/android/server/wifi/WifiStateMachine.java27
2 files changed, 22 insertions, 9 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java
index 63168e995..9cbb48515 100644
--- a/service/java/com/android/server/wifi/WifiConfigManager.java
+++ b/service/java/com/android/server/wifi/WifiConfigManager.java
@@ -998,6 +998,10 @@ public class WifiConfigManager {
Log.e(TAG, "Cannot add/update network with null config");
return new NetworkUpdateResult(WifiConfiguration.INVALID_NETWORK_ID);
}
+ if (mPendingStoreRead) {
+ Log.e(TAG, "Cannot add/update network before store is read!");
+ return new NetworkUpdateResult(WifiConfiguration.INVALID_NETWORK_ID);
+ }
NetworkUpdateResult result = addOrUpdateNetworkInternal(config, uid);
if (!result.isSuccess()) {
Log.e(TAG, "Failed to add/update network " + config.getPrintableSsid());
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index 6e5da1716..3825ea61b 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -3667,7 +3667,24 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
BluetoothAdapter.STATE_DISCONNECTED);
break;
case CMD_ENABLE_NETWORK:
+ boolean disableOthers = message.arg2 == 1;
+ int netId = message.arg1;
+ boolean ok = mWifiConfigManager.enableNetwork(
+ netId, disableOthers, message.sendingUid);
+ if (!ok) {
+ messageHandlingStatus = MESSAGE_HANDLING_STATUS_FAIL;
+ }
+ replyToMessage(message, message.what, ok ? SUCCESS : FAILURE);
+ break;
case CMD_ADD_OR_UPDATE_NETWORK:
+ WifiConfiguration config = (WifiConfiguration) message.obj;
+ NetworkUpdateResult result =
+ mWifiConfigManager.addOrUpdateNetwork(config, message.sendingUid);
+ if (!result.isSuccess()) {
+ messageHandlingStatus = MESSAGE_HANDLING_STATUS_FAIL;
+ }
+ replyToMessage(message, message.what, result.getNetworkId());
+ break;
case CMD_SAVE_CONFIG:
replyToMessage(message, message.what, FAILURE);
break;
@@ -3692,7 +3709,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
}
break;
case CMD_INITIALIZE:
- boolean ok = mWifiNative.initializeVendorHal(mVendorHalDeathRecipient);
+ ok = mWifiNative.initializeVendorHal(mVendorHalDeathRecipient);
replyToMessage(message, message.what, ok ? SUCCESS : FAILURE);
break;
case CMD_BOOT_COMPLETED:
@@ -4772,14 +4789,6 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
mTemporarilyDisconnectWifi = false;
}
break;
- case CMD_ADD_OR_UPDATE_NETWORK:
- config = (WifiConfiguration) message.obj;
- result = mWifiConfigManager.addOrUpdateNetwork(config, message.sendingUid);
- if (!result.isSuccess()) {
- messageHandlingStatus = MESSAGE_HANDLING_STATUS_FAIL;
- }
- replyToMessage(message, message.what, result.getNetworkId());
- break;
case CMD_REMOVE_NETWORK:
if (!deleteNetworkConfigAndSendReply(message, false)) {
// failed to remove the config and caller was notified