package com.bytedance.sdk.openadsdk.core.settings;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.SystemClock;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
import com.bytedance.sdk.component.utils.duv;
import com.bytedance.sdk.component.utils.wey;
import com.bytedance.sdk.openadsdk.ApmHelper;
import com.bytedance.sdk.openadsdk.TTAdConstant;
import com.bytedance.sdk.openadsdk.common.TTAdDislikeToast;
import com.bytedance.sdk.openadsdk.core.fhx;
import com.bytedance.sdk.openadsdk.core.gof;
import com.bytedance.sdk.openadsdk.core.settings.TTSdkSettings;
import com.bytedance.sdk.openadsdk.core.settings.ef;
import com.bytedance.sdk.openadsdk.core.settings.jnr;
import com.bytedance.sdk.openadsdk.core.settings.vt;
import com.bytedance.sdk.openadsdk.utils.DeviceUtils;
import com.bytedance.sdk.openadsdk.utils.bx;
import com.bytedance.sdk.openadsdk.utils.xgn;
import com.bytedance.sdk.openadsdk.yz.fm.vt;
import com.pgl.ssdk.ces.out.PglSSConfig;
import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicBoolean;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/* JADX INFO: loaded from: classes2.dex */
public class ku implements ef.fm {
    public static String ajl;

    /* JADX INFO: renamed from: ef, reason: collision with root package name */
    private static final String f7278ef;
    public static final String fm;
    private static final ConcurrentLinkedQueue<vt.fm> gqi;
    private static String hi;
    public static int jnr;
    private static boolean ku;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    public static final String f7279lb;
    public static final String ro;
    static final ConcurrentHashMap<String, Integer> wsy;
    public static String yz;
    private final wu dsz;
    private final com.bytedance.sdk.openadsdk.core.settings.fm duv;
    private volatile boolean fhx;
    private boolean gof;
    private jnr.ro<JSONObject> hlt;
    private int irt;
    private final jnr.ro<Set<String>> lse;
    private final Set<String> maa;
    private final AtomicBoolean onz;
    private int qhl;
    private final jnr.ro<Map<String, Integer>> sds;
    private Set<String> vt;
    private final Runnable wey;
    jnr.ro<com.bytedance.sdk.openadsdk.yz.fm.vt> wu;

    public static final class fm {
        static final ku fm = new ku();
    }

    static {
        CharSequence[] charSequenceArr = {"bus_con_collect", bx.ol()};
        StringBuilder sb = new StringBuilder();
        sb.append(charSequenceArr[0]);
        sb.append((CharSequence) "_");
        sb.append(charSequenceArr[1]);
        fm = sb.toString();
        CharSequence[] charSequenceArr2 = {"bus_con", bx.ol(), bx.ai(), "timeout"};
        StringBuilder sb2 = new StringBuilder();
        sb2.append(charSequenceArr2[0]);
        for (int i10 = 1; i10 < 4; i10++) {
            sb2.append((CharSequence) "_");
            sb2.append(charSequenceArr2[i10]);
        }
        ro = sb2.toString();
        CharSequence[] charSequenceArr3 = {"bus_con", bx.ol(), bx.ai(), "alpha"};
        StringBuilder sb3 = new StringBuilder();
        sb3.append(charSequenceArr3[0]);
        for (int i11 = 1; i11 < 4; i11++) {
            sb3.append((CharSequence) "_");
            sb3.append(charSequenceArr3[i11]);
        }
        f7279lb = sb3.toString();
        f7278ef = bx.lse();
        yz = "";
        jnr = -2;
        ajl = "IABTCF_TCString";
        ku = false;
        gqi = new ConcurrentLinkedQueue<>();
        wsy = new ConcurrentHashMap<>();
    }

    public static String ex() {
        if (hi == null) {
            String strRo = com.bytedance.sdk.openadsdk.core.lb.fm().ro("settings_host_from_meta", "");
            hi = strRo;
            if (strRo == null) {
                hi = "";
            }
        }
        return hi;
    }

    private Set<String> kc() {
        return (Set) this.dsz.fm("perf_con_applog_send", this.maa, this.lse);
    }

    private String oy() {
        return this.dsz.fm("force_language", "");
    }

