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

import android.database.Cursor;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.kernel.g;
import com.tencent.mm.plugin.fts.a.a.a;
import com.tencent.mm.plugin.messenger.foundation.a.j;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.storage.bi;
import com.tencent.mm.vfs.e;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

class g$f extends a {
    private int count;
    private String cuP;
    final /* synthetic */ g mGX;

    public g$f(g gVar, int i, String str) {
        this.mGX = gVar;
        this.count = i;
        this.cuP = str;
    }

    public final boolean execute() {
        AppMethodBeat.i(136802);
        if (this.mGX.mGV == null) {
            String cy = e.cy("/sdcard/test_insert_msg_words.txt");
            this.mGX.mGV = cy.split(",");
        }
        if (this.mGX.mGW == null) {
            this.mGX.mGW = new ArrayList();
            if (bo.isNullOrNil(this.cuP)) {
                Cursor dss = ((j) g.K(j.class)).XM().dss();
                while (dss.moveToNext()) {
                    this.mGX.mGW.add(dss.getString(0));
                }
                dss.close();
            } else {
                this.mGX.mGW.add(this.cuP);
            }
        }
        if (this.mGX.mGV != null) {
            for (int i = 0; i < this.count; i++) {
                Object obj;
                String D = D(this.mGX.mGV);
                bi biVar = new bi();
                biVar.setType(1);
                biVar.hO(1);
                biVar.setStatus(4);
                biVar.setContent(D);
                List list = this.mGX.mGW;
                if (list.size() > 1) {
                    obj = list.get(new Random().nextInt(list.size() - 1));
                } else {
                    obj = list.get(0);
                }
                biVar.ju((String) obj);
                biVar.eJ(System.currentTimeMillis() - 250327040);
                ((j) g.K(j.class)).bOr().Z(biVar);
                ab.i("MicroMsg.FTS.FTSSearchTestLogic", "InsertMsgInfoTask %d %d %d %d", new Object[]{Integer.valueOf(this.count), Integer.valueOf(i), Integer.valueOf(D.length()), Long.valueOf(biVar.field_msgId)});
            }
        }
        AppMethodBeat.o(136802);
        return true;
    }

    private static String D(String[] strArr) {
        AppMethodBeat.i(136803);
        Random random = new Random();
        StringBuffer stringBuffer = new StringBuffer();
        for (int i = 0; i < 300; i++) {
            stringBuffer.append(strArr[random.nextInt(strArr.length - 1)]);
        }
        String stringBuffer2 = stringBuffer.toString();
        AppMethodBeat.o(136803);
        return stringBuffer2;
    }
}
