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

import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable.Creator;
import com.google.firebase.analytics.FirebaseAnalytics$a;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.kernel.g;
import com.tencent.mm.plugin.appbrand.ipc.MainProcessTask;
import com.tencent.mm.plugin.appbrand.jsapi.h;
import com.tencent.mm.protocal.protobuf.buj;
import com.tencent.mm.protocal.protobuf.cxh;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.al;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.z.a.c;
import com.tencent.mm.z.a.d;
import com.tencent.tmassistantsdk.openSDK.TMQQDownloaderOpenSDKConst;
import com.tencent.ytcommon.BuildConfig;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;

class JsApiLogin$LoginTask extends MainProcessTask {
    public static final Creator<JsApiLogin$LoginTask> CREATOR = new 3();
    public String aIm;
    public String appId;
    public String code;
    public String data;
    public int errCode;
    public int gwX;
    f hBQ;
    h hBR;
    d hBS;
    public ArrayList<String> hBT;
    public String hBU;
    public String hBV;
    public int hBW;
    public String hBX;
    public int hCd;
    public Bundle hCe;
    int hCf;
    public int har;
    public int hwi;
    public int hyE;
    public String hzR;
    public String mAppName;

    interface a {
        void P(int i, String str);

        void a(LinkedList<buj> linkedList, String str, String str2, String str3);

        void onSuccess(String str);
    }

    static /* synthetic */ boolean a(JsApiLogin$LoginTask jsApiLogin$LoginTask) {
        AppMethodBeat.i(130867);
        boolean aCb = jsApiLogin$LoginTask.aCb();
        AppMethodBeat.o(130867);
        return aCb;
    }

    static /* synthetic */ boolean b(JsApiLogin$LoginTask jsApiLogin$LoginTask) {
        AppMethodBeat.i(130868);
        boolean aCb = jsApiLogin$LoginTask.aCb();
        AppMethodBeat.o(130868);
        return aCb;
    }

    static /* synthetic */ boolean c(JsApiLogin$LoginTask jsApiLogin$LoginTask) {
        AppMethodBeat.i(130869);
        boolean aCb = jsApiLogin$LoginTask.aCb();
        AppMethodBeat.o(130869);
        return aCb;
    }

    static /* synthetic */ boolean d(JsApiLogin$LoginTask jsApiLogin$LoginTask) {
        AppMethodBeat.i(130870);
        boolean aCb = jsApiLogin$LoginTask.aCb();
        AppMethodBeat.o(130870);
        return aCb;
    }

    public JsApiLogin$LoginTask(Parcel parcel) {
        AppMethodBeat.i(130862);
        g(parcel);
        AppMethodBeat.o(130862);
    }

    public final void asP() {
        AppMethodBeat.i(130863);
        1 1 = new 1(this);
        if (this.hBU.equals(FirebaseAnalytics$a.LOGIN)) {
            ab.i("MicroMsg.JsApiLogin", "start login");
            LinkedList linkedList = new LinkedList();
            this.gwX = 1;
            this.hzR = BuildConfig.FLAVOR;
            c cVar = new c(this.appId, linkedList, this.gwX, BuildConfig.FLAVOR, this.hzR, this.har, this.hyE, new 4(this, 1));
            if (cVar.Qu().wzG == null) {
                cVar.Qu().wzG = new cxh();
            }
            cVar.Qu().wzG.xsJ = this.hCf;
            g.Rg().a(cVar, 0);
            AppMethodBeat.o(130863);
            return;
        }
        if (this.hBU.equals("loginConfirm")) {
            ab.i("MicroMsg.JsApiLogin", "start loginConfirm");
            String str = this.appId;
            ArrayList arrayList = this.hBT;
            int i = this.gwX;
            String str2 = this.hzR;
            int i2 = this.har;
            int i3 = this.hBW;
            d dVar = new d(str, f.k(arrayList), i, str2, i2, i3, this.hyE, new 5(this, 1, i3));
            if (dVar.Qw().wzG == null) {
                dVar.Qw().wzG = new cxh();
            }
            dVar.Qw().wzG.xsJ = this.hCf;
            g.Rg().a(dVar, 0);
        }
        AppMethodBeat.o(130863);
    }

