package com.bytedance.sdk.openadsdk.maa;

import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewTreeObserver;
import android.webkit.ValueCallback;
import android.webkit.WebView;
import androidx.annotation.Nullable;
import androidx.media3.exoplayer.rtsp.SessionDescription;
import androidx.media3.exoplayer.upstream.CmcdConfiguration;
import defpackage.e;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.json.JSONException;
import org.json.JSONObject;
import tv.danmaku.ijk.media.player.IjkEventListener;
import tv.danmaku.ijk.media.player.IjkMediaPlayer;

/* JADX INFO: loaded from: classes2.dex */
public class wu {
    private int ado;
    private long ai;
    private final String ajl;
    private boolean anz;
    private long aws;
    private int bkb;
    private int bp;
    private int bwv;
    private String bx;

    /* JADX INFO: renamed from: cc, reason: collision with root package name */
    private boolean f7488cc;
    private com.bytedance.sdk.openadsdk.maa.fm cg;
    private String cpu;
    private String cyr;
    private int daz;
    private Runnable dsz;
    private final Handler duv;

    /* JADX INFO: renamed from: ef, reason: collision with root package name */
    private Runnable f7489ef;
    private String eo;
    private ViewTreeObserver.OnGlobalLayoutListener ew;
    private int ex;
    private String eys;

    /* JADX INFO: renamed from: ff, reason: collision with root package name */
    private int f7490ff;
    private ro fhx;
    public final String fm;

    /* JADX INFO: renamed from: gc, reason: collision with root package name */
    private long f7491gc;
    private boolean gof;
    private Set<String> gqi;
    private Map<String, String> grs;
    private volatile boolean gt;
    private int gzf;

    /* JADX INFO: renamed from: ha, reason: collision with root package name */
    private long f7492ha;
    private String hi;
    private boolean hlt;
    private String hm;
    private boolean hou;
    private long hxv;
    private List<JSONObject> iat;

    /* JADX INFO: renamed from: ib, reason: collision with root package name */
    private boolean f7493ib;
    private boolean irt;
    private int jm;
    private String jn;
    public final String jnr;

    /* JADX INFO: renamed from: kc, reason: collision with root package name */
    private int f7494kc;
    private int kec;
    private Runnable ku;
    private int kwx;
    private int ky;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    public final String f7495lb;
    private Context lcp;

    /* JADX INFO: renamed from: le, reason: collision with root package name */
    private int f7496le;
    private int lmk;
    private float lsa;
    private boolean lse;
    private String lz;
    private boolean maa;
    private boolean mj;
    private long mon;
    private int mpp;
    private long mq;
    private boolean mu;

    /* JADX INFO: renamed from: ne, reason: collision with root package name */
    private int f7497ne;
    private boolean nn;
    private fm no;
    private long nt;
    private long ol;
    private Runnable onz;
    private int oy;
    private int pbk;
    private int pcm;

    /* JADX INFO: renamed from: pf, reason: collision with root package name */
    private JSONObject f7498pf;
    private long pkk;
    private float po;
    private String pyj;

    /* JADX INFO: renamed from: qb, reason: collision with root package name */
    private WeakReference<View> f7499qb;

    /* JADX INFO: renamed from: qf, reason: collision with root package name */
    private int f7500qf;
    private boolean qhl;
    private boolean qlg;
    private JSONObject qph;
    private int rbn;
    private JSONObject rka;
    public final String ro;
    private String sds;
    private int si;
    private volatile boolean siu;
    private long so;

    /* JADX INFO: renamed from: te, reason: collision with root package name */
    private ajl f7501te;
    private int ttj;
    private String tzk;
    private JSONObject ucr;
    private int ug;
    private boolean vj;
    private float vod;
    private Runnable vt;
    private String vvj;
    private long wbw;
    private String wey;
    private int wjb;
    private final String wsy;
    private final Handler wu;
    private lb xca;
    private long xgn;
    private boolean xp;
    private String xw;

    /* JADX INFO: renamed from: ya, reason: collision with root package name */
    private boolean f7502ya;
    private int ywr;
    public final String yz;
    private String zan;
    private String zes;
    private String zh;
    private String zjk;

    @Nullable
    private WebView zow;
    private boolean zzm;
    private String zzn;

    public enum fm {
        LAND_PAGE,
        FEED,
        OTHER,
        FEED_AWEME
    }

    private wu(Context context, WebView webView, lb lbVar, com.bytedance.sdk.openadsdk.maa.fm fmVar, fm fmVar2) {
        this.ajl = "playable_stuck_check_ping";
        this.wsy = "playable_apply_media_permission_callback";
        this.wu = new Handler(Looper.getMainLooper());
        this.duv = new Handler(Looper.getMainLooper());
        this.irt = true;
        this.qhl = true;
        this.gof = true;
        this.fm = "PL_sdk_playable_global_viewable";
        this.ro = "PL_sdk_page_screen_blank";
        this.f7495lb = "PL_sdk_playable_destroy_analyze_summary";
        this.yz = "PL_sdk_playable_hardware_dialog_cancel";
        this.jnr = "PL_sdk_playable_hardware_dialog_setting";
        this.gqi = new HashSet(Arrays.asList("adInfo", "appInfo", "subscribe_app_ad", "download_app_ad"));
        this.wey = null;
        this.sds = "embeded_ad";
        this.maa = true;
        this.lse = true;
        this.hlt = false;
        this.hi = "";
        this.nt = 10L;
        this.mq = 10L;
        this.gzf = 700;
        this.ai = 0L;
        this.ol = 0L;
        this.wbw = -1L;
        this.f7492ha = -1L;
        this.pkk = -1L;
        this.hxv = -1L;
        this.f7491gc = -1L;
        this.xgn = -1L;
        this.mon = -1L;
        this.bx = "";
        this.zan = "";
        this.tzk = "";
        this.lz = "";
        this.f7500qf = 0;
        this.si = 0;
        this.f7493ib = false;
        this.f7497ne = 0;
        this.kwx = -1;
        this.bkb = 0;
        this.lmk = 0;
        this.mpp = 0;
        this.vvj = null;
        this.mj = false;
        this.ado = 0;
        this.bwv = 0;
        this.ywr = 0;
        this.pcm = 0;
        this.so = 0L;
        this.aws = 0L;
        this.pbk = -2;
        this.jm = 0;
        this.ttj = 0;
        this.daz = 0;
        this.qph = new JSONObject();
        this.grs = new HashMap();
        this.f7498pf = new JSONObject();
        this.cyr = "";
        this.po = 0.0f;
        this.vod = 0.0f;
        this.vj = false;
        this.nn = false;
        this.anz = false;
        this.iat = new ArrayList();
        this.f7502ya = true;
        this.gt = true;
        this.siu = true;
        this.ew = new ViewTreeObserver.OnGlobalLayoutListener() { // from class: com.bytedance.sdk.openadsdk.maa.wu.1
            @Override // android.view.ViewTreeObserver.OnGlobalLayoutListener
            public void onGlobalLayout() {
                try {
                    View view = (View) wu.this.f7499qb.get();
                    if (view == null) {
                        return;
                    }
                    wu.this.ro(view);
                } catch (Throwable th) {
                    wsy.fm("PlayablePlugin", "onSizeChanged error", th);
                }
            }
        };
        this.kec = -1;
        this.pbk = 0;
        this.no = fmVar2;
        this.zow = webView;
        ef.fm(webView);
        fm(webView);
        fm(context, lbVar, fmVar);
    }

