diff options
author | Irfan Sheriff <isheriff@google.com> | 2012-09-05 10:46:24 -0700 |
---|---|---|
committer | Irfan Sheriff <isheriff@google.com> | 2012-09-11 10:50:04 -0700 |
commit | b6deeed3ceff9e0f754697987b7c724901996082 (patch) | |
tree | 790b652af7de47429fc4a92d1680d01b57a92269 /wifi/java/android/net/wifi/WifiInfo.java | |
parent | 799553e02aa3350397d723982d42198a5bab774c (diff) | |
download | frameworks_base-b6deeed3ceff9e0f754697987b7c724901996082.zip frameworks_base-b6deeed3ceff9e0f754697987b7c724901996082.tar.gz frameworks_base-b6deeed3ceff9e0f754697987b7c724901996082.tar.bz2 |
Handle ascii encoded SSID
Supplicant now passes as an ascii encoded string that allows it to
pass any sequence of bytes for a SSID. see src/utils/common.c in supplicant
for details of the implementation.
We create a SSID structure WifiSsid in framework to store the ssid and handle
the conversion appropriately when required for printing and for an application.
At this point, we still do not handle non-printable octets from an application perspective
for connectivity
Bug: 7110903
Change-Id: I520e5ee23baed4867b8b408bbb3eda5c9e92b6bf
Diffstat (limited to 'wifi/java/android/net/wifi/WifiInfo.java')
-rw-r--r-- | wifi/java/android/net/wifi/WifiInfo.java | 44 |
1 files changed, 33 insertions, 11 deletions
diff --git a/wifi/java/android/net/wifi/WifiInfo.java b/wifi/java/android/net/wifi/WifiInfo.java index 1f1cfdd..05db571 100644 --- a/wifi/java/android/net/wifi/WifiInfo.java +++ b/wifi/java/android/net/wifi/WifiInfo.java @@ -20,6 +20,7 @@ import android.os.Parcelable; import android.os.Parcel; import android.net.NetworkInfo.DetailedState; import android.net.NetworkUtils; +import android.text.TextUtils; import java.net.InetAddress; import java.net.Inet6Address; @@ -31,6 +32,7 @@ import java.util.EnumMap; * is in the process of being set up. */ public class WifiInfo implements Parcelable { + private static final String TAG = "WifiInfo"; /** * This is the map described in the Javadoc comment above. The positions * of the elements of the array must correspond to the ordinal values @@ -57,7 +59,7 @@ public class WifiInfo implements Parcelable { private SupplicantState mSupplicantState; private String mBSSID; - private String mSSID; + private WifiSsid mWifiSsid; private int mNetworkId; private boolean mHiddenSSID; /** Received Signal Strength Indicator */ @@ -77,7 +79,7 @@ public class WifiInfo implements Parcelable { private boolean mMeteredHint; WifiInfo() { - mSSID = null; + mWifiSsid = null; mBSSID = null; mNetworkId = -1; mSupplicantState = SupplicantState.UNINITIALIZED; @@ -94,7 +96,7 @@ public class WifiInfo implements Parcelable { if (source != null) { mSupplicantState = source.mSupplicantState; mBSSID = source.mBSSID; - mSSID = source.mSSID; + mWifiSsid = source.mWifiSsid; mNetworkId = source.mNetworkId; mHiddenSSID = source.mHiddenSSID; mRssi = source.mRssi; @@ -105,21 +107,34 @@ public class WifiInfo implements Parcelable { } } - void setSSID(String SSID) { - mSSID = SSID; + void setSSID(WifiSsid wifiSsid) { + mWifiSsid = wifiSsid; // network is considered not hidden by default mHiddenSSID = false; } /** * Returns the service set identifier (SSID) of the current 802.11 network. - * If the SSID is an ASCII string, it will be returned surrounded by double - * quotation marks.Otherwise, it is returned as a string of hex digits. The + * If the SSID can be decoded as UTF-8, it will be returned surrounded by double + * quotation marks. Otherwise, it is returned as a string of hex digits. The * SSID may be {@code null} if there is no network currently connected. * @return the SSID */ public String getSSID() { - return mSSID; + if (mWifiSsid != null) { + String unicode = mWifiSsid.toString(); + if (!TextUtils.isEmpty(unicode)) { + return "\"" + unicode + "\""; + } else { + return mWifiSsid.getHexString(); + } + } + return WifiSsid.NONE; + } + + /** @hide */ + public WifiSsid getWifiSsid() { + return mWifiSsid; } void setBSSID(String BSSID) { @@ -279,7 +294,7 @@ public class WifiInfo implements Parcelable { StringBuffer sb = new StringBuffer(); String none = "<none>"; - sb.append("SSID: ").append(mSSID == null ? none : mSSID). + sb.append("SSID: ").append(mWifiSsid == null ? WifiSsid.NONE : mWifiSsid). append(", BSSID: ").append(mBSSID == null ? none : mBSSID). append(", MAC: ").append(mMacAddress == null ? none : mMacAddress). append(", Supplicant state: "). @@ -308,7 +323,12 @@ public class WifiInfo implements Parcelable { } else { dest.writeByte((byte)0); } - dest.writeString(getSSID()); + if (mWifiSsid != null) { + dest.writeInt(1); + mWifiSsid.writeToParcel(dest, flags); + } else { + dest.writeInt(0); + } dest.writeString(mBSSID); dest.writeString(mMacAddress); dest.writeInt(mMeteredHint ? 1 : 0); @@ -328,7 +348,9 @@ public class WifiInfo implements Parcelable { info.setInetAddress(InetAddress.getByAddress(in.createByteArray())); } catch (UnknownHostException e) {} } - info.setSSID(in.readString()); + if (in.readInt() == 1) { + info.mWifiSsid = WifiSsid.CREATOR.createFromParcel(in); + } info.mBSSID = in.readString(); info.mMacAddress = in.readString(); info.mMeteredHint = in.readInt() != 0; |