50度灰 v5.8.2版本的 MD5 值为:9fe3d350fdc75fa1a3ec45509fa0107e

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


package com.flurry.sdk;

import android.content.Context;
import android.content.SharedPreferences;
import android.location.Location;
import android.os.Build;
import android.text.TextUtils;
import com.flurry.sdk.aq;
import com.flurry.sdk.az;
import com.flurry.sdk.di;
import com.flurry.sdk.dk;
import com.flurry.sdk.eh;
import com.lzy.okgo.model.HttpHeaders;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
public class as implements eh.a {
    private static final String f2563e = "as";
    public final cv<bt> f2565b;
    public final cv<bu> f2566c;
    public final cv<bx> f2567d;
    private ct<aq> k;
    private ct<List<az>> l;
    private boolean m;
    private String n;
    private boolean o;
    private boolean p;
    private long r;
    private boolean s;
    private af t;
    private boolean u;
    private final dg<ae> f2568f = new dg<>("proton config request", new be());
    private final dg<af> f2569g = new dg<>("proton config response", new bf());
    private final ar h = new ar();
    private final cq<String, ai> i = new cq<>();
    private final List<az> j = new ArrayList();
    private long f2570q = 10000;
    public final Runnable f2564a = new eo() {
        @Override
        public final void a() {
            as.this.e();
        }
    };

    public as() {
        this.o = true;
        cv<bt> cvVar = new cv<bt>() {
            @Override
            public final void a(bt btVar) {
                as.this.e();
            }
        };
        this.f2565b = cvVar;
        cv<bu> cvVar2 = new cv<bu>() {
            @Override
            public final void a(bu buVar) {
                as.this.e();
            }
        };
        this.f2566c = cvVar2;
        cv<bx> cvVar3 = new cv<bx>() {
            @Override
            public final void a(bx bxVar) {
                if (bxVar.f2823a) {
                    as.this.e();
                }
            }
        };
        this.f2567d = cvVar3;
        eg a2 = eg.a();
        this.m = ((Boolean) a2.a("ProtonEnabled")).booleanValue();
        a2.a("ProtonEnabled", (eh.a) this);
        String str = f2563e;
        db.a(4, str, "initSettings, protonEnabled = " + this.m);
        this.n = (String) a2.a("ProtonConfigUrl");
        a2.a("ProtonConfigUrl", (eh.a) this);
        db.a(4, str, "initSettings, protonConfigUrl = " + this.n);
        this.o = ((Boolean) a2.a("analyticsEnabled")).booleanValue();
        a2.a("analyticsEnabled", (eh.a) this);
        db.a(4, str, "initSettings, AnalyticsEnabled = " + this.o);
        cw.a().a("com.flurry.android.sdk.IdProviderFinishedEvent", cvVar);
        cw.a().a("com.flurry.android.sdk.IdProviderUpdatedAdvertisingId", cvVar2);
        cw.a().a("com.flurry.android.sdk.NetworkStateEvent", cvVar3);
        Context context = ck.a().f2892a;
        this.k = new ct<>(context.getFileStreamPath(".yflurryprotonconfig." + Long.toString(em.g(ck.a().f2893b), 16)), ".yflurryprotonconfig.", 1, new dz<aq>() {
            @Override
            public final dw<aq> a(int i) {
                return new aq.a();
            }
        });
        this.l = new ct<>(context.getFileStreamPath(".yflurryprotonreport." + Long.toString(em.g(ck.a().f2893b), 16)), ".yflurryprotonreport.", 1, new dz<List<az>>() {
            @Override
            public final dw<List<az>> a(int i) {
                return new dv(new az.a());
            }
        });
        ck.a().b(new eo() {
            @Override
            public final void a() {
                as.this.l();
            }
        });
        ck.a().b(new eo() {
            @Override
            public final void a() {
                as.this.m();
            }
        });
    }

