Fix the double-quoted SSID issue.
Bug id http://b/issue?id=2684571 Change-Id: I0f1e508b9a3d0fefcef28235380392368a51e42a
This commit is contained in:
@@ -74,7 +74,7 @@ class AccessPoint extends Preference {
|
||||
AccessPoint(Context context, WifiConfiguration config) {
|
||||
super(context);
|
||||
setWidgetLayoutResource(R.layout.preference_widget_wifi_signal);
|
||||
ssid = (config.SSID == null ? "" : config.SSID);
|
||||
ssid = (config.SSID == null ? "" : removeDoubleQuotes(config.SSID));
|
||||
security = getSecurity(config);
|
||||
networkId = config.networkId;
|
||||
mConfig = config;
|
||||
@@ -181,6 +181,19 @@ class AccessPoint extends Preference {
|
||||
return mState;
|
||||
}
|
||||
|
||||
static String removeDoubleQuotes(String string) {
|
||||
int length = string.length();
|
||||
if ((length > 1) && (string.charAt(0) == '"')
|
||||
&& (string.charAt(length - 1) == '"')) {
|
||||
return string.substring(1, length - 1);
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
static String convertToQuotedString(String string) {
|
||||
return "\"" + string + "\"";
|
||||
}
|
||||
|
||||
private void refresh() {
|
||||
if (mSignal == null) {
|
||||
return;
|
||||
|
@@ -72,7 +72,7 @@ class WifiApDialog extends AlertDialog implements View.OnClickListener,
|
||||
|
||||
WifiConfiguration config = new WifiConfiguration();
|
||||
|
||||
config.SSID = mSsid.getText().toString();
|
||||
config.SSID = AccessPoint.convertToQuotedString(mSsid.getText().toString());
|
||||
|
||||
switch (mSecurityType) {
|
||||
case AccessPoint.SECURITY_NONE:
|
||||
@@ -115,7 +115,7 @@ class WifiApDialog extends AlertDialog implements View.OnClickListener,
|
||||
context.getString(R.string.wifi_cancel), mListener);
|
||||
|
||||
if (mWifiConfig != null) {
|
||||
mSsid.setText(mWifiConfig.SSID);
|
||||
mSsid.setText(AccessPoint.removeDoubleQuotes(mWifiConfig.SSID));
|
||||
switch (mSecurityType) {
|
||||
case AccessPoint.SECURITY_NONE:
|
||||
mSecurity.setSelection(OPEN_INDEX);
|
||||
|
@@ -153,7 +153,8 @@ public class WifiApEnabler implements Preference.OnPreferenceChangeListener {
|
||||
com.android.internal.R.string.wifi_tether_configure_ssid_default);
|
||||
mCheckBox.setSummary(String.format(
|
||||
mContext.getString(R.string.wifi_tether_enabled_subtext),
|
||||
(wifiConfig == null) ? s : wifiConfig.SSID));
|
||||
(wifiConfig == null) ? s : AccessPoint.removeDoubleQuotes(
|
||||
wifiConfig.SSID)));
|
||||
}
|
||||
|
||||
private void updateTetherState(Object[] available, Object[] tethered, Object[] errored) {
|
||||
|
@@ -81,7 +81,7 @@ public class WifiApSettings extends PreferenceActivity
|
||||
s, mSecurityType[OPEN_INDEX]));
|
||||
} else {
|
||||
mCreateNetwork.setSummary(String.format(getString(CONFIG_SUBTEXT),
|
||||
mWifiConfig.SSID,
|
||||
AccessPoint.removeDoubleQuotes(mWifiConfig.SSID),
|
||||
mWifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ?
|
||||
mSecurityType[WPA_INDEX] : mSecurityType[OPEN_INDEX]));
|
||||
}
|
||||
@@ -123,7 +123,7 @@ public class WifiApSettings extends PreferenceActivity
|
||||
if(mWifiConfig != null) {
|
||||
mWifiManager.setWifiApEnabled(mWifiConfig, true);
|
||||
mCreateNetwork.setSummary(String.format(getString(CONFIG_SUBTEXT),
|
||||
mWifiConfig.SSID,
|
||||
AccessPoint.removeDoubleQuotes(mWifiConfig.SSID),
|
||||
mWifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ?
|
||||
mSecurityType[WPA_INDEX] : mSecurityType[OPEN_INDEX]));
|
||||
/**
|
||||
|
@@ -92,11 +92,13 @@ class WifiDialog extends AlertDialog implements View.OnClickListener,
|
||||
WifiConfiguration config = new WifiConfiguration();
|
||||
|
||||
if (mAccessPoint == null) {
|
||||
config.SSID = mSsid.getText().toString();
|
||||
config.SSID = AccessPoint.convertToQuotedString(
|
||||
mSsid.getText().toString());
|
||||
// If the user adds a network manually, assume that it is hidden.
|
||||
config.hiddenSSID = true;
|
||||
} else if (mAccessPoint.networkId == -1) {
|
||||
config.SSID = mAccessPoint.ssid;
|
||||
config.SSID = AccessPoint.convertToQuotedString(
|
||||
mAccessPoint.ssid);
|
||||
} else {
|
||||
config.networkId = mAccessPoint.networkId;
|
||||
}
|
||||
|
@@ -216,7 +216,7 @@ public class WifiSettings extends PreferenceActivity implements DialogInterface.
|
||||
} else if (mSelected.security == AccessPoint.SECURITY_NONE) {
|
||||
// Shortcut for open networks.
|
||||
WifiConfiguration config = new WifiConfiguration();
|
||||
config.SSID = mSelected.ssid;
|
||||
config.SSID = AccessPoint.convertToQuotedString(mSelected.ssid);
|
||||
config.allowedKeyManagement.set(KeyMgmt.NONE);
|
||||
int networkId = mWifiManager.addNetwork(config);
|
||||
mWifiManager.enableNetwork(networkId, false);
|
||||
|
Reference in New Issue
Block a user