package com.tencent.mm.plugin.s;

import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.a.e;
import com.tencent.mm.ai.b;
import com.tencent.mm.ai.x;
import com.tencent.mm.platformtools.aa;
import com.tencent.mm.plugin.s.a.a;
import com.tencent.mm.pluginsdk.model.app.ab;
import com.tencent.mm.pluginsdk.model.app.f;
import com.tencent.mm.pluginsdk.model.app.i;
import com.tencent.mm.protocal.protobuf.SKBuiltinBuffer_t;
import com.tencent.mm.protocal.protobuf.dl;
import com.tencent.mm.protocal.protobuf.dm;
import com.tencent.mm.sdk.platformtools.BackwardSupportUtil;
import com.tencent.mm.sdk.platformtools.ah;
import java.util.LinkedList;

class a$1 implements a {
    final /* synthetic */ a pbz;

    a$1(a aVar) {
        this.pbz = aVar;
    }

    public final f Uq(String str) {
        AppMethodBeat.i(79114);
        f aiJ = a.bYJ().aiJ(str);
        AppMethodBeat.o(79114);
        return aiJ;
    }

    public final f Ur(String str) {
        AppMethodBeat.i(79115);
        a.bYI();
        if (str == null || str.length() == 0) {
            AppMethodBeat.o(79115);
            return null;
        }
        LinkedList linkedList = new LinkedList();
        linkedList.add(str);
        ab abVar = new ab(linkedList);
        b.a aVar = new b.a();
        aVar.fsJ = new dl();
        aVar.fsK = new dm();
        aVar.uri = "/cgi-bin/micromsg-bin/appcenter";
        aVar.fsI = 452;
        aVar.fsL = 0;
        aVar.fsM = 0;
        b acD = aVar.acD();
        dl dlVar = (dl) acD.fsG.fsP;
        byte[] dhj = abVar.dhj();
        if (dhj != null) {
            dlVar.ReqBuf = new SKBuiltinBuffer_t().setBuffer(dhj);
        }
        dlVar.jCt = 7;
        com.tencent.mm.ai.a.a c = x.c(acD);
        com.tencent.mm.sdk.platformtools.ab.e("MicroMsg.AppInfoService", "call getAppInfoList cgi result, errType = %d, errCode = %d", new Object[]{Integer.valueOf(c.errType), Integer.valueOf(c.errCode)});
        if (c.errType == 0 && c.errCode == 0) {
            abVar.bG(aa.a(((dm) c.fsy).vFq));
            abVar.a(0, c.errType, c.errCode, c.aIm, acD, new byte[0]);
            a bYQ = a.a.bYQ();
            if (bYQ == null) {
                com.tencent.mm.sdk.platformtools.ab.e("MicroMsg.AppInfoService", "getISubCorePluginBase() == null");
                AppMethodBeat.o(79115);
                return null;
            }
            f Uq = bYQ.Uq(str);
            AppMethodBeat.o(79115);
            return Uq;
        }
        AppMethodBeat.o(79115);
        return null;
    }

    public final Cursor bYN() {
        AppMethodBeat.i(79116);
        Cursor rawQuery = a.bYJ().rawQuery("select * from AppInfo where status = 5 order by modifyTime asc", new String[0]);
        if (rawQuery == null) {
            com.tencent.mm.sdk.platformtools.ab.e("MicroMsg.AppInfoStorage", "getAppByStatus : cursor is null");
            AppMethodBeat.o(79116);
            return null;
        }
        AppMethodBeat.o(79116);
        return rawQuery;
    }

    public final Cursor x(int[] iArr) {
        AppMethodBeat.i(79117);
        i bYJ = a.bYJ();
        String str = "select * from AppInfo where ";
        for (int i = 0; i <= 0; i++) {
            str = str + " status = " + iArr[0];
        }
        Cursor rawQuery = bYJ.rawQuery(str + " order by status desc, modifyTime asc", new String[0]);
        if (rawQuery == null) {
            com.tencent.mm.sdk.platformtools.ab.e("MicroMsg.AppInfoStorage", "getAppByStatus : cursor is null");
            AppMethodBeat.o(79117);
            return null;
        }
        AppMethodBeat.o(79117);
        return rawQuery;
    }