    static boolean h(as asVar) {
        asVar.u = true;
        return true;
    }

    public synchronized void l() {
        af afVar;
        aq a2 = this.k.a();
        if (a2 != null) {
            af afVar2 = null;
            try {
                afVar = this.f2569g.c(a2.f2559c);
            } catch (Exception e2) {
                db.a(5, f2563e, "Failed to decode saved proton config response: ".concat(String.valueOf(e2)));
                this.k.b();
                afVar = null;
            }
            if (b(afVar)) {
                afVar2 = afVar;
            }
            if (afVar2 != null) {
                db.a(4, f2563e, "Loaded saved proton config response");
                this.f2570q = 10000L;
                this.r = a2.f2557a;
                this.s = a2.f2558b;
                this.t = afVar2;
                g();
            }
        }
        this.p = true;
        ck.a().b(new eo() {
            @Override
            public final void a() {
                as.this.e();
            }
        });
    }

    public synchronized void m() {
        db.a(4, f2563e, "Loading queued report data.");
        List<az> a2 = this.l.a();
        if (a2 != null) {
            this.j.addAll(a2);
        }
    }

    public synchronized void e() {
        if (this.m) {
            em.a();
            if (this.p) {
                if (bs.a().c()) {
                    final long currentTimeMillis = System.currentTimeMillis();
                    final boolean z = !bs.a().f();
                    if (this.t != null) {
                        if (this.s != z) {
                            db.a(3, f2563e, "Limit ad tracking value has changed, purging");
                            this.t = null;
                        } else if (System.currentTimeMillis() < this.r + (this.t.f2530b * 1000)) {
                            db.a(3, f2563e, "Cached Proton config valid, no need to refresh");
                            if (!this.u) {
                                this.u = true;
                                b("flurry.session_start", (Map<String, String>) null);
                            }
                            return;
                        } else {
                            long currentTimeMillis2 = System.currentTimeMillis();
                            long j = this.r;
                            long j2 = this.t.f2531c;
                            Long.signum(j2);
                            if (currentTimeMillis2 >= j + (j2 * 1000)) {
                                db.a(3, f2563e, "Cached Proton config expired, purging");
                                this.t = null;
                                this.i.a();
                            }
                        }
                    }
                    cg.a().a(this);
                    db.a(3, f2563e, "Requesting proton config");
                    ?? f2 = f();
                    if (f2 == 0) {
                        return;
                    }
                    di diVar = new di();
                    diVar.f3019g = TextUtils.isEmpty(this.n) ? "https://proton.flurry.com/sdk/v1/config" : this.n;
                    diVar.u = 5000;
                    diVar.h = dk.a.kPost;
                    String num = Integer.toString(dg.a(f2));
                    diVar.a("Content-Type", "application/x-flurry;version=2");
                    diVar.a(HttpHeaders.HEAD_KEY_ACCEPT, "application/x-flurry;version=2");
                    diVar.a("FM-Checksum", num);
                    diVar.f3005c = new ds();
                    diVar.f3006d = new ds();
                    diVar.f3004b = f2;
                    diVar.f3003a = new di.a<byte[], byte[]>() {
                        @Override
                        public final void a(di<byte[], byte[]> diVar2, byte[] bArr) {
                            af afVar;
                            final byte[] bArr2 = bArr;
                            int i = diVar2.f3020q;
                            db.a(3, as.f2563e, "Proton config request: HTTP status code is:".concat(String.valueOf(i)));
                            if (i == 400 || i == 406 || i == 412 || i == 415) {
                                as.this.f2570q = 10000L;
                                return;
                            }
                            if (diVar2.b() && bArr2 != null) {
                                ck.a().b(new eo() {
                                    @Override
                                    public final void a() {
                                        AnonymousClass2 anonymousClass2 = AnonymousClass2.this;
                                        as.this.a(currentTimeMillis, z, bArr2);
                                    }
                                });
                                try {
                                    afVar = (af) as.this.f2569g.c(bArr2);
                                } catch (Exception e2) {
                                    db.a(5, as.f2563e, "Failed to decode proton config response: ".concat(String.valueOf(e2)));
                                    afVar = null;
                                }
                                r5 = as.b(afVar) ? afVar : null;
                                if (r5 != null) {
                                    as.this.f2570q = 10000L;
                                    as.this.r = currentTimeMillis;
                                    as.this.s = z;
                                    as.this.t = r5;
                                    as.this.g();
                                    if (!as.this.u) {
                                        as.h(as.this);
                                        as.this.b("flurry.session_start", (Map<String, String>) null);
                                    }
                                    as.this.h();
                                }
                            }
                            if (r5 == null) {
                                long j3 = as.this.f2570q << 1;
                                if (i == 429) {
                                    List<String> a2 = diVar2.a("Retry-After");
                                    if (!a2.isEmpty()) {
                                        String str = a2.get(0);
                                        db.a(3, as.f2563e, "Server returned retry time: ".concat(String.valueOf(str)));
                                        try {
                                            j3 = Long.parseLong(str) * 1000;
                                        } catch (NumberFormatException unused) {
                                            db.a(3, as.f2563e, "Server returned nonsensical retry time");
                                        }
                                    }
                                }
                                as.this.f2570q = j3;
                                db.a(3, as.f2563e, "Proton config request failed, backing off: " + as.this.f2570q + "ms");
                                ck.a().a(as.this.f2564a, as.this.f2570q);
                            }
                        }
                    };
                    cg.a().a((Object) this, (as) diVar);
                }
            }
        }
    }