    public static boolean zh() {
        return ku;
    }

    public boolean ado() {
        return this.fhx;
    }

    public boolean ai() {
        return this.dsz.fm("landingpage_new_style", -1) == 1;
    }

    @Nullable
    public JSONObject ajl() {
        return (JSONObject) this.dsz.fm("digest", null, jnr.fm);
    }

    public String[] aws() {
        Set<String> set;
        try {
            set = this.vt;
        } catch (Throwable unused) {
        }
        if (set == null || set.size() == 0) {
            JSONArray jSONArray = new JSONArray(this.dsz.fm("gecko_hosts", (String) null));
            if (jSONArray.length() != 0) {
                for (int i10 = 0; i10 < jSONArray.length(); i10++) {
                    this.vt.add(jSONArray.getString(i10));
                }
            }
            Set<String> setFm = wu.fm(this.vt);
            this.vt = setFm;
            if (setFm != null) {
                if (setFm.size() == 0) {
                }
            }
            return null;
        }
        return (String[]) this.vt.toArray(new String[0]);
    }

    public int bkb() {
        int iFm = this.dsz.fm("privacy_personalized_ad", Integer.MAX_VALUE);
        if (iFm != Integer.MAX_VALUE) {
            return iFm;
        }
        int iHi = bx.hi();
        if (iHi == 1 || iHi == 2) {
            return 2;
        }
        return iHi != 3 ? 0 : 1;
    }

    public boolean bwv() {
        return this.dsz.fm("global_rate", 1.0f) == 1.0f;
    }

    public String bx() {
        return this.dsz.fm("settings_url", "");
    }

    public boolean cg() {
        return this.dsz.fm("perf_con_is_new_net_thread", 0) == 1;
    }

    public Set<String> cpu() {
        Set<String> set = (Set) this.dsz.fm("dual_event_url_backup", Collections.emptySet(), jnr.ro);
        return (set == null || set.size() == 0) ? Collections.emptySet() : set;
    }

    public Set<String> cyr() {
        return (Set) this.dsz.fm("privacy_fields_allowed", Collections.emptySet(), jnr.ro);
    }

    public boolean daz() {
        return this.dsz.fm("perf_con_adlog_turn_off_retry_stats", 0) == 1;
    }

    public int dsz() {
        kc();
        return this.qhl;
    }

    public Set<String> duv() {
        return kc();
    }

    public String ef() {
        return this.dsz.fm("ab_test_version", "");
    }

    public boolean fhx() {
        return this.dsz.fm("allow_blind_mode_request_ad", false);
    }

    public void gc() {
        String strOy = oy();
        if (TextUtils.isEmpty(strOy)) {
            return;
        }
        if (strOy.equals("zh-Hant")) {
            duv.fm(gof.fm(), "zh", "tw");
        } else {
            duv.fm(gof.fm(), strOy, null);
        }
        try {
            TTAdDislikeToast.onResourceUpdated();
        } catch (Throwable th) {
            wey.lb("TTAD.SdkSettings", th.getMessage());
        }
    }

    public boolean gof() {
        return this.dsz.fm("bus_con_adshow_check_enable", true);
    }

    public String gqi() {
        return this.dsz.fm("bus_con_express_host", "https://lf-static.tiktokpangle-cdn-us.com/obj/ad-pattern-tx/");
    }

    public Set<String> grs() {
        return (Set) this.dsz.fm("perf_con_drop2rt_skip_label_list", Collections.emptySet(), jnr.ro);
    }

    public String gzf() {
        return this.dsz.fm("ab_test_param", "");
    }

    public ajl ha() {
        return (ajl) this.dsz.fm("insert_js_config", ajl.fm, new jnr.ro<ajl>() { // from class: com.bytedance.sdk.openadsdk.core.settings.ku.5
            @Override // com.bytedance.sdk.openadsdk.core.settings.jnr.ro
            /* JADX INFO: renamed from: fm, reason: merged with bridge method [inline-methods] */
            public ajl ro(String str) {
                return new ajl(str);
            }
        });
    }

    public float hi() {
        return this.dsz.fm(f7279lb, 1.0f);
    }

