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

import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.plugin.appbrand.config.AppBrandLaunchReferrer;
import com.tencent.mm.plugin.appbrand.ipc.AppBrandMainProcessService;
import com.tencent.mm.plugin.appbrand.jsapi.fakenative.OpenBusinessViewUtil;
import com.tencent.mm.plugin.appbrand.n;
import com.tencent.mm.plugin.appbrand.o;
import com.tencent.mm.plugin.appbrand.q;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.al;
import com.tencent.mm.sdk.platformtools.bo;
import org.json.JSONObject;

public final class JsApiNavigateBackApplication extends a<q> {
    private static final int CTRL_INDEX = 288;
    public static final String NAME = "navigateBackApplication";

    public final /* synthetic */ void a(c cVar, JSONObject jSONObject, int i) {
        String str;
        AppMethodBeat.i(130501);
        q qVar = (q) cVar;
        AppBrandLaunchReferrer appBrandLaunchReferrer = qVar.getRuntime().yf().hgF;
        String optString = jSONObject.optString("appId");
        String optString2 = jSONObject.optString("extraData");
        if (appBrandLaunchReferrer != null) {
            str = appBrandLaunchReferrer.businessType;
        } else {
            str = null;
        }
        if (qVar.getRuntime() instanceof o) {
            o oVar = (o) qVar.getRuntime();
            if (appBrandLaunchReferrer != null && appBrandLaunchReferrer.hgQ == 4 && OpenBusinessViewUtil.l(oVar)) {
                ab.i("MicroMsg.JsApiNavigateBackApplication", "navigate back Application, businessType:%s", new Object[]{appBrandLaunchReferrer.businessType});
                n.xb(qVar.getAppId()).gPn = true;
            }
        }
        if (!bo.isNullOrNil(optString)) {
            AppBrandMainProcessService.a(new NavigateBackAppTask(optString, bo.bc(optString2, "{}"), str, 0));
        } else if (bo.isNullOrNil(appBrandLaunchReferrer.appId) || !(appBrandLaunchReferrer.hgQ == 4 || appBrandLaunchReferrer.hgQ == 7)) {
            ab.w("MicroMsg.JsApiNavigateBackApplication", "navigateBackApplication appid %s,launchScene %d", new Object[]{appBrandLaunchReferrer.appId, Integer.valueOf(appBrandLaunchReferrer.hgQ)});
            qVar.M(i, j("fail:not from opensdk", null));
            AppMethodBeat.o(130501);
            return;
        } else {
            AppBrandMainProcessService.a(new NavigateBackAppTask(appBrandLaunchReferrer.appId, bo.bc(optString2, "{}"), str, 0));
        }
        qVar.M(i, j("ok", null));
        if (!bo.isNullOrNil(str)) {
            al.n(new 1(this, qVar), 1000);
        }
        AppMethodBeat.o(130501);
    }
}