    private byte[] f() {
        try {
            ae aeVar = new ae();
            aeVar.f2522a = ck.a().f2893b;
            aeVar.f2523b = ej.a(ck.a().f2892a);
            aeVar.f2524c = ej.b(ck.a().f2892a);
            aeVar.f2525d = cl.b();
            aeVar.f2526e = 3;
            cb.a();
            aeVar.f2527f = cb.c();
            aeVar.f2528g = !bs.a().f();
            ah ahVar = new ah();
            aeVar.h = ahVar;
            ahVar.f2537a = new ab();
            ab abVar = aeVar.h.f2537a;
            abVar.f2504a = Build.MODEL;
            abVar.f2505b = Build.BRAND;
            abVar.f2506c = Build.ID;
            abVar.f2507d = Build.DEVICE;
            abVar.f2508e = Build.PRODUCT;
            abVar.f2509f = Build.VERSION.RELEASE;
            aeVar.i = new ArrayList();
            for (Map.Entry entry : Collections.unmodifiableMap(bs.a().f2792a).entrySet()) {
                ag agVar = new ag();
                agVar.f2535a = ((ca) entry.getKey()).f2854d;
                if (((ca) entry.getKey()).f2855e) {
                    agVar.f2536b = new String((byte[]) entry.getValue());
                } else {
                    agVar.f2536b = em.b((byte[]) entry.getValue());
                }
                aeVar.i.add(agVar);
            }
            Location g2 = bw.a().g();
            if (g2 != null) {
                int d2 = bw.d();
                al alVar = new al();
                aeVar.j = alVar;
                alVar.f2545a = new ak();
                aeVar.j.f2545a.f2542a = em.a(g2.getLatitude(), d2);
                aeVar.j.f2545a.f2543b = em.a(g2.getLongitude(), d2);
                aeVar.j.f2545a.f2544c = (float) em.a(g2.getAccuracy(), d2);
            }
            String str = (String) eg.a().a("UserId");
            if (!str.equals("")) {
                ao aoVar = new ao();
                aeVar.k = aoVar;
                aoVar.f2554a = str;
            }
            dg<ae> dgVar = this.f2568f;
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            dgVar.f3001c.a(byteArrayOutputStream, aeVar);
            byte[] byteArray = byteArrayOutputStream.toByteArray();
            String str2 = dg.f2998a;
            db.a(3, str2, "Encoding " + dgVar.f3000b + ": " + new String(byteArray));
            du duVar = new du(new ds());
            ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream();
            duVar.a(byteArrayOutputStream2, byteArray);
            byte[] byteArray2 = byteArrayOutputStream2.toByteArray();
            dg.b(byteArray2);
            return byteArray2;
        } catch (Exception e2) {
            db.a(5, f2563e, "Proton config request failed with exception: ".concat(String.valueOf(e2)));
            return null;
        }
    }

