Merge change Ic6d1545d into eclair-mr2

* changes:
  Support double-quote SSID in WifiService.
This commit is contained in:
Android (Google) Code Review
2009-10-12 21:33:04 -04:00

View File

@@ -542,7 +542,7 @@ public class WifiService extends IWifiManager.Stub {
value = WifiNative.getNetworkVariableCommand(netId, WifiConfiguration.ssidVarName); value = WifiNative.getNetworkVariableCommand(netId, WifiConfiguration.ssidVarName);
if (!TextUtils.isEmpty(value)) { if (!TextUtils.isEmpty(value)) {
config.SSID = value; config.SSID = removeDoubleQuotes(value);
} else { } else {
config.SSID = null; config.SSID = null;
} }
@@ -675,11 +675,21 @@ public class WifiService extends IWifiManager.Stub {
value = WifiNative.getNetworkVariableCommand(netId, value = WifiNative.getNetworkVariableCommand(netId,
field.varName()); field.varName());
if (!TextUtils.isEmpty(value)) { if (!TextUtils.isEmpty(value)) {
if (field != config.eap) value = removeDoubleQuotes(value);
field.setValue(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)} * see {@link android.net.wifi.WifiManager#addOrUpdateNetwork(WifiConfiguration)}
* @return the supplicant-assigned identifier for the new or updated * @return the supplicant-assigned identifier for the new or updated
@@ -731,7 +741,7 @@ public class WifiService extends IWifiManager.Stub {
!WifiNative.setNetworkVariableCommand( !WifiNative.setNetworkVariableCommand(
netId, netId,
WifiConfiguration.ssidVarName, WifiConfiguration.ssidVarName,
config.SSID)) { convertToQuotedString(config.SSID))) {
if (DBG) { if (DBG) {
Log.d(TAG, "failed to set SSID: "+config.SSID); Log.d(TAG, "failed to set SSID: "+config.SSID);
} }
@@ -894,18 +904,22 @@ public class WifiService extends IWifiManager.Stub {
: config.enterpriseFields) { : config.enterpriseFields) {
String varName = field.varName(); String varName = field.varName();
String value = field.value(); String value = field.value();
if ((value != null) && !WifiNative.setNetworkVariableCommand( if (value != null) {
netId, if (field != config.eap) {
varName, value = convertToQuotedString(value);
value)) { }
if (DBG) { if (!WifiNative.setNetworkVariableCommand(
Log.d(TAG, config.SSID + ": failed to set " + varName + netId,
": " + value); varName,
value)) {
if (DBG) {
Log.d(TAG, config.SSID + ": failed to set " + varName +
": " + value);
}
break setVariables;
} }
break setVariables;
} }
} }
return netId; return netId;
} }