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

import android.database.Cursor;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.plugin.fts.a.a.h;
import com.tencent.mm.plugin.fts.a.a.i;
import com.tencent.mm.plugin.fts.a.a.j;
import com.tencent.mm.plugin.fts.a.a.m;
import com.tencent.mm.plugin.fts.c.d;
import java.util.ArrayList;

public class d$d extends h {
    final /* synthetic */ d mGN;

    public d$d(d dVar, i iVar) {
        this.mGN = dVar;
        super(iVar);
    }

    public final void a(j jVar) {
        Cursor rawQuery;
        AppMethodBeat.i(136771);
        super.a(jVar);
        jVar.mEy = new ArrayList();
        d dVar = this.mGN.mGL;
        String str = this.mEl.query;
        int i = this.mEl.mEt;
        if (str.trim().length() > 0) {
            str = com.tencent.mm.plugin.fts.a.d.B(new String[]{str});
            rawQuery = dVar.mBT.rawQuery(String.format("SELECT history FROM %s NOT INDEXED JOIN %s ON (%s.docid = %s.rowid) WHERE %s MATCH '%s' ORDER BY timestamp desc LIMIT ".concat(String.valueOf(i)), new Object[]{"FTS5MetaSOSHistory", "FTS5IndexSOSHistory", "FTS5MetaSOSHistory", "FTS5IndexSOSHistory", "FTS5IndexSOSHistory", str}), null);
        } else {
            rawQuery = dVar.mBT.rawQuery(String.format("SELECT history FROM %s ORDER BY timestamp desc LIMIT ".concat(String.valueOf(i)), new Object[]{"FTS5MetaSOSHistory"}), null);
        }
        while (rawQuery.moveToNext()) {
            str = rawQuery.getString(0);
            m mVar = new m();
            mVar.content = str;
            jVar.mEy.add(mVar);
        }
        rawQuery.close();
        AppMethodBeat.o(136771);
    }

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