package epson.scan.lib;

import java.util.List;

public class CancelableScannerProbe {
    private escanLib mEscanLib;
    private volatile boolean mProbingScanner;

    /*  JADX ERROR: IndexOutOfBoundsException in pass: RegionMakerVisitor
        java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        	at java.util.ArrayList.rangeCheck(ArrayList.java:657)
        	at java.util.ArrayList.get(ArrayList.java:433)
        	at jadx.core.dex.nodes.InsnNode.getArg(InsnNode.java:101)
        	at jadx.core.dex.visitors.regions.RegionMaker.traverseMonitorExits(RegionMaker.java:611)
        	at jadx.core.dex.visitors.regions.RegionMaker.traverseMonitorExits(RegionMaker.java:619)
        	at jadx.core.dex.visitors.regions.RegionMaker.traverseMonitorExits(RegionMaker.java:619)
        	at jadx.core.dex.visitors.regions.RegionMaker.traverseMonitorExits(RegionMaker.java:619)
        	at jadx.core.dex.visitors.regions.RegionMaker.processMonitorEnter(RegionMaker.java:561)
        	at jadx.core.dex.visitors.regions.RegionMaker.traverse(RegionMaker.java:133)
        	at jadx.core.dex.visitors.regions.RegionMaker.makeRegion(RegionMaker.java:86)
        	at jadx.core.dex.visitors.regions.RegionMaker.processHandlersOutBlocks(RegionMaker.java:1008)
        	at jadx.core.dex.visitors.regions.RegionMaker.processTryCatchBlocks(RegionMaker.java:978)
        	at jadx.core.dex.visitors.regions.RegionMakerVisitor.visit(RegionMakerVisitor.java:52)
        */
    public java.lang.String probeScanner_test(epson.scan.activity.ScannerPropertyWrapper r7, android.content.Context r8) {
        /*
            r6 = this;
            r0 = 0
            r6.mEscanLib = r0
            r1 = 0
            monitor-enter(r6)     // Catch:{ all -> 0x00d2 }
            epson.scan.lib.escanLib r2 = new epson.scan.lib.escanLib     // Catch:{ all -> 0x00cf }
            r2.<init>()     // Catch:{ all -> 0x00cf }
            r6.mEscanLib = r2     // Catch:{ all -> 0x00cf }
            monitor-exit(r6)     // Catch:{ all -> 0x00cf }
            r2 = 0
        L_0x000e:
            epson.scan.lib.escanLib r3 = r6.mEscanLib     // Catch:{ all -> 0x00cd }
            int r3 = r3.escanWrapperInitDriver(r8)     // Catch:{ all -> 0x00cd }
            r4 = -1050(0xfffffffffffffbe6, float:NaN)
            r5 = 1
            if (r3 == r4) goto L_0x0035
            if (r3 == 0) goto L_0x0033
            monitor-enter(r6)
            r6.mProbingScanner = r1     // Catch:{ all -> 0x0030 }
            monitor-exit(r6)     // Catch:{ all -> 0x0030 }
            epson.scan.lib.escanLib r7 = r6.mEscanLib
            if (r7 == 0) goto L_0x0028
            if (r2 == 0) goto L_0x0028
            r7.escanWrapperReleaseDriver()
        L_0x0028:
            monitor-enter(r6)
            r6.mEscanLib = r0     // Catch:{ all -> 0x002d }
            monitor-exit(r6)     // Catch:{ all -> 0x002d }
            return r0
        L_0x002d:
            r7 = move-exception
            monitor-exit(r6)     // Catch:{ all -> 0x002d }
            throw r7
        L_0x0030:
            r7 = move-exception
            monitor-exit(r6)     // Catch:{ all -> 0x0030 }
            throw r7
        L_0x0033:
            r2 = 1
            goto L_0x003a
        L_0x0035:
            epson.scan.lib.escanLib r3 = r6.mEscanLib     // Catch:{ all -> 0x00cd }
            r3.escanWrapperReleaseDriver()     // Catch:{ all -> 0x00cd }
        L_0x003a:
            if (r2 == 0) goto L_0x000e
            java.lang.String r8 = r7.getIp()     // Catch:{ all -> 0x00cd }
            java.lang.String r3 = r7.getScannerId()     // Catch:{ all -> 0x00cd }
            monitor-enter(r6)     // Catch:{ all -> 0x00cd }
            r6.mProbingScanner = r5     // Catch:{ all -> 0x00ca }
            monitor-exit(r6)     // Catch:{ all -> 0x00ca }
            if (r8 == 0) goto L_0x00ac
            boolean r4 = r8.isEmpty()     // Catch:{ all -> 0x00cd }
            if (r4 != 0) goto L_0x00ac
            epson.scan.lib.escanLib r4 = r6.mEscanLib     // Catch:{ all -> 0x00cd }
            int r4 = r4.probeScannerByIp(r3, r8)     // Catch:{ all -> 0x00cd }
            if (r4 != 0) goto L_0x0070
            monitor-enter(r6)
            r6.mProbingScanner = r1     // Catch:{ all -> 0x006d }
            monitor-exit(r6)     // Catch:{ all -> 0x006d }
            epson.scan.lib.escanLib r7 = r6.mEscanLib
            if (r7 == 0) goto L_0x0065
            if (r2 == 0) goto L_0x0065
            r7.escanWrapperReleaseDriver()
        L_0x0065:
            monitor-enter(r6)
            r6.mEscanLib = r0     // Catch:{ all -> 0x006a }
            monitor-exit(r6)     // Catch:{ all -> 0x006a }
            return r8
        L_0x006a:
            r7 = move-exception
            monitor-exit(r6)     // Catch:{ all -> 0x006a }
            throw r7
        L_0x006d:
            r7 = move-exception
            monitor-exit(r6)     // Catch:{ all -> 0x006d }
            throw r7
        L_0x0070:
            int r7 = r7.getLocation()     // Catch:{ all -> 0x00cd }
            if (r7 == r5) goto L_0x008e
            monitor-enter(r6)
            r6.mProbingScanner = r1     // Catch:{ all -> 0x008b }
            monitor-exit(r6)     // Catch:{ all -> 0x008b }
            epson.scan.lib.escanLib r7 = r6.mEscanLib
            if (r7 == 0) goto L_0x0083
            if (r2 == 0) goto L_0x0083
            r7.escanWrapperReleaseDriver()
        L_0x0083:
            monitor-enter(r6)
            r6.mEscanLib = r0     // Catch:{ all -> 0x0088 }
            monitor-exit(r6)     // Catch:{ all -> 0x0088 }
            return r0
        L_0x0088:
            r7 = move-exception
            monitor-exit(r6)     // Catch:{ all -> 0x0088 }
            throw r7
        L_0x008b:
            r7 = move-exception
            monitor-exit(r6)     // Catch:{ all -> 0x008b }
            throw r7
        L_0x008e:
            epson.scan.lib.escanLib r7 = r6.mEscanLib     // Catch:{ all -> 0x00cd }
            java.lang.String r7 = localProbeById(r7, r3, r8)     // Catch:{ all -> 0x00cd }
            monitor-enter(r6)
            r6.mProbingScanner = r1     // Catch:{ all -> 0x00a9 }
            monitor-exit(r6)     // Catch:{ all -> 0x00a9 }
            epson.scan.lib.escanLib r8 = r6.mEscanLib
            if (r8 == 0) goto L_0x00a1
            if (r2 == 0) goto L_0x00a1
            r8.escanWrapperReleaseDriver()
        L_0x00a1:
            monitor-enter(r6)
            r6.mEscanLib = r0     // Catch:{ all -> 0x00a6 }
            monitor-exit(r6)     // Catch:{ all -> 0x00a6 }
            return r7
        L_0x00a6:
            r7 = move-exception
            monitor-exit(r6)     // Catch:{ all -> 0x00a6 }
            throw r7
        L_0x00a9:
            r7 = move-exception
            monitor-exit(r6)     // Catch:{ all -> 0x00a9 }
            throw r7
        L_0x00ac:
            epson.scan.lib.escanLib r7 = r6.mEscanLib     // Catch:{ all -> 0x00cd }
            java.lang.String r7 = localProbeById(r7, r3, r8)     // Catch:{ all -> 0x00cd }
            monitor-enter(r6)
            r6.mProbingScanner = r1     // Catch:{ all -> 0x00c7 }
            monitor-exit(r6)     // Catch:{ all -> 0x00c7 }
            epson.scan.lib.escanLib r8 = r6.mEscanLib
            if (r8 == 0) goto L_0x00bf
            if (r2 == 0) goto L_0x00bf
            r8.escanWrapperReleaseDriver()
        L_0x00bf:
            monitor-enter(r6)
            r6.mEscanLib = r0     // Catch:{ all -> 0x00c4 }
            monitor-exit(r6)     // Catch:{ all -> 0x00c4 }
            return r7
        L_0x00c4:
            r7 = move-exception
            monitor-exit(r6)     // Catch:{ all -> 0x00c4 }
            throw r7
        L_0x00c7:
            r7 = move-exception
            monitor-exit(r6)     // Catch:{ all -> 0x00c7 }
            throw r7
        L_0x00ca:
            r7 = move-exception
            monitor-exit(r6)     // Catch:{ all -> 0x00ca }
            throw r7     // Catch:{ all -> 0x00cd }
        L_0x00cd:
            r7 = move-exception
            goto L_0x00d4
        L_0x00cf:
            r7 = move-exception
            monitor-exit(r6)     // Catch:{ all -> 0x00cf }
            throw r7     // Catch:{ all -> 0x00d2 }
        L_0x00d2:
            r7 = move-exception
            r2 = 0
        L_0x00d4:
            monitor-enter(r6)
            r6.mProbingScanner = r1     // Catch:{ all -> 0x00e9 }
            monitor-exit(r6)     // Catch:{ all -> 0x00e9 }
            epson.scan.lib.escanLib r8 = r6.mEscanLib
            if (r8 == 0) goto L_0x00e1
            if (r2 == 0) goto L_0x00e1
            r8.escanWrapperReleaseDriver()
        L_0x00e1:
            monitor-enter(r6)
            r6.mEscanLib = r0     // Catch:{ all -> 0x00e6 }
            monitor-exit(r6)     // Catch:{ all -> 0x00e6 }
            throw r7
        L_0x00e6:
            r7 = move-exception
            monitor-exit(r6)     // Catch:{ all -> 0x00e6 }
            throw r7
        L_0x00e9:
            r7 = move-exception
            monitor-exit(r6)     // Catch:{ all -> 0x00e9 }
            throw r7
        */
        throw new UnsupportedOperationException("Method not decompiled: epson.scan.lib.CancelableScannerProbe.probeScanner_test(epson.scan.activity.ScannerPropertyWrapper, android.content.Context):java.lang.String");
    }

