summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/java/com/android/server/wifi/hotspot2/SupplicantBridge.java115
1 files changed, 0 insertions, 115 deletions
diff --git a/service/java/com/android/server/wifi/hotspot2/SupplicantBridge.java b/service/java/com/android/server/wifi/hotspot2/SupplicantBridge.java
index 400f6cf8e..08d41a1ac 100644
--- a/service/java/com/android/server/wifi/hotspot2/SupplicantBridge.java
+++ b/service/java/com/android/server/wifi/hotspot2/SupplicantBridge.java
@@ -376,119 +376,4 @@ public class SupplicantBridge {
}
}
- private static final Map<Character,Integer> sMappings = new HashMap<Character, Integer>();
-
- static {
- sMappings.put('\\', (int)'\\');
- sMappings.put('"', (int)'"');
- sMappings.put('e', 0x1b);
- sMappings.put('n', (int)'\n');
- sMappings.put('r', (int)'\n');
- sMappings.put('t', (int)'\t');
- }
-
- public static String unescapeSSID(String ssid) {
-
- CharIterator chars = new CharIterator(ssid);
- byte[] octets = new byte[ssid.length()];
- int bo = 0;
-
- while (chars.hasNext()) {
- char ch = chars.next();
- if (ch != '\\' || ! chars.hasNext()) {
- octets[bo++] = (byte)ch;
- }
- else {
- char suffix = chars.next();
- Integer mapped = sMappings.get(suffix);
- if (mapped != null) {
- octets[bo++] = mapped.byteValue();
- }
- else if (suffix == 'x' && chars.hasDoubleHex()) {
- octets[bo++] = (byte)chars.nextDoubleHex();
- }
- else {
- octets[bo++] = '\\';
- octets[bo++] = (byte)suffix;
- }
- }
- }
-
- boolean asciiOnly = true;
- for (byte b : octets) {
- if ((b&0x80) != 0) {
- asciiOnly = false;
- break;
- }
- }
- if (asciiOnly) {
- return new String(octets, 0, bo, StandardCharsets.UTF_8);
- } else {
- try {
- // If UTF-8 decoding is successful it is almost certainly UTF-8
- CharBuffer cb = StandardCharsets.UTF_8.newDecoder().decode(
- ByteBuffer.wrap(octets, 0, bo));
- return cb.toString();
- } catch (CharacterCodingException cce) {
- return new String(octets, 0, bo, StandardCharsets.ISO_8859_1);
- }
- }
- }
-
- private static class CharIterator {
- private final String mString;
- private int mPosition;
- private int mHex;
-
- private CharIterator(String s) {
- mString = s;
- }
-
- private boolean hasNext() {
- return mPosition < mString.length();
- }
-
- private char next() {
- return mString.charAt(mPosition++);
- }
-
- private boolean hasDoubleHex() {
- if (mString.length() - mPosition < 2) {
- return false;
- }
- int nh = Utils.fromHex(mString.charAt(mPosition), true);
- if (nh < 0) {
- return false;
- }
- int nl = Utils.fromHex(mString.charAt(mPosition + 1), true);
- if (nl < 0) {
- return false;
- }
- mPosition += 2;
- mHex = (nh << 4) | nl;
- return true;
- }
-
- private int nextDoubleHex() {
- return mHex;
- }
- }
-
- private static final String[] TestStrings = {
- "test-ssid",
- "test\\nss\\tid",
- "test\\x2d\\x5f\\nss\\tid",
- "test\\x2d\\x5f\\nss\\tid\\\\",
- "test\\x2d\\x5f\\nss\\tid\\n",
- "test\\x2d\\x5f\\nss\\tid\\x4a",
- "another\\",
- "an\\other",
- "another\\x2"
- };
-
- public static void main(String[] args) {
- for (String string : TestStrings) {
- System.out.println(unescapeSSID(string));
- }
- }
}