package com.tencent.mm.plugin.appbrand.jsapi.auth;

import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable.Creator;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.ah.d;
import com.tencent.mm.kernel.g;
import com.tencent.mm.plugin.appbrand.ipc.MainProcessTask;
import com.tencent.mm.plugin.appbrand.jsapi.auth.e.a;
import com.tencent.mm.plugin.appbrand.jsapi.h;
import com.tencent.mm.plugin.appbrand.k.c;
import com.tencent.mm.protocal.protobuf.buj;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.al;
import com.tencent.ytcommon.BuildConfig;
import java.io.IOException;
import java.util.HashMap;
import java.util.LinkedList;

class JsApiOperateWXData$OperateWXDataTask extends MainProcessTask {
    public static final Creator<JsApiOperateWXData$OperateWXDataTask> CREATOR = new 3();
    public String appId;
    f hBQ;
    h hBR;
    d hBS;
    public String hBU;
    public String hBV;
    public int hBW;
    public String hBX;
    public String hBY;
    public String hBZ;
    public String hCa;
    public String hCb = BuildConfig.FLAVOR;
    public String hCc = BuildConfig.FLAVOR;
    public int hCd;
    public Bundle hCe;
    int hCf;
    public String hCo;
    public String hCp;
    public String hCq;
    public int har;
    public int hwi;
    int hyE;
    public String mAppName;

    static /* synthetic */ boolean a(JsApiOperateWXData$OperateWXDataTask jsApiOperateWXData$OperateWXDataTask) {
        AppMethodBeat.i(130889);
        boolean aCb = jsApiOperateWXData$OperateWXDataTask.aCb();
        AppMethodBeat.o(130889);
        return aCb;
    }

    static /* synthetic */ boolean b(JsApiOperateWXData$OperateWXDataTask jsApiOperateWXData$OperateWXDataTask) {
        AppMethodBeat.i(130890);
        boolean aCb = jsApiOperateWXData$OperateWXDataTask.aCb();
        AppMethodBeat.o(130890);
        return aCb;
    }

    static /* synthetic */ boolean c(JsApiOperateWXData$OperateWXDataTask jsApiOperateWXData$OperateWXDataTask) {
        AppMethodBeat.i(130891);
        boolean aCb = jsApiOperateWXData$OperateWXDataTask.aCb();
        AppMethodBeat.o(130891);
        return aCb;
    }

    static /* synthetic */ boolean d(JsApiOperateWXData$OperateWXDataTask jsApiOperateWXData$OperateWXDataTask) {
        AppMethodBeat.i(130892);
        boolean aCb = jsApiOperateWXData$OperateWXDataTask.aCb();
        AppMethodBeat.o(130892);
        return aCb;
    }

    static /* synthetic */ boolean e(JsApiOperateWXData$OperateWXDataTask jsApiOperateWXData$OperateWXDataTask) {
        AppMethodBeat.i(130893);
        boolean aCb = jsApiOperateWXData$OperateWXDataTask.aCb();
        AppMethodBeat.o(130893);
        return aCb;
    }

    public JsApiOperateWXData$OperateWXDataTask(Parcel parcel) {
        AppMethodBeat.i(130883);
        g(parcel);
        AppMethodBeat.o(130883);
    }

    public final void asP() {
        AppMethodBeat.i(130884);
        1 1 = new 1(this);
        if (this.hBU.equals("operateWXData")) {
            a(this.appId, this.hCo, BuildConfig.FLAVOR, this.har, this.hBW, 1);
            AppMethodBeat.o(130884);
            return;
        }
        if (this.hBU.equals("operateWXDataConfirm")) {
            a(this.appId, this.hCo, this.hCq, this.har, this.hBW, 1);
        }
        AppMethodBeat.o(130884);
    }

