package com.epson.mobilephone.common.wifidirect;

import android.content.Context;
import java.util.ArrayList;
import java.util.Iterator;

public class MacAddrFilter {
    private static String COMMENT_PREFIX = "#";
    private static String EXCLUDE_MACADDRESS_FILE = "exclude_macaddress.csv";
    private static final String TAG = "MacAddrFilter";
    private static MacAddrFilter instance;
    private ArrayList<MacAddressEntry> excludeMacAddressList = null;
    private Context mAppContext = null;

    class MacAddressEntry {
        String end;
        String start;

        public MacAddressEntry(String str, String str2) {
            start = str;
            end = str2;
        }

        public boolean equals(Object obj) {
            if (!(obj instanceof MacAddressEntry)) {
                return false;
            }
            MacAddressEntry macAddressEntry = (MacAddressEntry) obj;
            if (!this.start.equals(macAddressEntry.start) || !this.end.equals(macAddressEntry.end)) {
                return false;
            }
            return true;
        }
    }

    public static MacAddrFilter getInstance(Context context) {
        MacAddrFilter macAddrFilter = instance;
        if (macAddrFilter != null) {
            return macAddrFilter;
        }
        instance = new MacAddrFilter(context);
        return instance;
    }

    private MacAddrFilter(Context context) {
        mAppContext = context.getApplicationContext();
    }

