Perfume Of Love v2.14.9版本的 MD5 值为:16011aefc5a55805771706ce3b259b4e

以下内容为反编译后的 n.java 源代码,内容仅作参考


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

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.SystemClock;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.util.Log;
import com.bytedance.sdk.component.utils.r;
import com.bytedance.sdk.openadsdk.common.TTAdDislikeToast;
import com.bytedance.sdk.openadsdk.core.o;
import com.bytedance.sdk.openadsdk.core.settings.d;
import com.bytedance.sdk.openadsdk.core.settings.k;
import com.bytedance.sdk.openadsdk.n.aa;
import com.bytedance.sdk.openadsdk.n.y;
import com.ironsource.mediationsdk.utils.IronSourceConstants;
import com.smaato.sdk.core.gdpr.CmpApiConstants;
import java.io.File;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import org.json.JSONObject;
public class n implements k.a {
    private final h e;
    private final j f;
    private final AtomicBoolean g;
    private volatile boolean h;
    private boolean i;
    private g j;
    private final Runnable k;
    private static final String c = aa.n();
    private static final com.bytedance.sdk.component.g.g d = new com.bytedance.sdk.component.g.g("TemplateReInitTask") {
        @Override
        public void run() {
            com.bytedance.sdk.component.adexpress.a.b.c.a().g();
            com.bytedance.sdk.component.adexpress.a.b.c.a().b(false);
            com.bytedance.sdk.component.adexpress.a.b.a.b();
            com.bytedance.sdk.component.adexpress.a.b.c.a().b();
        }
    };
    public static String a = null;
    public static String b = CmpApiConstants.IABTCF_TC_STRING;

    public static class a {
        static n a = new n();
    }

    private int b(boolean z) {
        return z ? 20 : 5;
    }

    private n() {
        this.e = new h();
        this.f = new j();
        this.g = new AtomicBoolean(false);
        this.h = false;
        this.i = false;
        this.k = new Runnable() {
            @Override
            public void run() {
                com.bytedance.sdk.component.utils.l.b("SdkSettings", "auto fetch task active, try fetch remote data");
                n.this.c(2);
                n.this.Y();
            }
        };
        try {
            Context a2 = o.a();
            IntentFilter intentFilter = new IntentFilter();
            if (r.a(a2)) {
                intentFilter.addAction("_tryFetRemoDat");
            } else {
                intentFilter.addAction("_dataChanged");
            }
            a2.registerReceiver(new b(), intentFilter);
        } catch (Exception e) {
            com.bytedance.sdk.component.utils.l.c("SdkSettings", "", e);
        }
    }

    public void a() {
        File file;
        try {
            com.bytedance.sdk.openadsdk.core.settings.b.a();
            this.f.c();
            this.e.c();
            Context a2 = o.a();
            if (Build.VERSION.SDK_INT >= 24) {
                file = new File(a2.getDataDir(), "shared_prefs");
            } else {
                file = new File(a2.getDatabasePath("1").getParentFile().getParentFile(), "shared_prefs");
            }
            File file2 = new File(file, "tt_sdk_settings.xml");
            if (file2.exists() && file2.isFile()) {
                String replace = file2.getName().replace(".xml", "");
                if (Build.VERSION.SDK_INT >= 24) {
                    a2.deleteSharedPreferences(replace);
                    return;
                }
                a2.getSharedPreferences(replace, 0).edit().clear().apply();
                com.bytedance.sdk.component.utils.f.c(file2);
            }
        } catch (Throwable unused) {
        }
    }

    private static void b(int i, boolean z) {
        Context a2 = o.a();
        if (a2 != null) {
            try {
                Intent intent = new Intent();
                intent.setPackage(a2.getPackageName());
                intent.setAction("_tryFetRemoDat");
                intent.putExtra("_force", z);
                intent.putExtra("_source", i);
                a2.sendBroadcast(intent);
            } catch (Throwable th) {
                Log.e("SdkSettings", "requestMainProcessFetchRemoteData: ", th);
            }
        }
    }

    private static void ab() {
        Context a2 = o.a();
        if (a2 != null) {
            try {
                Intent intent = new Intent();
                intent.setPackage(a2.getPackageName());
                intent.setAction("_dataChanged");
                a2.sendBroadcast(intent);
            } catch (Throwable th) {
                com.bytedance.sdk.component.utils.l.c("SdkSettings", "", th);
            }
        }
    }

    public static int a(Context context) {
        SharedPreferences c2;
        if (context == null || (c2 = c(context)) == null) {
            return -2;
        }
        if ((c2.getInt(CmpApiConstants.IABTCF_CMP_SDK_ID, Integer.MIN_VALUE) == Integer.MIN_VALUE && c2.getInt(CmpApiConstants.IABTCF_CMP_SDK_VERSION, Integer.MIN_VALUE) == Integer.MIN_VALUE) ? false : true) {
            return c2.getInt(CmpApiConstants.IABTCF_GDPR_APPLIES, -1);
        }
        return -2;
    }

