package com.tencent.mm.plugin.scanner.util;

import android.graphics.Point;
import android.graphics.Rect;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.plugin.scanner.util.b.a;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.qbar.QbarNative;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public final class d extends b {
    private Object cli = new Object();
    private QbarNative hHf = new QbarNative();
    private boolean hHg = false;
    private byte[] hHh;
    private byte[] hHi;
    public volatile boolean isDecoding = false;
    public boolean ovx = true;
    public boolean qdM = false;
    public Set<Integer> qfh;
    public int qht;

    public d(a aVar, int i, boolean z) {
        super(aVar);
        AppMethodBeat.i(81381);
        this.qht = i;
        this.ovx = z;
        AppMethodBeat.o(81381);
    }

    private synchronized byte[] a(byte[] bArr, Point point, Rect rect, Point point2) {
        byte[] bArr2;
        AppMethodBeat.i(81382);
        if (bArr == null || bArr.length <= 0) {
            ab.w("MicroMsg.scanner.QBarDecoder", "prepareGrayData , data is null");
            bArr2 = null;
            AppMethodBeat.o(81382);
        } else {
            ab.i("MicroMsg.scanner.QBarDecoder", "resolution %s, coverage %s", new Object[]{point, rect});
            long currentTimeMillis = System.currentTimeMillis();
            Rect rect2 = new Rect();
            int width;
            int height;
            if (com.tencent.mm.compatible.e.d.Lt() || !this.ovx) {
                width = rect.width() % 4;
                height = rect.height() % 4;
                rect2.left = rect.left;
                rect2.right = rect.right - width;
                rect2.top = rect.top;
                rect2.bottom = rect.bottom - height;
                if (rect2.right <= rect2.left || rect2.bottom <= rect2.top) {
                    bArr2 = null;
                    AppMethodBeat.o(81382);
                }
            } else {
                rect2.left = (point.x / 2) - (rect.height() / 2);
                rect2.right = (point.x / 2) + (rect.height() / 2);
                rect2.top = (point.y / 2) - (rect.width() / 2);
                rect2.bottom = (point.y / 2) + (rect.width() / 2);
                if (rect2.left < 0) {
                    rect2.left = 0;
                }
                if (rect2.right > point.x - 1) {
                    rect2.right = point.x - 1;
                }
                if (rect2.top < 0) {
                    rect2.top = 0;
                }
                if (rect2.bottom > point.y - 1) {
                    rect2.bottom = point.y - 1;
                }
                width = rect2.width() % 4;
                height = rect2.height() % 4;
                if (width != 0) {
                    rect2.right -= width;
                }
                if (height != 0) {
                    rect2.bottom -= height;
                }
                if (rect2.right <= rect2.left || rect2.bottom <= rect2.top) {
                    bArr2 = null;
                    AppMethodBeat.o(81382);
                }
            }
            ab.i("MicroMsg.scanner.QBarDecoder", "targetRect %s", new Object[]{rect2});
            c cVar = new c(bArr, point.x, point.y, rect2);
            point2.x = cVar.width;
            point2.y = cVar.height;
            int i = 0;
            if (!com.tencent.mm.compatible.e.d.Lt()) {
                i = 90;
                point2.x = cVar.height;
                point2.y = cVar.width;
            }
            ab.d("MicroMsg.scanner.QBarDecoder", "rotate angle: ".concat(String.valueOf(i)));
            if (this.hHh == null) {
                this.hHh = new byte[(((cVar.width * cVar.height) * 3) / 2)];
                this.hHi = new byte[(cVar.width * cVar.height)];
                ab.d("MicroMsg.scanner.QBarDecoder", "tempOutBytes = null, new byte[%s]", new Object[]{Integer.valueOf(((cVar.width * cVar.height) * 3) / 2)});
            } else if (this.hHh.length != ((cVar.width * cVar.height) * 3) / 2) {
                this.hHh = null;
                this.hHh = new byte[(((cVar.width * cVar.height) * 3) / 2)];
                this.hHi = null;
                this.hHi = new byte[(cVar.width * cVar.height)];
                ab.d("MicroMsg.scanner.QBarDecoder", "tempOutBytes size change, new byte[%s]", new Object[]{Integer.valueOf(((cVar.width * cVar.height) * 3) / 2)});
            }
            if (QbarNative.a(this.hHh, new int[]{point2.x, point2.y}, bArr, point.x, point.y, cVar.left, cVar.top, cVar.width, cVar.height, i) != 0) {
                ab.e("MicroMsg.scanner.QBarDecoder", "decode pro_result %s", new Object[]{Integer.valueOf(QbarNative.a(this.hHh, new int[]{point2.x, point2.y}, bArr, point.x, point.y, cVar.left, cVar.top, cVar.width, cVar.height, i))});
                bArr2 = null;
                AppMethodBeat.o(81382);
            } else {
                System.arraycopy(this.hHh, 0, this.hHi, 0, this.hHi.length);
                ab.d("MicroMsg.scanner.QBarDecoder", "decode, rotate and gray, cost:%d", new Object[]{Long.valueOf(System.currentTimeMillis() - currentTimeMillis)});
                bArr2 = this.hHi;
                AppMethodBeat.o(81382);
            }
        }
        return bArr2;
    }

    public final boolean a(byte[] bArr, Point point, Rect rect) {
        AppMethodBeat.i(81383);
        Point point2 = new Point();
        byte[] a = a(bArr, point, rect, point2);
        if (a == null || a.length <= 0) {
            AppMethodBeat.o(81383);
            return false;
        }
        boolean b = b(a, point2);
        AppMethodBeat.o(81383);
        return b;
    }

    public final synchronized byte[] a(byte[] bArr, Point point, int i, Rect rect, Point point2) {
        byte[] bArr2;
        AppMethodBeat.i(81384);
        if (270 == i) {
            bArr2 = new byte[bArr.length];
            QbarNative.a(bArr2, bArr, point.x, point.y);
            bArr = new byte[bArr.length];
            QbarNative.a(bArr, bArr2, point.y, point.x);
            QbarNative.nativeRelease();
        }
        bArr2 = a(bArr, point, rect, point2);
        AppMethodBeat.o(81384);
        return bArr2;
    }

    public final void a(byte[] bArr, Point point) {
        AppMethodBeat.i(81385);
        com.tencent.mm.sdk.g.d.f(new 1(this, bArr, point), "scan_decode");
        AppMethodBeat.o(81385);
    }

    /* JADX WARNING: Missing block: B:72:0x02a7, code skipped:
            com.tencent.matrix.trace.core.AppMethodBeat.o(81386);
     */
    /* JADX WARNING: Missing block: B:89:?, code skipped:
            return r2;
     */
    private boolean b(byte[] r16, android.graphics.Point r17) {
        /*
        r15 = this;
        r2 = 81386; // 0x13dea float:1.14046E-40 double:4.021E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r2);
        r10 = java.lang.System.currentTimeMillis();
        r2 = "MicroMsg.scanner.QBarDecoder";
        r3 = "decode() start";
        com.tencent.mm.sdk.platformtools.ab.i(r2, r3);
        r2 = r15.isDecoding;
        if (r2 == 0) goto L_0x0028;
    L_0x0017:
        r2 = "MicroMsg.scanner.QBarDecoder";
        r3 = "is decoding, return false";
        com.tencent.mm.sdk.platformtools.ab.e(r2, r3);
        r2 = 0;
        r3 = 81386; // 0x13dea float:1.14046E-40 double:4.021E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r3);
    L_0x0027:
        return r2;
    L_0x0028:
        r2 = r15.qdM;
        if (r2 == 0) goto L_0x003d;
    L_0x002c:
        r2 = "MicroMsg.scanner.QBarDecoder";
        r3 = "isReleasing, return false 1";
        com.tencent.mm.sdk.platformtools.ab.w(r2, r3);
        r2 = 0;
        r3 = 81386; // 0x13dea float:1.14046E-40 double:4.021E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r3);
        goto L_0x0027;
    L_0x003d:
        if (r16 != 0) goto L_0x0050;
    L_0x003f:
        r2 = "MicroMsg.scanner.QBarDecoder";
        r3 = "wrong args";
        com.tencent.mm.sdk.platformtools.ab.e(r2, r3);
        r2 = 0;
        r3 = 81386; // 0x13dea float:1.14046E-40 double:4.021E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r3);
        goto L_0x0027;
    L_0x0050:
        r9 = r15.cli;
        monitor-enter(r9);
        r2 = 1;
        r15.isDecoding = r2;	 Catch:{ all -> 0x02dd }
        r2 = 0;
        r15.qhl = r2;	 Catch:{ all -> 0x02dd }
        r2 = 0;
        r15.cvo = r2;	 Catch:{ all -> 0x02dd }
        r15.cvn = r2;	 Catch:{ all -> 0x02dd }
        r2 = com.tencent.mm.plugin.scanner.a.m.pZK;	 Catch:{ all -> 0x02dd }
        r2.cgI();	 Catch:{ all -> 0x02dd }
        r2 = r15.qht;	 Catch:{ Exception -> 0x02cf }
        r3 = r15.hHg;	 Catch:{ Exception -> 0x02cf }
        if (r3 != 0) goto L_0x00e9;
    L_0x0069:
        r2 = Ca(r2);	 Catch:{ Exception -> 0x02cf }
        r3 = r15.hHg;	 Catch:{ Exception -> 0x02cf }
        if (r3 != 0) goto L_0x00ca;
    L_0x0071:
        r3 = r2.isEmpty();	 Catch:{ Exception -> 0x02cf }
        if (r3 != 0) goto L_0x00ca;
    L_0x0077:
        r3 = r15.hHf;	 Catch:{ Exception -> 0x02cf }
        r4 = 0;
        r5 = "ANY";
        r6 = "UTF-8";
        r7 = com.tencent.mm.sdk.platformtools.ah.getContext();	 Catch:{ Exception -> 0x02cf }
        r7 = com.tencent.qbar.a.iy(r7);	 Catch:{ Exception -> 0x02cf }
        r3 = r3.a(r4, r5, r6, r7);	 Catch:{ Exception -> 0x02cf }
        r4 = r15.hHf;	 Catch:{ Exception -> 0x02cf }
        com.tencent.qbar.a.a(r4);	 Catch:{ Exception -> 0x02cf }
        r4 = com.tencent.mm.plugin.scanner.a.m.pZK;	 Catch:{ Exception -> 0x02cf }
        r5 = 3;
        r5 = java.lang.Integer.valueOf(r5);	 Catch:{ Exception -> 0x02cf }
        r5 = r2.contains(r5);	 Catch:{ Exception -> 0x02cf }
        r4.qaa = r5;	 Catch:{ Exception -> 0x02cf }
        r2 = r15.h(r2);	 Catch:{ Exception -> 0x02cf }
        r4 = "MicroMsg.scanner.QBarDecoder";
        r5 = "QbarNative.Init = [%s], SetReaders = [%s], version = [%s]";
        r6 = 3;
        r6 = new java.lang.Object[r6];	 Catch:{ Exception -> 0x02cf }
        r7 = 0;
        r8 = java.lang.Integer.valueOf(r3);	 Catch:{ Exception -> 0x02cf }
        r6[r7] = r8;	 Catch:{ Exception -> 0x02cf }
        r7 = 1;
        r8 = java.lang.Integer.valueOf(r2);	 Catch:{ Exception -> 0x02cf }
        r6[r7] = r8;	 Catch:{ Exception -> 0x02cf }
        r7 = 2;
        r8 = com.tencent.qbar.QbarNative.getVersion();	 Catch:{ Exception -> 0x02cf }
        r6[r7] = r8;	 Catch:{ Exception -> 0x02cf }
        com.tencent.mm.sdk.platformtools.ab.i(r4, r5, r6);	 Catch:{ Exception -> 0x02cf }
        if (r3 != 0) goto L_0x00de;
    L_0x00c5:
        if (r2 != 0) goto L_0x00de;
    L_0x00c7:
        r2 = 1;
        r15.hHg = r2;	 Catch:{ Exception -> 0x02cf }
    L_0x00ca:
        r2 = r15.hHg;	 Catch:{ Exception -> 0x02cf }
    L_0x00cc:
        if (r2 != 0) goto L_0x00ec;
    L_0x00ce:
        r15.sI();	 Catch:{ Exception -> 0x02cf }
        r2 = 0;
        r15.isDecoding = r2;	 Catch:{ Exception -> 0x02cf }
        r2 = 0;
        monitor-exit(r9);	 Catch:{ all -> 0x02dd }
        r3 = 81386; // 0x13dea float:1.14046E-40 double:4.021E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r3);
        goto L_0x0027;
    L_0x00de:
        r2 = "MicroMsg.scanner.QBarDecoder";
        r3 = "QbarNative failed, releaseDecoder 1";
        com.tencent.mm.sdk.platformtools.ab.e(r2, r3);	 Catch:{ Exception -> 0x02cf }
        r2 = 0;
        goto L_0x00cc;
    L_0x00e9:
        r2 = r15.hHg;	 Catch:{ Exception -> 0x02cf }
        goto L_0x00cc;
    L_0x00ec:
        r2 = java.lang.System.currentTimeMillis();	 Catch:{ Exception -> 0x02cf }
        r4 = "MicroMsg.scanner.QBarDecoder";
        r5 = "data len %d, image size %s";
        r6 = 2;
        r6 = new java.lang.Object[r6];	 Catch:{ Exception -> 0x02cf }
        r7 = 0;
        r0 = r16;
        r8 = r0.length;	 Catch:{ Exception -> 0x02cf }
        r8 = java.lang.Integer.valueOf(r8);	 Catch:{ Exception -> 0x02cf }
        r6[r7] = r8;	 Catch:{ Exception -> 0x02cf }
        r7 = 1;
        r6[r7] = r17;	 Catch:{ Exception -> 0x02cf }
        com.tencent.mm.sdk.platformtools.ab.i(r4, r5, r6);	 Catch:{ Exception -> 0x02cf }
        r4 = r15.hHf;	 Catch:{ Exception -> 0x02cf }
        r0 = r17;
        r5 = r0.x;	 Catch:{ Exception -> 0x02cf }
        r0 = r17;
        r6 = r0.y;	 Catch:{ Exception -> 0x02cf }
        r0 = r16;
        r4 = r4.z(r0, r5, r6);	 Catch:{ Exception -> 0x02cf }
        r6 = java.lang.System.currentTimeMillis();	 Catch:{ Exception -> 0x02cf }
        r2 = r6 - r2;
        r5 = r15.hHf;	 Catch:{ Exception -> 0x02cf }
        r6 = new com.tencent.qbar.QbarNative$QBarZoomInfo;	 Catch:{ Exception -> 0x02cf }
        r6.<init>();	 Catch:{ Exception -> 0x02cf }
        r7 = r5.Aqx;	 Catch:{ Exception -> 0x02cf }
        r5.GetZoomInfo(r6, r7);	 Catch:{ Exception -> 0x02cf }
        r5 = "MicroMsg.scanner.QBarDecoder";
        r7 = "after scanImage, result:%d, isZoom %b, zoomFactor %f";
        r8 = 3;
        r8 = new java.lang.Object[r8];	 Catch:{ Exception -> 0x02cf }
        r12 = 0;
        r13 = java.lang.Integer.valueOf(r4);	 Catch:{ Exception -> 0x02cf }
        r8[r12] = r13;	 Catch:{ Exception -> 0x02cf }
        r12 = 1;
        r13 = r6.isZoom;	 Catch:{ Exception -> 0x02cf }
        r13 = java.lang.Boolean.valueOf(r13);	 Catch:{ Exception -> 0x02cf }
        r8[r12] = r13;	 Catch:{ Exception -> 0x02cf }
        r12 = 2;
        r13 = r6.zoomFactor;	 Catch:{ Exception -> 0x02cf }
        r13 = java.lang.Float.valueOf(r13);	 Catch:{ Exception -> 0x02cf }
        r8[r12] = r13;	 Catch:{ Exception -> 0x02cf }
        com.tencent.mm.sdk.platformtools.ab.i(r5, r7, r8);	 Catch:{ Exception -> 0x02cf }
        if (r4 >= 0) goto L_0x017e;
    L_0x0152:
        r5 = r6.isZoom;	 Catch:{ Exception -> 0x02cf }
        if (r5 == 0) goto L_0x017e;
    L_0x0156:
        r5 = r15.qhj;	 Catch:{ Exception -> 0x02cf }
        if (r5 == 0) goto L_0x017e;
    L_0x015a:
        r5 = new android.os.Bundle;	 Catch:{ Exception -> 0x02cf }
        r5.<init>();	 Catch:{ Exception -> 0x02cf }
        r7 = "zoom_action";
        r8 = 6;
        r5.putInt(r7, r8);	 Catch:{ Exception -> 0x02cf }
        r7 = "zoom_type";
        r8 = 1;
        r5.putInt(r7, r8);	 Catch:{ Exception -> 0x02cf }
        r7 = "zoom_scale";
        r8 = 1120403456; // 0x42c80000 float:100.0 double:5.53552857E-315;
        r6 = r6.zoomFactor;	 Catch:{ Exception -> 0x02cf }
        r6 = r6 * r8;
        r6 = (int) r6;	 Catch:{ Exception -> 0x02cf }
        r5.putInt(r7, r6);	 Catch:{ Exception -> 0x02cf }
        r6 = r15.qhj;	 Catch:{ Exception -> 0x02cf }
        r6.K(r5);	 Catch:{ Exception -> 0x02cf }
    L_0x017e:
        r5 = com.tencent.mm.plugin.scanner.a.m.pZK;	 Catch:{ Exception -> 0x02cf }
        r0 = r17;
        r6 = r0.x;	 Catch:{ Exception -> 0x02cf }
        r0 = r17;
        r7 = r0.y;	 Catch:{ Exception -> 0x02cf }
        r5.fc(r6, r7);	 Catch:{ Exception -> 0x02cf }
        r5 = com.tencent.mm.plugin.scanner.a.m.pZK;	 Catch:{ Exception -> 0x02cf }
        r5.cgJ();	 Catch:{ Exception -> 0x02cf }
        r6 = java.lang.System.currentTimeMillis();	 Catch:{ Exception -> 0x02cf }
        r6 = r6 - r10;
        r5 = com.tencent.mm.plugin.scanner.a.m.pZK;	 Catch:{ Exception -> 0x02cf }
        r5.jH(r2);	 Catch:{ Exception -> 0x02cf }
        r5 = "MicroMsg.scanner.QBarDecoder";
        r8 = "decode ScanImage %s, cost:%d";
        r12 = 2;
        r12 = new java.lang.Object[r12];	 Catch:{ Exception -> 0x02cf }
        r13 = 0;
        r14 = java.lang.Integer.valueOf(r4);	 Catch:{ Exception -> 0x02cf }
        r12[r13] = r14;	 Catch:{ Exception -> 0x02cf }
        r13 = 1;
        r6 = java.lang.Long.valueOf(r6);	 Catch:{ Exception -> 0x02cf }
        r12[r13] = r6;	 Catch:{ Exception -> 0x02cf }
        com.tencent.mm.sdk.platformtools.ab.d(r5, r8, r12);	 Catch:{ Exception -> 0x02cf }
        if (r4 == 0) goto L_0x01d6;
    L_0x01b6:
        r2 = com.tencent.mm.plugin.scanner.a.m.pZK;	 Catch:{ Exception -> 0x02cf }
        r3 = new java.util.ArrayList;	 Catch:{ Exception -> 0x02cf }
        r3.<init>();	 Catch:{ Exception -> 0x02cf }
        r4 = new java.util.ArrayList;	 Catch:{ Exception -> 0x02cf }
        r4.<init>();	 Catch:{ Exception -> 0x02cf }
        r5 = r15.hHf;	 Catch:{ Exception -> 0x02cf }
        r5.t(r3, r4);	 Catch:{ Exception -> 0x02cf }
        r2.qab = r3;	 Catch:{ Exception -> 0x02cf }
        r2 = 0;
        r15.isDecoding = r2;	 Catch:{ Exception -> 0x02cf }
        r2 = 0;
        monitor-exit(r9);	 Catch:{ all -> 0x02dd }
        r3 = 81386; // 0x13dea float:1.14046E-40 double:4.021E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r3);
        goto L_0x0027;
    L_0x01d6:
        r4 = com.tencent.mm.plugin.scanner.a.m.pZK;	 Catch:{ Exception -> 0x02cf }
        r4.cgH();	 Catch:{ Exception -> 0x02cf }
        r4 = com.tencent.mm.plugin.scanner.a.m.pZK;	 Catch:{ Exception -> 0x02cf }
        r4.jI(r2);	 Catch:{ Exception -> 0x02cf }
        r7 = new java.util.LinkedList;	 Catch:{ Exception -> 0x02cf }
        r7.<init>();	 Catch:{ Exception -> 0x02cf }
        r8 = new java.util.LinkedList;	 Catch:{ Exception -> 0x02cf }
        r8.<init>();	 Catch:{ Exception -> 0x02cf }
        r2 = r15.hHf;	 Catch:{ Exception -> 0x02cf }
        r2.s(r7, r8);	 Catch:{ Exception -> 0x02cf }
        r2 = r7.size();	 Catch:{ Exception -> 0x02cf }
        if (r2 == 0) goto L_0x0279;
    L_0x01f5:
        r2 = 0;
        r2 = r7.get(r2);	 Catch:{ Exception -> 0x02cf }
        r0 = r2;
        r0 = (com.tencent.qbar.QbarNative.QBarResult) r0;	 Catch:{ Exception -> 0x02cf }
        r5 = r0;
        r2 = "MicroMsg.scanner.QBarDecoder";
        r3 = "decode size %d, type:%s, sCharset: %s, data:%s";
        r4 = 4;
        r4 = new java.lang.Object[r4];	 Catch:{ Exception -> 0x02cf }
        r6 = 0;
        r12 = r7.size();	 Catch:{ Exception -> 0x02cf }
        r12 = java.lang.Integer.valueOf(r12);	 Catch:{ Exception -> 0x02cf }
        r4[r6] = r12;	 Catch:{ Exception -> 0x02cf }
        r6 = 1;
        r12 = r5.typeName;	 Catch:{ Exception -> 0x02cf }
        r4[r6] = r12;	 Catch:{ Exception -> 0x02cf }
        r6 = 2;
        r12 = r5.charset;	 Catch:{ Exception -> 0x02cf }
        r4[r6] = r12;	 Catch:{ Exception -> 0x02cf }
        r6 = 3;
        r12 = r5.data;	 Catch:{ Exception -> 0x02cf }
        r4[r6] = r12;	 Catch:{ Exception -> 0x02cf }
        com.tencent.mm.sdk.platformtools.ab.i(r2, r3, r4);	 Catch:{ Exception -> 0x02cf }
        r6 = 0;
        r2 = com.tencent.mm.sdk.platformtools.bo.ek(r8);	 Catch:{ Exception -> 0x02cf }
        if (r2 != 0) goto L_0x0233;
    L_0x022b:
        r2 = 0;
        r2 = r8.get(r2);	 Catch:{ Exception -> 0x02cf }
        r2 = (com.tencent.qbar.QbarNative.QBarReportMsg) r2;	 Catch:{ Exception -> 0x02cf }
        r6 = r2;
    L_0x0233:
        if (r5 == 0) goto L_0x0279;
    L_0x0235:
        r2 = r5.data;	 Catch:{ Exception -> 0x02cf }
        r2 = com.tencent.mm.sdk.platformtools.bo.isNullOrNil(r2);	 Catch:{ Exception -> 0x02cf }
        if (r2 != 0) goto L_0x0258;
    L_0x023d:
        r2 = r5.typeName;	 Catch:{ Exception -> 0x02cf }
        r3 = "QR_CODE";
        r3 = r2.equals(r3);	 Catch:{ Exception -> 0x02cf }
        if (r3 != 0) goto L_0x0251;
    L_0x0248:
        r3 = "WX_CODE";
        r3 = r2.equals(r3);	 Catch:{ Exception -> 0x02cf }
        if (r3 == 0) goto L_0x02af;
    L_0x0251:
        r2 = r5.data;	 Catch:{ Exception -> 0x02cf }
        r15.qhl = r2;	 Catch:{ Exception -> 0x02cf }
        r2 = 1;
        qhm = r2;	 Catch:{ Exception -> 0x02cf }
    L_0x0258:
        r2 = r5.typeName;	 Catch:{ Exception -> 0x02cf }
        r2 = com.tencent.mm.plugin.scanner.util.r.Ws(r2);	 Catch:{ Exception -> 0x02cf }
        r15.cvn = r2;	 Catch:{ Exception -> 0x02cf }
        if (r6 == 0) goto L_0x02e6;
    L_0x0262:
        r2 = r6.qrcodeVersion;	 Catch:{ Exception -> 0x02cf }
    L_0x0264:
        r15.cvo = r2;	 Catch:{ Exception -> 0x02cf }
        r2 = r5.rawData;	 Catch:{ Exception -> 0x02cf }
        r15.rawData = r2;	 Catch:{ Exception -> 0x02cf }
        r2 = com.tencent.mm.plugin.scanner.a.m.pZK;	 Catch:{ Exception -> 0x02cf }
        r3 = r5.typeName;	 Catch:{ Exception -> 0x02cf }
        r4 = r15.qhl;	 Catch:{ Exception -> 0x02cf }
        r5 = r5.charset;	 Catch:{ Exception -> 0x02cf }
        r7 = r7.size();	 Catch:{ Exception -> 0x02cf }
        r2.a(r3, r4, r5, r6, r7, r8);	 Catch:{ Exception -> 0x02cf }
    L_0x0279:
        r2 = 0;
        r15.isDecoding = r2;	 Catch:{ all -> 0x02dd }
        r2 = java.lang.System.currentTimeMillis();	 Catch:{ all -> 0x02dd }
        r2 = r2 - r10;
        r15.qhn = r2;	 Catch:{ all -> 0x02dd }
        r2 = "MicroMsg.scanner.QBarDecoder";
        r3 = "decode() finish, resultText = [%s], cost:%d";
        r4 = 2;
        r4 = new java.lang.Object[r4];	 Catch:{ all -> 0x02dd }
        r5 = 0;
        r6 = r15.qhl;	 Catch:{ all -> 0x02dd }
        r4[r5] = r6;	 Catch:{ all -> 0x02dd }
        r5 = 1;
        r6 = r15.qhn;	 Catch:{ all -> 0x02dd }
        r6 = java.lang.Long.valueOf(r6);	 Catch:{ all -> 0x02dd }
        r4[r5] = r6;	 Catch:{ all -> 0x02dd }
        com.tencent.mm.sdk.platformtools.ab.i(r2, r3, r4);	 Catch:{ all -> 0x02dd }
        r2 = r15.qhl;	 Catch:{ all -> 0x02dd }
        r2 = com.tencent.mm.sdk.platformtools.bo.isNullOrNil(r2);	 Catch:{ all -> 0x02dd }
        if (r2 != 0) goto L_0x02e9;
    L_0x02a5:
        r2 = 1;
    L_0x02a6:
        monitor-exit(r9);	 Catch:{ all -> 0x02dd }
        r3 = 81386; // 0x13dea float:1.14046E-40 double:4.021E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r3);
        goto L_0x0027;
    L_0x02af:
        r3 = new java.lang.StringBuilder;	 Catch:{ Exception -> 0x02cf }
        r3.<init>();	 Catch:{ Exception -> 0x02cf }
        r2 = r3.append(r2);	 Catch:{ Exception -> 0x02cf }
        r3 = ",";
        r2 = r2.append(r3);	 Catch:{ Exception -> 0x02cf }
        r3 = r5.data;	 Catch:{ Exception -> 0x02cf }
        r2 = r2.append(r3);	 Catch:{ Exception -> 0x02cf }
        r2 = r2.toString();	 Catch:{ Exception -> 0x02cf }
        r15.qhl = r2;	 Catch:{ Exception -> 0x02cf }
        r2 = 2;
        qhm = r2;	 Catch:{ Exception -> 0x02cf }
        goto L_0x0258;
    L_0x02cf:
        r2 = move-exception;
        r3 = "MicroMsg.scanner.QBarDecoder";
        r4 = "decodeInternal error";
        r5 = 0;
        r5 = new java.lang.Object[r5];	 Catch:{ all -> 0x02dd }
        com.tencent.mm.sdk.platformtools.ab.printErrStackTrace(r3, r2, r4, r5);	 Catch:{ all -> 0x02dd }
        goto L_0x0279;
    L_0x02dd:
        r2 = move-exception;
        monitor-exit(r9);	 Catch:{ all -> 0x02dd }
        r3 = 81386; // 0x13dea float:1.14046E-40 double:4.021E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r3);
        throw r2;
    L_0x02e6:
        r2 = 0;
        goto L_0x0264;
    L_0x02e9:
        r2 = 0;
        goto L_0x02a6;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.plugin.scanner.util.d.b(byte[], android.graphics.Point):boolean");
    }

    private static Set<Integer> Ca(int i) {
        AppMethodBeat.i(81387);
        HashSet hashSet = new HashSet();
        if (i == 1) {
            hashSet.add(Integer.valueOf(2));
            hashSet.add(Integer.valueOf(4));
            hashSet.add(Integer.valueOf(5));
            hashSet.add(Integer.valueOf(3));
        } else if (i == 2) {
            hashSet.add(Integer.valueOf(1));
            hashSet.add(Integer.valueOf(4));
            hashSet.add(Integer.valueOf(5));
        } else if (i == 0) {
            hashSet.add(Integer.valueOf(2));
            hashSet.add(Integer.valueOf(1));
            hashSet.add(Integer.valueOf(4));
            hashSet.add(Integer.valueOf(5));
            hashSet.add(Integer.valueOf(3));
        } else if (i == 3) {
            hashSet.add(Integer.valueOf(2));
            hashSet.add(Integer.valueOf(3));
        }
        AppMethodBeat.o(81387);
        return hashSet;
    }

    public final void chT() {
        AppMethodBeat.i(81388);
        if (this.hHg) {
            Set set = this.qfh;
            if (set == null || set.isEmpty()) {
                set = Ca(this.qht);
            }
            h(set);
        }
        AppMethodBeat.o(81388);
    }

    private int h(Set<Integer> set) {
        int i = 0;
        AppMethodBeat.i(81389);
        if (set == null || set.isEmpty()) {
            AppMethodBeat.o(81389);
        } else {
            int[] iArr = new int[set.size()];
            int i2 = 0;
            for (Integer num : set) {
                if (num != null) {
                    int i3 = i2 + 1;
                    iArr[i2] = num.intValue();
                    i2 = i3;
                }
            }
            ab.i("MicroMsg.scanner.QBarDecoder", "QBarNative.SetReaders, readers:%s", new Object[]{Arrays.toString(iArr)});
            synchronized (this.cli) {
                try {
                    if (this.hHf != null) {
                        i = this.hHf.i(iArr, iArr.length);
                    } else {
                        AppMethodBeat.o(81389);
                    }
                } finally {
                    while (true) {
                    }
                    AppMethodBeat.o(81389);
                }
            }
        }
        return i;
    }

    public final void sI() {
        AppMethodBeat.i(81390);
        ab.d("MicroMsg.scanner.QBarDecoder", "releaseDecoder() start, hasInitQBar = %s", new Object[]{Boolean.valueOf(this.hHg)});
        this.qdM = true;
        synchronized (this.cli) {
            try {
                if (this.hHg) {
                    int release = this.hHf.release();
                    this.hHf = null;
                    this.hHg = false;
                    ab.d("MicroMsg.scanner.QBarDecoder", "QbarNative.Release() = [%s]", new Object[]{Integer.valueOf(release)});
                }
            } finally {
                while (true) {
                }
                AppMethodBeat.o(81390);
            }
        }
        c.chQ();
    }

    public final void chP() {
        AppMethodBeat.i(81391);
        if (this.hHg) {
            sI();
            this.hHg = false;
        }
        this.qdM = false;
        this.isDecoding = false;
        this.hHf = new QbarNative();
        AppMethodBeat.o(81391);
    }
}