    public static /* synthetic */ int dsz(wu wuVar) {
        int i10 = wuVar.si;
        wuVar.si = i10 + 1;
        return i10;
    }

    public static /* synthetic */ int duv(wu wuVar) {
        int i10 = wuVar.f7500qf;
        wuVar.f7500qf = i10 + 1;
        return i10;
    }

    private void lz() {
        Runnable runnable;
        Runnable runnable2;
        this.fhx.fm(System.currentTimeMillis());
        Handler handler = this.duv;
        if (handler != null) {
            int i10 = this.pbk;
            if (i10 == 0 && (runnable2 = this.dsz) != null) {
                handler.post(runnable2);
            } else if ((i10 == 1 || i10 == 2) && (runnable = this.onz) != null) {
                handler.post(runnable);
            }
            this.fhx.fm(IjkEventListener.BUFFERING_START);
        }
    }

    private void tzk() {
        String str;
        if (this.f7498pf == null || (str = this.zh) == null || str.contains("/cid_")) {
            return;
        }
        String strOptString = this.f7498pf.optString(CmcdConfiguration.KEY_CONTENT_ID);
        if (TextUtils.isEmpty(strOptString)) {
            return;
        }
        String host = Uri.parse(this.zh).getHost();
        if (TextUtils.isEmpty(host)) {
            this.zh = e.p(new StringBuilder(), this.zh, "/cid_", strOptString);
        } else {
            this.zh = this.zh.replace(host, e.j(host, "/cid_", strOptString));
        }
    }

    private void zan() {
        this.fhx = new ro(this, this.gzf);
        this.f7489ef = new Runnable() { // from class: com.bytedance.sdk.openadsdk.maa.wu.5
            @Override // java.lang.Runnable
            public void run() {
                if (wu.this.maa) {
                    wu.this.maa = false;
                    wu.this.wu.removeCallbacks(wu.this.vt);
                    wu.this.fm(2, "ContainerLoadTimeOut");
                }
            }
        };
        this.vt = new Runnable() { // from class: com.bytedance.sdk.openadsdk.maa.wu.6
            @Override // java.lang.Runnable
            public void run() {
                if (wu.this.maa) {
                    wu.this.maa = false;
                    wu.this.gt = false;
                    wu.this.wu.removeCallbacks(wu.this.f7489ef);
                    wu.this.fm(3, "JSSDKLoadTimeOut");
                }
            }
        };
        this.dsz = new Runnable() { // from class: com.bytedance.sdk.openadsdk.maa.wu.7
            @Override // java.lang.Runnable
            public void run() {
                System.currentTimeMillis();
                if (wu.this.zow != null) {
                    wu.this.zow.evaluateJavascript("javascript:typeof playable_callJS === 'function' && playable_callJS()", new ValueCallback<String>() { // from class: com.bytedance.sdk.openadsdk.maa.wu.7.1
                        @Override // android.webkit.ValueCallback
                        /* JADX INFO: renamed from: fm, reason: merged with bridge method [inline-methods] */
                        public void onReceiveValue(String str) {
                            if (wu.this.fhx != null) {
                                wu.this.fhx.fm(System.currentTimeMillis());
                            }
                        }
                    });
                }
                if (wu.this.duv != null) {
                    wu.this.duv.postDelayed(this, 500L);
                }
            }
        };
        this.onz = new Runnable() { // from class: com.bytedance.sdk.openadsdk.maa.wu.8
            @Override // java.lang.Runnable
            public void run() {
                System.currentTimeMillis();
                wu.this.fm("playable_stuck_check_ping", new JSONObject());
                if (wu.this.duv != null) {
                    wu.this.duv.postDelayed(this, 500L);
                }
            }
        };
        this.ku = new Runnable() { // from class: com.bytedance.sdk.openadsdk.maa.wu.9
            @Override // java.lang.Runnable
            public void run() {
                if (wu.this.aws <= 0) {
                    wu.this.ro(1, "Clicking on the hot zone causes the program to freeze.");
                } else {
                    if (wu.this.aws - wu.this.so > wu.this.gzf) {
                        wu.this.ro(1, "Clicking on the hot zone causes the program to freeze.");
                        return;
                    }
                    wu.this.ha();
                    wu.this.so = 0L;
                    wu.this.aws = 0L;
                }
            }
        };
    }

    public void ai() {
        ro roVar;
        this.aws = System.currentTimeMillis();
        int i10 = this.pbk;
        if ((i10 == 1 || i10 == 2) && (roVar = this.fhx) != null) {
            roVar.fm(System.currentTimeMillis());
        }
    }

    public wu ajl(String str) {
        this.sds = str;
        return this;
    }

    public int bx() {
        return this.kec;
    }

    public boolean ef() {
        return this.hou;
    }

    public JSONObject fhx() {
        try {
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("scene_type", this.no.ordinal());
            jSONObject.put("safe_area_top_height", this.po);
            jSONObject.put("safe_area_bottom_height", this.vod);
            jSONObject.put("playable_enter_from", this.lmk);
            jSONObject.put("playable_retry_count", this.bkb);
            jSONObject.put("playable_card_session", this.bx);
            jSONObject.put("playable_video_session", this.zan);
            jSONObject.put("playable_network_type", irt());
            jSONObject.put("aweme_id", this.lz);
            return jSONObject;
        } catch (Throwable th) {
            wsy.fm("PlayablePlugin", "playableInfo error", th);
            return new JSONObject();
        }
    }

    public Context fm() {
        return this.lcp;
    }

