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

import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable.Creator;
import android.text.TextUtils;
import com.google.android.gms.common.util.CrashUtils.ErrorDialogData;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.g.a.jc;
import com.tencent.mm.opensdk.modelmsg.WXAppExtendObject;
import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
import com.tencent.mm.plugin.appbrand.ipc.AppBrandProxyTransparentUIProcessTask;
import com.tencent.mm.plugin.appbrand.ipc.AppBrandProxyTransparentUIProcessTask.a;
import com.tencent.mm.pluginsdk.model.app.g;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.ah;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.ui.MMActivity;
import java.util.List;

class JsApiLaunchApplicationDirectly$LaunchApplicationTask extends AppBrandProxyTransparentUIProcessTask {
    public static final Creator<JsApiLaunchApplicationDirectly$LaunchApplicationTask> CREATOR = new 2();
    public String appId;
    public Bundle cvs;
    public String extInfo;
    public Runnable hww;
    public String hxq;
    public int showType;
    public boolean success;

    /* synthetic */ JsApiLaunchApplicationDirectly$LaunchApplicationTask(Parcel parcel, byte b) {
        this(parcel);
    }

    public final void a(Context context, a aVar) {
        AppMethodBeat.i(130470);
        JsApiLaunchApplicationDirectly.a aVar2 = new JsApiLaunchApplicationDirectly.a(new 1(this, aVar));
        WXAppExtendObject wXAppExtendObject = new WXAppExtendObject();
        wXAppExtendObject.extInfo = this.extInfo;
        WXMediaMessage wXMediaMessage = new WXMediaMessage(wXAppExtendObject);
        wXMediaMessage.sdkVer = 620954368;
        wXMediaMessage.messageExt = this.extInfo;
        jc jcVar = new jc();
        jcVar.cEj.cEl = wXMediaMessage;
        jcVar.cEj.appId = this.appId;
        jcVar.cEj.showType = this.showType;
        jcVar.cEj.context = context;
        jcVar.cEj.cvs = this.cvs;
        jcVar.cEj.cEm = aVar2;
        com.tencent.mm.sdk.b.a.xxA.m(jcVar);
        boolean z = jcVar.cEk.cEn;
        if (!z) {
            if (bo.isNullOrNil(this.appId) || bo.isNullOrNil(this.hxq)) {
                ab.i("MicroMsg.JsApiLaunchApplicationDirectly", "launchApplication nil appId or parameter.");
            } else {
                boolean a;
                Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(this.appId + "://" + this.hxq));
                ab.i("MicroMsg.JsApiLaunchApplicationDirectly", "launchApplication by opensdk failed, try to launch by scheme(%s).", new Object[]{r0});
                intent.addFlags(ErrorDialogData.BINDER_CRASH);
                List H = bo.H(context, intent);
                if (!(H == null || H.isEmpty())) {
                    Object b;
                    if (TextUtils.isEmpty(intent.getPackage()) && H.size() == 1) {
                        b = g.b((ResolveInfo) H.get(0));
                    } else {
                        b = intent.getPackage();
                    }
                    if (!bo.nullAsNil(ah.getPackageName()).equals(b)) {
                        aVar2.ftW = false;
                        aVar2.hxt = false;
                        aVar2.hxu = false;
                        aVar2.cEn = false;
                        a = g.a(context, intent, null, aVar2, this.cvs);
                        z = a;
                    }
                }
                a = z;
                z = a;
            }
        }
        aVar2.dS(z);
        AppMethodBeat.o(130470);
    }

    public final void asQ() {
        AppMethodBeat.i(130471);
        ab.i("MicroMsg.JsApiLaunchApplicationDirectly", "runInClientProcess");
        if (this.hww != null) {
            ab.i("MicroMsg.JsApiLaunchApplicationDirectly", "runInClientProcess asyncCallback != null");
            this.hww.run();
        }
        AppMethodBeat.o(130471);
    }

    public final void g(Parcel parcel) {
        boolean z = true;
        AppMethodBeat.i(130472);
        this.showType = parcel.readInt();
        this.appId = parcel.readString();
        this.hxq = parcel.readString();
        this.extInfo = parcel.readString();
        this.cvs = parcel.readBundle();
        if (parcel.readByte() != (byte) 1) {
            z = false;
        }
        this.success = z;
        AppMethodBeat.o(130472);
    }

    public void writeToParcel(Parcel parcel, int i) {
        AppMethodBeat.i(130473);
        parcel.writeInt(this.showType);
        parcel.writeString(this.appId);
        parcel.writeString(this.hxq);
        parcel.writeString(this.extInfo);
        parcel.writeBundle(this.cvs);
        parcel.writeByte((byte) (this.success ? 1 : 0));
        AppMethodBeat.o(130473);
    }

    public JsApiLaunchApplicationDirectly$LaunchApplicationTask(MMActivity mMActivity) {
        super(mMActivity);
    }

    private JsApiLaunchApplicationDirectly$LaunchApplicationTask(Parcel parcel) {
        AppMethodBeat.i(130474);
        g(parcel);
        AppMethodBeat.o(130474);
    }

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