Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8c81257f authored by Chung-yih Wang's avatar Chung-yih Wang
Browse files

Fix the double-quoted SSID issue.

Bug id http://b/issue?id=2684571

Change-Id: I0f1e508b9a3d0fefcef28235380392368a51e42a
parent e434bfb2
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -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;
+2 −2
Original line number Diff line number Diff line
@@ -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);
+2 −1
Original line number Diff line number Diff line
@@ -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) {
+2 −2
Original line number Diff line number Diff line
@@ -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]));
                /**
+4 −2
Original line number Diff line number Diff line
@@ -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;
        }
Loading