翰林优商.apk(点击下载) / i.java


package com.sigmob.sdk.base;

import aegon.chrome.base.TimeUtils;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import com.czhj.sdk.common.ClientMetadata;
import com.czhj.sdk.common.models.Config;
import com.czhj.sdk.common.network.Networking;
import com.czhj.sdk.common.network.SigmobRequestQueue;
import com.czhj.sdk.logger.SigmobLog;
import com.czhj.volley.VolleyError;
import com.czhj.wire.Wire;
import com.sigmob.sdk.b;
import com.sigmob.sdk.base.models.config.Android;
import com.sigmob.sdk.base.models.config.Common;
import com.sigmob.sdk.base.models.config.CommonEndpointsConfig;
import com.sigmob.sdk.base.models.config.DialogSetting;
import com.sigmob.sdk.base.models.config.NativeConfig;
import com.sigmob.sdk.base.models.config.RvConfig;
import com.sigmob.sdk.base.models.config.SdkConfig;
import com.sigmob.sdk.base.models.config.SdkConfigResponse;
import com.sigmob.sdk.base.models.config.SplashConfig;
import com.sigmob.sdk.base.network.d;
import com.sigmob.sdk.base.utils.c;
import com.sigmob.windad.WindAdOptions;
import com.sigmob.windad.WindAds;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.List;

public class i {
    private static final String a = "sdkConfigVer";
    private static i b = null;
    private static boolean c = false;
    private final Handler d = new Handler(Looper.getMainLooper());
    private final Runnable e = new Runnable() {
        /* class com.sigmob.sdk.base.i.AnonymousClass1 */

        public void run() {
            i.this.S();
        }
    };
    private final String f = "4.3.0";
    private boolean g = true;
    private long h = 0;
    private SdkConfig i = null;
    private SdkConfig j = null;
    private a k;

    public interface a {
        void a();
    }

    private i() {
        R();
    }

