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

import android.text.TextUtils;
import com.tencent.luggage.g.d;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.sdk.platformtools.bo;
import org.json.JSONObject;

class d$4 extends y {
    final /* synthetic */ int eIl;
    final /* synthetic */ m gML;
    final /* synthetic */ d hvO;
    final /* synthetic */ String hvS;

    d$4(d dVar, String str, m mVar, int i) {
        this.hvO = dVar;
        this.hvS = str;
        this.gML = mVar;
        this.eIl = i;
    }

    private String aCe() {
        AppMethodBeat.i(91013);
        try {
            String j;
            JSONObject AI = d.AI(this.hvS);
            if (AI == null) {
                j = this.gML.j("fail:invalid data", null);
            } else {
                j = this.hvO.a(this.gML, AI, this.eIl);
            }
            d dVar = this.hvO;
            m mVar = this.gML;
            String str = this.hvS;
            int i = this.eIl;
            if (dVar.hvM != null) {
                dVar.hvM.a(mVar, str, i, j);
            }
            AppMethodBeat.o(91013);
            return j;
        } catch (OutOfMemoryError e) {
            d.e("MicroMsg.AppBrandComponentImpl", "invokeImpl() parseDataStr oom, api[%s], data_length[%d]", new Object[]{this.gML.getName(), Integer.valueOf(bo.nullAsNil(this.hvS).length())});
            AppMethodBeat.o(91013);
            throw e;
        }
    }

    private void AJ(String str) {
        AppMethodBeat.i(91014);
        this.hwo = str;
        this.hvO.M(this.eIl, str);
        AppMethodBeat.o(91014);
    }

    public final void proceed() {
        AppMethodBeat.i(91015);
        if (TextUtils.isEmpty(this.hwo)) {
            CharSequence aCe;
            boolean isRunning = this.hvO.isRunning();
            if (!isRunning) {
                d.e("MicroMsg.AppBrandComponentImpl", "invoke handler.proceed() log[%s] api[%s], callbackId[%d], component not running", new Object[]{this.hvO.auc(), this.gML, Integer.valueOf(this.eIl)});
            }
            if (isRunning) {
                aCe = aCe();
            } else {
                aCe = this.gML.j("fail:interrupted", null);
            }
            if (!TextUtils.isEmpty(aCe)) {
                AJ(aCe);
            }
            AppMethodBeat.o(91015);
            return;
        }
        AppMethodBeat.o(91015);
    }

    public final void AH(String str) {
        AppMethodBeat.i(91016);
        if (TextUtils.isEmpty(this.hwo)) {
            if (!TextUtils.isEmpty(str)) {
                AJ(str);
            }
            AppMethodBeat.o(91016);
            return;
        }
        AppMethodBeat.o(91016);
    }
}
