TikTok.apk(点击下载) / JC7.java


package X;

import android.net.Uri;
import android.os.Build;
import android.text.TextUtils;
import android.webkit.ValueCallback;
import com.bytedance.covode.number.Covode;
import java.util.Arrays;
import kotlin.g.b.m;
import org.json.JSONArray;
import org.json.JSONObject;

public final class JC7 extends JCB implements JAR {
    public final C48716JAz LIZ;
    public final String LJ = "bytedance";
    public final String LJFF = "IESJSBridgeSupport";

    static {
        Covode.recordClassIndex(32166);
    }

    /* JADX INFO: super call moved to the top of the method (can break code semantics) */
    public JC7(C48716JAz jAz) {
        super(jAz);
        C21090sc.LIZ(jAz);
        this.LIZ = jAz;
    }

    private final JSONObject LIZIZ(JC3 jc3, C48704JAn jAn) {
        JSONObject jSONObject = new JSONObject();
        jSONObject.put("__msg_type", "callback");
        jSONObject.put("__callback_id", jc3 != null ? jc3.LIZ : null);
        jSONObject.put("__params", jAn.LIZ());
        return jSONObject;
    }

    private final boolean LJI(String str) {
        if (!AnonymousClass1ZS.LIZIZ(str, this.LJ, false)) {
            return false;
        }
        String str2 = this.LJ + "://private/setresult/";
        try {
            if (str.equals(this.LJ + "://dispatch_message/")) {
                LIZ("javascript:ToutiaoJSBridge._fetchQueue()", (ValueCallback<String>) new C69792oy(this));
                return true;
            }
            if (AnonymousClass1ZS.LIZIZ(str, str2, false)) {
                int i2 = Build.VERSION.SDK_INT;
                return true;
            }
            return false;
        } catch (Exception unused) {
        }
    }

    @Override // X.JCB
    public final String LIZ(JC3 jc3, C48704JAn jAn) {
        C21090sc.LIZ(jc3, jAn);
        if (!TextUtils.isEmpty(jc3.LJII)) {
            JSONObject LIZIZ = LIZIZ(jc3, jAn);
            Object[] objArr = new Object[3];
            String str = null;
            objArr[0] = jc3 != null ? jc3.LJII : null;
            objArr[1] = LIZIZ.toString();
            if (jc3 != null) {
                str = jc3.LJII;
            }
            objArr[2] = str;
            String LIZ2 = AnonymousClass0EJ.LIZ("javascript:(function(){   const iframe = document.querySelector('iframe[src=\"%s\"');   if (iframe && iframe.contentWindow) {        iframe.contentWindow.postMessage(%s, '%s');   }})()", Arrays.copyOf(objArr, 3));
            m.LIZ((Object) LIZ2, "");
            return LIZ2;
        }
        return "javascript:ToutiaoJSBridge._handleMessageFromToutiao(" + LIZIZ(jc3, jAn) + ')';
    }

    @Override // X.JBB, X.JCB
    public final void LIZ() {
        JCK jck = this.LIZLLL.LIZJ;
        if (jck != null) {
            jck.LIZ(this);
        }
    }

    @Override // X.JAR
    public final void LIZ(String str) {
        C21090sc.LIZ(str);
    }

    @Override // X.JCB
    public final void LIZ(String str, JSONObject jSONObject) {
        C21090sc.LIZ(str);
    }

    @Override // X.JCB
    public final String LIZIZ() {
        return "";
    }

    @Override // X.JAR
    public final boolean LIZIZ(String str) {
        String str2;
        if (str != null && !TextUtils.isEmpty(str) && !TextUtils.isEmpty(this.LJ)) {
            Uri parse = Uri.parse(str);
            m.LIZ((Object) parse, "");
            String scheme = parse.getScheme();
            if (scheme == null) {
                str2 = null;
            } else if (scheme != null) {
                str2 = scheme.toLowerCase();
                m.LIZ((Object) str2, "");
            } else {
                throw new C23830x2("null cannot be cast to non-null type java.lang.String");
            }
            return m.LIZ(this.LJ, str2) && LJI(str);
        }
    }

    @Override // X.JAR
    public final void LIZJ() {
    }

    @Override // X.JAR
    public final void LIZJ(String str) {
        C21090sc.LIZ(str);
        LJI(str);
    }

    @Override // X.JCB
    public final JC3 LIZLLL(String str) {
        String LIZ2;
        String str2 = "";
        C21090sc.LIZ(str);
        JSONObject jSONObject = new JSONObject(str);
        JC3 jc3 = new JC3(this.LIZ);
        try {
            String string = jSONObject.getString("__msg_type");
            m.LIZ((Object) string, str2);
            jc3.LIZLLL(string);
            String optString = jSONObject.optString("__callback_id", null);
            m.LIZ((Object) optString, str2);
            jc3.LIZ(optString);
            String optString2 = jSONObject.optString("func");
            m.LIZ((Object) optString2, str2);
            jc3.LIZIZ(optString2);
            jc3.LJ = jSONObject.opt("params");
            String optString3 = jSONObject.optString("JSSDK");
            m.LIZ((Object) optString3, str2);
            jc3.LJ(optString3);
            jc3.LJIIIIZZ = jSONObject.optLong("__timestamp", System.currentTimeMillis());
            String optString4 = jSONObject.optString("namespace", "DEFAULT");
            m.LIZ((Object) optString4, str2);
            jc3.LJFF(optString4);
            String optString5 = jSONObject.optString("__iframe_url");
            m.LIZ((Object) optString5, str2);
            jc3.LJI(optString5);
            jc3.LJII(str);
            JCK jck = this.LIZIZ;
            if (!(jck == null || (LIZ2 = jck.LIZ()) == null)) {
                str2 = LIZ2;
            }
            jc3.LIZJ(str2);
            C21090sc.LIZ("JsBridge", "parseMsQueue:" + Thread.currentThread());
            jc3.LIZ(JCM.Web);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return jc3;
    }

    public final void LJ(String str) {
        try {
            JSONArray jSONArray = new JSONArray(str);
            int length = jSONArray.length();
            for (int i2 = 0; i2 < length; i2++) {
                LIZ(jSONArray.getJSONObject(i2).toString(), (JCH) null);
            }
        } catch (Exception unused) {
        }
    }
}