    public int hlt() {
        return this.dsz.fm(ro, 10000);
    }

    public void hm() {
        jnr.fm fmVarRo = this.dsz.ro();
        fmVarRo.fm("settings_url", "");
        fmVarRo.fm();
        ol("");
    }

    public int hxv() {
        int iFm = this.dsz.fm("fetch_tpl_second", 0);
        if (iFm <= 0) {
            return 0;
        }
        return iFm;
    }

    public String ib() {
        return this.dsz.fm("dc", "");
    }

    public boolean irt() {
        return this.dsz.fm("support_gzip", false);
    }

    public long jm() {
        return this.dsz.fm("last_req_time", 0L);
    }

    public int jn() {
        int iFm = this.dsz.fm("bus_con_auto_click_delay", 3000);
        if (iFm <= 0) {
            return 3000;
        }
        return iFm;
    }

    public int jnr() {
        return this.dsz.fm("max_tpl_cnts", 100);
    }

    public int ku() {
        return this.dsz.fm("perf_con_drawable_code", 0);
    }

    public boolean kwx() {
        int iFm = this.dsz.fm("privacy_ad_enable", Integer.MAX_VALUE);
        if (iFm == 1) {
            return true;
        }
        if (iFm == 0) {
            return false;
        }
        int iHi = bx.hi();
        return iHi == 1 || iHi == 2 || iHi == 3;
    }

    public boolean lcp() {
        return this.onz.get();
    }

    public boolean lmk() {
        return this.dsz.fm("perf_con_apm_native", Integer.MAX_VALUE) == 1;
    }

    public String lsa() {
        return this.dsz.fm("target_region", "");
    }

    public boolean lse() {
        return this.dsz.fm(fm, false);
    }

    public int lz() {
        return this.dsz.fm("ivrv_downward", 0);
    }

    public boolean maa() {
        return this.dsz.fm("bus_con_url_check", 1) != 0;
    }

    public String mj() {
        return this.dsz.fm("privacy_app_reg", "");
    }

    public String mon() {
        return this.dsz.fm("ads_url", "");
    }

    public boolean mpp() {
        return this.dsz.fm("bus_con_sec_type", Integer.MAX_VALUE) != 0;
    }

    public int mq() {
        return this.dsz.fm("loadedCallbackOpportunity", 0);
    }

    public int ne() {
        return this.dsz.fm("vbtt", 5);
    }

    public void no() {
        fhx.ro().removeCallbacks(this.wey);
        fhx.ro().postDelayed(this.wey, pbk());
    }

    public int nt() {
        return this.dsz.fm("bus_con_slide_num", 2);
    }

    public long ol() {
        return this.dsz.fm("duration", 10000L);
    }

    public int onz() {
        kc();
        return this.irt;
    }

    public long pbk() {
        long jFm = this.dsz.fm("req_inter_min", TTAdConstant.AD_MAX_EVENT_TIME);
        return (jFm < 0 || jFm > 86400000) ? TTAdConstant.AD_MAX_EVENT_TIME : jFm;
    }

    public int pcm() {
        int iFm = this.dsz.fm("perf_con_webview_cache_count", 0);
        if (iFm < 0) {
            return 0;
        }
        return iFm;
    }

    public int pf() {
        return this.dsz.fm("perf_con_sync_gaid", 0);
    }

    public int pkk() {
        int iFm = this.dsz.fm("fetch_tpl_timeout_ctrl", 3000);
        if (iFm <= 0) {
            return 3000;
        }
        return iFm;
    }

    public Set<String> po() {
        return (Set) this.dsz.fm("token_adx_ids", Collections.emptySet(), jnr.ro);
    }

    public boolean qb() {
        int iFm = this.duv.fm("perf_con_apm", 100);
        if (iFm == 0) {
            return false;
        }
        return iFm < 0 || iFm >= 100 || iFm > ((int) (Math.random() * 100.0d));
    }

    public String qf() {
        return this.dsz.fm("dyn_draw_engine_url", f7278ef);
    }

    public boolean qhl() {
        return this.dsz.fm("ad_revenue_enable", true);
    }

    public String qph() {
        return this.dsz.fm("dual_event_url", (String) null);
    }

