package com.tencent.mm.plugin.fts.b;

import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.plugin.fts.a.a.a;
import com.tencent.mm.storage.ad;
import java.util.HashMap;
import java.util.HashSet;

class a$b extends a {
    final /* synthetic */ a mFK;
    private HashSet<String> mFM;
    private HashMap<String, ad> mFN;
    private long mFO;
    private long mFP;
    private int mFQ;
    private int mFR;
    private int mFS;
    private int mFT;
    private int mFU;
    private int mFV;
    private int mFW;
    private int mFX;

    private a$b(a aVar) {
        this.mFK = aVar;
        AppMethodBeat.i(136666);
        this.mFN = new HashMap();
        this.mFO = -1;
        this.mFP = -1;
        this.mFQ = 0;
        this.mFR = 0;
        this.mFS = 0;
        this.mFT = 0;
        this.mFU = 0;
        AppMethodBeat.o(136666);
    }

    /* synthetic */ a$b(a aVar, byte b) {
        this(aVar);
    }

    /* JADX WARNING: Removed duplicated region for block: B:133:0x02a3 A:{SYNTHETIC} */
    /* JADX WARNING: Removed duplicated region for block: B:95:0x0319  */
    /* JADX WARNING: Removed duplicated region for block: B:95:0x0319  */
    /* JADX WARNING: Removed duplicated region for block: B:133:0x02a3 A:{SYNTHETIC} */
    /* JADX WARNING: Removed duplicated region for block: B:133:0x02a3 A:{SYNTHETIC} */
    /* JADX WARNING: Removed duplicated region for block: B:95:0x0319  */
    public final boolean execute() {
        /*
        r15 = this;
        r10 = 50;
        r14 = 2;
        r13 = 136667; // 0x215db float:1.91511E-40 double:6.75225E-319;
        r2 = 1;
        r3 = 0;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r13);
        r0 = "MicroMsg.FTS.FTS5SearchContactLogic";
        r1 = "Start building contact index.";
        com.tencent.mm.sdk.platformtools.ab.i(r0, r1);
        r0 = "start";
        r15.Ng(r0);
        r0 = r15.mFM;
        if (r0 != 0) goto L_0x00ae;
    L_0x001e:
        r0 = new java.util.HashSet;
        r0.<init>();
        r15.mFM = r0;
        r0 = r15.mFK;
        r0 = com.tencent.mm.plugin.fts.b.a.a(r0);
        r1 = com.tencent.mm.plugin.fts.a.c.mCk;
        r4 = r2;
        r5 = r3;
        r6 = r2;
        r1 = r0.a(r1, r2, r3, r4, r5, r6);
    L_0x0034:
        r0 = r1.moveToNext();
        if (r0 == 0) goto L_0x007f;
    L_0x003a:
        r4 = r1.getString(r2);
        r0 = r1.getInt(r14);
        r6 = r1.getLong(r3);
        if (r0 != r2) goto L_0x006e;
    L_0x0048:
        r0 = r15.mFK;
        r0 = com.tencent.mm.plugin.fts.b.a.b(r0);
        r0 = r0.get(r4);
        r0 = (java.util.List) r0;
        if (r0 != 0) goto L_0x0066;
    L_0x0056:
        r0 = new java.util.ArrayList;
        r5 = 16;
        r0.<init>(r5);
        r5 = r15.mFK;
        r5 = com.tencent.mm.plugin.fts.b.a.b(r5);
        r5.put(r4, r0);
    L_0x0066:
        r4 = java.lang.Long.valueOf(r6);
        r0.add(r4);
        goto L_0x0034;
    L_0x006e:
        r5 = r15.mFM;
        r5.add(r4);
        if (r0 != r14) goto L_0x0034;
    L_0x0075:
        r0 = r15.mFK;
        r0 = com.tencent.mm.plugin.fts.b.a.c(r0);
        r0.add(r4);
        goto L_0x0034;
    L_0x007f:
        r1.close();
        r0 = r15.mFK;
        r0 = com.tencent.mm.plugin.fts.b.a.b(r0);
        r0 = r0.size();
        r15.mFV = r0;
        r0 = r15.mFK;
        r0 = com.tencent.mm.plugin.fts.b.a.c(r0);
        r0 = r0.size();
        r15.mFW = r0;
        r0 = r15.mFM;
        r0 = r0.size();
        r15.mFX = r0;
        r0 = r15.mFX;
        r1 = 5;
        if (r0 >= r1) goto L_0x00ae;
    L_0x00a7:
        r0 = r15.mDq;
        r4 = 1;
        r0 = r0 | r4;
        r15.mDq = r0;
    L_0x00ae:
        r0 = "getBuildContact";
        r15.Ng(r0);
        r0 = java.lang.Thread.interrupted();
        if (r0 == 0) goto L_0x00c3;
    L_0x00ba:
        r0 = new java.lang.InterruptedException;
        r0.<init>();
        com.tencent.matrix.trace.core.AppMethodBeat.o(r13);
        throw r0;
    L_0x00c3:
        r0 = r15.mFK;
        r0 = com.tencent.mm.plugin.fts.b.a.b(r0);
        r0 = r0.size();
        if (r0 <= 0) goto L_0x0104;
    L_0x00cf:
        r1 = new java.util.ArrayList;
        r1.<init>();
        r0 = r15.mFK;
        r0 = com.tencent.mm.plugin.fts.b.a.b(r0);
        r0 = r0.values();
        r4 = r0.iterator();
    L_0x00e2:
        r0 = r4.hasNext();
        if (r0 == 0) goto L_0x00f2;
    L_0x00e8:
        r0 = r4.next();
        r0 = (java.util.List) r0;
        r1.addAll(r0);
        goto L_0x00e2;
    L_0x00f2:
        r0 = r15.mFK;
        r0 = com.tencent.mm.plugin.fts.b.a.b(r0);
        r0.clear();
        r0 = r15.mFK;
        r0 = com.tencent.mm.plugin.fts.b.a.a(r0);
        r0.bV(r1);
    L_0x0104:
        r0 = "deleteDirtyContact";
        r15.Ng(r0);
        r0 = java.lang.Thread.interrupted();
        if (r0 == 0) goto L_0x0119;
    L_0x0110:
        r0 = new java.lang.InterruptedException;
        r0.<init>();
        com.tencent.matrix.trace.core.AppMethodBeat.o(r13);
        throw r0;
    L_0x0119:
        r0 = r15.mFK;
        r0 = com.tencent.mm.plugin.fts.b.a.c(r0);
        r0 = r0.size();
        if (r0 <= 0) goto L_0x0158;
    L_0x0125:
        r0 = r15.mFK;
        r0 = com.tencent.mm.plugin.fts.b.a.c(r0);
        r1 = r0.iterator();
    L_0x012f:
        r0 = r1.hasNext();
        if (r0 == 0) goto L_0x014f;
    L_0x0135:
        r0 = r1.next();
        r0 = (java.lang.String) r0;
        r4 = r15.mFK;
        r4 = com.tencent.mm.plugin.fts.b.a.d(r4);
        r4 = r4.MW(r0);
        r6 = r15.mFK;
        r6 = com.tencent.mm.plugin.fts.b.a.a(r6);
        r6.G(r0, r4);
        goto L_0x012f;
    L_0x014f:
        r0 = r15.mFK;
        r0 = com.tencent.mm.plugin.fts.b.a.c(r0);
        r0.clear();
    L_0x0158:
        r0 = "updateTimestampContact";
        r15.Ng(r0);
        r0 = java.lang.Thread.interrupted();
        if (r0 == 0) goto L_0x016d;
    L_0x0164:
        r0 = new java.lang.InterruptedException;
        r0.<init>();
        com.tencent.matrix.trace.core.AppMethodBeat.o(r13);
        throw r0;
    L_0x016d:
        r0 = "SELECT ROWID, username, alias, conRemark, nickname, verifyFlag, type, lvbuff, contactLabelIds FROM rcontact WHERE ROWID > ? AND deleteFlag=0 ORDER BY ROWID;";
        r1 = r15.mFK;
        r1 = com.tencent.mm.plugin.fts.b.a.d(r1);
        r4 = new java.lang.String[r2];
        r6 = r15.mFO;
        r5 = java.lang.Long.toString(r6);
        r4[r3] = r5;
        r4 = r1.i(r0, r4);
        r0 = r10;
    L_0x0185:
        r1 = r4.moveToNext();
        if (r1 == 0) goto L_0x026a;
    L_0x018b:
        r1 = java.lang.Thread.interrupted();
        if (r1 == 0) goto L_0x01a6;
    L_0x0191:
        r4.close();
        r0 = r15.mFK;
        r0 = com.tencent.mm.plugin.fts.b.a.a(r0);
        r0.commit();
        r0 = new java.lang.InterruptedException;
        r0.<init>();
        com.tencent.matrix.trace.core.AppMethodBeat.o(r13);
        throw r0;
    L_0x01a6:
        r6 = r4.getLong(r3);
        r15.mFO = r6;
        r1 = new com.tencent.mm.storage.ad;
        r1.<init>();
        r1.ewQ = r6;
        r5 = r4.getString(r2);
        r1.setUsername(r5);
        r5 = r4.getString(r14);
        r1.iy(r5);
        r5 = 3;
        r5 = r4.getString(r5);
        r1.iz(r5);
        r5 = 4;
        r5 = r4.getString(r5);
        r1.iB(r5);
        r5 = 5;
        r5 = r4.getInt(r5);
        r1.hw(r5);
        r5 = 6;
        r5 = r4.getInt(r5);
        r1.setType(r5);
        r5 = 7;
        r5 = r4.getBlob(r5);
        r1.H(r5);
        r5 = 8;
        r5 = r4.getString(r5);
        r1.iI(r5);
        r1.hy(r3);
        r5 = r15.mFN;
        r6 = r1.field_username;
        r5.put(r6, r1);
        r5 = r1.field_username;
        r5 = com.tencent.mm.model.t.kH(r5);
        if (r5 != 0) goto L_0x0185;
    L_0x0204:
        r5 = r15.mFK;
        r5 = r5.H(r1);
        if (r5 == 0) goto L_0x0185;
    L_0x020c:
        r5 = r15.mFM;
        r6 = r1.field_username;
        r5 = r5.remove(r6);
        if (r5 != 0) goto L_0x0185;
    L_0x0216:
        if (r0 < r10) goto L_0x022b;
    L_0x0218:
        r0 = r15.mFK;
        r0 = com.tencent.mm.plugin.fts.b.a.a(r0);
        r0.commit();
        r0 = r15.mFK;
        r0 = com.tencent.mm.plugin.fts.b.a.a(r0);
        r0.beginTransaction();
        r0 = r3;
    L_0x022b:
        r5 = r1.field_username;	 Catch:{ Exception -> 0x0256 }
        r6 = "@chatroom";
        r5 = r5.endsWith(r6);	 Catch:{ Exception -> 0x0256 }
        if (r5 != 0) goto L_0x0247;
    L_0x0236:
        r5 = r1.field_verifyFlag;	 Catch:{ Exception -> 0x0256 }
        r6 = com.tencent.mm.storage.ad.dsh();	 Catch:{ Exception -> 0x0256 }
        r5 = r5 & r6;
        if (r5 != 0) goto L_0x0247;
    L_0x023f:
        r5 = r15.mFK;	 Catch:{ Exception -> 0x0256 }
        r5.F(r1);	 Catch:{ Exception -> 0x0256 }
        r1.dsk();	 Catch:{ Exception -> 0x0256 }
    L_0x0247:
        r5 = r15.mFK;	 Catch:{ Exception -> 0x0256 }
        r1 = r5.J(r1);	 Catch:{ Exception -> 0x0256 }
        r0 = r0 + r1;
        r1 = r15.mFR;	 Catch:{ Exception -> 0x0256 }
        r1 = r1 + 1;
        r15.mFR = r1;	 Catch:{ Exception -> 0x0256 }
        goto L_0x0185;
    L_0x0256:
        r1 = move-exception;
        r5 = "MicroMsg.FTS.FTS5SearchContactLogic";
        r6 = "Build contact index failed with exception.\n";
        r7 = new java.lang.Object[r3];
        com.tencent.mm.sdk.platformtools.ab.printErrStackTrace(r5, r1, r6, r7);
        r1 = r15.mFT;
        r1 = r1 + 1;
        r15.mFT = r1;
        goto L_0x0185;
    L_0x026a:
        r4.close();
        r0 = r15.mFK;
        r0 = com.tencent.mm.plugin.fts.b.a.a(r0);
        r0.commit();
        r0 = "buildWXContact";
        r15.Ng(r0);
        r0 = java.lang.Thread.interrupted();
        if (r0 == 0) goto L_0x028b;
    L_0x0282:
        r0 = new java.lang.InterruptedException;
        r0.<init>();
        com.tencent.matrix.trace.core.AppMethodBeat.o(r13);
        throw r0;
    L_0x028b:
        r0 = "SELECT rowid, chatroomname, memberlist, roomdata FROM chatroom WHERE ROWID > ? ORDER BY ROWID;";
        r1 = r15.mFK;
        r1 = com.tencent.mm.plugin.fts.b.a.d(r1);
        r4 = new java.lang.String[r2];
        r6 = r15.mFP;
        r5 = java.lang.Long.toString(r6);
        r4[r3] = r5;
        r12 = r1.i(r0, r4);
        r0 = r10;
    L_0x02a3:
        r1 = r12.moveToNext();
        if (r1 == 0) goto L_0x0343;
    L_0x02a9:
        r1 = java.lang.Thread.interrupted();
        if (r1 == 0) goto L_0x02c4;
    L_0x02af:
        r12.close();
        r0 = r15.mFK;
        r0 = com.tencent.mm.plugin.fts.b.a.a(r0);
        r0.commit();
        r0 = new java.lang.InterruptedException;
        r0.<init>();
        com.tencent.matrix.trace.core.AppMethodBeat.o(r13);
        throw r0;
    L_0x02c4:
        r4 = r12.getLong(r3);
        r15.mFP = r4;
        r5 = r12.getString(r2);
        r1 = r15.mFM;
        r1 = r1.remove(r5);
        if (r1 != 0) goto L_0x02a3;
    L_0x02d6:
        r1 = r15.mFN;
        r6 = r1.get(r5);
        r6 = (com.tencent.mm.storage.ad) r6;
        if (r6 != 0) goto L_0x02e7;
    L_0x02e0:
        r1 = r15.mFU;
        r1 = r1 + 1;
        r15.mFU = r1;
        goto L_0x02a3;
    L_0x02e7:
        r1 = r12.getString(r14);
        r4 = 3;
        r8 = r12.getBlob(r4);
        r4 = com.tencent.mm.plugin.fts.a.c.a.mCy;	 Catch:{ Exception -> 0x032e }
        r7 = r4.split(r1);	 Catch:{ Exception -> 0x032e }
        r1 = new com.tencent.mm.plugin.fts.b.a$b$1;	 Catch:{ Exception -> 0x032e }
        r1.<init>(r15);	 Catch:{ Exception -> 0x032e }
        java.util.Arrays.sort(r7, r1);	 Catch:{ Exception -> 0x032e }
        r1 = r15.mFK;	 Catch:{ Exception -> 0x032e }
        r1 = r1.j(r5, r7);	 Catch:{ Exception -> 0x032e }
        r11 = r0 + r1;
        r4 = r15.mFK;	 Catch:{ Exception -> 0x03ba }
        r9 = r15.mFN;	 Catch:{ Exception -> 0x03ba }
        r0 = r4.a(r5, r6, r7, r8, r9);	 Catch:{ Exception -> 0x03ba }
        r4 = r11 + r0;
        r0 = r15.mFQ;	 Catch:{ Exception -> 0x03bf }
        r0 = r0 + 1;
        r15.mFQ = r0;	 Catch:{ Exception -> 0x03bf }
        r0 = r4;
    L_0x0317:
        if (r0 < r10) goto L_0x02a3;
    L_0x0319:
        r0 = r15.mFK;
        r0 = com.tencent.mm.plugin.fts.b.a.a(r0);
        r0.commit();
        r0 = r15.mFK;
        r0 = com.tencent.mm.plugin.fts.b.a.a(r0);
        r0.beginTransaction();
        r0 = r3;
        goto L_0x02a3;
    L_0x032e:
        r1 = move-exception;
        r4 = r0;
    L_0x0330:
        r0 = "MicroMsg.FTS.FTS5SearchContactLogic";
        r5 = "Build contact index failed with exception.\n";
        r6 = new java.lang.Object[r3];
        com.tencent.mm.sdk.platformtools.ab.printErrStackTrace(r0, r1, r5, r6);
        r0 = r15.mFU;
        r0 = r0 + 1;
        r15.mFU = r0;
        r0 = r4;
        goto L_0x0317;
    L_0x0343:
        r12.close();
        r0 = r15.mFK;
        r0 = com.tencent.mm.plugin.fts.b.a.a(r0);
        r0.commit();
        r0 = "buildChatroomContact";
        r15.Ng(r0);
        r0 = java.lang.Thread.interrupted();
        if (r0 == 0) goto L_0x0364;
    L_0x035b:
        r0 = new java.lang.InterruptedException;
        r0.<init>();
        com.tencent.matrix.trace.core.AppMethodBeat.o(r13);
        throw r0;
    L_0x0364:
        r0 = r15.mFM;
        r0 = r0.size();
        r15.mFS = r0;
        r0 = r15.mFM;
        r3 = r0.iterator();
    L_0x0372:
        r0 = r3.hasNext();
        if (r0 == 0) goto L_0x039b;
    L_0x0378:
        r0 = r3.next();
        r0 = (java.lang.String) r0;
        r1 = r15.mFK;
        r1 = com.tencent.mm.plugin.fts.b.a.a(r1);
        r4 = com.tencent.mm.plugin.fts.a.c.mCk;
        r1.b(r4, r0);
        r1 = com.tencent.mm.plugin.fts.PluginFTS.class;
        r1 = com.tencent.mm.kernel.g.M(r1);
        r1 = (com.tencent.mm.plugin.fts.PluginFTS) r1;
        r1 = r1.getTopHitsLogic();
        r4 = com.tencent.mm.plugin.fts.a.c.mCk;
        r1.d(r4, r0);
        goto L_0x0372;
    L_0x039b:
        r0 = r15.mFM;
        r0.clear();
        r0 = r15.mFN;
        r0.clear();
        r0 = "deleteUnusedContact";
        r15.Ng(r0);
        r0 = com.tencent.mm.plugin.fts.PluginFTS.class;
        r0 = com.tencent.mm.kernel.g.M(r0);
        r0 = (com.tencent.mm.plugin.fts.PluginFTS) r0;
        r0.setFTSIndexReady(r2);
        com.tencent.matrix.trace.core.AppMethodBeat.o(r13);
        return r2;
    L_0x03ba:
        r0 = move-exception;
        r1 = r0;
        r4 = r11;
        goto L_0x0330;
    L_0x03bf:
        r0 = move-exception;
        r1 = r0;
        goto L_0x0330;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.plugin.fts.b.a$b.execute():boolean");
    }

    public final String aAo() {
        AppMethodBeat.i(136668);
        String format = String.format("{build: %d newContact: %d, newChatroom: %d, remove: %d, dirty: %d, timestamp: %d, failContact: %d, failChatroom}", new Object[]{Integer.valueOf(this.mFX), Integer.valueOf(this.mFR), Integer.valueOf(this.mFQ), Integer.valueOf(this.mFS), Integer.valueOf(this.mFV), Integer.valueOf(this.mFW), Integer.valueOf(this.mFT), Integer.valueOf(this.mFU)});
        AppMethodBeat.o(136668);
        return format;
    }

    public final String getName() {
        return "BuildContactIndexTask";
    }

    public final int getId() {
        return 1;
    }
}