    public static String b(Context context) {
        SharedPreferences c2;
        return (context == null || (c2 = c(context)) == null) ? "" : c2.getString(b, "");
    }

    private static SharedPreferences c(Context context) {
        try {
            return PreferenceManager.getDefaultSharedPreferences(context);
        } catch (Exception unused) {
            return null;
        }
    }

    public static n b() {
        return a.a;
    }

    public synchronized void c() {
        com.bytedance.sdk.component.utils.l.b("SdkSettings", "loadLocalData: ");
        long elapsedRealtime = SystemClock.elapsedRealtime();
        boolean z = !this.h;
        this.e.a(this.h);
        this.f.a(this.h);
        com.bytedance.sdk.openadsdk.core.settings.b.a(z);
        com.bytedance.sdk.openadsdk.core.h.b().d(C());
        this.h = true;
        com.bytedance.sdk.component.utils.l.a("SdkSettings", "loadLocalData: finished, used", Long.valueOf(SystemClock.elapsedRealtime() - elapsedRealtime), "ms");
        if (z && r.a(o.a())) {
            com.bytedance.sdk.openadsdk.core.l.b().postDelayed(new Runnable() {
                @Override
                public void run() {
                    n.this.c(1);
                    n.this.Y();
                }
            }, 1000L);
        }
    }

    public int d() {
        return this.f.a("max_tpl_cnts", 100);
    }

    public JSONObject e() {
        return (JSONObject) this.f.a("digest", null, d.a);
    }

    public long f() {
        return this.f.a("data_time", 0L);
    }

    public void g() {
        this.f.a().a("tt_sdk_settings").a("ab_test_param").a();
    }

    public void a(JSONObject jSONObject, d.a aVar) {
        if (jSONObject == null || !jSONObject.has("dyn_draw_engine_url")) {
            return;
        }
        j jVar = this.f;
        String str = c;
        String a2 = jVar.a("dyn_draw_engine_url", str);
        String optString = jSONObject.optString("dyn_draw_engine_url", str);
        if (!TextUtils.isEmpty(a2) && !TextUtils.isEmpty(optString) && !optString.equals(a2)) {
            com.bytedance.sdk.openadsdk.core.l.b().postDelayed(new Runnable() {
                @Override
                public void run() {
                    y.a(n.d);
                }
            }, 5000L);
        }
        aVar.a("dyn_draw_engine_url", optString);
    }

    public int a(String str) {
        if (str == null) {
            return 0;
        }
        return o.d().y(str).r;
    }

    public void b(JSONObject jSONObject, d.a aVar) {
        if (jSONObject.has("is_gdpr_user")) {
            int i = -1;
            int optInt = jSONObject.optInt("is_gdpr_user", -1);
            if (optInt == -1 || optInt == 1 || optInt == 0) {
                i = optInt;
            }
            aVar.a("isGdprUser", i);
        }
    }

    public boolean h() {
        return this.f.a("if_both_open", 0) == 1;
    }

    public boolean i() {
        return !(this.f.a("support_tnc", 1) == 0);
    }

    public String j() {
        return this.f.a("ab_test_version", "");
    }

    public int k() {
        return this.f.a("load_callback_strategy", 0);
    }

    public boolean l() {
        return this.f.a("support_mem_dynamic", 0) == 1;
    }

    public int m() {
        return this.f.a("loadedCallbackOpportunity", 0);
    }

    public String n() {
        return this.f.a("ab_test_param", "");
    }

    public g o() {
        g gVar = this.j;
        if (gVar != null) {
            return gVar;
        }
        g gVar2 = (g) this.e.a("mediation_init_conf", g.a, new d.b<g>() {
            @Override
            public g b(String str) {
                return new g(str);
            }
        });
        this.j = gVar2;
        return gVar2;
    }

    public boolean p() {
        return this.f.a("landingpage_new_style", -1) == 1;
    }

    public long q() {
        return this.f.a(IronSourceConstants.EVENTS_DURATION, 10000L);
    }

    public int r() {
        return this.f.a("max", 50);
    }

    public String s() {
        return this.f.a("pyload_h5", (String) null);
    }

    public e t() {
        return (e) this.f.a("insert_js_config", e.a, new d.b<e>() {
            @Override
            public e b(String str) {
                return new e(str);
            }
        });
    }

    public String u() {
        return this.f.a("playableLoadH5Url", "");
    }

    public int v() {
        int a2 = this.f.a("fetch_tpl_timeout_ctrl", 3000);
        if (a2 <= 0) {
            return 3000;
        }
        return a2;
    }

