summaryrefslogtreecommitdiffstats
path: root/services/java/com/android/server/wifi
diff options
context:
space:
mode:
authorVinit Deshapnde <vinitd@google.com>2013-09-12 20:28:57 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-09-12 20:28:57 +0000
commitb481dae2f5238252d81dafeecf13d5f387824689 (patch)
tree35f2ff737e4f3ffcfa912c61d5a609147c70535f /services/java/com/android/server/wifi
parentef2088a26a42621329c6b9fecb323566e19490e4 (diff)
parent10652a95b16909acf26f31cdafc0c6aa09212f26 (diff)
downloadframeworks_base-b481dae2f5238252d81dafeecf13d5f387824689.zip
frameworks_base-b481dae2f5238252d81dafeecf13d5f387824689.tar.gz
frameworks_base-b481dae2f5238252d81dafeecf13d5f387824689.tar.bz2
Merge "Fix invalid Wifi Network system crash" into klp-dev
Diffstat (limited to 'services/java/com/android/server/wifi')
-rw-r--r--services/java/com/android/server/wifi/WifiService.java49
1 files changed, 43 insertions, 6 deletions
diff --git a/services/java/com/android/server/wifi/WifiService.java b/services/java/com/android/server/wifi/WifiService.java
index ed2b8fd..46f100e 100644
--- a/services/java/com/android/server/wifi/WifiService.java
+++ b/services/java/com/android/server/wifi/WifiService.java
@@ -170,7 +170,20 @@ public final class WifiService extends IWifiManager.Stub {
}
/* Client commands are forwarded to state machine */
case WifiManager.CONNECT_NETWORK:
- case WifiManager.SAVE_NETWORK:
+ case WifiManager.SAVE_NETWORK: {
+ WifiConfiguration config = (WifiConfiguration) msg.obj;
+ if (config.isValid()) {
+ mWifiStateMachine.sendMessage(Message.obtain(msg));
+ } else {
+ Slog.d(TAG, "ClientHandler.handleMessage ignoring msg=" + msg);
+ if (msg.what == WifiManager.CONNECT_NETWORK) {
+ replyFailed(msg, WifiManager.CONNECT_NETWORK_FAILED);
+ } else {
+ replyFailed(msg, WifiManager.SAVE_NETWORK_FAILED);
+ }
+ }
+ break;
+ }
case WifiManager.FORGET_NETWORK:
case WifiManager.START_WPS:
case WifiManager.CANCEL_WPS:
@@ -185,6 +198,17 @@ public final class WifiService extends IWifiManager.Stub {
}
}
}
+
+ private void replyFailed(Message msg, int what) {
+ Message reply = msg.obtain();
+ reply.what = what;
+ reply.arg1 = WifiManager.INVALID_ARGS;
+ try {
+ msg.replyTo.send(reply);
+ } catch (RemoteException e) {
+ // There's not much we can do if reply can't be sent!
+ }
+ }
}
private ClientHandler mClientHandler;
@@ -555,7 +579,11 @@ public final class WifiService extends IWifiManager.Stub {
*/
public void setWifiApEnabled(WifiConfiguration wifiConfig, boolean enabled) {
enforceChangePermission();
- mWifiController.obtainMessage(CMD_SET_AP, enabled ? 1 : 0, 0, wifiConfig).sendToTarget();
+ if (wifiConfig.isValid()) {
+ mWifiController.obtainMessage(CMD_SET_AP, enabled ? 1 : 0, 0, wifiConfig).sendToTarget();
+ } else {
+ Slog.e(TAG, "Invalid WifiConfiguration");
+ }
}
/**
@@ -588,7 +616,11 @@ public final class WifiService extends IWifiManager.Stub {
enforceChangePermission();
if (wifiConfig == null)
return;
- mWifiStateMachine.setWifiApConfiguration(wifiConfig);
+ if (wifiConfig.isValid()) {
+ mWifiStateMachine.setWifiApConfiguration(wifiConfig);
+ } else {
+ Slog.e(TAG, "Invalid WifiConfiguration");
+ }
}
/**
@@ -646,10 +678,15 @@ public final class WifiService extends IWifiManager.Stub {
*/
public int addOrUpdateNetwork(WifiConfiguration config) {
enforceChangePermission();
- if (mWifiStateMachineChannel != null) {
- return mWifiStateMachine.syncAddOrUpdateNetwork(mWifiStateMachineChannel, config);
+ if (config.isValid()) {
+ if (mWifiStateMachineChannel != null) {
+ return mWifiStateMachine.syncAddOrUpdateNetwork(mWifiStateMachineChannel, config);
+ } else {
+ Slog.e(TAG, "mWifiStateMachineChannel is not initialized");
+ return -1;
+ }
} else {
- Slog.e(TAG, "mWifiStateMachineChannel is not initialized");
+ Slog.e(TAG, "bad network configuration");
return -1;
}
}