    private void R() {
        if (this.i == null) {
            SdkConfig.Builder builder = new SdkConfig.Builder();
            Common.Builder builder2 = new Common.Builder();
            Android.Builder builder3 = new Android.Builder();
            builder2.endpoints(new CommonEndpointsConfig.Builder().build());
            RvConfig.Builder builder4 = new RvConfig.Builder();
            builder4.cacheTop(4);
            builder2.rv_config(builder4.build());
            builder2.configRefresh(1000);
            builder2.disable_up_location(true);
            builder2.is_gdpr_region(false);
            builder2.enable_debug_level(false);
            builder3.disable_boot_mark(true);
            builder3.disableUpAppInfo(true);
            builder3.oaid_api_is_disable(true);
            builder3.enable_permission(false);
            builder3.enable_report_crash(false);
            builder.common_config(builder2.build());
            builder.android_config(builder3.build());
            this.i = builder.build();
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void S() {
        if (b.b() != null) {
            if (!ClientMetadata.getInstance().isNetworkConnected(c()) || !c.a().i()) {
                SigmobLog.d("Can't load an ad because there is no network connectivity.");
                V();
                return;
            }
            T();
        }
    }

    private void T() {
        SigmobRequestQueue requestQueue = Networking.getRequestQueue();
        d dVar = new d(c(), new d.a() {
            /* class com.sigmob.sdk.base.i.AnonymousClass2 */

            @Override // com.sigmob.sdk.base.network.d.a
            public void a(SdkConfigResponse sdkConfigResponse) {
                SigmobLog.d(sdkConfigResponse.toString());
                SdkConfig sdkConfig = sdkConfigResponse.config;
                if (sdkConfig != null) {
                    i.this.b((i) sdkConfig);
                    i.this.a((i) sdkConfig);
                } else {
                    SigmobLog.e(sdkConfigResponse.error_message);
                }
                i.this.V();
            }

            @Override // com.czhj.volley.Response.ErrorListener
            public void onErrorResponse(VolleyError volleyError) {
                SigmobLog.e(volleyError.toString());
                i.this.V();
            }
        });
        if (requestQueue == null) {
            SigmobLog.e("queue is null");
            V();
            return;
        }
        requestQueue.add(dVar);
        SigmobLog.i("update sdk config");
    }

    private void U() {
        this.d.removeCallbacks(this.e);
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void V() {
        U();
        if (this.g) {
            this.d.postDelayed(this.e, Math.max(30000L, this.h));
        }
    }

    private SplashConfig W() {
        if (i() != null) {
            return i().splash_config;
        }
        return null;
    }

    private NativeConfig X() {
        if (i() != null) {
            return i().native_config;
        }
        return null;
    }

    public static i a() {
        if (b == null) {
            synchronized (i.class) {
                if (b == null) {
                    b = new i();
                }
            }
        }
        return b;
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    /* JADX WARNING: Removed duplicated region for block: B:20:0x0063  */
    /* JADX WARNING: Removed duplicated region for block: B:24:0x0072 A[SYNTHETIC, Splitter:B:24:0x0072] */
    /* JADX WARNING: Removed duplicated region for block: B:30:? A[RETURN, SYNTHETIC] */
    private void a(SdkConfig sdkConfig) {
        Throwable th;
        IOException e2;
        if (sdkConfig != null) {
            ObjectOutputStream objectOutputStream = null;
            File file = new File(com.sigmob.sdk.base.utils.b.a() + "/config");
            if (file.exists()) {
                file.delete();
            }
            file.getParentFile().mkdirs();
            try {
                ObjectOutputStream objectOutputStream2 = new ObjectOutputStream(new FileOutputStream(file));
                try {
                    sdkConfig.encode(objectOutputStream2);
                    c.a().edit().putString(a, "4.3.0").apply();
                    try {
                        objectOutputStream2.close();
                    } catch (IOException e3) {
                        SigmobLog.e(e3.getMessage());
                    }
                } catch (IOException e4) {
                    e2 = e4;
                    objectOutputStream = objectOutputStream2;
                    try {
                        SigmobLog.e(e2.getMessage());
                        if (objectOutputStream == null) {
                        }
                    } catch (Throwable th2) {
                        th = th2;
                        if (objectOutputStream != null) {
                            try {
                                objectOutputStream.close();
                            } catch (IOException e5) {
                                SigmobLog.e(e5.getMessage());
                            }
                        }
                        throw th;
                    }
                } catch (Throwable th3) {
                    th = th3;
                    objectOutputStream = objectOutputStream2;
                    if (objectOutputStream != null) {
                    }
                    throw th;
                }
            } catch (IOException e6) {
                e2 = e6;
                SigmobLog.e(e2.getMessage());
                if (objectOutputStream == null) {
                    objectOutputStream.close();
                }
            }
        }
    }

    public static String b() {
        return "appId=" + WindAds.sharedAds().getAppId() + "&" + "sdkVersion=4.3.0";
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void b(SdkConfig sdkConfig) {
        if (sdkConfig != null && sdkConfig.common_config != null) {
            this.j = sdkConfig;
            c = sdkConfig.common_config.is_gdpr_region.booleanValue();
            this.h = (long) (this.j.common_config.configRefresh.intValue() * 1000);
            a aVar = this.k;
            if (aVar != null) {
                aVar.a();
            }
            Config.sharedInstance().update(c, P(), O(), K(), k(), C(), B());
        }
    }

    public static String c() {
        String str;
        WindAdOptions options = WindAds.sharedAds().getOptions();
        if (options == null || options.getExtData() == null || (str = options.getExtData().get(h.d)) == null || TextUtils.isEmpty(str)) {
            if (!TextUtils.isEmpty(h.f)) {
                return h.f + "?" + b();
            }
            return "https://adservice.sigmob.cn/sigmob/config?" + b();
        } else if (str.indexOf(63) == -1) {
            return str + "?" + b();
        } else {
            return str + "&" + b();
        }
    }

    public static String d() {
        return "https://adservice.sigmob.cn/extconfig?" + b();
    }

    public static boolean g() {
        return c;
    }

    public int A() {
        int i2 = 10;
        int intValue = i() != null ? ((Integer) Wire.get(i().tracking_retry_interval, 180)).intValue() : 10;
        if (intValue >= 10) {
            i2 = intValue;
        }
        return i2 * 1000;
    }

    public int B() {
        int intValue = i() != null ? ((Integer) Wire.get(i().max_send_log_records, 10)).intValue() : 10;
        if (intValue < 10) {
            return 10;
        }
        return intValue;
    }

    public int C() {
        int intValue;
        if (i() == null || (intValue = ((Integer) Wire.get(i().send_log_interval, 3)).intValue()) < 3) {
            return 3;
        }
        return intValue;
    }

    public List<Integer> D() {
        if (i() != null) {
            return i().dclog_blacklist;
        }
        return null;
    }

    public boolean E() {
        if (i() != null) {
            return ((Boolean) Wire.get(i().enable_debug_level, false)).booleanValue();
        }
        return false;
    }

    public long F() {
        if (i() == null) {
            return 0;
        }
        long intValue = (long) ((Integer) Wire.get(i().load_interval, 0)).intValue();
        if (intValue < 1) {
            return 0;
        }
        return intValue * 1000;
    }

    public boolean G() {
        if (i() != null) {
            return ((Boolean) Wire.get(i().disable_up_location, false)).booleanValue();
        }
        return true;
    }

    public boolean H() {
        if (j() != null) {
            return ((Boolean) Wire.get(j().disableUpAppInfo, false)).booleanValue();
        }
        return true;
    }

    public int I() {
        if (j() != null) {
            return ((Integer) Wire.get(j().report_log, 0)).intValue();
        }
        return 0;
    }

    public boolean J() {
        Android j2 = j();
        return j2 != null && ((Integer) Wire.get(j2.up_wifi_list_interval, 0)).intValue() >= 60;
    }

    public int K() {
        if (j() != null) {
            return ((Integer) Wire.get(j().disable_up_oaid, 0)).intValue();
        }
        return 0;
    }

    public boolean L() {
        if (j() != null) {
            return ((Boolean) Wire.get(j().enable_permission, false)).booleanValue();
        }
        return false;
    }

    public int M() {
        if (j() != null) {
            return ((Integer) Wire.get(j().apk_expired_time, 0)).intValue();
        }
        return 0;
    }

    public boolean N() {
        if (j() != null) {
            return ((Boolean) Wire.get(j().enable_report_crash, false)).booleanValue();
        }
        return false;
    }

    public boolean O() {
        if (j() != null) {
            return ((Boolean) Wire.get(j().oaid_api_is_disable, false)).booleanValue();
        }
        return true;
    }

    public boolean P() {
        if (j() != null) {
            return ((Boolean) Wire.get(j().disable_boot_mark, false)).booleanValue();
        }
        return true;
    }

    public int Q() {
        return 20;
    }

    public i a(a aVar) {
        this.k = aVar;
        return b;
    }

    public boolean a(String str) {
        if (!v() || i().anti_fraud_log.events == null) {
            return false;
        }
        return i().anti_fraud_log.events.contains(str);
    }

    /* JADX WARNING: Removed duplicated region for block: B:16:0x005e  */
    /* JADX WARNING: Removed duplicated region for block: B:28:? A[RETURN, SYNTHETIC] */
    public void e() {
        Throwable th;
        ObjectInputStream objectInputStream = null;
        String string = c.a().getString(a, null);
        File file = new File(com.sigmob.sdk.base.utils.b.a() + "/config");
        if (!"4.3.0".equals(string) || !file.exists()) {
            b(this.i);
            return;
        }
        try {
            ObjectInputStream objectInputStream2 = new ObjectInputStream(new FileInputStream(file));
            try {
                b(SdkConfig.ADAPTER.decode(objectInputStream2));
                try {
                    objectInputStream2.close();
                    return;
                } catch (Throwable th2) {
                    SigmobLog.e(th2.getMessage());
                    return;
                }
            } catch (Throwable th3) {
                th = th3;
                objectInputStream = objectInputStream2;
                try {
                    b(this.i);
                    SigmobLog.e(th.getMessage());
                    if (objectInputStream == null) {
                        objectInputStream.close();
                        return;
                    }
                    return;
                } catch (Throwable th4) {
                    SigmobLog.e(th4.getMessage());
                }
            }
        } catch (Throwable th5) {
            th = th5;
            b(this.i);
            SigmobLog.e(th.getMessage());
            if (objectInputStream == null) {
            }
        }
        throw th;
    }

    public void f() {
        U();
        this.d.post(this.e);
    }

    public SdkConfig h() {
        SdkConfig sdkConfig = this.j;
        return sdkConfig == null ? this.i : sdkConfig;
    }

    public Common i() {
        if (h() == null) {
            return null;
        }
        return h().common_config;
    }

    public Android j() {
        if (h() == null) {
            return null;
        }
        return h().android_config;
    }

    public String k() {
        StringBuilder sb;
        String str;
        String str2 = i().endpoints.log;
        if (TextUtils.isEmpty(str2)) {
            str2 = "https://dc.sigmob.cn/log";
        }
        if (str2.indexOf(63) == -1) {
            sb = new StringBuilder();
            sb.append(str2);
            str = "?";
        } else {
            sb = new StringBuilder();
            sb.append(str2);
            str = "&";
        }
        sb.append(str);
        sb.append(b());
        return sb.toString();
    }

    public String l() {
        StringBuilder sb;
        String str;
        String str2 = i().endpoints.ads;
        if (TextUtils.isEmpty(str2)) {
            str2 = "https://adservice.sigmob.cn/ad/v4";
        }
        if (str2.indexOf(63) == -1) {
            sb = new StringBuilder();
            sb.append(str2);
            str = "?";
        } else {
            sb = new StringBuilder();
            sb.append(str2);
            str = "&";
        }
        sb.append(str);
        sb.append(b());
        return sb.toString();
    }

    public String m() {
        StringBuilder sb;
        String str;
        String str2 = i().endpoints.hb_ads;
        if (TextUtils.isEmpty(str2)) {
            str2 = "https://adservice.sigmob.cn/hb/v2/ad";
        }
        if (str2.indexOf(63) == -1) {
            sb = new StringBuilder();
            sb.append(str2);
            str = "?";
        } else {
            sb = new StringBuilder();
            sb.append(str2);
            str = "&";
        }
        sb.append(str);
        sb.append(b());
        return sb.toString();
    }

    public RvConfig n() {
        if (i() != null) {
            return i().rv_config;
        }
        return null;
    }

    public int o() {
        if (n() != null) {
            return ((Integer) Wire.get(n().cacheTop, 5)).intValue();
        }
        return 5;
    }

    public long p() {
        if (n() == null) {
            return 45000;
        }
        int intValue = ((Integer) Wire.get(n().ad_load_timeout, 45)).intValue();
        if (intValue < 10) {
            intValue = 10;
        }
        return (long) (intValue * 1000);
    }

    public DialogSetting q() {
        if (n() != null) {
            return n().close_dialog_setting;
        }
        return null;
    }

    public int r() {
        if (W() == null) {
            return 50;
        }
        return ((Integer) Wire.get(W().cacheTop, 50)).intValue();
    }

    public long s() {
        int i2 = 2;
        if (W() != null) {
            i2 = ((Integer) Wire.get(W().material_expired_time, 2)).intValue();
        }
        return i2 < 0 ? (long) i2 : ((long) i2) * 24 * 60 * 60 * 1000;
    }

    public int t() {
        if (X() != null) {
            return ((Integer) Wire.get(X().cacheTop, 50)).intValue();
        }
        return 50;
    }

    public long u() {
        if (X() == null) {
            return 45000;
        }
        int intValue = X().ad_load_timeout.intValue();
        if (intValue < 10) {
            intValue = 10;
        }
        return (long) (intValue * 1000);
    }

    public boolean v() {
        return (i() == null || i().anti_fraud_log == null || i().anti_fraud_log.events == null) ? false : true;
    }

    public int w() {
        if (!v() || i().anti_fraud_log.motion_config == null) {
            return 0;
        }
        return i().anti_fraud_log.motion_config.interval.intValue();
    }

    public int x() {
        if (!v() || i().anti_fraud_log.motion_config == null) {
            return 0;
        }
        return i().anti_fraud_log.motion_config.count.intValue();
    }

    public int y() {
        if (!v() || i().anti_fraud_log.motion_config == null) {
            return 0;
        }
        return i().anti_fraud_log.motion_config.queue_max.intValue() + -50 < i().anti_fraud_log.motion_config.count.intValue() * 2 ? (i().anti_fraud_log.motion_config.count.intValue() * 2) + 50 : i().anti_fraud_log.motion_config.queue_max.intValue();
    }

    public long z() {
        long j2 = 180;
        long intValue = i() != null ? (long) ((Integer) Wire.get(i().tracking_expiration_time, Integer.valueOf((int) TimeUtils.SECONDS_PER_DAY))).intValue() : 180;
        if (intValue >= 180) {
            j2 = intValue;
        }
        return j2 * 1000;
    }
}