diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2016-08-26 22:50:02 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2016-08-26 22:50:03 +0000 |
commit | 8381c56df953265b362d66bee9028d535960f410 (patch) | |
tree | ff82bb0698a7ae6401723ac153bb7a5daff761fe /service | |
parent | a7e6e8c269f8273f7d462aa28de4cfdc69b7cea0 (diff) | |
parent | ca62e5b2c8e533e481f7ed0ee7ca1b80670fc8f5 (diff) |
Merge "Remove unused code in SupplicantBridge"
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/hotspot2/SupplicantBridge.java | 115 |
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)); - } - } } |