    public final void asQ() {
        AppMethodBeat.i(130864);
        aBW();
        if (!this.hBR.isRunning()) {
            this.hBS.aCB();
            AppMethodBeat.o(130864);
        } else if (this.hBV.equals("ok")) {
            HashMap hashMap = new HashMap();
            hashMap.put(TMQQDownloaderOpenSDKConst.UINTYPE_CODE, this.code);
            this.hBR.M(this.hwi, this.hBQ.j("ok", hashMap));
            this.hBS.aCB();
            AppMethodBeat.o(130864);
        } else if (this.hBV.equals("fail")) {
            String format;
            if (bo.isNullOrNil(this.aIm)) {
                format = String.format("fail:login error %s", new Object[]{Integer.valueOf(this.errCode)});
            } else {
                format = String.format("fail:%s", new Object[]{this.aIm});
            }
            this.hBQ.b(this.hBR, this.hwi, format);
            this.hBS.aCB();
            AppMethodBeat.o(130864);
        } else {
            if (this.hBV.equals("needConfirm")) {
                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.JsApiLogin", "parse scope info error %s", new Object[]{e.getMessage()});
                        ab.printErrStackTrace("MicroMsg.JsApiLogin", e, BuildConfig.FLAVOR, new Object[0]);
                        this.hBQ.b(this.hBR, this.hwi, "fail:internal error scope error");
                        this.hBS.aCB();
                        AppMethodBeat.o(130864);
                        return;
                    }
                }
                if (linkedList.size() > 0) {
                    al.d(new 2(this, linkedList));
                    AppMethodBeat.o(130864);
                    return;
                }
                this.hBQ.b(this.hBR, this.hwi, "fail:internal error scope empty");
                this.hBS.aCB();
            }
            AppMethodBeat.o(130864);
        }
    }

    public final void g(Parcel parcel) {
        AppMethodBeat.i(130865);
        this.data = parcel.readString();
        this.hwi = parcel.readInt();
        this.hBU = parcel.readString();
        this.appId = parcel.readString();
        this.code = parcel.readString();
        this.hBV = parcel.readString();
        this.hzR = parcel.readString();
        this.gwX = parcel.readInt();
        this.mAppName = parcel.readString();
        this.hBX = parcel.readString();
        this.hCd = parcel.readInt();
        this.hCe = parcel.readBundle(JsApiLogin.class.getClassLoader());
        this.hBT = parcel.createStringArrayList();
        this.har = parcel.readInt();
        this.hBW = parcel.readInt();
        this.hyE = parcel.readInt();
        this.hCf = parcel.readInt();
        this.errCode = parcel.readInt();
        this.aIm = parcel.readString();
        AppMethodBeat.o(130865);
    }

    public void writeToParcel(Parcel parcel, int i) {
        AppMethodBeat.i(130866);
        parcel.writeString(this.data);
        parcel.writeInt(this.hwi);
        parcel.writeString(this.hBU);
        parcel.writeString(this.appId);
        parcel.writeString(this.code);
        parcel.writeString(this.hBV);
        parcel.writeString(this.hzR);
        parcel.writeInt(this.gwX);
        parcel.writeString(this.mAppName);
        parcel.writeString(this.hBX);
        parcel.writeInt(this.hCd);
        parcel.writeBundle(this.hCe);
        parcel.writeStringList(this.hBT);
        parcel.writeInt(this.har);
        parcel.writeInt(this.hBW);
        parcel.writeInt(this.hyE);
        parcel.writeInt(this.hCf);
        parcel.writeInt(this.errCode);
        parcel.writeString(this.aIm);
        AppMethodBeat.o(130866);
    }

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