    public void g() {
        List<ac> list;
        List<ai> list2;
        if (this.t == null) {
            return;
        }
        db.a(5, f2563e, "Processing config response");
        ay.a(this.t.f2533e.f2519c);
        ay.b(this.t.f2533e.f2520d * 1000);
        ba a2 = ba.a();
        String str = this.t.f2533e.f2521e;
        if (str != null && !str.endsWith(".do")) {
            db.a(5, ba.f2659a, "overriding analytics agent report URL without an endpoint, are you sure?");
        }
        a2.f2661b = str;
        if (this.m) {
            eg.a().a("analyticsEnabled", Boolean.valueOf(this.t.f2534f.f2556b));
        }
        this.i.a();
        ad adVar = this.t.f2533e;
        if (adVar == null || (list = adVar.f2517a) == null) {
            return;
        }
        for (ac acVar : list) {
            if (acVar != null && (list2 = acVar.f2512c) != null) {
                for (ai aiVar : list2) {
                    if (aiVar != null && !TextUtils.isEmpty(aiVar.f2538a)) {
                        aiVar.f2539b = acVar;
                        this.i.a((cq<String, ai>) aiVar.f2538a, (String) aiVar);
                    }
                }
            }
        }
    }

    public synchronized void h() {
        if (this.m) {
            em.a();
            SharedPreferences sharedPreferences = ck.a().f2892a.getSharedPreferences("FLURRY_SHARED_PREFERENCES", 0);
            if (sharedPreferences.getBoolean("com.flurry.android.flurryAppInstall", true)) {
                b("flurry.app_install", (Map<String, String>) null);
                SharedPreferences.Editor edit = sharedPreferences.edit();
                edit.putBoolean("com.flurry.android.flurryAppInstall", false);
                edit.apply();
            }
        }
    }

    private synchronized void i() {
        if (!this.o) {
            db.e(f2563e, "Analytics disabled, not sending pulse reports.");
            return;
        }
        String str = f2563e;
        db.a(4, str, "Sending " + this.j.size() + " queued reports.");
        for (az azVar : this.j) {
            String str2 = f2563e;
            db.a(3, str2, "Firing Pulse callbacks for event: " + azVar.f2643d);
            ay.d().a(azVar);
        }
        j();
    }

    private synchronized void j() {
        this.j.clear();
        this.l.b();
    }

    public synchronized void k() {
        db.a(4, f2563e, "Saving queued report data.");
        this.l.a(this.j);
    }

    public final synchronized void c() {
        if (this.m) {
            em.a();
            i();
        }
    }

    public final synchronized void b() {
        if (this.m) {
            em.a();
            bq.a();
            b(bq.d());
            i();
        }
    }