    /*  JADX ERROR: IndexOutOfBoundsException in pass: RegionMakerVisitor
        java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        	at java.util.ArrayList.rangeCheck(ArrayList.java:657)
        	at java.util.ArrayList.get(ArrayList.java:433)
        	at jadx.core.dex.nodes.InsnNode.getArg(InsnNode.java:101)
        	at jadx.core.dex.visitors.regions.RegionMaker.traverseMonitorExits(RegionMaker.java:611)
        	at jadx.core.dex.visitors.regions.RegionMaker.traverseMonitorExits(RegionMaker.java:619)
        	at jadx.core.dex.visitors.regions.RegionMaker.traverseMonitorExits(RegionMaker.java:619)
        	at jadx.core.dex.visitors.regions.RegionMaker.traverseMonitorExits(RegionMaker.java:619)
        	at jadx.core.dex.visitors.regions.RegionMaker.processMonitorEnter(RegionMaker.java:561)
        	at jadx.core.dex.visitors.regions.RegionMaker.traverse(RegionMaker.java:133)
        	at jadx.core.dex.visitors.regions.RegionMaker.makeRegion(RegionMaker.java:86)
        	at jadx.core.dex.visitors.regions.RegionMaker.processHandlersOutBlocks(RegionMaker.java:1008)
        	at jadx.core.dex.visitors.regions.RegionMaker.processTryCatchBlocks(RegionMaker.java:978)
        	at jadx.core.dex.visitors.regions.RegionMakerVisitor.visit(RegionMakerVisitor.java:52)
        */
    public java.lang.String probeScanner(epson.scan.activity.ScannerPropertyWrapper r7, android.content.Context r8) throws epson.scan.lib.EscanLibException {
        /*
            r6 = this;
            r0 = 0
            r6.mEscanLib = r0
            r1 = 0
            monitor-enter(r6)     // Catch:{ all -> 0x009b }
            epson.scan.lib.escanLib r2 = new epson.scan.lib.escanLib     // Catch:{ all -> 0x0098 }
            r2.<init>()     // Catch:{ all -> 0x0098 }
            r6.mEscanLib = r2     // Catch:{ all -> 0x0098 }
            monitor-exit(r6)     // Catch:{ all -> 0x0098 }
            r2 = 0
        L_0x000e:
            epson.scan.lib.escanLib r3 = r6.mEscanLib     // Catch:{ all -> 0x0096 }
            int r3 = r3.escanWrapperInitDriver(r8)     // Catch:{ all -> 0x0096 }
            r4 = -1050(0xfffffffffffffbe6, float:NaN)
            r5 = 1
            if (r3 == r4) goto L_0x0035
            if (r3 == 0) goto L_0x0033
            monitor-enter(r6)
            r6.mProbingScanner = r1     // Catch:{ all -> 0x0030 }
            monitor-exit(r6)     // Catch:{ all -> 0x0030 }
            epson.scan.lib.escanLib r7 = r6.mEscanLib
            if (r7 == 0) goto L_0x0028
            if (r2 == 0) goto L_0x0028
            r7.escanWrapperReleaseDriver()
        L_0x0028:
            monitor-enter(r6)
            r6.mEscanLib = r0     // Catch:{ all -> 0x002d }
            monitor-exit(r6)     // Catch:{ all -> 0x002d }
            return r0
        L_0x002d:
            r7 = move-exception
            monitor-exit(r6)     // Catch:{ all -> 0x002d }
            throw r7
        L_0x0030:
            r7 = move-exception
            monitor-exit(r6)     // Catch:{ all -> 0x0030 }
            throw r7
        L_0x0033:
            r2 = 1
            goto L_0x003a
        L_0x0035:
            epson.scan.lib.escanLib r3 = r6.mEscanLib     // Catch:{ all -> 0x0096 }
            r3.escanWrapperReleaseDriver()     // Catch:{ all -> 0x0096 }
        L_0x003a:
            if (r2 == 0) goto L_0x000e
            java.lang.String r8 = r7.getIp()     // Catch:{ all -> 0x0096 }
            java.lang.String r3 = r7.getScannerId()     // Catch:{ all -> 0x0096 }
            monitor-enter(r6)     // Catch:{ all -> 0x0096 }
            r6.mProbingScanner = r5     // Catch:{ all -> 0x0093 }
            monitor-exit(r6)     // Catch:{ all -> 0x0093 }
            int r7 = r7.getLocation()     // Catch:{ all -> 0x0096 }
            r4 = 3
            if (r7 != r4) goto L_0x0075
            epson.scan.lib.escanLib r7 = r6.mEscanLib     // Catch:{ all -> 0x0096 }
            int r7 = r7.probeScannerByIp(r3, r8)     // Catch:{ all -> 0x0096 }
            if (r7 != 0) goto L_0x006f
            monitor-enter(r6)
            r6.mProbingScanner = r1     // Catch:{ all -> 0x006c }
            monitor-exit(r6)     // Catch:{ all -> 0x006c }
            epson.scan.lib.escanLib r7 = r6.mEscanLib
            if (r7 == 0) goto L_0x0064
            if (r2 == 0) goto L_0x0064
            r7.escanWrapperReleaseDriver()
        L_0x0064:
            monitor-enter(r6)
            r6.mEscanLib = r0     // Catch:{ all -> 0x0069 }
            monitor-exit(r6)     // Catch:{ all -> 0x0069 }
            return r8
        L_0x0069:
            r7 = move-exception
            monitor-exit(r6)     // Catch:{ all -> 0x0069 }
            throw r7
        L_0x006c:
            r7 = move-exception
            monitor-exit(r6)     // Catch:{ all -> 0x006c }
            throw r7
        L_0x006f:
            epson.scan.lib.EscanLibException r8 = new epson.scan.lib.EscanLibException     // Catch:{ all -> 0x0096 }
            r8.<init>(r7)     // Catch:{ all -> 0x0096 }
            throw r8     // Catch:{ all -> 0x0096 }
        L_0x0075:
            epson.scan.lib.escanLib r7 = r6.mEscanLib     // Catch:{ all -> 0x0096 }
            java.lang.String r7 = localProbeById(r7, r3, r8)     // Catch:{ all -> 0x0096 }
            monitor-enter(r6)
            r6.mProbingScanner = r1     // Catch:{ all -> 0x0090 }
            monitor-exit(r6)     // Catch:{ all -> 0x0090 }
            epson.scan.lib.escanLib r8 = r6.mEscanLib
            if (r8 == 0) goto L_0x0088
            if (r2 == 0) goto L_0x0088
            r8.escanWrapperReleaseDriver()
        L_0x0088:
            monitor-enter(r6)
            r6.mEscanLib = r0     // Catch:{ all -> 0x008d }
            monitor-exit(r6)     // Catch:{ all -> 0x008d }
            return r7
        L_0x008d:
            r7 = move-exception
            monitor-exit(r6)     // Catch:{ all -> 0x008d }
            throw r7
        L_0x0090:
            r7 = move-exception
            monitor-exit(r6)     // Catch:{ all -> 0x0090 }
            throw r7
        L_0x0093:
            r7 = move-exception
            monitor-exit(r6)     // Catch:{ all -> 0x0093 }
            throw r7     // Catch:{ all -> 0x0096 }
        L_0x0096:
            r7 = move-exception
            goto L_0x009d
        L_0x0098:
            r7 = move-exception
            monitor-exit(r6)     // Catch:{ all -> 0x0098 }
            throw r7     // Catch:{ all -> 0x009b }
        L_0x009b:
            r7 = move-exception
            r2 = 0
        L_0x009d:
            monitor-enter(r6)
            r6.mProbingScanner = r1     // Catch:{ all -> 0x00b2 }
            monitor-exit(r6)     // Catch:{ all -> 0x00b2 }
            epson.scan.lib.escanLib r8 = r6.mEscanLib
            if (r8 == 0) goto L_0x00aa
            if (r2 == 0) goto L_0x00aa
            r8.escanWrapperReleaseDriver()
        L_0x00aa:
            monitor-enter(r6)
            r6.mEscanLib = r0     // Catch:{ all -> 0x00af }
            monitor-exit(r6)     // Catch:{ all -> 0x00af }
            throw r7
        L_0x00af:
            r7 = move-exception
            monitor-exit(r6)     // Catch:{ all -> 0x00af }
            throw r7
        L_0x00b2:
            r7 = move-exception
            monitor-exit(r6)     // Catch:{ all -> 0x00b2 }
            throw r7
        */
        throw new UnsupportedOperationException("Method not decompiled: epson.scan.lib.CancelableScannerProbe.probeScanner(epson.scan.activity.ScannerPropertyWrapper, android.content.Context):java.lang.String");
    }

    private static String localProbeById(escanLib escanlib, String str, String str2) {
        List<ScannerInfo> listFoundScanner;
        escanlib.resetEscanLib();
        if (escanlib.probeScannerById(str, str2) == 0 && (listFoundScanner = escanlib.getListFoundScanner()) != null && listFoundScanner.size() > 0) {
            return listFoundScanner.get(0).getIp();
        }
        return null;
    }

    public void cancel() {
        synchronized (this) {
            if (mProbingScanner && mEscanLib != null) {
                mEscanLib.escanWrapperCancelFindScanner();
            }
        }
    }
}