    public int rka() {
        return this.dsz.fm("blank_detect_rate", 30);
    }

    public String sds() {
        return this.dsz.fm("bus_con_check_clz", "");
    }

    public String si() {
        return this.dsz.fm("dc", "TX");
    }

    public int so() {
        int iFm = this.dsz.fm("perf_con_webview_cache_count_v3", 0);
        if (iFm < 0) {
            return 0;
        }
        return iFm;
    }

    public long te() {
        return this.dsz.fm("perf_con_adlog_expire_time", 0L);
    }

    public boolean ttj() {
        return this.dsz.fm("perf_con_adlog_turn_off_retry_ad", 0) == 1;
    }

    public String tzk() {
        return this.dsz.fm("policy_url", "");
    }

    public boolean ucr() {
        return this.dsz.fm("token_enable", 0) == 1;
    }

    public Set<String> vod() {
        Set<String> set = (Set) this.dsz.fm("ads_url_backup", Collections.emptySet(), jnr.ro);
        return (set == null || set.size() == 0) ? Collections.emptySet() : set;
    }

    public int vt() {
        return this.dsz.fm("splash_video_load_strategy", 0);
    }

    public boolean vvj() {
        return this.dsz.fm("privacy_debug_unlock", 1) != 0;
    }

    public int wbw() {
        return this.dsz.fm("max", 50);
    }

    public int wey() {
        return this.dsz.fm("bus_con_behavior_count", 300);
    }

    public long wsy() {
        return this.dsz.fm("data_time", 0L);
    }

    public void wu() {
        this.dsz.ro().fm("ab_test_param").fm();
    }

    public JSONObject xca() {
        return (JSONObject) this.dsz.fm("perf_con_thread_pool_config", new JSONObject(), this.hlt);
    }

    public boolean xgn() {
        return this.dsz.lb();
    }

    public boolean ywr() {
        return this.dsz.fm("read_video_from_cache", 1) == 1;
    }

    public String yz() {
        return this.dsz.fm("aes_key", "");
    }

    public String zan() {
        return this.dsz.fm("app_log_url", "");
    }

    public com.bytedance.sdk.openadsdk.yz.fm.vt zjk() {
        return (com.bytedance.sdk.openadsdk.yz.fm.vt) this.dsz.fm("perf_con_track_url_strategy", com.bytedance.sdk.openadsdk.yz.fm.vt.fm, this.wu);
    }

    public boolean zow() {
        if (com.bytedance.sdk.component.adexpress.yz.ro.fm(gof.fm())) {
            return this.dsz.fm("support_rtl", false);
        }
        return false;
    }

    public boolean zzn() {
        return this.dsz.fm("bus_con_video_keep_screen_on", 1) == 1;
    }

