得物.apk(点击下载) / a.java


package com.tencent.bugly.crashreport.common.strategy;

import android.content.Context;
import com.tencent.bugly.crashreport.biz.b;
import com.tencent.bugly.proguard.ar;
import com.tencent.bugly.proguard.as;
import com.tencent.bugly.proguard.o;
import com.tencent.bugly.proguard.p;
import com.tencent.bugly.proguard.r;
import com.tencent.bugly.proguard.w;
import com.tencent.bugly.proguard.x;
import com.tencent.bugly.proguard.z;
import java.util.List;
import java.util.Map;

/* compiled from: BUGLY */
public final class a {

    /* renamed from: a  reason: collision with root package name */
    public static int f26508a = 1000;
    private static a b;

    /* renamed from: h  reason: collision with root package name */
    private static String f26509h;

    /* renamed from: c  reason: collision with root package name */
    private final List<com.tencent.bugly.a> f26510c;
    private final w d;
    private final StrategyBean e;
    private StrategyBean f;

    /* renamed from: g  reason: collision with root package name */
    private Context f26511g;

    private a(Context context, List<com.tencent.bugly.a> list) {
        String str;
        this.f26511g = context;
        if (com.tencent.bugly.crashreport.common.info.a.a(context) != null) {
            String str2 = com.tencent.bugly.crashreport.common.info.a.a(context).z;
            if ("oversea".equals(str2)) {
                str = "http://astat.bugly.qcloud.com/rqd/async";
            } else if ("na_https".equals(str2)) {
                str = "https://astat.bugly.cros.wr.pvp.net/:8180/rqd/async";
            } else if ("na_http".equals(str2)) {
                str = "http://astat.bugly.cros.wr.pvp.net/:8180/rqd/async";
            }
            StrategyBean.b = str;
            StrategyBean.f26502c = str;
        }
        this.e = new StrategyBean();
        this.f26510c = list;
        this.d = w.a();
    }

    public static StrategyBean d() {
        byte[] bArr;
        List<r> a5 = p.a().a(2);
        if (a5 == null || a5.size() <= 0 || (bArr = a5.get(0).f26895g) == null) {
            return null;
        }
        return (StrategyBean) z.a(bArr, StrategyBean.CREATOR);
    }

    public final StrategyBean c() {
        StrategyBean strategyBean = this.f;
        if (strategyBean != null) {
            if (!z.c(strategyBean.r)) {
                this.f.r = StrategyBean.b;
            }
            if (!z.c(this.f.s)) {
                this.f.s = StrategyBean.f26502c;
            }
            return this.f;
        }
        if (!z.a(f26509h) && z.c(f26509h)) {
            StrategyBean strategyBean2 = this.e;
            String str = f26509h;
            strategyBean2.r = str;
            strategyBean2.s = str;
        }
        return this.e;
    }

    public final synchronized boolean b() {
        return this.f != null;
    }

    public static synchronized a a(Context context, List<com.tencent.bugly.a> list) {
        a aVar;
        synchronized (a.class) {
            if (b == null) {
                b = new a(context, list);
            }
            aVar = b;
        }
        return aVar;
    }

    public final void a(long j) {
        this.d.a(new Thread() {
            /* class com.tencent.bugly.crashreport.common.strategy.a.AnonymousClass1 */

            public final void run() {
                try {
                    Map<String, byte[]> a5 = p.a().a(a.f26508a, (o) null, true);
                    if (a5 != null) {
                        byte[] bArr = a5.get("device");
                        byte[] bArr2 = a5.get("gateway");
                        if (bArr != null) {
                            com.tencent.bugly.crashreport.common.info.a.a(a.this.f26511g).e(new String(bArr));
                        }
                        if (bArr2 != null) {
                            com.tencent.bugly.crashreport.common.info.a.a(a.this.f26511g).d(new String(bArr2));
                        }
                    }
                    a.this.f = a.d();
                    if (a.this.f != null) {
                        if (z.a(a.f26509h) || !z.c(a.f26509h)) {
                            a.this.f.r = StrategyBean.b;
                            a.this.f.s = StrategyBean.f26502c;
                        } else {
                            a.this.f.r = a.f26509h;
                            a.this.f.s = a.f26509h;
                        }
                    }
                } catch (Throwable th2) {
                    if (!x.a(th2)) {
                        th2.printStackTrace();
                    }
                }
                a aVar = a.this;
                aVar.a(aVar.f, false);
            }
        }, j);
    }

    public static synchronized a a() {
        a aVar;
        synchronized (a.class) {
            aVar = b;
        }
        return aVar;
    }