    @Override
    public final void a(String str, Object obj) {
        str.hashCode();
        char c2 = 65535;
        switch (str.hashCode()) {
            case -1720015653:
                if (str.equals("analyticsEnabled")) {
                    c2 = 0;
                    break;
                }
                break;
            case 640941243:
                if (str.equals("ProtonEnabled")) {
                    c2 = 1;
                    break;
                }
                break;
            case 1591403975:
                if (str.equals("ProtonConfigUrl")) {
                    c2 = 2;
                    break;
                }
                break;
        }
        switch (c2) {
            case 0:
                this.o = ((Boolean) obj).booleanValue();
                String str2 = f2563e;
                db.a(4, str2, "onSettingUpdate, AnalyticsEnabled = " + this.o);
                return;
            case 1:
                this.m = ((Boolean) obj).booleanValue();
                String str3 = f2563e;
                db.a(4, str3, "onSettingUpdate, protonEnabled = " + this.m);
                return;
            case 2:
                this.n = (String) obj;
                String str4 = f2563e;
                db.a(4, str4, "onSettingUpdate, protonConfigUrl = " + this.n);
                return;
            default:
                db.a(6, f2563e, "onSettingUpdate internal error!");
                return;
        }
    }

    public synchronized void b(String str, Map<String, String> map) {
        boolean z;
        String str2;
        Map<String, String> map2 = map;
        synchronized (this) {
            String str3 = f2563e;
            db.a(3, str3, "Event triggered: ".concat(String.valueOf(str)));
            if (!this.o) {
                db.e(str3, "Analytics and pulse have been disabled.");
            } else if (this.t == null) {
                db.a(3, str3, "Config response is empty. No events to fire.");
            } else {
                em.a();
                if (TextUtils.isEmpty(str)) {
                    return;
                }
                List<ai> a2 = this.i.a(str);
                if (a2 == null) {
                    db.a(3, str3, "No events to fire. Returning.");
                } else if (a2.size() == 0) {
                    db.a(3, str3, "No events to fire. Returning.");
                } else {
                    long currentTimeMillis = System.currentTimeMillis();
                    boolean z2 = map2 != null;
                    char c2 = 65535;
                    int hashCode = str.hashCode();
                    if (hashCode != 645204782) {
                        if (hashCode != 1371447545) {
                            if (hashCode == 1579613685 && str.equals("flurry.session_start")) {
                                c2 = 0;
                            }
                        } else if (str.equals("flurry.app_install")) {
                            c2 = 2;
                        }
                    } else if (str.equals("flurry.session_end")) {
                        c2 = 1;
                    }
                    bd bdVar = bd.SESSION_START;
                    HashMap hashMap = new HashMap();
                    Iterator<ai> it = a2.iterator();
                    while (it.hasNext()) {
                        ai next = it.next();
                        if (next instanceof aj) {
                            String str4 = f2563e;
                            db.a(4, str4, "Event contains triggers.");
                            String[] strArr = ((aj) next).f2541d;
                            if (strArr == null) {
                                db.a(4, str4, "Template does not contain trigger values. Firing.");
                            } else if (strArr.length == 0) {
                                db.a(4, str4, "Template does not contain trigger values. Firing.");
                            } else if (map2 == null) {
                                db.a(4, str4, "Publisher has not passed in params list. Not firing.");
                            } else {
                                z = false;
                                str2 = map2.get(((aj) next).f2540c);
                                if (str2 != null) {
                                    db.a(4, str4, "Publisher params has no value associated with proton key. Not firing.");
                                } else {
                                    int length = strArr.length;
                                    int i = 0;
                                    while (true) {
                                        if (i >= length) {
                                            break;
                                        } else if (strArr[i].equals(str2)) {
                                            z = true;
                                            break;
                                        } else {
                                            i++;
                                        }
                                    }
                                    if (!z) {
                                        db.a(4, f2563e, "Publisher params list does not match proton param values. Not firing.");
                                    } else {
                                        db.a(4, f2563e, "Publisher params match proton values. Firing.");
                                    }
                                }
                            }
                            z = true;
                            str2 = map2.get(((aj) next).f2540c);
                            if (str2 != null) {
                            }
                        }
                        ac acVar = next.f2539b;
                        if (acVar == null) {
                            db.a(3, f2563e, "Template is empty. Not firing current event.");
                        } else {
                            String str5 = f2563e;
                            db.a(3, str5, "Creating callback report for partner: " + acVar.f2511b);
                            HashMap hashMap2 = new HashMap();
                            hashMap2.put("event_name", str);
                            hashMap2.put("event_time_millis", String.valueOf(currentTimeMillis));
                            String a3 = this.h.a(acVar.f2514e, hashMap2);
                            String str6 = acVar.f2515f;
                            hashMap.put(Long.valueOf(acVar.f2510a), new av(acVar.f2511b, acVar.f2510a, a3, System.currentTimeMillis() + 259200000, this.t.f2533e.f2518b, acVar.f2516g, acVar.f2513d, acVar.j, acVar.i, acVar.h, str6 != null ? this.h.a(str6, hashMap2) : null));
                            map2 = map;
                            it = it;
                            currentTimeMillis = currentTimeMillis;
                        }
                    }
                    if (hashMap.size() != 0) {
                        bq.a();
                        long d2 = bq.d();
                        bq.a();
                        az azVar = new az(str, z2, d2, bq.g(), bdVar, hashMap);
                        if ("flurry.session_end".equals(str)) {
                            db.a(3, f2563e, "Storing Pulse callbacks for event: ".concat(str));
                            this.j.add(azVar);
                            return;
                        }
                        db.a(3, f2563e, "Firing Pulse callbacks for event: ".concat(str));
                        ay.d().a(azVar);
                    }
                }
            }
        }
    }