    public void w() {
        if (Build.VERSION.SDK_INT >= 17) {
            String ac = ac();
            if (TextUtils.isEmpty(ac)) {
                return;
            }
            if (ac.equals("zh-Hant")) {
                com.bytedance.sdk.component.utils.i.a(o.a(), "zh", "tw");
            } else {
                com.bytedance.sdk.component.utils.i.a(o.a(), ac, null);
            }
            TTAdDislikeToast.a();
        }
    }

    private String ac() {
        return this.f.a("force_language", "");
    }

    public int x() {
        return this.f.a("disable_rotate_banner_on_dislike", Integer.MAX_VALUE);
    }

    public boolean b(String str) {
        return y(str).c == 1;
    }

    public boolean c(String str) {
        return y(str).B;
    }

    public boolean d(String str) {
        int i = y(str).e;
        if (i != 1) {
            return i == 2 && com.bytedance.sdk.component.utils.o.c(o.a()) != 0;
        }
        return com.bytedance.sdk.component.utils.o.d(o.a());
    }

    public boolean e(String str) {
        return y(str).g == 1;
    }

    public int f(String str) {
        return y(str).q;
    }

    public boolean g(String str) {
        return str == null || y(str).m == 1;
    }

    public int h(String str) {
        if (str == null) {
            return 1500;
        }
        return y(str).o;
    }

    public int i(String str) {
        return y(str).k;
    }

    public boolean j(String str) {
        try {
            return y(str).v != null;
        } catch (Exception e) {
            Log.e("SdkSettings", "haveTplIds: ", e);
            return false;
        }
    }

    public boolean k(String str) {
        try {
            return y(str).w == 8;
        } catch (Exception e) {
            com.bytedance.sdk.component.utils.l.c("SdkSettings", "", e);
            return false;
        }
    }

    public boolean y() {
        return this.f.b();
    }

    public int l(String str) {
        return y(String.valueOf(str)).h;
    }

    public boolean m(String str) {
        return l(str) != 1;
    }

    public int n(String str) {
        return y(str).j;
    }

    public int a(String str, boolean z) {
        if (str == null) {
            return b(z);
        }
        com.bytedance.sdk.openadsdk.core.settings.a y = y(str);
        return y.x != -1 ? y.x : b(z);
    }

    public boolean o(String str) {
        return y(str).u == 0;
    }

    public boolean p(String str) {
        return str == null || y(str).l == 1;
    }

    public String z() {
        return this.f.a("ads_url", "");
    }

    public String A() {
        return this.f.a("app_log_url", "");
    }

    public String B() {
        return this.f.a("apm_url", "");
    }

    public int C() {
        return this.f.a("coppa", -99);
    }

    public String D() {
        return this.f.a("policy_url", "");
    }

    public String E() {
        return this.f.a("consent_url", "https://lf-hs-sg.ibytedtos.com/obj/union-platform-i18n/union_platform_gdpr_607_en.html");
    }

    public int F() {
        return this.f.a("ivrv_downward", 0);
    }

    public String G() {
        return this.f.a("dyn_draw_engine_url", c);
    }

    public String H() {
        return this.f.a("dc", "");
    }

    public int I() {
        return this.f.a("isGdprUser", -1);
    }

    public int a(int i) {
        return y(String.valueOf(i)).b;
    }

    public int b(int i) {
        return y(String.valueOf(i)).i;
    }

    public int J() {
        return this.f.a("vbtt", 5);
    }

    public int q(String str) {
        return y(str).s;
    }

    public boolean r(String str) {
        return y(str).t;
    }

    public int s(String str) {
        return y(str).y;
    }

    public int t(String str) {
        return y(str).z;
    }

    public int u(String str) {
        return y(str).A;
    }

    public boolean v(String str) {
        return y(str).C;
    }

    public boolean w(String str) {
        return y(str).D;
    }

    public boolean x(String str) {
        return o.d().y(str).n == 1;
    }

    public com.bytedance.sdk.openadsdk.core.settings.a y(String str) {
        return com.bytedance.sdk.openadsdk.core.settings.b.a(str);
    }

    public void z(String str) {
        com.bytedance.sdk.openadsdk.core.settings.b.b(str);
    }

    public boolean K() {
        int a2 = this.f.a("privacy_ad_enable", Integer.MAX_VALUE);
        if (a2 == 1) {
            return true;
        }
        if (a2 == 0) {
            return false;
        }
        int p = aa.p();
        return p == 1 || p == 2 || p == 3;
    }

    public int L() {
        int a2 = this.f.a("privacy_personalized_ad", Integer.MAX_VALUE);
        if (a2 != Integer.MAX_VALUE) {
            return a2;
        }
        int p = aa.p();
        if (p == 1 || p == 2) {
            return 2;
        }
        return p != 3 ? 0 : 1;
    }

    public boolean M() {
        return this.f.a("privacy_sladar_enable", Integer.MAX_VALUE) == 1;
    }

