summaryrefslogtreecommitdiffstats
path: root/wifi
diff options
context:
space:
mode:
authorIrfan Sheriff <isheriff@google.com>2012-10-09 10:52:57 -0700
committerIrfan Sheriff <isheriff@google.com>2012-10-09 10:56:47 -0700
commit462ff630e441f5bc36c4b926ce81bdb35fe7d04b (patch)
tree22d7cc2d83d4153219be93257284da44ae737258 /wifi
parentb3f55fdef6659b836d97e6859e89a9427b97cc67 (diff)
downloadframeworks_base-462ff630e441f5bc36c4b926ce81bdb35fe7d04b.zip
frameworks_base-462ff630e441f5bc36c4b926ce81bdb35fe7d04b.tar.gz
frameworks_base-462ff630e441f5bc36c4b926ce81bdb35fe7d04b.tar.bz2
Fix handling of hidden access points
We now get raw hex data from the supplicant and we convert it into printable format. For hidden access point, we always used to return a single empty string. We need to make sure we maintain that behavior for apps to not start displaying empty strings. Bug: 7310749 Change-Id: I2599b9b5e15be91fc34e9af629ad893b1a0357fc
Diffstat (limited to 'wifi')
-rw-r--r--wifi/java/android/net/wifi/WifiSsid.java15
1 files changed, 13 insertions, 2 deletions
diff --git a/wifi/java/android/net/wifi/WifiSsid.java b/wifi/java/android/net/wifi/WifiSsid.java
index 6f36111..3e5f10f 100644
--- a/wifi/java/android/net/wifi/WifiSsid.java
+++ b/wifi/java/android/net/wifi/WifiSsid.java
@@ -156,7 +156,11 @@ public class WifiSsid implements Parcelable {
@Override
public String toString() {
- if (octets.size() <= 0) return "";
+ byte[] ssidBytes = octets.toByteArray();
+ // Supplicant returns \x00\x00\x00\x00\x00\x00\x00\x00 hex string
+ // for a hidden access point. Make sure we maintain the previous
+ // behavior of returning empty string for this case.
+ if (octets.size() <= 0 || isArrayAllZeroes(ssidBytes)) return "";
// TODO: Handle conversion to other charsets upon failure
Charset charset = Charset.forName("UTF-8");
CharsetDecoder decoder = charset.newDecoder()
@@ -164,7 +168,7 @@ public class WifiSsid implements Parcelable {
.onUnmappableCharacter(CodingErrorAction.REPLACE);
CharBuffer out = CharBuffer.allocate(32);
- CoderResult result = decoder.decode(ByteBuffer.wrap(octets.toByteArray()), out, true);
+ CoderResult result = decoder.decode(ByteBuffer.wrap(ssidBytes), out, true);
out.flip();
if (result.isError()) {
return NONE;
@@ -172,6 +176,13 @@ public class WifiSsid implements Parcelable {
return out.toString();
}
+ private boolean isArrayAllZeroes(byte[] ssidBytes) {
+ for (int i = 0; i< ssidBytes.length; i++) {
+ if (ssidBytes[i] != 0) return false;
+ }
+ return true;
+ }
+
/** @hide */
public byte[] getOctets() {
return octets.toByteArray();