    private ku() {
        this.vt = Collections.synchronizedSet(new HashSet());
        this.duv = new com.bytedance.sdk.openadsdk.core.settings.fm();
        this.dsz = new wu(new vt.fm() { // from class: com.bytedance.sdk.openadsdk.core.settings.ku.1
            @Override // com.bytedance.sdk.openadsdk.core.settings.vt.fm
            public void fm() {
                vt.fm[] fmVarArr;
                boolean unused = ku.ku = true;
                com.bytedance.sdk.openadsdk.core.ku.ro.fm().onz();
                if (ku.gqi == null || ku.gqi.size() == 0 || (fmVarArr = (vt.fm[]) ku.gqi.toArray()) == null) {
                    return;
                }
                for (vt.fm fmVar : fmVarArr) {
                    fmVar.fm();
                }
            }

            @Override // com.bytedance.sdk.openadsdk.core.settings.vt.fm
            public void ro() {
                com.bytedance.sdk.openadsdk.core.ku.ro.fm().fhx();
                if (ku.gqi == null || ku.gqi.isEmpty()) {
                    return;
                }
                Iterator it = ku.gqi.iterator();
                while (it.hasNext()) {
                    ((vt.fm) it.next()).ro();
                }
            }
        });
        this.onz = new AtomicBoolean(false);
        this.fhx = false;
        this.irt = 5000;
        this.qhl = 10;
        this.wey = new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.settings.ku.7
            @Override // java.lang.Runnable
            public void run() {
                ku.this.fm(2, false);
                ku.this.no();
            }
        };
        this.sds = new jnr.ro<Map<String, Integer>>() { // from class: com.bytedance.sdk.openadsdk.core.settings.ku.8
            @Override // com.bytedance.sdk.openadsdk.core.settings.jnr.ro
            /* JADX INFO: renamed from: fm, reason: merged with bridge method [inline-methods] */
            public Map<String, Integer> ro(String str) {
                if (TextUtils.isEmpty(str)) {
                    return null;
                }
                try {
                    JSONObject jSONObject = new JSONObject(str);
                    HashMap map = new HashMap(jSONObject.length());
                    Iterator<String> itKeys = jSONObject.keys();
                    while (itKeys.hasNext()) {
                        String next = itKeys.next();
                        if (!TextUtils.isEmpty(next)) {
                            int iOptInt = jSONObject.optInt(next, 100);
                            if (iOptInt < 0 || iOptInt > 100) {
                                map.put(next, 100);
                            } else {
                                map.put(next, Integer.valueOf(iOptInt));
                            }
                        }
                    }
                    return map;
                } catch (Exception e10) {
                    wey.lb("get applog rate from sp failed:" + e10.getMessage(), new Object[0]);
                    return null;
                }
            }
        };
        this.maa = new HashSet();
        this.lse = new jnr.ro<Set<String>>() { // from class: com.bytedance.sdk.openadsdk.core.settings.ku.9
            @Override // com.bytedance.sdk.openadsdk.core.settings.jnr.ro
            /* JADX INFO: renamed from: fm, reason: merged with bridge method [inline-methods] */
            public Set<String> ro(String str) {
                HashSet hashSet = new HashSet();
                if (!TextUtils.isEmpty(str)) {
                    try {
                        JSONObject jSONObject = new JSONObject(str);
                        int iOptInt = jSONObject.optInt("applog_count");
                        if (iOptInt >= 2 && iOptInt <= 100) {
                            ku.this.qhl = iOptInt;
                        }
                        int iOptInt2 = jSONObject.optInt("applog_interval");
                        if (iOptInt2 >= 100 && iOptInt2 <= 30000) {
                            ku.this.irt = iOptInt2;
                        }
                        JSONArray jSONArray = jSONObject.getJSONArray("core_label_arr");
                        if (jSONArray != null) {
                            for (int i10 = 0; i10 < jSONArray.length(); i10++) {
                                String string = jSONArray.getString(i10);
                                if (!TextUtils.isEmpty(string)) {
                                    hashSet.add(string);
                                }
                            }
                        }
                    } catch (JSONException e10) {
                        e10.getMessage();
                    }
                }
                return hashSet.size() == 0 ? new HashSet(Arrays.asList("click", "show", "insight_log", "mrc_show")) : hashSet;
            }
        };
        this.hlt = new jnr.ro<JSONObject>() { // from class: com.bytedance.sdk.openadsdk.core.settings.ku.10
            @Override // com.bytedance.sdk.openadsdk.core.settings.jnr.ro
            /* JADX INFO: renamed from: fm, reason: merged with bridge method [inline-methods] */
            public JSONObject ro(String str) {
                JSONObject jSONObject;
                try {
                    jSONObject = new JSONObject(str);
                } catch (Throwable th) {
                    wey.lb("TTAD.SdkSettings", th.getMessage());
                    jSONObject = null;
                }
                return jSONObject == null ? new JSONObject() : jSONObject;
            }
        };
        this.wu = new jnr.ro<com.bytedance.sdk.openadsdk.yz.fm.vt>() { // from class: com.bytedance.sdk.openadsdk.core.settings.ku.2
            @Override // com.bytedance.sdk.openadsdk.core.settings.jnr.ro
            /* JADX INFO: renamed from: fm, reason: merged with bridge method [inline-methods] */
            public com.bytedance.sdk.openadsdk.yz.fm.vt ro(String str) {
                com.bytedance.sdk.openadsdk.yz.fm.vt vtVar = new com.bytedance.sdk.openadsdk.yz.fm.vt();
                try {
                    JSONObject jSONObject = new JSONObject(str);
                    vtVar.fm(jSONObject.optInt("enable_strategy", 0) == 1);
                    vtVar.fm(fm(jSONObject.optJSONObject("default")));
                    JSONObject jSONObjectOptJSONObject = jSONObject.optJSONObject("adid_configs");
                    if (jSONObjectOptJSONObject != null) {
                        Iterator<String> itKeys = jSONObjectOptJSONObject.keys();
                        while (itKeys.hasNext()) {
                            String next = itKeys.next();
                            vtVar.fm(next, fm(jSONObjectOptJSONObject.getJSONObject(next)));
                        }
                    }
                } catch (Exception unused) {
                }
                return vtVar;
            }

            private vt.fm fm(JSONObject jSONObject) {
                if (jSONObject != null) {
                    return new vt.fm(jSONObject.optInt("retry_times", -1), jSONObject.optInt("time_interval", -1));
                }
                return null;
            }
        };
    }

    @Nullable
    private static SharedPreferences lb(Context context) {
        try {
            return PreferenceManager.getDefaultSharedPreferences(context);
        } catch (Throwable unused) {
            return null;
        }
    }

    public static void ol(String str) {
        if (str == null) {
            str = "";
        }
        String strEx = ex();
        if (strEx == null || !strEx.equals(str)) {
            com.bytedance.sdk.openadsdk.core.lb.fm().fm("settings_host_from_meta", str);
            hi = str;
            ro().fm(8, true);
        }
    }

    public boolean ai(String str) {
        Set<String> setPo;
        if (TextUtils.isEmpty(str) || (setPo = po()) == null || setPo.size() == 0) {
            return false;
        }
        return setPo.contains(str);
    }

    public boolean ajl(String str) {
        return mq(str).wsy == 1;
    }

    public boolean dsz(String str) {
        try {
            return mq(str).lse != null;
        } catch (Exception unused) {
            return false;
        }
    }

    public int duv(String str) {
        return mq(str).duv;
    }

    public int ef(String str) {
        if (str == null) {
            return 1;
        }
        return mq(str).onz;
    }

    public boolean fhx(String str) {
        return onz(str) != 1;
    }

    public boolean gof(String str) {
        return str == null || DeviceUtils.vt(gof.fm()) == 0 || mq(str).dsz == 1;
    }

    public JSONObject gqi(String str) {
        JSONObject jSONObject = null;
        try {
            JSONObject jSONObject2 = new JSONObject(this.dsz.fm("core_settings", ""));
            try {
                jSONObject2.put("ad_slot_setting", mq(str).f7281ha);
                return jSONObject2;
            } catch (JSONException e10) {
                e = e10;
                jSONObject = jSONObject2;
                wey.lb("TTAD.SdkSettings", "getCoreSettingJsonObj", e.getMessage());
                return jSONObject;
            }
        } catch (JSONException e11) {
            e = e11;
        }
    }

    public boolean gzf(@NonNull String str) {
        Set set = (Set) this.dsz.fm("privacy_fields_allowed", Collections.emptySet(), jnr.ro);
        if (!set.isEmpty()) {
            return set.contains(str);
        }
        int iHi = bx.hi();
        if (iHi != 1) {
            if (iHi != 2 && iHi != 3) {
                return false;
            }
            if (!"mcc".equals(str) && !"mnc".equals(str)) {
                return false;
            }
        }
        return true;
    }

    public boolean hi(String str) {
        return mq(str).ol;
    }

    public int hlt(String str) {
        return mq(str).mq;
    }

    public int irt(String str) {
        return mq(str).vt;
    }

    public boolean jnr(String str) {
        int i10 = mq(str).jnr;
        return i10 != 1 ? i10 == 2 && com.bytedance.sdk.component.utils.gof.lb(gof.fm()) != 0 : com.bytedance.sdk.component.utils.gof.yz(gof.fm());
    }

    public int ku(String str) {
        return mq(str).ku;
    }

    public int lse(String str) {
        return mq(str).nt;
    }

    public int maa(String str) {
        return mq(str).hi;
    }

    @NonNull
    public ro mq(String str) {
        return lb.fm(str);
    }

    public boolean nt(String str) {
        return gof.yz().mq(str).fhx == 1;
    }

    public int onz(String str) {
        return mq(String.valueOf(str)).wu;
    }

    public boolean qhl(String str) {
        return mq(str).maa == 0;
    }

    public boolean sds(String str) {
        return mq(str).sds;
    }

    public int vt(String str) {
        if (str == null) {
            return 5000;
        }
        return mq(str).irt;
    }

    public int wey(String str) {
        return mq(str).wey;
    }

    public int wsy(String str) {
        return mq(str).gof;
    }

    public boolean wu(String str) {
        return str == null || mq(str).onz == 1;
    }

    public boolean yz(String str) {
        return mq(str).gzf;
    }

    public void fm() {
        try {
            lb.ro();
            this.dsz.yz();
            this.duv.yz();
            Context contextFm = gof.fm();
            File file = new File(new File(contextFm.getDataDir(), "shared_prefs"), "tt_sdk_settings.xml");
            if (file.exists() && file.isFile()) {
                contextFm.deleteSharedPreferences(file.getName().replace(".xml", ""));
            }
        } catch (Throwable unused) {
        }
    }

    @WorkerThread
    public synchronized void lb() {
        SystemClock.elapsedRealtime();
        boolean z10 = !this.fhx;
        this.duv.fm(this.fhx);
        this.dsz.fm(this.fhx);
        lb.fm(z10);
        this.fhx = true;
        SystemClock.elapsedRealtime();
        if (z10) {
            fhx.ro().postDelayed(new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.settings.ku.3
                @Override // java.lang.Runnable
                public void run() {
                    ku.this.fm(1, com.bytedance.sdk.openadsdk.core.ku.ro.fm().wsy() || com.bytedance.sdk.openadsdk.core.ku.ro.fm().vt());
                    ku.this.no();
                }
            }, 1000L);
        }
    }

    public static String ro(Context context) {
        SharedPreferences sharedPreferencesLb;
        return (context == null || (sharedPreferencesLb = lb(context)) == null) ? "" : sharedPreferencesLb.getString(ajl, "");
    }

    public static ku ro() {
        return fm.fm;
    }

    public int ro(String str) {
        Integer num;
        Map map = (Map) this.dsz.fm("perf_con_applog_rate", null, this.sds);
        if (map == null || (num = (Integer) map.get(str)) == null || num.intValue() < 0 || num.intValue() > 100) {
            return 100;
        }
        return num.intValue();
    }

    public boolean lb(String str) {
        return mq(str).f7282lb == 1;
    }

    public int ro(int i10) {
        return mq(String.valueOf(i10)).ro;
    }

    public int lb(int i10) {
        return mq(String.valueOf(i10)).f7280ef;
    }

    public static int fm(Context context) {
        if (context == null) {
            return -2;
        }
        try {
            SharedPreferences sharedPreferencesLb = lb(context);
            if (sharedPreferencesLb == null) {
                return -2;
            }
            int i10 = sharedPreferencesLb.getInt("IABTCF_CmpSdkID", Integer.MIN_VALUE);
            int i11 = sharedPreferencesLb.getInt("IABTCF_CmpSdkVersion", Integer.MIN_VALUE);
            if (i10 == Integer.MIN_VALUE && i11 == Integer.MIN_VALUE) {
                return -2;
            }
            return sharedPreferencesLb.getInt("IABTCF_gdprApplies", -1);
        } catch (Throwable unused) {
            return -2;
        }
    }

    public void fm(JSONObject jSONObject, jnr.fm fmVar) {
        if (jSONObject == null || !jSONObject.has("dyn_draw_engine_url")) {
            return;
        }
        wu wuVar = this.dsz;
        String str = f7278ef;
        String strFm = wuVar.fm("dyn_draw_engine_url", str);
        final String strOptString = jSONObject.optString("dyn_draw_engine_url", str);
        if (!TextUtils.isEmpty(strFm) && !TextUtils.isEmpty(strOptString) && !strOptString.equals(strFm)) {
            fhx.ro().postDelayed(new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.settings.ku.4
                @Override // java.lang.Runnable
                public void run() {
                    if (TextUtils.equals(ku.this.dsz.fm("dyn_draw_engine_url", ku.f7278ef), strOptString)) {
                        com.bytedance.sdk.component.adexpress.fm.ro.jnr.ro().lb();
                    }
                }
            }, 5000L);
        }
        fmVar.fm("dyn_draw_engine_url", strOptString);
    }

    public int fm(String str) {
        if (str == null) {
            return 0;
        }
        return gof.yz().mq(str).gqi;
    }

    public int fm(int i10) {
        return mq(String.valueOf(i10)).wbw;
    }

    public void fm(long j10) {
        this.dsz.ro().fm("last_req_time", j10).fm();
    }

    public void fm(@TTSdkSettings.FETCH_REQUEST_SOURCE final int i10, boolean z10) {
        if (com.bytedance.sdk.openadsdk.core.ku.ro.fm().yz()) {
            return;
        }
        if (!fhx.jnr() && i10 != 1 && i10 != 2) {
            if (z10) {
                this.gof = true;
                return;
            }
            return;
        }
        try {
            if (TextUtils.isEmpty(com.bytedance.sdk.openadsdk.core.vt.ro().yz())) {
                return;
            }
            if (this.gof) {
                this.gof = false;
                if (!z10) {
                    z10 = true;
                }
            }
            long jJm = jm();
            long jCurrentTimeMillis = System.currentTimeMillis();
            long jPbk = pbk();
            long j10 = jCurrentTimeMillis - jJm;
            if ((z10 || j10 >= jPbk) && this.onz.compareAndSet(false, true)) {
                xgn.lb((Runnable) new com.bytedance.sdk.component.wu.ro.lb("setting_req") { // from class: com.bytedance.sdk.openadsdk.core.settings.ku.6
                    @Override // java.lang.Runnable
                    public void run() {
                        com.bytedance.sdk.openadsdk.core.ku.ro.fm().fm(new com.bytedance.sdk.openadsdk.core.ku.yz() { // from class: com.bytedance.sdk.openadsdk.core.settings.ku.6.1
                            @Override // com.bytedance.sdk.openadsdk.core.ku.yz
                            public void fm(boolean z11) {
                                if (!z11) {
                                    ku.this.onz.set(false);
                                } else {
                                    ku kuVar = ku.this;
                                    new ef(kuVar, kuVar.dsz, ku.this.duv).run();
                                }
                            }
                        }, i10 == 6);
                    }
                });
                fhx.ro().removeCallbacks(this.wey);
            }
        } catch (Throwable th) {
            ApmHelper.reportCustomError("settings request error", "settings", th);
        }
    }

    @Override // com.bytedance.sdk.openadsdk.core.settings.ef.fm
    public void fm(boolean z10) {
        Set<String> setVod;
        this.onz.set(false);
        no();
        if (z10) {
            HashMap map = new HashMap();
            Set<String> setCyr = cyr();
            if (setCyr != null && !setCyr.isEmpty()) {
                map.put(PglSSConfig.CUSTOMINFO_KEY_ALLOWED_FIELDS, setCyr);
            }
            String strGof = bx.gof();
            if (!TextUtils.isEmpty(strGof)) {
                map.put(PglSSConfig.CUSTOMINFO_KEY_TRANSFER_HOST, strGof);
            }
            if (com.bytedance.sdk.openadsdk.utils.ro.ro() && (setVod = ro().vod()) != null && !setVod.isEmpty()) {
                map.put(PglSSConfig.CUSTOMINFO_KEY_ADS_URL_BACKUP, setVod);
            } else {
                map.put(PglSSConfig.CUSTOMINFO_KEY_ADS_URL_BACKUP, new HashSet());
            }
            map.put(PglSSConfig.CUSTOMINFO_KEY_TARGET_IDC, lsa());
            com.bytedance.sdk.openadsdk.core.duv.lb.fm(map);
        }
    }

    public static void fm(vt.fm fmVar) {
        ConcurrentLinkedQueue<vt.fm> concurrentLinkedQueue = gqi;
        if (concurrentLinkedQueue.contains(fmVar)) {
            return;
        }
        concurrentLinkedQueue.add(fmVar);
    }
}