    public boolean isExcludedMacAddress(String str) {
        try {
            String p2pAddr2MacAddrStr = MacAddrUtils.p2pAddr2MacAddrStr(str);
            if (this.excludeMacAddressList == null) {
                excludeMacAddressList = readMacAddressTable(EXCLUDE_MACADDRESS_FILE);
            }
            Iterator<MacAddressEntry> it = excludeMacAddressList.iterator();
            while (it.hasNext()) {
                MacAddressEntry next = it.next();
                if (next.start.compareTo(p2pAddr2MacAddrStr) <= 0 && next.end.compareTo(p2pAddr2MacAddrStr) >= 0) {
                    return true;
                }
            }
            return false;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    /* JADX WARNING: type inference failed for: r5v2 */
    /* JADX WARNING: type inference failed for: r5v5, types: [java.io.InputStream] */
    /* JADX WARNING: type inference failed for: r5v7, types: [java.io.InputStream] */
    /* JADX WARNING: type inference failed for: r5v10, types: [java.io.BufferedReader] */
    /* JADX WARNING: type inference failed for: r5v11 */
    /* JADX WARNING: type inference failed for: r5v12 */
    /* JADX WARNING: type inference failed for: r5v15 */
    /* JADX WARNING: Multi-variable type inference failed */
    /* JADX WARNING: Removed duplicated region for block: B:102:0x01b6 A[SYNTHETIC, Splitter:B:102:0x01b6] */
    /* JADX WARNING: Removed duplicated region for block: B:107:0x01c1 A[SYNTHETIC, Splitter:B:107:0x01c1] */
    /* JADX WARNING: Removed duplicated region for block: B:78:0x0158 A[SYNTHETIC, Splitter:B:78:0x0158] */
    /* JADX WARNING: Removed duplicated region for block: B:83:0x0163 A[SYNTHETIC, Splitter:B:83:0x0163] */
    /* JADX WARNING: Removed duplicated region for block: B:90:0x016e A[SYNTHETIC, Splitter:B:90:0x016e] */
    /* JADX WARNING: Removed duplicated region for block: B:95:0x0179 A[SYNTHETIC, Splitter:B:95:0x0179] */
    /* JADX WARNING: Unknown top exception splitter block from list: {B:75:0x0153=Splitter:B:75:0x0153, B:87:0x0169=Splitter:B:87:0x0169} */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private java.util.ArrayList<com.epson.mobilephone.common.wifidirect.MacAddrFilter.MacAddressEntry> readMacAddressTable(java.lang.String r17) {
        /*
            r16 = this;
            r1 = r16
            r0 = r17
            long r2 = java.lang.System.currentTimeMillis()
            java.lang.String r4 = "MacAddrFilter"
            java.lang.StringBuilder r5 = new java.lang.StringBuilder
            r5.<init>()
            java.lang.String r6 = "Enter readMacAddressTable: path = "
            r5.append(r6)
            r5.append(r0)
            java.lang.String r5 = r5.toString()
            com.epson.mobilephone.common.wifidirect.EPLog.m86d(r4, r5)
            java.util.ArrayList r4 = new java.util.ArrayList
            r4.<init>()
            r5 = 0
            r6 = 0
            android.content.Context r7 = r1.mAppContext     // Catch:{ IOException -> 0x0167, Exception -> 0x0151, all -> 0x014c }
            android.content.res.AssetManager r7 = r7.getAssets()     // Catch:{ IOException -> 0x0167, Exception -> 0x0151, all -> 0x014c }
            java.io.InputStream r7 = r7.open(r0)     // Catch:{ IOException -> 0x0167, Exception -> 0x0151, all -> 0x014c }
            if (r7 == 0) goto L_0x0135
            java.io.BufferedReader r8 = new java.io.BufferedReader     // Catch:{ IOException -> 0x0131, Exception -> 0x012d, all -> 0x0128 }
            java.io.InputStreamReader r0 = new java.io.InputStreamReader     // Catch:{ IOException -> 0x0131, Exception -> 0x012d, all -> 0x0128 }
            r0.<init>(r7)     // Catch:{ IOException -> 0x0131, Exception -> 0x012d, all -> 0x0128 }
            r8.<init>(r0)     // Catch:{ IOException -> 0x0131, Exception -> 0x012d, all -> 0x0128 }
            r5 = 0
        L_0x003c:
            java.lang.String r0 = r8.readLine()     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            if (r0 == 0) goto L_0x011b
            boolean r9 = r0.isEmpty()     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            if (r9 != 0) goto L_0x003c
            java.lang.String r9 = COMMENT_PREFIX     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            boolean r9 = r0.startsWith(r9)     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            if (r9 == 0) goto L_0x0051
            goto L_0x003c
        L_0x0051:
            int r5 = r5 + 1
            java.lang.String r9 = "[,\\u002C\t\\u0009]+"
            java.lang.String[] r9 = r0.split(r9, r6)     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            int r10 = r9.length     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            r11 = 2
            if (r10 >= r11) goto L_0x0074
            java.lang.String r9 = "MacAddrFilter"
            java.lang.StringBuilder r10 = new java.lang.StringBuilder     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            r10.<init>()     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            java.lang.String r11 = "Illegal Line = "
            r10.append(r11)     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            r10.append(r0)     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            java.lang.String r0 = r10.toString()     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            com.epson.mobilephone.common.wifidirect.EPLog.m90w(r9, r0)     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            goto L_0x003c
        L_0x0074:
            r10 = 1
            r12 = 1
        L_0x0076:
            int r13 = r9.length     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            if (r12 >= r13) goto L_0x00a1
            r13 = r9[r12]     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            java.lang.String r14 = "\""
            boolean r14 = r13.startsWith(r14)     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            if (r14 == 0) goto L_0x0087
            java.lang.String r13 = r13.substring(r10)     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
        L_0x0087:
            java.lang.String r14 = "\""
            boolean r14 = r13.endsWith(r14)     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            if (r14 == 0) goto L_0x0098
            int r14 = r13.length()     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            int r14 = r14 - r10
            java.lang.String r13 = r13.substring(r6, r14)     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
        L_0x0098:
            java.lang.String r13 = r13.trim()     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            r9[r12] = r13     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            int r12 = r12 + 1
            goto L_0x0076
        L_0x00a1:
            r12 = 1
        L_0x00a2:
            int r13 = r9.length     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            if (r12 >= r13) goto L_0x003c
            r13 = r9[r12]     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            java.lang.String r14 = "[-–]"
            java.lang.String r15 = " "
            java.lang.String r13 = r13.replaceAll(r14, r15)     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            java.lang.String r14 = "[\\s]+"
            java.lang.String[] r14 = r13.split(r14, r6)     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            int r15 = r14.length     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            if (r15 == r11) goto L_0x00cf
            java.lang.String r14 = "MacAddrFilter"
            java.lang.StringBuilder r15 = new java.lang.StringBuilder     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            r15.<init>()     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            java.lang.String r11 = "Illegal item = "
            r15.append(r11)     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            r15.append(r13)     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            java.lang.String r11 = r15.toString()     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            com.epson.mobilephone.common.wifidirect.EPLog.m90w(r14, r11)     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            goto L_0x0117
        L_0x00cf:
            r11 = r14[r6]     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            java.lang.String r11 = com.epson.mobilephone.common.wifidirect.MacAddrUtils.p2pAddr2MacAddrStr(r11)     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            r13 = r14[r10]     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            java.lang.String r13 = com.epson.mobilephone.common.wifidirect.MacAddrUtils.p2pAddr2MacAddrStr(r13)     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            if (r11 == 0) goto L_0x0101
            int r14 = r11.length()     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            r15 = 12
            if (r14 != r15) goto L_0x0101
            if (r13 == 0) goto L_0x0101
            int r14 = r13.length()     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            if (r14 != r15) goto L_0x0101
            com.epson.mobilephone.common.wifidirect.MacAddrFilter$MacAddressEntry r14 = new com.epson.mobilephone.common.wifidirect.MacAddrFilter$MacAddressEntry     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            r14.<init>(r11, r13)     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            boolean r14 = r4.contains(r14)     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            if (r14 != 0) goto L_0x0117
            com.epson.mobilephone.common.wifidirect.MacAddrFilter$MacAddressEntry r14 = new com.epson.mobilephone.common.wifidirect.MacAddrFilter$MacAddressEntry     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            r14.<init>(r11, r13)     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            r4.add(r14)     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            goto L_0x0117
        L_0x0101:
            java.lang.String r11 = "MacAddrFilter"
            java.lang.StringBuilder r13 = new java.lang.StringBuilder     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            r13.<init>()     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            java.lang.String r14 = "Illegal Line = "
            r13.append(r14)     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            r13.append(r0)     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            java.lang.String r13 = r13.toString()     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
            com.epson.mobilephone.common.wifidirect.EPLog.m90w(r11, r13)     // Catch:{ IOException -> 0x0125, Exception -> 0x0122, all -> 0x011e }
        L_0x0117:
            int r12 = r12 + 1
            r11 = 2
            goto L_0x00a2
        L_0x011b:
            r6 = r5
            r5 = r8
            goto L_0x0135
        L_0x011e:
            r0 = move-exception
            r2 = r0
            goto L_0x01b4
        L_0x0122:
            r0 = move-exception
            r6 = r5
            goto L_0x012f
        L_0x0125:
            r0 = move-exception
            r6 = r5
            goto L_0x0133
        L_0x0128:
            r0 = move-exception
            r2 = r0
            r8 = r5
            goto L_0x01b4
        L_0x012d:
            r0 = move-exception
            r8 = r5
        L_0x012f:
            r5 = r7
            goto L_0x0153
        L_0x0131:
            r0 = move-exception
            r8 = r5
        L_0x0133:
            r5 = r7
            goto L_0x0169
        L_0x0135:
            if (r7 == 0) goto L_0x0140
            r7.close()     // Catch:{ IOException -> 0x013b }
            goto L_0x0140
        L_0x013b:
            r0 = move-exception
            r7 = r0
            r7.printStackTrace()
        L_0x0140:
            if (r5 == 0) goto L_0x017c
            r5.close()     // Catch:{ IOException -> 0x0146 }
            goto L_0x017c
        L_0x0146:
            r0 = move-exception
            r5 = r0
            r5.printStackTrace()
            goto L_0x017c
        L_0x014c:
            r0 = move-exception
            r2 = r0
            r7 = r5
            r8 = r7
            goto L_0x01b4
        L_0x0151:
            r0 = move-exception
            r8 = r5
        L_0x0153:
            r0.printStackTrace()     // Catch:{ all -> 0x01b1 }
            if (r5 == 0) goto L_0x0161
            r5.close()     // Catch:{ IOException -> 0x015c }
            goto L_0x0161
        L_0x015c:
            r0 = move-exception
            r5 = r0
            r5.printStackTrace()
        L_0x0161:
            if (r8 == 0) goto L_0x017c
            r8.close()     // Catch:{ IOException -> 0x0146 }
            goto L_0x017c
        L_0x0167:
            r0 = move-exception
            r8 = r5
        L_0x0169:
            r0.printStackTrace()     // Catch:{ all -> 0x01b1 }
            if (r5 == 0) goto L_0x0177
            r5.close()     // Catch:{ IOException -> 0x0172 }
            goto L_0x0177
        L_0x0172:
            r0 = move-exception
            r5 = r0
            r5.printStackTrace()
        L_0x0177:
            if (r8 == 0) goto L_0x017c
            r8.close()     // Catch:{ IOException -> 0x0146 }
        L_0x017c:
            java.lang.String r0 = "MacAddrFilter"
            java.lang.StringBuilder r5 = new java.lang.StringBuilder
            r5.<init>()
            java.lang.String r7 = "Leave readMacAddressTable: readlinecount = "
            r5.append(r7)
            r5.append(r6)
            java.lang.String r6 = " entry = "
            r5.append(r6)
            int r6 = r4.size()
            r5.append(r6)
            java.lang.String r6 = " time = "
            r5.append(r6)
            long r6 = java.lang.System.currentTimeMillis()
            long r6 = r6 - r2
            r5.append(r6)
            java.lang.String r2 = " msec"
            r5.append(r2)
            java.lang.String r2 = r5.toString()
            com.epson.mobilephone.common.wifidirect.EPLog.m86d(r0, r2)
            return r4
        L_0x01b1:
            r0 = move-exception
            r2 = r0
            r7 = r5
        L_0x01b4:
            if (r7 == 0) goto L_0x01bf
            r7.close()     // Catch:{ IOException -> 0x01ba }
            goto L_0x01bf
        L_0x01ba:
            r0 = move-exception
            r3 = r0
            r3.printStackTrace()
        L_0x01bf:
            if (r8 == 0) goto L_0x01ca
            r8.close()     // Catch:{ IOException -> 0x01c5 }
            goto L_0x01ca
        L_0x01c5:
            r0 = move-exception
            r3 = r0
            r3.printStackTrace()
        L_0x01ca:
            throw r2
        */
        throw new UnsupportedOperationException("Method not decompiled: com.epson.mobilephone.common.wifidirect.MacAddrFilter.readMacAddressTable(java.lang.String):java.util.ArrayList");
    }
}