    public void gc() {
        if (this.anz) {
            return;
        }
        this.anz = true;
        this.ol = 0L;
        this.qhl = true;
        hxv();
        try {
            View view = this.f7499qb.get();
            if (view != null) {
                view.getViewTreeObserver().removeOnGlobalLayoutListener(this.ew);
            }
        } catch (Throwable unused) {
        }
        try {
            this.f7501te.ro();
        } catch (Throwable unused2) {
        }
        try {
            ro roVar = this.fhx;
            if (roVar != null) {
                roVar.fm();
                this.fhx = null;
            }
            Handler handler = this.duv;
            if (handler != null) {
                handler.removeCallbacksAndMessages(null);
            }
        } catch (Throwable th) {
            th.toString();
        }
        try {
            if (!TextUtils.isEmpty(this.zh)) {
                JSONObject jSONObject = new JSONObject();
                jSONObject.put("playable_all_times", this.f7500qf);
                jSONObject.put("playable_hit_times", this.si);
                int i10 = this.f7500qf;
                if (i10 > 0) {
                    jSONObject.put("playable_hit_ratio", ((double) this.si) / (((double) i10) * 1.0d));
                } else {
                    jSONObject.put("playable_hit_ratio", 0);
                }
                lb("PL_sdk_preload_times", jSONObject);
            }
        } catch (Throwable unused3) {
        }
        try {
            if (!TextUtils.isEmpty(this.zh)) {
                if (this.wbw != -1) {
                    this.ai += System.currentTimeMillis() - this.wbw;
                    this.wbw = -1L;
                }
                JSONObject jSONObject2 = new JSONObject();
                jSONObject2.put("playable_user_play_duration", this.ai);
                lb("PL_sdk_user_play_duration", jSONObject2);
            }
        } catch (Throwable unused4) {
        }
        this.gt = false;
        this.siu = false;
        this.wu.removeCallbacks(this.f7489ef);
        this.wu.removeCallbacks(this.vt);
        this.wu.removeCallbacksAndMessages(null);
    }

    public JSONObject gof() {
        if (this.qph.isNull("width")) {
            View view = this.f7499qb.get();
            if (view == null) {
                return this.qph;
            }
            ro(view);
        }
        return this.qph;
    }

    public JSONObject gqi() {
        return this.f7498pf;
    }

    public void gzf() {
        try {
            JSONObject jSONObject = new JSONObject();
            if (this.f7491gc > 0) {
                jSONObject.put("playable_material_first_frame_show_duration", System.currentTimeMillis() - this.f7491gc);
            } else {
                jSONObject.put("playable_material_first_frame_show_duration", 0L);
            }
            if (this.pkk > 0) {
                jSONObject.put("playable_material_first_frame_load_duration", System.currentTimeMillis() - this.pkk);
            } else {
                jSONObject.put("playable_material_first_frame_load_duration", 0L);
            }
            lb("PL_sdk_material_first_frame_show", jSONObject);
        } catch (JSONException unused) {
        }
    }

    public void ha() {
        if (this.lse) {
            this.xgn = System.currentTimeMillis();
            if (this.no == fm.FEED_AWEME) {
                if (this.hou && this.jm == 3) {
                    ro roVar = this.fhx;
                    if (roVar != null && roVar.ro()) {
                        lz();
                        return;
                    } else {
                        if (this.fhx == null) {
                            this.fhx = new ro(this, this.gzf);
                            lz();
                            return;
                        }
                        return;
                    }
                }
                return;
            }
            if (this.hou && this.jm == 2) {
                ro roVar2 = this.fhx;
                if (roVar2 != null && roVar2.ro()) {
                    lz();
                } else if (this.fhx == null) {
                    this.fhx = new ro(this, this.gzf);
                    lz();
                }
            }
        }
    }

    public void hi() {
        this.mj = true;
    }

    public void hlt() {
        this.kwx = 2;
    }

    public void hxv() {
        this.ttj = 0;
        this.daz = 0;
        this.lsa = 0.0f;
        this.ex = 0;
        this.wjb = 0;
        this.ky = 0;
        this.oy = 0;
        this.f7494kc = 0;
        this.ug = 0;
        this.bp = 0;
        this.f7490ff = 0;
        this.f7496le = 0;
        this.rbn = 0;
    }

    public String irt() {
        com.bytedance.sdk.openadsdk.maa.fm fmVar;
        if (TextUtils.isEmpty(this.tzk) && (fmVar = this.cg) != null) {
            this.tzk = fmVar.fm().toString();
        }
        return this.tzk;
    }

    public wu jnr(String str) {
        this.pyj = str;
        return this;
    }

    public wu lb(JSONObject jSONObject) {
        this.f7498pf = jSONObject;
        return this;
    }

    public void lse() {
        try {
            JSONObject jSONObject = new JSONObject();
            if (this.f7491gc > 0) {
                jSONObject.put("playable_material_interactable_duration", System.currentTimeMillis() - this.f7491gc);
            } else {
                jSONObject.put("playable_material_interactable_duration", 0L);
            }
            if (this.pkk > 0) {
                long jCurrentTimeMillis = System.currentTimeMillis() - this.pkk;
                this.mon = jCurrentTimeMillis;
                jSONObject.put("playable_material_interactable_load_duration", jCurrentTimeMillis);
            } else {
                jSONObject.put("playable_material_interactable_load_duration", 0L);
            }
            lb("PL_sdk_material_interactable", jSONObject);
        } catch (JSONException unused) {
        }
    }

    public void maa() {
        com.bytedance.sdk.openadsdk.maa.fm fmVar = this.cg;
        if (fmVar != null) {
            fmVar.lb();
        }
    }

    public String mon() {
        return "function playable_callJS(){return \"Android call the JS method is callJS\";}";
    }

    public void mq() {
        if (this.cg != null) {
            fm fmVar = fm.LAND_PAGE;
        }
    }

    public void nt() {
        if (this.cg != null) {
            fm fmVar = fm.LAND_PAGE;
        }
    }

    public void ol() {
        int i10;
        int i11 = this.pbk;
        if (i11 == 0 || i11 == 1 || i11 == 2) {
            if (this.gt) {
                this.wu.postDelayed(this.f7489ef, this.nt * 1000);
            }
            if ((this.siu && duv(this.zh)) || (i10 = this.pbk) == 1 || i10 == 2) {
                this.wu.postDelayed(this.vt, this.mq * 1000);
            }
        }
    }

    public JSONObject onz() {
        boolean zFm;
        boolean zFm2;
        try {
            boolean z10 = true;
            if (Build.VERSION.SDK_INT >= 33) {
                zFm = jnr.fm(this.lcp, "android.permission.READ_MEDIA_IMAGES");
                zFm2 = true;
            } else {
                zFm = jnr.fm(this.lcp, "android.permission.READ_EXTERNAL_STORAGE");
                zFm2 = jnr.fm(this.lcp, "android.permission.WRITE_EXTERNAL_STORAGE");
            }
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("isHasRead", zFm);
            jSONObject.put("isHasWrite", zFm2);
            if (!zFm || !zFm2) {
                z10 = false;
            }
            jSONObject.put("result", z10);
            return jSONObject;
        } catch (Throwable th) {
            wsy.fm("PlayablePlugin", "getCameraPermission error", th);
            return new JSONObject();
        }
    }

    public void pkk() {
        try {
            ro roVar = this.fhx;
            if (roVar != null) {
                roVar.fm();
            }
            Handler handler = this.duv;
            if (handler != null) {
                handler.removeCallbacksAndMessages(null);
            }
        } catch (Throwable th) {
            th.toString();
        }
    }

    public com.bytedance.sdk.openadsdk.maa.fm qhl() {
        return this.cg;
    }

