diff options
| author | 2009-10-09 11:01:49 +0800 | |
|---|---|---|
| committer | 2009-10-13 09:03:35 +0800 | |
| commit | a8d15941392956c383902e715028032afb583952 (patch) | |
| tree | 281e75f1a98ad3fa91c5d4a085ae7f92c03e8a08 | |
| parent | 5a016488da5ff6c1ecdff0b1febd836cc1711531 (diff) | |
Support double-quote SSID in WifiService.
+ push the double-quote handling down to framework.
wpa_supplicant keeps the ssid in a quoted string in the config file. However,
the UI currently needs to handle the quoted string which makes it difficult
to handle the SSID containing the quotes. The change will move the
supplicant-specific double-quote handling from UI to framework, i.e. to
add/remove doubel-quotes in framework instead of in UI settings.
| -rw-r--r-- | services/java/com/android/server/WifiService.java | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/services/java/com/android/server/WifiService.java b/services/java/com/android/server/WifiService.java index a3589c79a796..154a2031743d 100644 --- a/services/java/com/android/server/WifiService.java +++ b/services/java/com/android/server/WifiService.java @@ -542,7 +542,7 @@ public class WifiService extends IWifiManager.Stub { value = WifiNative.getNetworkVariableCommand(netId, WifiConfiguration.ssidVarName); if (!TextUtils.isEmpty(value)) { - config.SSID = value; + config.SSID = removeDoubleQuotes(value); } else { config.SSID = null; } @@ -675,11 +675,21 @@ public class WifiService extends IWifiManager.Stub { value = WifiNative.getNetworkVariableCommand(netId, field.varName()); if (!TextUtils.isEmpty(value)) { + if (field != config.eap) value = removeDoubleQuotes(value); field.setValue(value); } } } + private static String removeDoubleQuotes(String string) { + if (string.length() <= 2) return ""; + return string.substring(1, string.length() - 1); + } + + private static String convertToQuotedString(String string) { + return "\"" + string + "\""; + } + /** * see {@link android.net.wifi.WifiManager#addOrUpdateNetwork(WifiConfiguration)} * @return the supplicant-assigned identifier for the new or updated @@ -731,7 +741,7 @@ public class WifiService extends IWifiManager.Stub { !WifiNative.setNetworkVariableCommand( netId, WifiConfiguration.ssidVarName, - config.SSID)) { + convertToQuotedString(config.SSID))) { if (DBG) { Log.d(TAG, "failed to set SSID: "+config.SSID); } @@ -894,18 +904,22 @@ public class WifiService extends IWifiManager.Stub { : config.enterpriseFields) { String varName = field.varName(); String value = field.value(); - if ((value != null) && !WifiNative.setNetworkVariableCommand( - netId, - varName, - value)) { - if (DBG) { - Log.d(TAG, config.SSID + ": failed to set " + varName + - ": " + value); + if (value != null) { + if (field != config.eap) { + value = convertToQuotedString(value); + } + if (!WifiNative.setNetworkVariableCommand( + netId, + varName, + value)) { + if (DBG) { + Log.d(TAG, config.SSID + ": failed to set " + varName + + ": " + value); + } + break setVariables; } - break setVariables; } } - return netId; } |