Wolves Themes v1.0版本的 MD5 值为:cddc92b47f6b7c4a195c9625507eb51c

以下内容为反编译后的 ip.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.in;
import com.flurry.sdk.iw;
import com.flurry.sdk.le;
import com.flurry.sdk.lg;
import com.flurry.sdk.md;
import com.ironsource.sdk.precache.DownloadManager;
import com.tapjoy.TJAdUnitConstants;
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 ip implements md.a {
    private static final String a = "ip";
    private kp<in> g;
    private kp<List<iw>> h;
    private boolean i;
    private String j;
    private boolean k;
    private boolean l;
    private long n;
    private boolean o;
    private ic p;
    private boolean q;
    private final lc<ib> b = new lc<>("proton config request", new jb());
    private final lc<ic> c = new lc<>("proton config response", new jc());
    private final io d = new io();
    private final km<String, Cif> e = new km<>();
    private final List<iw> f = new ArrayList();
    private long m = 10000;
    private final Runnable r = new mk() {
        @Override
        public final void a() {
            ip.this.e();
        }
    };
    private final kr<jq> s = new kr<jq>() {
        @Override
        public final void a(jq jqVar) {
            ip.this.e();
        }
    };
    private final kr<jr> t = new kr<jr>() {
        @Override
        public final void a(jr jrVar) {
            ip.this.e();
        }
    };
    private final kr<ju> u = new kr<ju>() {
        @Override
        public final void a(ju juVar) {
            if (juVar.a) {
                ip.this.e();
            }
        }
    };

    static boolean g(ip ipVar) {
        ipVar.q = true;
        return true;
    }

    public ip() {
        this.k = true;
        mc a2 = mc.a();
        this.i = ((Boolean) a2.a("ProtonEnabled")).booleanValue();
        a2.a("ProtonEnabled", (md.a) this);
        String str = a;
        kx.a(4, str, "initSettings, protonEnabled = " + this.i);
        this.j = (String) a2.a("ProtonConfigUrl");
        a2.a("ProtonConfigUrl", (md.a) this);
        String str2 = a;
        kx.a(4, str2, "initSettings, protonConfigUrl = " + this.j);
        this.k = ((Boolean) a2.a("analyticsEnabled")).booleanValue();
        a2.a("analyticsEnabled", (md.a) this);
        String str3 = a;
        kx.a(4, str3, "initSettings, AnalyticsEnabled = " + this.k);
        ks.a().a("com.flurry.android.sdk.IdProviderFinishedEvent", this.s);
        ks.a().a("com.flurry.android.sdk.IdProviderUpdatedAdvertisingId", this.t);
        ks.a().a("com.flurry.android.sdk.NetworkStateEvent", this.u);
        Context context = kh.a().a;
        this.g = new kp<>(context.getFileStreamPath(".yflurryprotonconfig." + Long.toString(mi.i(kh.a().d), 16)), ".yflurryprotonconfig.", 1, new lv<in>() {
            @Override
            public final ls<in> a(int i) {
                return new in.a();
            }
        });
        this.h = new kp<>(context.getFileStreamPath(".yflurryprotonreport." + Long.toString(mi.i(kh.a().d), 16)), ".yflurryprotonreport.", 1, new lv<List<iw>>() {
            @Override
            public final ls<List<iw>> a(int i) {
                return new lr(new iw.a());
            }
        });
        kh.a().b(new mk() {
            @Override
            public final void a() {
                ip.this.l();
            }
        });
        kh.a().b(new mk() {
            @Override
            public final void a() {
                ip.this.m();
            }
        });
    }

    @Override
    public final void a(String str, Object obj) {
        char c;
        int hashCode = str.hashCode();
        if (hashCode == -1720015653) {
            if (str.equals("analyticsEnabled")) {
                c = 2;
            }
            c = 65535;
        } else if (hashCode != 640941243) {
            if (hashCode == 1591403975 && str.equals("ProtonConfigUrl")) {
                c = 1;
            }
            c = 65535;
        } else {
            if (str.equals("ProtonEnabled")) {
                c = 0;
            }
            c = 65535;
        }
        switch (c) {
            case 0:
                this.i = ((Boolean) obj).booleanValue();
                String str2 = a;
                kx.a(4, str2, "onSettingUpdate, protonEnabled = " + this.i);
                return;
            case 1:
                this.j = (String) obj;
                String str3 = a;
                kx.a(4, str3, "onSettingUpdate, protonConfigUrl = " + this.j);
                return;
            case 2:
                this.k = ((Boolean) obj).booleanValue();
                String str4 = a;
                kx.a(4, str4, "onSettingUpdate, AnalyticsEnabled = " + this.k);
                return;
            default:
                kx.a(6, a, "onSettingUpdate internal error!");
                return;
        }
    }

    public final synchronized void a() {
        if (this.i) {
            mi.b();
            jn.a();
            ir.a = jn.d();
            this.q = false;
            e();
        }
    }

    public synchronized void e() {
        if (this.i) {
            mi.b();
            if (this.l) {
                if (jp.a().b()) {
                    final long currentTimeMillis = System.currentTimeMillis();
                    final boolean z = !jp.a().e();
                    if (this.p != null) {
                        if (this.o != z) {
                            kx.a(3, a, "Limit ad tracking value has changed, purging");
                            this.p = null;
                        } else if (System.currentTimeMillis() < this.n + (this.p.b * 1000)) {
                            kx.a(3, a, "Cached Proton config valid, no need to refresh");
                            if (!this.q) {
                                this.q = true;
                                b("flurry.session_start", (Map<String, String>) null);
                            }
                            return;
                        } else if (System.currentTimeMillis() >= this.n + (this.p.c * 1000)) {
                            kx.a(3, a, "Cached Proton config expired, purging");
                            this.p = null;
                            this.e.a();
                        }
                    }
                    kd.a().a(this);
                    kx.a(3, a, "Requesting proton config");
                    ?? f = f();
                    if (f == 0) {
                        return;
                    }
                    le leVar = new le();
                    leVar.g = TextUtils.isEmpty(this.j) ? "https://proton.flurry.com/sdk/v1/config" : this.j;
                    leVar.u = DownloadManager.OPERATION_TIMEOUT;
                    leVar.h = lg.a.kPost;
                    String num = Integer.toString(lc.a((byte[]) f));
                    leVar.a("Content-Type", "application/x-flurry;version=2");
                    leVar.a("Accept", "application/x-flurry;version=2");
                    leVar.a("FM-Checksum", num);
                    leVar.c = new lo();
                    leVar.d = new lo();
                    leVar.b = f;
                    leVar.a = new le.a<byte[], byte[]>() {
                        @Override
                        public final void a(le<byte[], byte[]> leVar2, byte[] bArr) {
                            ic icVar;
                            final byte[] bArr2 = bArr;
                            int i = leVar2.q;
                            String str = ip.a;
                            kx.a(3, str, "Proton config request: HTTP status code is:" + i);
                            if (i == 400 || i == 406 || i == 412 || i == 415) {
                                ip.this.m = 10000L;
                                return;
                            }
                            if (leVar2.b() && bArr2 != null) {
                                kh.a().b(new mk() {
                                    @Override
                                    public final void a() {
                                        ip.this.a(currentTimeMillis, z, bArr2);
                                    }
                                });
                                try {
                                    icVar = (ic) ip.this.c.b(bArr2);
                                } catch (Exception e) {
                                    String str2 = ip.a;
                                    kx.a(5, str2, "Failed to decode proton config response: " + e);
                                    icVar = null;
                                }
                                r5 = ip.b(icVar) ? icVar : null;
                                if (r5 != null) {
                                    ip.this.m = 10000L;
                                    ip.this.n = currentTimeMillis;
                                    ip.this.o = z;
                                    ip.this.p = r5;
                                    ip.this.g();
                                    if (!ip.this.q) {
                                        ip.g(ip.this);
                                        ip.this.b("flurry.session_start", (Map<String, String>) null);
                                    }
                                    ip.this.h();
                                }
                            }
                            if (r5 == null) {
                                long j = ip.this.m << 1;
                                if (i == 429) {
                                    List<String> a2 = leVar2.a("Retry-After");
                                    if (!a2.isEmpty()) {
                                        String str3 = a2.get(0);
                                        String str4 = ip.a;
                                        kx.a(3, str4, "Server returned retry time: " + str3);
                                        try {
                                            j = Long.parseLong(str3) * 1000;
                                        } catch (NumberFormatException unused) {
                                            kx.a(3, ip.a, "Server returned nonsensical retry time");
                                        }
                                    }
                                }
                                ip.this.m = j;
                                String str5 = ip.a;
                                kx.a(3, str5, "Proton config request failed, backing off: " + ip.this.m + "ms");
                                kh.a().a(ip.this.r, ip.this.m);
                            }
                        }
                    };
                    kd.a().a((Object) this, (ip) leVar);
                }
            }
        }
    }

    public synchronized void b(String str, Map<String, String> map) {
        ja jaVar;
        boolean z;
        String str2;
        Map<String, String> map2 = map;
        synchronized (this) {
            String str3 = a;
            kx.a(3, str3, "Event triggered: " + str);
            if (!this.k) {
                kx.e(a, "Analytics and pulse have been disabled.");
            } else if (this.p == null) {
                kx.a(3, a, "Config response is empty. No events to fire.");
            } else {
                mi.b();
                if (TextUtils.isEmpty(str)) {
                    return;
                }
                List<Cif> a2 = this.e.a((km<String, Cif>) str);
                if (a2 == null) {
                    kx.a(3, a, "No events to fire. Returning.");
                } else if (a2.size() == 0) {
                    kx.a(3, a, "No events to fire. Returning.");
                } else {
                    long currentTimeMillis = System.currentTimeMillis();
                    boolean z2 = map2 != null;
                    char c = 65535;
                    int hashCode = str.hashCode();
                    if (hashCode != 645204782) {
                        if (hashCode != 1371447545) {
                            if (hashCode == 1579613685 && str.equals("flurry.session_start")) {
                                c = 0;
                            }
                        } else if (str.equals("flurry.app_install")) {
                            c = 2;
                        }
                    } else if (str.equals("flurry.session_end")) {
                        c = 1;
                    }
                    switch (c) {
                        case 0:
                            jaVar = ja.SESSION_START;
                            break;
                        case 1:
                            jaVar = ja.SESSION_END;
                            break;
                        case 2:
                            jaVar = ja.INSTALL;
                            break;
                        default:
                            jaVar = ja.APPLICATION_EVENT;
                            break;
                    }
                    HashMap hashMap = new HashMap();
                    Iterator<Cif> it = a2.iterator();
                    while (it.hasNext()) {
                        Cif next = it.next();
                        if (next instanceof ig) {
                            kx.a(4, a, "Event contains triggers.");
                            String[] strArr = ((ig) next).d;
                            if (strArr == null) {
                                kx.a(4, a, "Template does not contain trigger values. Firing.");
                            } else if (strArr.length == 0) {
                                kx.a(4, a, "Template does not contain trigger values. Firing.");
                            } else if (map2 == null) {
                                kx.a(4, a, "Publisher has not passed in params list. Not firing.");
                            } else {
                                z = false;
                                str2 = map2.get(((ig) next).c);
                                if (str2 != null) {
                                    kx.a(4, a, "Publisher params has no value associated with proton key. Not firing.");
                                } else {
                                    int length = strArr.length;
                                    int i = 0;
                                    while (true) {
                                        if (i < length) {
                                            if (strArr[i].equals(str2)) {
                                                z = true;
                                            } else {
                                                i++;
                                            }
                                        }
                                    }
                                    if (!z) {
                                        kx.a(4, a, "Publisher params list does not match proton param values. Not firing.");
                                        map2 = map;
                                    } else {
                                        kx.a(4, a, "Publisher params match proton values. Firing.");
                                    }
                                }
                            }
                            z = true;
                            str2 = map2.get(((ig) next).c);
                            if (str2 != null) {
                            }
                        }
                        hz hzVar = next.b;
                        if (hzVar == null) {
                            kx.a(3, a, "Template is empty. Not firing current event.");
                        } else {
                            String str4 = a;
                            kx.a(3, str4, "Creating callback report for partner: " + hzVar.b);
                            HashMap hashMap2 = new HashMap();
                            hashMap2.put(TJAdUnitConstants.PARAM_PLACEMENT_NAME, str);
                            hashMap2.put("event_time_millis", String.valueOf(currentTimeMillis));
                            hashMap.put(Long.valueOf(hzVar.a), new is(hzVar.b, hzVar.a, this.d.a(hzVar.e, hashMap2), System.currentTimeMillis() + 259200000, this.p.e.b, hzVar.g, hzVar.d, hzVar.j, hzVar.i, hzVar.h, hzVar.f != null ? this.d.a(hzVar.f, hashMap2) : null));
                            it = it;
                            currentTimeMillis = currentTimeMillis;
                            jaVar = jaVar;
                        }
                        map2 = map;
                    }
                    ja jaVar2 = jaVar;
                    if (hashMap.size() != 0) {
                        jn.a();
                        long d = jn.d();
                        jn.a();
                        iw iwVar = new iw(str, z2, d, jn.g(), jaVar2, hashMap);
                        if ("flurry.session_end".equals(str)) {
                            String str5 = a;
                            kx.a(3, str5, "Storing Pulse callbacks for event: " + str);
                            this.f.add(iwVar);
                            return;
                        }
                        String str6 = a;
                        kx.a(3, str6, "Firing Pulse callbacks for event: " + str);
                        iv.c().a(iwVar);
                    }
                }
            }
        }
    }

    private byte[] f() {
        try {
            ib ibVar = new ib();
            ibVar.a = kh.a().d;
            ibVar.b = mf.a(kh.a().a);
            ibVar.c = mf.b(kh.a().a);
            ibVar.d = ki.b();
            ibVar.e = 3;
            jy.a();
            ibVar.f = jy.b();
            ibVar.g = !jp.a().e();
            ibVar.h = new ie();
            ibVar.h.a = new hy();
            ibVar.h.a.a = Build.MODEL;
            ibVar.h.a.b = Build.BRAND;
            ibVar.h.a.c = Build.ID;
            ibVar.h.a.d = Build.DEVICE;
            ibVar.h.a.e = Build.PRODUCT;
            ibVar.h.a.f = Build.VERSION.RELEASE;
            ibVar.i = new ArrayList();
            for (Map.Entry entry : Collections.unmodifiableMap(jp.a().a).entrySet()) {
                id idVar = new id();
                idVar.a = ((jx) entry.getKey()).d;
                if (((jx) entry.getKey()).e) {
                    idVar.b = new String((byte[]) entry.getValue());
                } else {
                    idVar.b = mi.b((byte[]) entry.getValue());
                }
                ibVar.i.add(idVar);
            }
            Location g = jt.a().g();
            if (g != null) {
                int d = jt.d();
                ibVar.j = new ii();
                ibVar.j.a = new ih();
                ibVar.j.a.a = mi.a(g.getLatitude(), d);
                ibVar.j.a.b = mi.a(g.getLongitude(), d);
                ibVar.j.a.c = (float) mi.a(g.getAccuracy(), d);
            }
            String str = (String) mc.a().a("UserId");
            if (!str.equals("")) {
                ibVar.k = new il();
                ibVar.k.a = str;
            }
            return this.b.a((lc<ib>) ibVar);
        } catch (Exception e) {
            String str2 = a;
            kx.a(5, str2, "Proton config request failed with exception: " + e);
            return null;
        }
    }

    public synchronized void a(long j, boolean z, byte[] bArr) {
        if (bArr == null) {
            return;
        }
        kx.a(4, a, "Saving proton config response");
        in inVar = new in();
        inVar.a = j;
        inVar.b = z;
        inVar.c = bArr;
        this.g.a(inVar);
    }

    public static boolean b(ic icVar) {
        boolean z;
        boolean z2;
        if (icVar == null) {
            return false;
        }
        ia iaVar = icVar.e;
        if (iaVar != null && iaVar.a != null) {
            for (int i = 0; i < iaVar.a.size(); i++) {
                hz hzVar = iaVar.a.get(i);
                if (hzVar != null) {
                    if (!hzVar.b.equals("") && hzVar.a != -1 && !hzVar.e.equals("")) {
                        List<Cif> list = hzVar.c;
                        if (list != null) {
                            for (Cif cif : list) {
                                if (cif.a.equals("")) {
                                    kx.a(3, a, "An event is missing a name");
                                } else if ((cif instanceof ig) && ((ig) cif).c.equals("")) {
                                    kx.a(3, a, "An event trigger is missing a param name");
                                }
                                z2 = false;
                            }
                        }
                        z2 = true;
                        if (!z2) {
                        }
                    }
                    kx.a(3, a, "A callback template is missing required values");
                    z = false;
                    break;
                }
            }
        }
        z = true;
        if (z && (icVar.e == null || icVar.e.e == null || !icVar.e.e.equals(""))) {
            return true;
        }
        kx.a(3, a, "Config response is missing required values.");
        return false;
    }

    public void g() {
        List<hz> list;
        List<Cif> list2;
        if (this.p == null) {
            return;
        }
        kx.a(5, a, "Processing config response");
        iv.a(this.p.e.c);
        iv.b(this.p.e.d * 1000);
        ix a2 = ix.a();
        String str = this.p.e.e;
        if (str != null && !str.endsWith(".do")) {
            kx.a(5, ix.a, "overriding analytics agent report URL without an endpoint, are you sure?");
        }
        a2.b = str;
        if (this.i) {
            mc.a().a("analyticsEnabled", Boolean.valueOf(this.p.f.b));
        }
        this.e.a();
        ia iaVar = this.p.e;
        if (iaVar == null || (list = iaVar.a) == null) {
            return;
        }
        for (hz hzVar : list) {
            if (hzVar != null && (list2 = hzVar.c) != null) {
                for (Cif cif : list2) {
                    if (cif != null && !TextUtils.isEmpty(cif.a)) {
                        cif.b = hzVar;
                        this.e.a((km<String, Cif>) cif.a, (String) cif);
                    }
                }
            }
        }
    }

    public synchronized void h() {
        if (this.i) {
            mi.b();
            SharedPreferences sharedPreferences = kh.a().a.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();
            }
        }
    }

    public final synchronized void b() {
        if (this.i) {
            mi.b();
            jn.a();
            b(jn.d());
            i();
        }
    }

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

    private synchronized void i() {
        if (!this.k) {
            kx.e(a, "Analytics disabled, not sending pulse reports.");
            return;
        }
        String str = a;
        kx.a(4, str, "Sending " + this.f.size() + " queued reports.");
        for (iw iwVar : this.f) {
            String str2 = a;
            kx.a(3, str2, "Firing Pulse callbacks for event: " + iwVar.d);
            iv.c().a(iwVar);
        }
        j();
    }

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

    public final synchronized void a(long j) {
        if (this.i) {
            mi.b();
            b(j);
            b("flurry.session_end", (Map<String, String>) null);
            kh.a().b(new mk() {
                @Override
                public final void a() {
                    ip.this.k();
                }
            });
        }
    }

    public synchronized void k() {
        kx.a(4, a, "Saving queued report data.");
        this.h.a(this.f);
    }

    public final synchronized void c() {
        if (this.i) {
            mi.b();
            i();
        }
    }

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

    public synchronized void l() {
        ic icVar;
        in a2 = this.g.a();
        if (a2 != null) {
            ic icVar2 = null;
            try {
                icVar = this.c.b(a2.c);
            } catch (Exception e) {
                String str = a;
                kx.a(5, str, "Failed to decode saved proton config response: " + e);
                this.g.b();
                icVar = null;
            }
            if (b(icVar)) {
                icVar2 = icVar;
            }
            if (icVar2 != null) {
                kx.a(4, a, "Loaded saved proton config response");
                this.m = 10000L;
                this.n = a2.a;
                this.o = a2.b;
                this.p = icVar2;
                g();
            }
        }
        this.l = true;
        kh.a().b(new mk() {
            @Override
            public final void a() {
                ip.this.e();
            }
        });
    }

    public synchronized void m() {
        kx.a(4, a, "Loading queued report data.");
        List<iw> a2 = this.h.a();
        if (a2 != null) {
            this.f.addAll(a2);
        }
    }
}