    public wu ro(int i10) {
        this.pbk = i10;
        return this;
    }

    public void sds() {
        com.bytedance.sdk.openadsdk.maa.fm fmVar = this.cg;
        if (fmVar != null) {
            fmVar.ro();
        }
    }

    public void wbw() {
        this.siu = false;
        this.wu.removeCallbacks(this.vt);
        try {
            JSONObject jSONObject = new JSONObject();
            if (this.pkk > 0) {
                jSONObject.put("playable_jssdk_load_success_duration", System.currentTimeMillis() - this.pkk);
            } else {
                jSONObject.put("playable_jssdk_load_success_duration", 0L);
            }
            lb("PL_sdk_jssdk_load_success", jSONObject);
        } catch (JSONException unused) {
        }
    }

    public JSONObject wey() {
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("devicePixelRatio", this.lsa);
            JSONObject jSONObject2 = new JSONObject();
            jSONObject2.put("width", this.ex);
            jSONObject2.put("height", this.wjb);
            jSONObject.put("screen", jSONObject2);
            JSONObject jSONObject3 = new JSONObject();
            jSONObject3.put("x", this.oy);
            jSONObject3.put("y", this.ky);
            jSONObject3.put("width", this.f7494kc);
            jSONObject3.put("height", this.ug);
            jSONObject.put("webview", jSONObject3);
            JSONObject jSONObject4 = new JSONObject();
            jSONObject4.put("x", this.f7490ff);
            jSONObject4.put("y", this.bp);
            jSONObject4.put("width", this.f7496le);
            jSONObject4.put("height", this.rbn);
            jSONObject.put("visible", jSONObject4);
        } catch (Throwable th) {
            wsy.fm("PlayablePlugin", "getViewport error", th);
        }
        return jSONObject;
    }

    public String wsy() {
        return this.pyj;
    }

    public boolean wu() {
        return this.xp;
    }

    public int xgn() {
        return (this.f7492ha == -1 || !this.hou) ? 1 : 2;
    }

    public wu yz(String str) {
        this.zjk = str;
        return this;
    }

    private boolean duv(String str) {
        if (TextUtils.isEmpty(str)) {
            return false;
        }
        return str.contains("/union-fe/playable/") || str.contains("/union-fe-sg/playable/") || str.contains("/union-fe-i18n/playable/");
    }

    public String ajl() {
        return this.zjk;
    }

    public JSONObject dsz() {
        try {
            boolean zFm = jnr.fm(this.lcp, "android.permission.CAMERA");
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("result", zFm);
            return jSONObject;
        } catch (Throwable th) {
            wsy.fm("PlayablePlugin", "getCameraPermission error", th);
            return new JSONObject();
        }
    }

    public wu fm(float f10) {
        this.lsa = f10;
        return this;
    }

    public wu jnr(boolean z10) {
        this.f7502ya = z10;
        return this;
    }

    public Set<String> ku() {
        return this.f7501te.fm();
    }

    public JSONObject lb() {
        return this.ucr;
    }

    public wu ro(long j10) {
        if (j10 <= 0) {
            this.mq = 10L;
        } else {
            this.mq = j10;
        }
        return this;
    }

    public JSONObject vt() {
        try {
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("send_click", this.zzm);
            return jSONObject;
        } catch (Throwable th) {
            wsy.fm("PlayablePlugin", "getPlayableClickStatus error", th);
            return new JSONObject();
        }
    }

    public void wsy(boolean z10) {
        this.mu = z10;
    }

    public String yz() {
        return this.jn;
    }

    public void ajl(boolean z10) {
        this.f7488cc = z10;
    }

    public JSONObject duv() {
        try {
            boolean zFm = jnr.fm(this.lcp, "android.permission.RECORD_AUDIO");
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("result", zFm);
            return jSONObject;
        } catch (Throwable th) {
            wsy.fm("PlayablePlugin", "getCameraPermission error", th);
            return new JSONObject();
        }
    }

    public void ef(String str) {
        WebView webView;
        boolean z10 = this.jm == -1;
        this.jm = 2;
        if (!z10) {
            this.zzn = str;
            JSONObject jSONObject = new JSONObject();
            try {
                long jCurrentTimeMillis = System.currentTimeMillis();
                this.hxv = jCurrentTimeMillis;
                long j10 = this.pkk;
                jSONObject.put("playable_html_load_start_duration", j10 != -1 ? jCurrentTimeMillis - j10 : 0L);
                jSONObject.put("playable_has_show", xgn());
            } catch (Throwable th) {
                wsy.fm("PlayablePlugin", "reportUrlLoadFinish error", th);
            }
            lb("PL_sdk_html_load_finish", jSONObject);
        }
        this.gt = false;
        this.wu.removeCallbacks(this.f7489ef);
        try {
            if (this.pbk == 0) {
                if (this.irt && (webView = this.zow) != null) {
                    this.irt = false;
                    webView.evaluateJavascript(mon(), new ValueCallback<String>() { // from class: com.bytedance.sdk.openadsdk.maa.wu.11
                        @Override // android.webkit.ValueCallback
                        public /* bridge */ /* synthetic */ void onReceiveValue(String str2) {
                        }
                    });
                }
                ha();
            }
        } catch (Throwable th2) {
            wsy.fm("PlayablePlugin", "crashMonitor error", th2);
        }
    }

    public wu fm(long j10) {
        if (j10 <= 0) {
            this.nt = 10L;
        } else {
            this.nt = j10;
        }
        return this;
    }

    public String jnr() {
        return this.cpu;
    }

    public void ku(String str) {
        this.wu.post(new Runnable() { // from class: com.bytedance.sdk.openadsdk.maa.wu.3
            @Override // java.lang.Runnable
            public void run() {
                wu.dsz(wu.this);
            }
        });
    }

    public wu ro(String str) {
        this.jn = str;
        return this;
    }

    public JSONObject wu(JSONObject jSONObject) {
        if (jSONObject == null) {
            return new JSONObject();
        }
        int iOptInt = jSONObject.optInt("type", 0);
        JSONObject jSONObject2 = new JSONObject();
        if (iOptInt == 1) {
            jSONObject2.put("result", jnr.ro(this.lcp, "android.permission.RECORD_AUDIO"));
        } else {
            if (iOptInt != 2) {
                if (iOptInt == 3) {
                    jSONObject2.put("result", jnr.fm(this.lcp));
                }
                return jSONObject2;
            }
            jSONObject2.put("result", jnr.ro(this.lcp, "android.permission.CAMERA"));
        }
        return jSONObject2;
    }

    public wu fm(String str) {
        this.cpu = str;
        return this;
    }

    public wu lb(String str) {
        try {
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("playable_style", str);
            this.ucr = jSONObject;
        } catch (Throwable th) {
            wsy.fm("PlayablePlugin", "setPlayableStyle error", th);
        }
        return this;
    }

    public wu ro(boolean z10) {
        this.qlg = z10;
        return this;
    }

    public wu wsy(String str) {
        int iIndexOf;
        String strDecode;
        this.cyr = str;
        try {
            Uri uri = Uri.parse(str);
            String scheme = uri.getScheme();
            if (!"http".equalsIgnoreCase(scheme) && !"https".equalsIgnoreCase(scheme)) {
                String host = uri.getHost();
                if (!"webview".equalsIgnoreCase(host) && (host == null || !host.contains("webview"))) {
                    if ("lynxview".equalsIgnoreCase(host) || (host != null && host.contains("lynxview"))) {
                        if (this.pbk == -1) {
                            ro(2);
                        } else {
                            ro(1);
                        }
                    }
                } else {
                    ro(0);
                    String queryParameter = uri.getQueryParameter(IjkMediaPlayer.OnNativeInvokeListener.ARG_URL);
                    if (!TextUtils.isEmpty(queryParameter) && (strDecode = Uri.decode(queryParameter)) != null) {
                        int iIndexOf2 = strDecode.indexOf("?");
                        str = iIndexOf2 != -1 ? strDecode.substring(0, iIndexOf2) : strDecode;
                    }
                }
            } else {
                ro(0);
                if (str != null && (iIndexOf = str.indexOf("?")) != -1) {
                    str = str.substring(0, iIndexOf);
                }
            }
        } catch (Throwable unused) {
        }
        this.zh = str;
        return this;
    }

    public wu yz(boolean z10) {
        this.zzm = z10;
        try {
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("send_click", this.zzm);
            fm("change_playable_click", jSONObject);
        } catch (Throwable th) {
            wsy.fm("PlayablePlugin", "setPlayableClick error", th);
        }
        return this;
    }

    public void ajl(JSONObject jSONObject) {
        ro(2, jSONObject != null ? jSONObject.optString("error_msg", "The material directly invokes the exception pocket mask on the client") : "The material directly invokes the exception pocket mask on the client");
    }

    public void fm(int i10) {
        this.kec = i10;
    }

    public void jnr(JSONObject jSONObject) {
        this.rka = jSONObject;
        this.mpp++;
        pkk();
        this.wu.removeCallbacks(this.ku);
        if (this.lse) {
            this.xgn = System.currentTimeMillis();
            this.so = System.currentTimeMillis();
            this.aws = 0L;
            int i10 = this.pbk;
            if (i10 == 0) {
                WebView webView = this.zow;
                if (webView != null) {
                    webView.evaluateJavascript("javascript:typeof playable_callJS === 'function' && playable_callJS()", new ValueCallback<String>() { // from class: com.bytedance.sdk.openadsdk.maa.wu.10
                        @Override // android.webkit.ValueCallback
                        /* JADX INFO: renamed from: fm, reason: merged with bridge method [inline-methods] */
                        public void onReceiveValue(String str) {
                            wu.this.aws = System.currentTimeMillis();
                        }
                    });
                }
            } else if (i10 == 1 || i10 == 2) {
                fm("playable_stuck_check_ping", new JSONObject());
            }
            this.wu.postDelayed(this.ku, this.gzf);
        }
    }

    public Map<String, String> ro() {
        return this.grs;
    }

    public void vt(String str) {
        this.wu.post(new Runnable() { // from class: com.bytedance.sdk.openadsdk.maa.wu.2
            @Override // java.lang.Runnable
            public void run() {
                wu.duv(wu.this);
            }
        });
    }

    public wu lb(boolean z10) {
        if (this.kec == -1 || this.hou == z10) {
            return this;
        }
        this.hou = z10;
        JSONObject jSONObject = new JSONObject();
        try {
            if (!this.hou) {
                jSONObject.put("playable_background_show_type", this.bwv);
            }
        } catch (JSONException unused) {
        }
        lb(this.hou ? "PL_sdk_viewable_true" : "PL_sdk_viewable_false", jSONObject);
        if (this.f7492ha == -1 && this.hou) {
            this.f7492ha = System.currentTimeMillis();
            JSONObject jSONObject2 = new JSONObject();
            try {
                jSONObject2.put("render_type", this.kec == 1 ? 1 : 2);
                int i10 = this.kec;
                if (i10 != -1) {
                    jSONObject2.put("webview_state", i10);
                }
            } catch (JSONException unused2) {
            }
            lb("PL_sdk_page_show", jSONObject2);
        }
        if (this.f7492ha != -1 && !this.hou && !this.vj) {
            this.vj = true;
        }
        if (this.hou) {
            this.wbw = System.currentTimeMillis();
        } else if (this.wbw != -1) {
            this.ai += System.currentTimeMillis() - this.wbw;
            this.wbw = -1L;
        }
        try {
            JSONObject jSONObject3 = new JSONObject();
            jSONObject3.put("viewStatus", this.hou);
            fm("viewableChange", jSONObject3);
        } catch (Throwable th) {
            wsy.fm("PlayablePlugin", "setViewable error", th);
        }
        if (this.hou) {
            ha();
        } else {
            pkk();
        }
        return this;
    }

    public void yz(JSONObject jSONObject) {
        if (jSONObject != null) {
            this.vvj = jSONObject.optString("section");
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void ro(View view) {
        if (view == null) {
            return;
        }
        try {
            if (this.ttj == view.getWidth() && this.daz == view.getHeight()) {
                return;
            }
            this.ttj = view.getWidth();
            this.daz = view.getHeight();
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("width", this.ttj);
            jSONObject.put("height", this.daz);
            fm("resize", jSONObject);
            this.qph = jSONObject;
        } catch (Throwable th) {
            wsy.fm("PlayablePlugin", "resetViewDataJsonByView error", th);
        }
    }

    private String yz(String str, String str2) {
        String str3 = String.format("rubeex://playable-minigamelite?id=%1s&schema=%2s", str, Uri.encode(str2));
        this.zh = str3;
        return str3;
    }

    public void wu(String str) {
        this.jm = 1;
        JSONObject jSONObject = new JSONObject();
        try {
            long jCurrentTimeMillis = System.currentTimeMillis();
            this.pkk = jCurrentTimeMillis;
            long j10 = this.f7492ha;
            jSONObject.put("playable_page_show_duration", j10 != -1 ? jCurrentTimeMillis - j10 : 0L);
        } catch (Throwable th) {
            wsy.fm("PlayablePlugin", "reportUrlLoadStart error", th);
        }
        lb("PL_sdk_html_load_start", jSONObject);
        this.gt = true;
        this.siu = true;
        if (this.f7502ya) {
            ol();
            this.gt = false;
            this.siu = false;
        }
        if (this.qhl) {
            try {
                StringBuffer stringBuffer = new StringBuffer();
                StringBuffer stringBuffer2 = new StringBuffer();
                StringBuffer stringBuffer3 = new StringBuffer();
                if (jnr.fm(this.lcp, jnr.duv)) {
                    stringBuffer.append("Microphone_");
                    stringBuffer2.append("1");
                    if (jnr.ro(this.lcp, "android.permission.RECORD_AUDIO")) {
                        stringBuffer3.append("1");
                    } else {
                        stringBuffer3.append(SessionDescription.SUPPORTED_SDP_VERSION);
                    }
                } else {
                    stringBuffer2.append(SessionDescription.SUPPORTED_SDP_VERSION);
                    stringBuffer3.append(SessionDescription.SUPPORTED_SDP_VERSION);
                }
                if (jnr.fm(this.lcp, jnr.ku)) {
                    stringBuffer.append("Magetometer_");
                    stringBuffer2.append("1");
                    stringBuffer3.append("1");
                } else {
                    stringBuffer2.append(SessionDescription.SUPPORTED_SDP_VERSION);
                    stringBuffer3.append(SessionDescription.SUPPORTED_SDP_VERSION);
                }
                if (jnr.fm(this.lcp, jnr.vt)) {
                    stringBuffer.append("Accelerometer_");
                    stringBuffer2.append("1");
                    stringBuffer3.append("1");
                } else {
                    stringBuffer2.append(SessionDescription.SUPPORTED_SDP_VERSION);
                    stringBuffer3.append(SessionDescription.SUPPORTED_SDP_VERSION);
                }
                if (jnr.fm(this.lcp, jnr.f7482ef)) {
                    stringBuffer.append("Gyro_");
                    stringBuffer2.append("1");
                    stringBuffer3.append("1");
                } else {
                    stringBuffer2.append(SessionDescription.SUPPORTED_SDP_VERSION);
                    stringBuffer3.append(SessionDescription.SUPPORTED_SDP_VERSION);
                }
                if (jnr.fm(this.lcp, jnr.wu)) {
                    stringBuffer.append("Camera_");
                    stringBuffer2.append("1");
                    if (jnr.ro(this.lcp, "android.permission.CAMERA")) {
                        stringBuffer3.append("1");
                    } else {
                        stringBuffer3.append(SessionDescription.SUPPORTED_SDP_VERSION);
                    }
                } else {
                    stringBuffer2.append(SessionDescription.SUPPORTED_SDP_VERSION);
                    stringBuffer3.append(SessionDescription.SUPPORTED_SDP_VERSION);
                }
                if (jnr.fm(this.lcp, jnr.wsy)) {
                    stringBuffer.append("Photo");
                    stringBuffer2.append("1");
                    if (jnr.fm(this.lcp)) {
                        stringBuffer3.append("1");
                    } else {
                        stringBuffer3.append(SessionDescription.SUPPORTED_SDP_VERSION);
                    }
                } else {
                    stringBuffer2.append(SessionDescription.SUPPORTED_SDP_VERSION);
                    stringBuffer3.append(SessionDescription.SUPPORTED_SDP_VERSION);
                }
                JSONObject jSONObject2 = new JSONObject();
                jSONObject2.put("playable_available_hardware_name", stringBuffer.toString());
                jSONObject2.put("playable_available_hardware_code", stringBuffer2.toString());
                jSONObject2.put("playable_available_hardware_auth_code", stringBuffer3.toString());
                lb("PL_sdk_hardware_detect", jSONObject2);
                this.qhl = false;
            } catch (Throwable th2) {
                wsy.fm("PlayablePlugin", "Hardware detect error", th2);
            }
        }
    }

    private void fm(Context context, lb lbVar, com.bytedance.sdk.openadsdk.maa.fm fmVar) {
        this.wey = UUID.randomUUID().toString();
        this.lcp = context;
        this.cg = fmVar;
        this.xca = lbVar;
        vt.fm(fmVar);
        this.f7501te = new ajl(this);
        zan();
        if (this.zow == null) {
            this.kec = 4;
            this.wu.post(new Runnable() { // from class: com.bytedance.sdk.openadsdk.maa.wu.4
                @Override // java.lang.Runnable
                public void run() {
                    wu.this.fm(5, "webview is null");
                }
            });
        }
    }

    public JSONObject yz(String str, JSONObject jSONObject) {
        System.currentTimeMillis();
        if (wsy.fm() && jSONObject != null) {
            jSONObject.toString();
        }
        JSONObject jSONObjectFm = this.f7501te.fm(str, jSONObject);
        if (wsy.fm()) {
            System.currentTimeMillis();
            if (jSONObjectFm != null) {
                jSONObjectFm.toString();
            }
        }
        return jSONObjectFm;
    }

    private void jnr(String str, JSONObject jSONObject) {
        try {
            int i10 = this.pbk;
            if (i10 == 0) {
                if (this.no != fm.LAND_PAGE && !duv(this.zh)) {
                    tzk();
                }
                jSONObject.put("playable_url", this.zh);
            } else if (i10 == 3 || i10 == 4) {
                jSONObject.put("playable_url", yz(this.eo, this.zes));
            } else if (i10 == 1 || i10 == 2) {
                jSONObject.put("playable_url", lb(this.eys, this.xw));
            }
            jSONObject.put("playable_render_type", this.pbk);
            if (this.cg != null) {
                if (this.pbk == 0 && (this.no != fm.LAND_PAGE || duv(this.zh))) {
                    this.cg.fm(jSONObject);
                } else if (this.pbk != 0) {
                    this.cg.fm(jSONObject);
                }
            }
        } catch (JSONException unused) {
        }
    }

    private wu(Context context, int i10, lb lbVar, com.bytedance.sdk.openadsdk.maa.fm fmVar) {
        this.ajl = "playable_stuck_check_ping";
        this.wsy = "playable_apply_media_permission_callback";
        this.wu = new Handler(Looper.getMainLooper());
        this.duv = new Handler(Looper.getMainLooper());
        this.irt = true;
        this.qhl = true;
        this.gof = true;
        this.fm = "PL_sdk_playable_global_viewable";
        this.ro = "PL_sdk_page_screen_blank";
        this.f7495lb = "PL_sdk_playable_destroy_analyze_summary";
        this.yz = "PL_sdk_playable_hardware_dialog_cancel";
        this.jnr = "PL_sdk_playable_hardware_dialog_setting";
        this.gqi = new HashSet(Arrays.asList("adInfo", "appInfo", "subscribe_app_ad", "download_app_ad"));
        this.wey = null;
        this.sds = "embeded_ad";
        this.maa = true;
        this.lse = true;
        this.hlt = false;
        this.hi = "";
        this.nt = 10L;
        this.mq = 10L;
        this.gzf = 700;
        this.ai = 0L;
        this.ol = 0L;
        this.wbw = -1L;
        this.f7492ha = -1L;
        this.pkk = -1L;
        this.hxv = -1L;
        this.f7491gc = -1L;
        this.xgn = -1L;
        this.mon = -1L;
        this.bx = "";
        this.zan = "";
        this.tzk = "";
        this.lz = "";
        this.f7500qf = 0;
        this.si = 0;
        this.f7493ib = false;
        this.f7497ne = 0;
        this.kwx = -1;
        this.bkb = 0;
        this.lmk = 0;
        this.mpp = 0;
        this.vvj = null;
        this.mj = false;
        this.ado = 0;
        this.bwv = 0;
        this.ywr = 0;
        this.pcm = 0;
        this.so = 0L;
        this.aws = 0L;
        this.pbk = -2;
        this.jm = 0;
        this.ttj = 0;
        this.daz = 0;
        this.qph = new JSONObject();
        this.grs = new HashMap();
        this.f7498pf = new JSONObject();
        this.cyr = "";
        this.po = 0.0f;
        this.vod = 0.0f;
        this.vj = false;
        this.nn = false;
        this.anz = false;
        this.iat = new ArrayList();
        this.f7502ya = true;
        this.gt = true;
        this.siu = true;
        this.ew = new ViewTreeObserver.OnGlobalLayoutListener() { // from class: com.bytedance.sdk.openadsdk.maa.wu.1
            @Override // android.view.ViewTreeObserver.OnGlobalLayoutListener
            public void onGlobalLayout() {
                try {
                    View view = (View) wu.this.f7499qb.get();
                    if (view == null) {
                        return;
                    }
                    wu.this.ro(view);
                } catch (Throwable th) {
                    wsy.fm("PlayablePlugin", "onSizeChanged error", th);
                }
            }
        };
        this.kec = -1;
        this.pbk = i10;
        this.no = fm.LAND_PAGE;
        fm(context, lbVar, fmVar);
    }

    public void ef(JSONObject jSONObject) {
        if (jSONObject != null) {
            boolean zOptBoolean = jSONObject.optBoolean("success", true);
            if (zOptBoolean) {
                this.jm = 3;
                ha();
            } else {
                this.jm = -2;
            }
            if (zOptBoolean || !this.maa) {
                return;
            }
            this.maa = false;
            this.gt = false;
            this.siu = false;
            this.wu.removeCallbacks(this.f7489ef);
            this.wu.removeCallbacks(this.vt);
            fm(4, "CaseRenderFail");
        }
    }

    public void fm(View view) {
        if (view == null) {
            return;
        }
        try {
            this.f7499qb = new WeakReference<>(view);
            ro(view);
            view.getViewTreeObserver().addOnGlobalLayoutListener(this.ew);
        } catch (Throwable th) {
            wsy.fm("PlayablePlugin", "setViewForScreenSize error", th);
        }
    }

    public void ro(JSONObject jSONObject) {
        if (this.cg != null) {
            try {
                jSONObject.optBoolean("isPrevent", false);
            } catch (Exception unused) {
            }
        }
    }

    public void ro(String str, String str2) {
        Bitmap bitmapFm;
        if (TextUtils.isEmpty(str2) || (bitmapFm = jnr.fm(str2)) == null) {
            return;
        }
        MediaStore.Images.Media.insertImage(this.lcp.getContentResolver(), bitmapFm, str, "");
    }

    public wu fm(String str, String str2) {
        this.grs.put(str, str2);
        return this;
    }

    public wu fm(boolean z10) {
        this.xp = z10;
        try {
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("endcard_mute", this.xp);
            fm("volumeChange", jSONObject);
        } catch (Throwable th) {
            wsy.fm("PlayablePlugin", "setIsMute error", th);
        }
        return this;
    }

    public void ro(int i10, String str) {
        this.kwx = i10;
        if (this.rka == null) {
            this.rka = new JSONObject();
        }
        try {
            this.rka.put("playable_stuck_type", i10);
            this.rka.put("playable_stuck_reason", str);
            if (this.xgn > 0) {
                this.rka.put("playable_stuck_duration", System.currentTimeMillis() - this.xgn);
            } else {
                this.rka.put("playable_stuck_duration", 0L);
            }
        } catch (Throwable unused) {
        }
        lb("PL_sdk_page_stuck", this.rka);
        pkk();
        if (this.cg == null || i10 != 2) {
            return;
        }
        this.rka = new JSONObject();
    }

    public JSONObject wsy(JSONObject jSONObject) {
        if (jSONObject == null) {
            return new JSONObject();
        }
        int iOptInt = jSONObject.optInt("type", 0);
        JSONObject jSONObject2 = new JSONObject();
        if (iOptInt == 1) {
            return duv();
        }
        if (iOptInt != 2) {
            return iOptInt != 3 ? jSONObject2 : onz();
        }
        return dsz();
    }

    private void lb(int i10, String str) {
        com.bytedance.sdk.openadsdk.maa.fm fmVar = this.cg;
        if (fmVar != null) {
            fmVar.fm(i10, str);
        }
    }

    private String lb(String str, String str2) {
        String queryParameter;
        String queryParameter2;
        if (TextUtils.isEmpty(this.hm) && !TextUtils.isEmpty(this.cyr)) {
            Uri uri = Uri.parse(this.cyr);
            String host = uri.getHost();
            if ("lynxview".equalsIgnoreCase(host) || (host != null && host.contains("lynxview"))) {
                queryParameter = uri.getQueryParameter("surl");
                queryParameter2 = uri.getQueryParameter("playable_hash");
            } else {
                queryParameter = "";
                queryParameter2 = "";
            }
            Uri.Builder builderAppendQueryParameter = new Uri.Builder().scheme(uri.getScheme()).authority(host).appendQueryParameter("surl", queryParameter);
            if (!TextUtils.isEmpty(queryParameter2)) {
                builderAppendQueryParameter.appendQueryParameter("playable_hash", queryParameter2);
            }
            this.hm = builderAppendQueryParameter.toString();
        }
        return this.hm;
    }

    public void fm(JSONObject jSONObject) {
        com.bytedance.sdk.openadsdk.maa.fm fmVar = this.cg;
        if (fmVar == null || fmVar.ro(jSONObject) || jSONObject == null) {
            return;
        }
        String strOptString = jSONObject.optString("resource_base64");
        if (TextUtils.isEmpty(strOptString)) {
            return;
        }
        int iOptInt = jSONObject.optInt("resource_type", -1);
        String strOptString2 = jSONObject.optString("resource_name", "playable_media");
        if (iOptInt == 1) {
            ro(strOptString2, strOptString);
        }
    }

    public void fm(String str, JSONObject jSONObject) {
        if (this.mu) {
            if (!wsy.fm() || jSONObject == null) {
                return;
            }
            jSONObject.toString();
            return;
        }
        if (wsy.fm() && jSONObject != null) {
            jSONObject.toString();
        }
        lb lbVar = this.xca;
        if (lbVar != null) {
            lbVar.fm(str, jSONObject);
        }
    }

    public void ro(String str, JSONObject jSONObject) {
        if (TextUtils.isEmpty(str)) {
            return;
        }
        jnr(str, jSONObject);
    }

    /* JADX WARN: Type inference fix 'apply assigned field type' failed
    java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$UnknownArg
    	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
    	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
    	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
     */
    public void lb(String str, JSONObject jSONObject) {
        if (TextUtils.isEmpty(str)) {
            return;
        }
        if (jSONObject == null) {
            jSONObject = new JSONObject();
        }
        try {
            if (!this.f7493ib && this.si > 0) {
                this.f7493ib = true;
            }
            if ("PL_sdk_html_load_start".equals(str) || "PL_sdk_html_load_finish".equals(str) || "PL_sdk_html_load_error".equals(str)) {
                jSONObject.put("usecache", this.f7488cc ? 1 : 0);
            }
            jSONObject.put("playable_event", str);
            jSONObject.put("playable_ts", System.currentTimeMillis());
            jSONObject.put("playable_viewable", this.hou);
            jSONObject.put("playable_session_id", this.wey);
            int i10 = this.pbk;
            if (i10 == 0) {
                if (this.no != fm.LAND_PAGE && !duv(this.zh)) {
                    tzk();
                }
                jSONObject.put("playable_url", this.zh);
            } else if (i10 == 3 || i10 == 4) {
                jSONObject.put("playable_url", yz(this.eo, this.zes));
            } else if (i10 == 1 || i10 == 2) {
                jSONObject.put("playable_url", lb(this.eys, this.xw));
            }
            jSONObject.put("playable_full_url", this.cyr);
            jSONObject.put("playable_replay_count", this.f7497ne);
            jSONObject.put("playable_is_prerender", this.qlg);
            jSONObject.put("playable_is_preload", this.f7493ib);
            jSONObject.put("playable_render_type", this.pbk);
            jSONObject.put("playable_scenes_type", this.no.ordinal());
            String str2 = "";
            jSONObject.put("playable_gecko_key", TextUtils.isEmpty(this.eys) ? "" : this.eys);
            if (!TextUtils.isEmpty(this.xw)) {
                str2 = this.xw;
            }
            jSONObject.put("playable_gecko_channel", str2);
            jSONObject.put("playable_sdk_version", "6.6.0");
            jSONObject.put("playable_minigamelite_id", this.eo);
            jSONObject.put("playable_minigamelite_schema", this.zes);
            jSONObject.put("playable_is_debug", this.nn);
            jSONObject.put("playable_retry_count", this.bkb);
            jSONObject.put("playable_enter_from", this.lmk);
            jSONObject.put("playable_sequence", this.mpp);
            jSONObject.put("playable_current_section", this.vvj);
            jSONObject.put("is_playable_finish", this.mj);
            jSONObject.put("playable_card_session", this.bx);
            jSONObject.put("playable_video_session", this.zan);
            jSONObject.put("playable_network_type", irt());
            jSONObject.put("playable_lynx_version", this.hi);
            JSONObject jSONObject2 = new JSONObject();
            jSONObject2.put("adExtraData", jSONObject);
            jSONObject2.put("tag", this.sds);
            jSONObject2.put("nt", 4);
            jSONObject2.put("category", "umeng");
            jSONObject2.put("is_ad_event", "1");
            jSONObject2.put("refer", "playable");
            jSONObject2.put("value", this.f7498pf.opt(CmcdConfiguration.KEY_CONTENT_ID));
            jSONObject2.put("log_extra", this.f7498pf.opt("log_extra"));
            int i11 = this.pbk;
            if (i11 != -1 && i11 != -2) {
                if (this.cg != null) {
                    List<JSONObject> list = this.iat;
                    if (list != null && !list.isEmpty()) {
                        Iterator<JSONObject> it = this.iat.iterator();
                        while (it.hasNext()) {
                            JSONObject jSONObjectOptJSONObject = it.next().optJSONObject("adExtraData");
                            if (jSONObjectOptJSONObject != null) {
                                jSONObjectOptJSONObject.put("playable_render_type", this.pbk);
                                jSONObjectOptJSONObject.put("playable_url", this.zh);
                            }
                            this.cg.fm(jSONObjectOptJSONObject);
                        }
                        this.iat.clear();
                    }
                    if (this.pbk == 0 && (this.no != fm.LAND_PAGE || duv(this.zh))) {
                        this.cg.fm(jSONObject);
                        return;
                    } else {
                        if (this.pbk != 0) {
                            this.cg.fm(jSONObject);
                            return;
                        }
                        return;
                    }
                }
                return;
            }
            if (this.iat == null) {
                this.iat = new ArrayList();
            }
            this.iat.add(jSONObject2);
        } catch (Throwable th) {
            wsy.fm("PlayablePlugin", "reportEvent error", th);
        }
    }

    public void fm(int i10, String str) {
        pkk();
        lb(i10, str);
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("playable_code", i10);
            jSONObject.put("playable_msg", str);
        } catch (Throwable th) {
            wsy.fm("PlayablePlugin", "reportRenderFatal error", th);
        }
        lb("PL_sdk_global_faild", jSONObject);
    }

    public void fm(int i10, String str, String str2) {
        this.jm = -1;
        this.zzn = str2;
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("playable_code", i10);
            jSONObject.put("playable_msg", str);
            jSONObject.put("playable_fail_url", str2);
            jSONObject.put("playable_has_show", xgn());
        } catch (Throwable th) {
            wsy.fm("PlayablePlugin", "onWebReceivedError error", th);
        }
        lb("PL_sdk_html_load_error", jSONObject);
        if (this.maa) {
            this.maa = false;
            this.gt = false;
            this.siu = false;
            this.wu.removeCallbacks(this.f7489ef);
            this.wu.removeCallbacks(this.vt);
            fm(1, "ContainerLoadFail");
        }
    }

    public void fm(boolean z10, String str, int i10) {
        if (z10) {
            this.jm = -1;
            this.zzn = str;
            JSONObject jSONObject = new JSONObject();
            try {
                jSONObject.put("playable_code", i10);
                jSONObject.put("playable_msg", "url load error");
                jSONObject.put("playable_fail_url", str);
                jSONObject.put("playable_has_show", xgn());
            } catch (Throwable th) {
                wsy.fm("PlayablePlugin", "onWebReceivedHttpError error", th);
            }
            lb("PL_sdk_html_load_error", jSONObject);
            if (this.maa) {
                this.maa = false;
                this.gt = false;
                this.siu = false;
                this.wu.removeCallbacks(this.f7489ef);
                this.wu.removeCallbacks(this.vt);
                fm(1, "ContainerLoadFail");
            }
        }
    }

    public static wu fm(Context context, @Nullable WebView webView, lb lbVar, com.bytedance.sdk.openadsdk.maa.fm fmVar) {
        if (lbVar == null || fmVar == null) {
            return null;
        }
        if (webView == null) {
            return new wu(context, 0, lbVar, fmVar);
        }
        return new wu(context, webView, lbVar, fmVar, fm.LAND_PAGE);
    }
}