    public final Bitmap a(String str, int i, float f) {
        AppMethodBeat.i(79118);
        a.bYJ();
        Bitmap decodeResource;
        if (str == null || str.length() == 0) {
            com.tencent.mm.sdk.platformtools.ab.e("MicroMsg.AppInfoStorage", "getIcon : invalid argument");
            AppMethodBeat.o(79118);
            return null;
        } else if (str.equals("wx7fa037cc7dfabad5")) {
            decodeResource = BitmapFactory.decodeResource(ah.getContext().getResources(), 2130837788);
            AppMethodBeat.o(79118);
            return decodeResource;
        } else {
            String dY = i.dY(str, i);
            if (e.ct(dY)) {
                decodeResource = BackwardSupportUtil.b.i(dY, f);
                AppMethodBeat.o(79118);
                return decodeResource;
            }
            com.tencent.mm.sdk.platformtools.ab.e("MicroMsg.AppInfoStorage", "icon does not exist, iconPath = " + dY + ", iconType = " + i);
            AppMethodBeat.o(79118);
            return null;
        }
    }

    public final void cN(String str, int i) {
        AppMethodBeat.i(79119);
        a.bYH().dW(str, i);
        AppMethodBeat.o(79119);
    }

    public final void Us(String str) {
        AppMethodBeat.i(79120);
        a.bYI().aiH(str);
        AppMethodBeat.o(79120);
    }

    public final void c(f fVar) {
        AppMethodBeat.i(79121);
        i bYJ = a.bYJ();
        if (!(fVar == null || fVar.field_status == 5)) {
            fVar.field_status = 3;
            com.tencent.mm.sdk.platformtools.ab.i("MicroMsg.AppInfoStorage", "setBlack package name = %s", new Object[]{fVar.field_packageName});
            bYJ.a(fVar, new String[0]);
        }
        AppMethodBeat.o(79121);
    }

    public final void d(f fVar) {
        AppMethodBeat.i(79122);
        i bYJ = a.bYJ();
        if (fVar == null || fVar.field_status != 3) {
            AppMethodBeat.o(79122);
            return;
        }
        fVar.field_status = 4;
        bYJ.a(fVar, new String[0]);
        AppMethodBeat.o(79122);
    }

    public final void e(f fVar) {
        AppMethodBeat.i(79123);
        a.bYJ().a(fVar, new String[0]);
        AppMethodBeat.o(79123);
    }

    public final i bYO() {
        AppMethodBeat.i(79124);
        i bYJ = a.bYJ();
        AppMethodBeat.o(79124);
        return bYJ;
    }

    public final void ah(LinkedList<String> linkedList) {
        AppMethodBeat.i(79125);
        a.bYI().aC(linkedList);
        AppMethodBeat.o(79125);
    }

    public final Cursor eQ(int i, int i2) {
        AppMethodBeat.i(79126);
        Cursor eQ = a.bYJ().eQ(i, i2);
        AppMethodBeat.o(79126);
        return eQ;
    }

    public final Cursor bYP() {
        AppMethodBeat.i(79127);
        i bYJ = a.bYJ();
        StringBuilder stringBuilder = new StringBuilder(256);
        stringBuilder.append("select * from AppInfo");
        stringBuilder.append(" where ");
        stringBuilder.append("serviceAppType > 0");
        Cursor rawQuery = bYJ.rawQuery(stringBuilder.toString(), new String[0]);
        if (rawQuery == null) {
            com.tencent.mm.sdk.platformtools.ab.e("MicroMsg.AppInfoStorage", "getAllServices : cursor is null");
            AppMethodBeat.o(79127);
            return null;
        }
        com.tencent.mm.sdk.platformtools.ab.d("MicroMsg.AppInfoStorage", "getAllServices count = %d", new Object[]{Integer.valueOf(rawQuery.getCount())});
        AppMethodBeat.o(79127);
        return rawQuery;
    }
}