    public final void a(StrategyBean strategyBean, boolean z) {
        x.c("[Strategy] Notify %s", b.class.getName());
        b.a(strategyBean, z);
        for (com.tencent.bugly.a aVar : this.f26510c) {
            try {
                x.c("[Strategy] Notify %s", aVar.getClass().getName());
                aVar.onServerStrategyChanged(strategyBean);
            } catch (Throwable th2) {
                if (!x.a(th2)) {
                    th2.printStackTrace();
                }
            }
        }
    }

    public static void a(String str) {
        if (z.a(str) || !z.c(str)) {
            x.d("URL user set is invalid.", new Object[0]);
        } else {
            f26509h = str;
        }
    }

    public final void a(as asVar) {
        if (asVar != null) {
            StrategyBean strategyBean = this.f;
            if (strategyBean == null || asVar.f26858h != strategyBean.p) {
                StrategyBean strategyBean2 = new StrategyBean();
                strategyBean2.f26503g = asVar.f26855a;
                strategyBean2.i = asVar.f26856c;
                strategyBean2.f26504h = asVar.b;
                if (z.a(f26509h) || !z.c(f26509h)) {
                    if (z.c(asVar.d)) {
                        x.c("[Strategy] Upload url changes to %s", asVar.d);
                        strategyBean2.r = asVar.d;
                    }
                    if (z.c(asVar.e)) {
                        x.c("[Strategy] Exception upload url changes to %s", asVar.e);
                        strategyBean2.s = asVar.e;
                    }
                }
                ar arVar = asVar.f;
                if (arVar != null && !z.a(arVar.f26854a)) {
                    strategyBean2.f26506u = asVar.f.f26854a;
                }
                long j = asVar.f26858h;
                if (j != 0) {
                    strategyBean2.p = j;
                }
                Map<String, String> map = asVar.f26857g;
                if (map != null && map.size() > 0) {
                    Map<String, String> map2 = asVar.f26857g;
                    strategyBean2.f26507v = map2;
                    String str = map2.get("B11");
                    if (str == null || !str.equals("1")) {
                        strategyBean2.j = false;
                    } else {
                        strategyBean2.j = true;
                    }
                    String str2 = asVar.f26857g.get("B3");
                    if (str2 != null) {
                        strategyBean2.y = Long.valueOf(str2).longValue();
                    }
                    int i = asVar.i;
                    strategyBean2.f26505q = (long) i;
                    strategyBean2.x = (long) i;
                    String str3 = asVar.f26857g.get("B27");
                    if (str3 != null && str3.length() > 0) {
                        try {
                            int parseInt = Integer.parseInt(str3);
                            if (parseInt > 0) {
                                strategyBean2.w = parseInt;
                            }
                        } catch (Exception e6) {
                            if (!x.a(e6)) {
                                e6.printStackTrace();
                            }
                        }
                    }
                    String str4 = asVar.f26857g.get("B25");
                    if (str4 == null || !str4.equals("1")) {
                        strategyBean2.l = false;
                    } else {
                        strategyBean2.l = true;
                    }
                }
                x.a("[Strategy] enableCrashReport:%b, enableQuery:%b, enableUserInfo:%b, enableAnr:%b, enableBlock:%b, enableSession:%b, enableSessionTimer:%b, sessionOverTime:%d, enableCocos:%b, strategyLastUpdateTime:%d", Boolean.valueOf(strategyBean2.f26503g), Boolean.valueOf(strategyBean2.i), Boolean.valueOf(strategyBean2.f26504h), Boolean.valueOf(strategyBean2.j), Boolean.valueOf(strategyBean2.k), Boolean.valueOf(strategyBean2.n), Boolean.valueOf(strategyBean2.o), Long.valueOf(strategyBean2.f26505q), Boolean.valueOf(strategyBean2.l), Long.valueOf(strategyBean2.p));
                this.f = strategyBean2;
                if (!z.c(asVar.d)) {
                    x.c("[Strategy] download url is null", new Object[0]);
                    this.f.r = "";
                }
                if (!z.c(asVar.e)) {
                    x.c("[Strategy] download crashurl is null", new Object[0]);
                    this.f.s = "";
                }
                p.a().b(2);
                r rVar = new r();
                rVar.b = 2;
                rVar.f26893a = strategyBean2.e;
                rVar.e = strategyBean2.f;
                rVar.f26895g = z.a(strategyBean2);
                p.a().a(rVar);
                a(strategyBean2, true);
            }
        }
    }
}