    public final void asQ() {
        AppMethodBeat.i(130885);
        aBW();
        if (!this.hBR.isRunning()) {
            this.hBS.aCB();
            AppMethodBeat.o(130885);
        } else if (this.hBV.equals("ok")) {
            HashMap hashMap = new HashMap();
            hashMap.put("data", this.hCp);
            this.hBR.M(this.hwi, this.hBQ.j("ok", hashMap));
            this.hBS.aCB();
            AppMethodBeat.o(130885);
        } else if (this.hBV.contains("fail")) {
            this.hBQ.b(this.hBR, this.hwi, this.hBV);
            this.hBS.aCB();
            AppMethodBeat.o(130885);
        } else {
            if (this.hBV.equals("needConfirm")) {
                final LinkedList linkedList = new LinkedList();
                int i = 0;
                while (i < this.hCd) {
                    byte[] byteArray = this.hCe.getByteArray(String.valueOf(i));
                    buj buj = new buj();
                    try {
                        buj.parseFrom(byteArray);
                        linkedList.add(buj);
                        i++;
                    } catch (IOException e) {
                        ab.e("MicroMsg.JsApiOperateWXData", "IOException %s", new Object[]{e.getMessage()});
                        ab.printErrStackTrace("MicroMsg.JsApiOperateWXData", e, BuildConfig.FLAVOR, new Object[0]);
                        this.hBQ.b(this.hBR, this.hwi, "fail");
                        this.hBS.aCB();
                        AppMethodBeat.o(130885);
                        return;
                    }
                }
                if (linkedList.size() > 0) {
                    al.d(new Runnable() {
                        public final void run() {
                            AppMethodBeat.i(130880);
                            buj buj = (buj) linkedList.getFirst();
                            com.tencent.mm.plugin.appbrand.widget.b.h hVar = new com.tencent.mm.plugin.appbrand.widget.b.h(f.a(JsApiOperateWXData$OperateWXDataTask.this.hBR), new 1(this));
                            hVar.Ez(JsApiOperateWXData$OperateWXDataTask.this.mAppName);
                            hVar.EA(buj.Desc);
                            hVar.EC(JsApiOperateWXData$OperateWXDataTask.this.hBY);
                            hVar.ED(JsApiOperateWXData$OperateWXDataTask.this.hBZ);
                            hVar.EE(JsApiOperateWXData$OperateWXDataTask.this.hCa);
                            hVar.jl(JsApiOperateWXData$OperateWXDataTask.this.hBX);
                            if ("scope.userInfo".equals(buj.vOF)) {
                                a aVar = e.hBN;
                                a.a(JsApiOperateWXData$OperateWXDataTask.this.hBR.getContext(), d.qi(JsApiOperateWXData$OperateWXDataTask.this.hCb), JsApiOperateWXData$OperateWXDataTask.this.hCc, buj.vOF, hVar);
                            } else {
                                hVar.EF(buj.vOF);
                            }
                            JsApiOperateWXData$OperateWXDataTask.this.hBR.asF().b(hVar);
                            AppMethodBeat.o(130880);
                        }
                    });
                    AppMethodBeat.o(130885);
                    return;
                }
                this.hBQ.b(this.hBR, this.hwi, "fail");
                this.hBS.aCB();
            }
            AppMethodBeat.o(130885);
        }
    }

    public final void g(Parcel parcel) {
        AppMethodBeat.i(130886);
        this.appId = parcel.readString();
        this.hBV = parcel.readString();
        this.mAppName = parcel.readString();
        this.hBX = parcel.readString();
        this.hCo = parcel.readString();
        this.hCp = parcel.readString();
        this.hwi = parcel.readInt();
        this.hBU = parcel.readString();
        this.hCq = parcel.readString();
        this.hCd = parcel.readInt();
        this.hCe = parcel.readBundle(JsApiOperateWXData.class.getClassLoader());
        this.har = parcel.readInt();
        this.hBW = parcel.readInt();
        this.hyE = parcel.readInt();
        this.hCf = parcel.readInt();
        this.hCc = parcel.readString();
        this.hCb = parcel.readString();
        this.hCa = parcel.readString();
        this.hBZ = parcel.readString();
        this.hBY = parcel.readString();
        AppMethodBeat.o(130886);
    }

    public void writeToParcel(Parcel parcel, int i) {
        AppMethodBeat.i(130887);
        parcel.writeString(this.appId);
        parcel.writeString(this.hBV);
        parcel.writeString(this.mAppName);
        parcel.writeString(this.hBX);
        parcel.writeString(this.hCo);
        parcel.writeString(this.hCp);
        parcel.writeInt(this.hwi);
        parcel.writeString(this.hBU);
        parcel.writeString(this.hCq);
        parcel.writeInt(this.hCd);
        parcel.writeBundle(this.hCe);
        parcel.writeInt(this.har);
        parcel.writeInt(this.hBW);
        parcel.writeInt(this.hyE);
        parcel.writeInt(this.hCf);
        parcel.writeString(this.hCc);
        parcel.writeString(this.hCb);
        parcel.writeString(this.hCa);
        parcel.writeString(this.hBZ);
        parcel.writeString(this.hBY);
        AppMethodBeat.o(130887);
    }

    static {
        AppMethodBeat.i(130894);
        AppMethodBeat.o(130894);
    }

    private void a(String str, String str2, String str3, int i, int i2, a aVar) {
        AppMethodBeat.i(130888);
        c cVar = new c(str, str2, str3, i, i2, this.hyE, new 4(this, aVar, i2, str2));
        cVar.pm(this.hCf);
        g.Rg().a(cVar, 0);
        AppMethodBeat.o(130888);
    }
}
