Methods Summary |
---|
private void | convertToBytes(java.lang.String asciiEncoded)
int i = 0;
int val = 0;
while (i< asciiEncoded.length()) {
char c = asciiEncoded.charAt(i);
switch (c) {
case '\\":
i++;
switch(asciiEncoded.charAt(i)) {
case '\\":
octets.write('\\");
i++;
break;
case '"":
octets.write('"");
i++;
break;
case 'n":
octets.write('\n");
i++;
break;
case 'r":
octets.write('\r");
i++;
break;
case 't":
octets.write('\t");
i++;
break;
case 'e":
octets.write(27); //escape char
i++;
break;
case 'x":
i++;
try {
val = Integer.parseInt(asciiEncoded.substring(i, i + 2), HEX_RADIX);
} catch (NumberFormatException e) {
val = -1;
}
if (val < 0) {
val = Character.digit(asciiEncoded.charAt(i), HEX_RADIX);
if (val < 0) break;
octets.write(val);
i++;
} else {
octets.write(val);
i += 2;
}
break;
case '0":
case '1":
case '2":
case '3":
case '4":
case '5":
case '6":
case '7":
val = asciiEncoded.charAt(i) - '0";
i++;
if (asciiEncoded.charAt(i) >= '0" && asciiEncoded.charAt(i) <= '7") {
val = val * 8 + asciiEncoded.charAt(i) - '0";
i++;
}
if (asciiEncoded.charAt(i) >= '0" && asciiEncoded.charAt(i) <= '7") {
val = val * 8 + asciiEncoded.charAt(i) - '0";
i++;
}
octets.write(val);
break;
default:
break;
}
break;
default:
octets.write(c);
i++;
break;
}
}
|
public static android.net.wifi.WifiSsid | createFromAsciiEncoded(java.lang.String asciiEncoded)
WifiSsid a = new WifiSsid();
a.convertToBytes(asciiEncoded);
return a;
|
public static android.net.wifi.WifiSsid | createFromHex(java.lang.String hexStr)
WifiSsid a = new WifiSsid();
if (hexStr == null) return a;
if (hexStr.startsWith("0x") || hexStr.startsWith("0X")) {
hexStr = hexStr.substring(2);
}
for (int i = 0; i < hexStr.length()-1; i += 2) {
int val;
try {
val = Integer.parseInt(hexStr.substring(i, i + 2), HEX_RADIX);
} catch(NumberFormatException e) {
val = 0;
}
a.octets.write(val);
}
return a;
|
public int | describeContents()Implement the Parcelable interface {@hide}
return 0;
|
public java.lang.String | getHexString()
String out = "0x";
byte[] ssidbytes = getOctets();
for (int i = 0; i < octets.size(); i++) {
out += String.format(Locale.US, "%02x", ssidbytes[i]);
}
return out;
|
public byte[] | getOctets()
return octets.toByteArray();
|
private boolean | isArrayAllZeroes(byte[] ssidBytes)
for (int i = 0; i< ssidBytes.length; i++) {
if (ssidBytes[i] != 0) return false;
}
return true;
|
public boolean | isHidden()
return isArrayAllZeroes(octets.toByteArray());
|
public java.lang.String | toString()
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()
.onMalformedInput(CodingErrorAction.REPLACE)
.onUnmappableCharacter(CodingErrorAction.REPLACE);
CharBuffer out = CharBuffer.allocate(32);
CoderResult result = decoder.decode(ByteBuffer.wrap(ssidBytes), out, true);
out.flip();
if (result.isError()) {
return NONE;
}
return out.toString();
|
public void | writeToParcel(android.os.Parcel dest, int flags)Implement the Parcelable interface {@hide}
dest.writeInt(octets.size());
dest.writeByteArray(octets.toByteArray());
|