    public boolean N() {
        if ("VA".equalsIgnoreCase(H()) || aa.p() == 3) {
            return false;
        }
        int a2 = this.f.a("privacy_sec_enable", Integer.MAX_VALUE);
        if (a2 == 1) {
            return true;
        }
        if (a2 == 0) {
            return false;
        }
        int p = aa.p();
        return p == 1 || p == 2 || p == 3;
    }

    public boolean O() {
        return this.f.a("privacy_debug_unlock", 1) != 0;
    }

    public boolean A(String str) {
        Set set = (Set) this.f.a("privacy_fields_allowed", Collections.emptySet(), d.b);
        if (set.isEmpty()) {
            int p = aa.p();
            if (p != 1) {
                if (p == 2 || p == 3) {
                    return "mcc".equals(str) || "mnc".equals(str);
                }
                return false;
            }
            return true;
        }
        return set.contains(str);
    }

    public boolean P() {
        return this.h;
    }

    public boolean Q() {
        return this.f.a("global_rate", 1.0f) == 1.0f;
    }

    public boolean R() {
        return this.f.a("read_video_from_cache", 1) == 1;
    }

    public int S() {
        int a2 = this.f.a("webview_cache_count", 20);
        if (a2 < 0) {
            return 20;
        }
        return a2;
    }

    public int T() {
        return this.f.a("blank_detect_rate", 30);
    }

    public JSONObject U() {
        return (JSONObject) this.f.a("video_cache_config", null, d.a);
    }

    public long V() {
        long a2 = this.f.a("req_inter_min", 600000L);
        if (a2 < 0 || a2 > 86400000) {
            return 600000L;
        }
        return a2;
    }

    public long W() {
        return this.f.a("last_req_time", 0L);
    }

    public void a(long j) {
        this.f.a().a("last_req_time", j).a();
    }

    public void X() {
        this.i = true;
    }

    void Y() {
        if (r.a(o.a())) {
            com.bytedance.sdk.openadsdk.core.l.b().removeCallbacks(this.k);
            long V = o.d().V();
            com.bytedance.sdk.component.utils.l.b("SdkSettings", "scheduleAutoFetchTask, nextTimeDelay=" + V);
            com.bytedance.sdk.openadsdk.core.l.b().postDelayed(this.k, V);
        }
    }

    public void c(int i) {
        a(i, false);
    }

    public void a(int i, boolean z) {
        try {
            if (ad()) {
                return;
            }
            long W = o.d().W();
            long currentTimeMillis = System.currentTimeMillis();
            long V = o.d().V();
            long j = currentTimeMillis - W;
            Log.d("SdkSettings", "fetchRemoteSdkSettings: lastReq=" + W + ", dis=" + j + "/" + V + ", force=" + z + ", source=" + i);
            if (!z && j < V) {
                com.bytedance.sdk.openadsdk.core.f.a.a();
            } else if (!r.a(o.a())) {
                b(i, z);
            } else if (!this.g.compareAndSet(false, true)) {
                Log.d("SdkSettings", "fetchRemoteSdkSettings: already requesting");
            } else {
                y.b(new k(this, this.f, this.e));
                com.bytedance.sdk.openadsdk.core.l.b().removeCallbacks(this.k);
            }
        } catch (Throwable th) {
            com.bytedance.sdk.component.utils.l.a("SdkSettings", "load sdk settings error: ", th);
        }
    }

    private boolean ad() {
        return TextUtils.isEmpty(com.bytedance.sdk.openadsdk.core.h.b().d());
    }

    @Override
    public void a(boolean z) {
        Log.d("SdkSettings", "onFetchFinish() called with: dataChanged = [" + z + "]");
        this.g.set(false);
        Y();
        if (z) {
            ab();
        }
    }

    public static void Z() {
        ab();
    }

    private class b extends BroadcastReceiver {
        private final Handler b;

        private b() {
            this.b = new Handler(Looper.getMainLooper()) {
                @Override
                public void handleMessage(Message message) {
                    super.handleMessage(message);
                    y.b(new com.bytedance.sdk.component.g.g("LoadLocalData") {
                        @Override
                        public void run() {
                            try {
                                n.this.c();
                            } catch (Exception e) {
                                Log.e("SdkSettings", "", e);
                            }
                        }
                    });
                }
            };
        }

        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent == null) {
                return;
            }
            String action = intent.getAction();
            com.bytedance.sdk.component.utils.l.b("SdkSettings", "onReceive: action=" + action);
            if ("_tryFetRemoDat".equals(action)) {
                n.this.a(intent.getIntExtra("_source", 0), intent.getBooleanExtra("_force", false));
            } else if ("_dataChanged".equals(action)) {
                this.b.removeMessages(0);
                this.b.sendEmptyMessageDelayed(0, 10000L);
            }
        }
    }
}