MacAddrFilter.java 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. package com.epson.mobilephone.common.wifidirect;
  2. import android.content.Context;
  3. import java.util.ArrayList;
  4. import java.util.Iterator;
  5. public class MacAddrFilter {
  6. private static String COMMENT_PREFIX = "#";
  7. private static String EXCLUDE_MACADDRESS_FILE = "exclude_macaddress.csv";
  8. private static final String TAG = "MacAddrFilter";
  9. private static MacAddrFilter instance;
  10. private ArrayList<MacAddressEntry> excludeMacAddressList = null;
  11. private Context mAppContext = null;
  12. class MacAddressEntry {
  13. String end;
  14. String start;
  15. public MacAddressEntry(String str, String str2) {
  16. start = str;
  17. end = str2;
  18. }
  19. public boolean equals(Object obj) {
  20. if (!(obj instanceof MacAddressEntry)) {
  21. return false;
  22. }
  23. MacAddressEntry macAddressEntry = (MacAddressEntry) obj;
  24. if (start.equals(macAddressEntry.start) || !this.end.equals(macAddressEntry.end)) {
  25. return false;
  26. }
  27. return true;
  28. }
  29. }
  30. public static MacAddrFilter getInstance(Context context) {
  31. MacAddrFilter macAddrFilter = instance;
  32. if (macAddrFilter != null) {
  33. return macAddrFilter;
  34. }
  35. instance = new MacAddrFilter(context);
  36. return instance;
  37. }
  38. private MacAddrFilter(Context context) {
  39. mAppContext = context.getApplicationContext();
  40. }
  41. public boolean isExcludedMacAddress(String str) {
  42. try {
  43. String p2pAddr2MacAddrStr = MacAddrUtils.p2pAddr2MacAddrStr(str);
  44. if (excludeMacAddressList == null) {
  45. excludeMacAddressList = readMacAddressTable(EXCLUDE_MACADDRESS_FILE);
  46. }
  47. Iterator<MacAddressEntry> it = excludeMacAddressList.iterator();
  48. while (it.hasNext()) {
  49. MacAddressEntry next = it.next();
  50. if (next.start.compareTo(p2pAddr2MacAddrStr) <= 0 && next.end.compareTo(p2pAddr2MacAddrStr) >= 0) {
  51. return true;
  52. }
  53. }
  54. return false;
  55. } catch (Exception e) {
  56. e.printStackTrace();
  57. return false;
  58. }
  59. }
  60. /* JADX WARNING: type inference failed for: r5v2 */
  61. /* JADX WARNING: type inference failed for: r5v5, types: [java.io.InputStream] */
  62. /* JADX WARNING: type inference failed for: r5v7, types: [java.io.InputStream] */
  63. /* JADX WARNING: type inference failed for: r5v10, types: [java.io.BufferedReader] */
  64. /* JADX WARNING: type inference failed for: r5v11 */
  65. /* JADX WARNING: type inference failed for: r5v12 */
  66. /* JADX WARNING: type inference failed for: r5v15 */
  67. /* JADX WARNING: Multi-variable type inference failed */
  68. /* JADX WARNING: Removed duplicated region for block: B:102:0x01b6 A[SYNTHETIC, Splitter:B:102:0x01b6] */
  69. /* JADX WARNING: Removed duplicated region for block: B:107:0x01c1 A[SYNTHETIC, Splitter:B:107:0x01c1] */
  70. /* JADX WARNING: Removed duplicated region for block: B:78:0x0158 A[SYNTHETIC, Splitter:B:78:0x0158] */
  71. /* JADX WARNING: Removed duplicated region for block: B:83:0x0163 A[SYNTHETIC, Splitter:B:83:0x0163] */
  72. /* JADX WARNING: Removed duplicated region for block: B:90:0x016e A[SYNTHETIC, Splitter:B:90:0x016e] */
  73. /* JADX WARNING: Removed duplicated region for block: B:95:0x0179 A[SYNTHETIC, Splitter:B:95:0x0179] */
  74. /* JADX WARNING: Unknown top exception splitter block from list: {B:75:0x0153=Splitter:B:75:0x0153, B:87:0x0169=Splitter:B:87:0x0169} */
  75. /* Code decompiled incorrectly, please refer to instructions dump. */
  76. private java.util.ArrayList<com.epson.mobilephone.common.wifidirect.MacAddrFilter.MacAddressEntry> readMacAddressTable(java.lang.String r17) {
  77. /*
  78. r16 = this;
  79. r1 = r16
  80. r0 = r17
  81. long r2 = java.lang.System.currentTimeMillis()
  82. java.lang.String r4 = "MacAddrFilter"
  83. java.lang.StringBuilder r5 = new java.lang.StringBuilder
  84. r5.<init>()
  85. java.lang.String r6 = "Enter readMacAddressTable: path = "
  86. r5.append(r6)
  87. r5.append(r0)
  88. java.lang.String r5 = r5.toString()
  89. com.epson.mobilephone.common.wifidirect.EPLog.m86d(r4, r5)
  90. java.util.ArrayList r4 = new java.util.ArrayList
  91. r4.<init>()
  92. r5 = 0
  93. r6 = 0
  94. android.content.Context r7 = r1.mAppContext // Catch:{ IOException -> 0x0167, Exception -> 0x0151, all -> 0x014c }
  95. android.content.res.AssetManager r7 = r7.getAssets() // Catch:{ IOException -> 0x0167, Exception -> 0x0151, all -> 0x014c }
  96. java.io.InputStream r7 = r7.open(r0) // Catch:{ IOException -> 0x0167, Exception -> 0x0151, all -> 0x014c }
  97. if (r7 == 0) goto L_0x0135
  98. java.io.BufferedReader r8 = new java.io.BufferedReader // Catch:{ IOException -> 0x0131, Exception -> 0x012d, all -> 0x0128 }
  99. java.io.InputStreamReader r0 = new java.io.InputStreamReader // Catch:{ IOException -> 0x0131, Exception -> 0x012d, all -> 0x0128 }
  100. r0.<init>(r7) // Catch:{ IOException -> 0x0131, Exception -> 0x012d, all -> 0x0128 }
  101. r8.<init>(r0) // Catch:{ IOException -> 0x0131, Exception -> 0x012d, all -> 0x0128 }
  102. r5 = 0
  103. L_0x003c:
  104. java.lang.String r0 = r8.readLine() // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  105. if (r0 == 0) goto L_0x011b
  106. boolean r9 = r0.isEmpty() // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  107. if (r9 != 0) goto L_0x003c
  108. java.lang.String r9 = COMMENT_PREFIX // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  109. boolean r9 = r0.startsWith(r9) // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  110. if (r9 == 0) goto L_0x0051
  111. goto L_0x003c
  112. L_0x0051:
  113. int r5 = r5 + 1
  114. java.lang.String r9 = "[,\\u002C\t\\u0009]+"
  115. java.lang.String[] r9 = r0.split(r9, r6) // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  116. int r10 = r9.length // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  117. r11 = 2
  118. if (r10 >= r11) goto L_0x0074
  119. java.lang.String r9 = "MacAddrFilter"
  120. java.lang.StringBuilder r10 = new java.lang.StringBuilder // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  121. r10.<init>() // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  122. java.lang.String r11 = "Illegal Line = "
  123. r10.append(r11) // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  124. r10.append(r0) // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  125. java.lang.String r0 = r10.toString() // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  126. com.epson.mobilephone.common.wifidirect.EPLog.m90w(r9, r0) // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  127. goto L_0x003c
  128. L_0x0074:
  129. r10 = 1
  130. r12 = 1
  131. L_0x0076:
  132. int r13 = r9.length // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  133. if (r12 >= r13) goto L_0x00a1
  134. r13 = r9[r12] // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  135. java.lang.String r14 = "\""
  136. boolean r14 = r13.startsWith(r14) // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  137. if (r14 == 0) goto L_0x0087
  138. java.lang.String r13 = r13.substring(r10) // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  139. L_0x0087:
  140. java.lang.String r14 = "\""
  141. boolean r14 = r13.endsWith(r14) // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  142. if (r14 == 0) goto L_0x0098
  143. int r14 = r13.length() // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  144. int r14 = r14 - r10
  145. java.lang.String r13 = r13.substring(r6, r14) // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  146. L_0x0098:
  147. java.lang.String r13 = r13.trim() // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  148. r9[r12] = r13 // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  149. int r12 = r12 + 1
  150. goto L_0x0076
  151. L_0x00a1:
  152. r12 = 1
  153. L_0x00a2:
  154. int r13 = r9.length // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  155. if (r12 >= r13) goto L_0x003c
  156. r13 = r9[r12] // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  157. java.lang.String r14 = "[-–]"
  158. java.lang.String r15 = " "
  159. java.lang.String r13 = r13.replaceAll(r14, r15) // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  160. java.lang.String r14 = "[\\s]+"
  161. java.lang.String[] r14 = r13.split(r14, r6) // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  162. int r15 = r14.length // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  163. if (r15 == r11) goto L_0x00cf
  164. java.lang.String r14 = "MacAddrFilter"
  165. java.lang.StringBuilder r15 = new java.lang.StringBuilder // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  166. r15.<init>() // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  167. java.lang.String r11 = "Illegal item = "
  168. r15.append(r11) // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  169. r15.append(r13) // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  170. java.lang.String r11 = r15.toString() // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  171. com.epson.mobilephone.common.wifidirect.EPLog.m90w(r14, r11) // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  172. goto L_0x0117
  173. L_0x00cf:
  174. r11 = r14[r6] // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  175. java.lang.String r11 = com.epson.mobilephone.common.wifidirect.MacAddrUtils.p2pAddr2MacAddrStr(r11) // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  176. r13 = r14[r10] // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  177. java.lang.String r13 = com.epson.mobilephone.common.wifidirect.MacAddrUtils.p2pAddr2MacAddrStr(r13) // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  178. if (r11 == 0) goto L_0x0101
  179. int r14 = r11.length() // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  180. r15 = 12
  181. if (r14 != r15) goto L_0x0101
  182. if (r13 == 0) goto L_0x0101
  183. int r14 = r13.length() // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  184. if (r14 != r15) goto L_0x0101
  185. com.epson.mobilephone.common.wifidirect.MacAddrFilter$MacAddressEntry r14 = new com.epson.mobilephone.common.wifidirect.MacAddrFilter$MacAddressEntry // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  186. r14.<init>(r11, r13) // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  187. boolean r14 = r4.contains(r14) // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  188. if (r14 != 0) goto L_0x0117
  189. com.epson.mobilephone.common.wifidirect.MacAddrFilter$MacAddressEntry r14 = new com.epson.mobilephone.common.wifidirect.MacAddrFilter$MacAddressEntry // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  190. r14.<init>(r11, r13) // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  191. r4.add(r14) // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  192. goto L_0x0117
  193. L_0x0101:
  194. java.lang.String r11 = "MacAddrFilter"
  195. java.lang.StringBuilder r13 = new java.lang.StringBuilder // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  196. r13.<init>() // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  197. java.lang.String r14 = "Illegal Line = "
  198. r13.append(r14) // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  199. r13.append(r0) // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  200. java.lang.String r13 = r13.toString() // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  201. com.epson.mobilephone.common.wifidirect.EPLog.m90w(r11, r13) // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
  202. L_0x0117:
  203. int r12 = r12 + 1
  204. r11 = 2
  205. goto L_0x00a2
  206. L_0x011b:
  207. r6 = r5
  208. r5 = r8
  209. goto L_0x0135
  210. L_0x011e:
  211. r0 = move-exception
  212. r2 = r0
  213. goto L_0x01b4
  214. L_0x0122:
  215. r0 = move-exception
  216. r6 = r5
  217. goto L_0x012f
  218. L_0x0125:
  219. r0 = move-exception
  220. r6 = r5
  221. goto L_0x0133
  222. L_0x0128:
  223. r0 = move-exception
  224. r2 = r0
  225. r8 = r5
  226. goto L_0x01b4
  227. L_0x012d:
  228. r0 = move-exception
  229. r8 = r5
  230. L_0x012f:
  231. r5 = r7
  232. goto L_0x0153
  233. L_0x0131:
  234. r0 = move-exception
  235. r8 = r5
  236. L_0x0133:
  237. r5 = r7
  238. goto L_0x0169
  239. L_0x0135:
  240. if (r7 == 0) goto L_0x0140
  241. r7.close() // Catch:{ IOException -> 0x013b }
  242. goto L_0x0140
  243. L_0x013b:
  244. r0 = move-exception
  245. r7 = r0
  246. r7.printStackTrace()
  247. L_0x0140:
  248. if (r5 == 0) goto L_0x017c
  249. r5.close() // Catch:{ IOException -> 0x0146 }
  250. goto L_0x017c
  251. L_0x0146:
  252. r0 = move-exception
  253. r5 = r0
  254. r5.printStackTrace()
  255. goto L_0x017c
  256. L_0x014c:
  257. r0 = move-exception
  258. r2 = r0
  259. r7 = r5
  260. r8 = r7
  261. goto L_0x01b4
  262. L_0x0151:
  263. r0 = move-exception
  264. r8 = r5
  265. L_0x0153:
  266. r0.printStackTrace() // Catch:{ all -> 0x01b1 }
  267. if (r5 == 0) goto L_0x0161
  268. r5.close() // Catch:{ IOException -> 0x015c }
  269. goto L_0x0161
  270. L_0x015c:
  271. r0 = move-exception
  272. r5 = r0
  273. r5.printStackTrace()
  274. L_0x0161:
  275. if (r8 == 0) goto L_0x017c
  276. r8.close() // Catch:{ IOException -> 0x0146 }
  277. goto L_0x017c
  278. L_0x0167:
  279. r0 = move-exception
  280. r8 = r5
  281. L_0x0169:
  282. r0.printStackTrace() // Catch:{ all -> 0x01b1 }
  283. if (r5 == 0) goto L_0x0177
  284. r5.close() // Catch:{ IOException -> 0x0172 }
  285. goto L_0x0177
  286. L_0x0172:
  287. r0 = move-exception
  288. r5 = r0
  289. r5.printStackTrace()
  290. L_0x0177:
  291. if (r8 == 0) goto L_0x017c
  292. r8.close() // Catch:{ IOException -> 0x0146 }
  293. L_0x017c:
  294. java.lang.String r0 = "MacAddrFilter"
  295. java.lang.StringBuilder r5 = new java.lang.StringBuilder
  296. r5.<init>()
  297. java.lang.String r7 = "Leave readMacAddressTable: readlinecount = "
  298. r5.append(r7)
  299. r5.append(r6)
  300. java.lang.String r6 = " entry = "
  301. r5.append(r6)
  302. int r6 = r4.size()
  303. r5.append(r6)
  304. java.lang.String r6 = " time = "
  305. r5.append(r6)
  306. long r6 = java.lang.System.currentTimeMillis()
  307. long r6 = r6 - r2
  308. r5.append(r6)
  309. java.lang.String r2 = " msec"
  310. r5.append(r2)
  311. java.lang.String r2 = r5.toString()
  312. com.epson.mobilephone.common.wifidirect.EPLog.m86d(r0, r2)
  313. return r4
  314. L_0x01b1:
  315. r0 = move-exception
  316. r2 = r0
  317. r7 = r5
  318. L_0x01b4:
  319. if (r7 == 0) goto L_0x01bf
  320. r7.close() // Catch:{ IOException -> 0x01ba }
  321. goto L_0x01bf
  322. L_0x01ba:
  323. r0 = move-exception
  324. r3 = r0
  325. r3.printStackTrace()
  326. L_0x01bf:
  327. if (r8 == 0) goto L_0x01ca
  328. r8.close() // Catch:{ IOException -> 0x01c5 }
  329. goto L_0x01ca
  330. L_0x01c5:
  331. r0 = move-exception
  332. r3 = r0
  333. r3.printStackTrace()
  334. L_0x01ca:
  335. throw r2
  336. */
  337. throw new UnsupportedOperationException("Method not decompiled: com.epson.mobilephone.common.wifidirect.MacAddrFilter.readMacAddressTable(java.lang.String):java.util.ArrayList");
  338. }
  339. }