    public final synchronized void a() {
        if (this.m) {
            em.a();
            bq.a();
            au.f2593a = bq.d();
            this.u = false;
            e();
        }
    }

    public final synchronized void a(long j) {
        if (this.m) {
            em.a();
            b(j);
            b("flurry.session_end", (Map<String, String>) null);
            ck.a().b(new eo() {
                @Override
                public final void a() {
                    as.this.k();
                }
            });
        }
    }

    public final synchronized void a(String str, Map<String, String> map) {
        if (this.m) {
            em.a();
            b(str, map);
        }
    }

    public synchronized void a(long j, boolean z, byte[] bArr) {
        if (bArr == null) {
            return;
        }
        db.a(4, f2563e, "Saving proton config response");
        aq aqVar = new aq();
        aqVar.f2557a = j;
        aqVar.f2558b = z;
        aqVar.f2559c = bArr;
        this.k.a(aqVar);
    }

    public static boolean b(af afVar) {
        boolean z;
        ad adVar;
        String str;
        boolean z2;
        if (afVar == null) {
            return false;
        }
        ad adVar2 = afVar.f2533e;
        if (adVar2 != null && adVar2.f2517a != null) {
            for (int i = 0; i < adVar2.f2517a.size(); i++) {
                ac acVar = adVar2.f2517a.get(i);
                if (acVar != null) {
                    if (!acVar.f2511b.equals("") && acVar.f2510a != -1 && !acVar.f2514e.equals("")) {
                        List<ai> list = acVar.f2512c;
                        if (list != null) {
                            for (ai aiVar : list) {
                                if (aiVar.f2538a.equals("")) {
                                    db.a(3, f2563e, "An event is missing a name");
                                } else if ((aiVar instanceof aj) && ((aj) aiVar).f2540c.equals("")) {
                                    db.a(3, f2563e, "An event trigger is missing a param name");
                                }
                                z2 = false;
                            }
                        }
                        z2 = true;
                        if (!z2) {
                        }
                    }
                    db.a(3, f2563e, "A callback template is missing required values");
                    z = false;
                    break;
                }
            }
        }
        z = true;
        if (z && ((adVar = afVar.f2533e) == null || (str = adVar.f2521e) == null || !str.equals(""))) {
            return true;
        }
        db.a(3, f2563e, "Config response is missing required values.");
        return false;
    }

    private synchronized void b(long j) {
        Iterator<az> it = this.j.iterator();
        while (it.hasNext()) {
            if (j == it.next().f2640a) {
                it.remove();
            }
        }
    }
}