Active IQ v6.7.1版本的 MD5 值为:5082594ca2b69fbfbe64e6d6ee2159a7

以下内容为反编译后的 ii.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.ig;
import com.flurry.sdk.ip;
import com.flurry.sdk.ku;
import com.flurry.sdk.kw;
import com.flurry.sdk.lt;
import com.netapp.myautosupport.fingerprintAuth.FingerPrintLoginHandler;
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 ii implements lt.a {
    private static final String a = "ii";
    private kg<ig> g;
    private kg<List<ip>> h;
    private boolean i;
    private String j;
    private boolean k;
    private boolean l;
    private long n;
    private boolean o;
    private hv p;
    private boolean q;
    private final ks<hu> b = new ks<>("proton config request", new iu());
    private final ks<hv> c = new ks<>("proton config response", new iv());
    private final ih d = new ih();
    private final kd<String, hy> e = new kd<>();
    private final List<ip> f = new ArrayList();
    private long m = 10000;
    private final Runnable r = new ma() {
        @Override
        public final void a() {
            ii.this.e();
        }
    };
    private final ki<jj> s = new ki<jj>() {
        @Override
        public final void a(jj jjVar) {
            ii.this.e();
        }
    };
    private final ki<jk> t = new ki<jk>() {
        @Override
        public final void a(jk jkVar) {
            ii.this.e();
        }
    };
    private final ki<jn> u = new ki<jn>() {
        @Override
        public final void a(jn jnVar) {
            if (jnVar.a) {
                ii.this.e();
            }
        }
    };

    static boolean g(ii iiVar) {
        iiVar.q = true;
        return true;
    }

    public ii() {
        this.k = true;
        ls a2 = ls.a();
        this.i = ((Boolean) a2.a("ProtonEnabled")).booleanValue();
        a2.a("ProtonEnabled", (lt.a) this);
        String str = a;
        kn.a(4, str, "initSettings, protonEnabled = " + this.i);
        this.j = (String) a2.a("ProtonConfigUrl");
        a2.a("ProtonConfigUrl", (lt.a) this);
        String str2 = a;
        kn.a(4, str2, "initSettings, protonConfigUrl = " + this.j);
        this.k = ((Boolean) a2.a("analyticsEnabled")).booleanValue();
        a2.a("analyticsEnabled", (lt.a) this);
        String str3 = a;
        kn.a(4, str3, "initSettings, AnalyticsEnabled = " + this.k);
        kj.a().a("com.flurry.android.sdk.IdProviderFinishedEvent", this.s);
        kj.a().a("com.flurry.android.sdk.IdProviderUpdatedAdvertisingId", this.t);
        kj.a().a("com.flurry.android.sdk.NetworkStateEvent", this.u);
        Context context = jy.a().a;
        this.g = new kg<>(context.getFileStreamPath(".yflurryprotonconfig." + Long.toString(ly.i(jy.a().d), 16)), ".yflurryprotonconfig.", 1, new ll<ig>() {
            @Override
            public final li<ig> a(int i) {
                return new ig.a();
            }
        });
        this.h = new kg<>(context.getFileStreamPath(".yflurryprotonreport." + Long.toString(ly.i(jy.a().d), 16)), ".yflurryprotonreport.", 1, new ll<List<ip>>() {
            @Override
            public final li<List<ip>> a(int i) {
                return new lh(new ip.a());
            }
        });
        jy.a().b(new ma() {
            @Override
            public final void a() {
                ii.this.l();
            }
        });
        jy.a().b(new ma() {
            @Override
            public final void a() {
                ii.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;
        }
        if (c == 0) {
            this.i = ((Boolean) obj).booleanValue();
            String str2 = a;
            kn.a(4, str2, "onSettingUpdate, protonEnabled = " + this.i);
        } else if (c == 1) {
            this.j = (String) obj;
            String str3 = a;
            kn.a(4, str3, "onSettingUpdate, protonConfigUrl = " + this.j);
        } else if (c == 2) {
            this.k = ((Boolean) obj).booleanValue();
            String str4 = a;
            kn.a(4, str4, "onSettingUpdate, AnalyticsEnabled = " + this.k);
        } else {
            kn.a(6, a, "onSettingUpdate internal error!");
        }
    }

    public final synchronized void a() {
        if (this.i) {
            ly.b();
            jg.a();
            ik.a = jg.d();
            this.q = false;
            e();
        }
    }

    public synchronized void e() {
        if (this.i) {
            ly.b();
            if (this.l) {
                if (ji.a().b()) {
                    final long currentTimeMillis = System.currentTimeMillis();
                    final boolean z = !ji.a().c();
                    if (this.p != null) {
                        if (this.o != z) {
                            kn.a(3, a, "Limit ad tracking value has changed, purging");
                            this.p = null;
                        } else if (System.currentTimeMillis() < this.n + (this.p.b * 1000)) {
                            kn.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 {
                            long currentTimeMillis2 = System.currentTimeMillis();
                            long j = this.n;
                            long j2 = this.p.c;
                            Long.signum(j2);
                            if (currentTimeMillis2 >= j + (j2 * 1000)) {
                                kn.a(3, a, "Cached Proton config expired, purging");
                                this.p = null;
                                this.e.a();
                            }
                        }
                    }
                    jw.a().a(this);
                    kn.a(3, a, "Requesting proton config");
                    ?? f = f();
                    if (f == 0) {
                        return;
                    }
                    ku kuVar = new ku();
                    kuVar.g = TextUtils.isEmpty(this.j) ? "https://proton.flurry.com/sdk/v1/config" : this.j;
                    kuVar.u = FingerPrintLoginHandler.ERROR_FP_AUTH_FAILED;
                    kuVar.h = kw.a.kPost;
                    String num = Integer.toString(ks.a((byte[]) f));
                    kuVar.a("Content-Type", "application/x-flurry;version=2");
                    kuVar.a("Accept", "application/x-flurry;version=2");
                    kuVar.a("FM-Checksum", num);
                    kuVar.c = new le();
                    kuVar.d = new le();
                    kuVar.b = f;
                    kuVar.a = new ku.a<byte[], byte[]>() {
                        @Override
                        public final void a(ku<byte[], byte[]> kuVar2, byte[] bArr) {
                            hv hvVar;
                            final byte[] bArr2 = bArr;
                            int i = kuVar2.q;
                            String str = ii.a;
                            kn.a(3, str, "Proton config request: HTTP status code is:" + i);
                            if (i == 400 || i == 406 || i == 412 || i == 415) {
                                ii.this.m = 10000L;
                                return;
                            }
                            if (kuVar2.b() && bArr2 != null) {
                                jy.a().b(new ma() {
                                    @Override
                                    public final void a() {
                                        ii.this.a(currentTimeMillis, z, bArr2);
                                    }
                                });
                                try {
                                    hvVar = (hv) ii.this.c.b(bArr2);
                                } catch (Exception e) {
                                    String str2 = ii.a;
                                    kn.a(5, str2, "Failed to decode proton config response: " + e);
                                    hvVar = null;
                                }
                                r5 = ii.b(hvVar) ? hvVar : null;
                                if (r5 != null) {
                                    ii.this.m = 10000L;
                                    ii.this.n = currentTimeMillis;
                                    ii.this.o = z;
                                    ii.this.p = r5;
                                    ii.this.g();
                                    if (!ii.this.q) {
                                        ii.g(ii.this);
                                        ii.this.b("flurry.session_start", (Map<String, String>) null);
                                    }
                                    ii.this.h();
                                }
                            }
                            if (r5 == null) {
                                long j3 = ii.this.m << 1;
                                if (i == 429) {
                                    List<String> a2 = kuVar2.a("Retry-After");
                                    if (!a2.isEmpty()) {
                                        String str3 = a2.get(0);
                                        String str4 = ii.a;
                                        kn.a(3, str4, "Server returned retry time: " + str3);
                                        try {
                                            j3 = Long.parseLong(str3) * 1000;
                                        } catch (NumberFormatException unused) {
                                            kn.a(3, ii.a, "Server returned nonsensical retry time");
                                        }
                                    }
                                }
                                ii.this.m = j3;
                                String str5 = ii.a;
                                kn.a(3, str5, "Proton config request failed, backing off: " + ii.this.m + "ms");
                                jy.a().a(ii.this.r, ii.this.m);
                            }
                        }
                    };
                    jw.a().a((Object) this, (ii) kuVar);
                }
            }
        }
    }

    public synchronized void b(String str, Map<String, String> map) {
        boolean z;
        String str2;
        Map<String, String> map2 = map;
        synchronized (this) {
            String str3 = a;
            kn.a(3, str3, "Event triggered: " + str);
            if (!this.k) {
                kn.e(a, "Analytics and pulse have been disabled.");
            } else if (this.p == null) {
                kn.a(3, a, "Config response is empty. No events to fire.");
            } else {
                ly.b();
                if (TextUtils.isEmpty(str)) {
                    return;
                }
                List<hy> a2 = this.e.a((kd<String, hy>) str);
                if (a2 == null) {
                    kn.a(3, a, "No events to fire. Returning.");
                } else if (a2.size() == 0) {
                    kn.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;
                    }
                    it itVar = it.SESSION_START;
                    HashMap hashMap = new HashMap();
                    Iterator<hy> it = a2.iterator();
                    while (it.hasNext()) {
                        hy next = it.next();
                        if (next instanceof hz) {
                            kn.a(4, a, "Event contains triggers.");
                            String[] strArr = ((hz) next).d;
                            if (strArr == null) {
                                kn.a(4, a, "Template does not contain trigger values. Firing.");
                            } else if (strArr.length == 0) {
                                kn.a(4, a, "Template does not contain trigger values. Firing.");
                            } else if (map2 == null) {
                                kn.a(4, a, "Publisher has not passed in params list. Not firing.");
                            } else {
                                z = false;
                                str2 = map2.get(((hz) next).c);
                                if (str2 != null) {
                                    kn.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) {
                                            break;
                                        } else if (strArr[i].equals(str2)) {
                                            z = true;
                                            break;
                                        } else {
                                            i++;
                                        }
                                    }
                                    if (!z) {
                                        kn.a(4, a, "Publisher params list does not match proton param values. Not firing.");
                                    } else {
                                        kn.a(4, a, "Publisher params match proton values. Firing.");
                                    }
                                }
                            }
                            z = true;
                            str2 = map2.get(((hz) next).c);
                            if (str2 != null) {
                            }
                        }
                        hs hsVar = next.b;
                        if (hsVar == null) {
                            kn.a(3, a, "Template is empty. Not firing current event.");
                        } else {
                            String str4 = a;
                            kn.a(3, str4, "Creating callback report for partner: " + hsVar.b);
                            HashMap hashMap2 = new HashMap();
                            hashMap2.put("event_name", str);
                            hashMap2.put("event_time_millis", String.valueOf(currentTimeMillis));
                            hashMap.put(Long.valueOf(hsVar.a), new il(hsVar.b, hsVar.a, this.d.a(hsVar.e, hashMap2), System.currentTimeMillis() + 259200000, this.p.e.b, hsVar.g, hsVar.d, hsVar.j, hsVar.i, hsVar.h, hsVar.f != null ? this.d.a(hsVar.f, hashMap2) : null));
                            map2 = map;
                            it = it;
                            currentTimeMillis = currentTimeMillis;
                        }
                    }
                    if (hashMap.size() != 0) {
                        jg.a();
                        long d = jg.d();
                        jg.a();
                        ip ipVar = new ip(str, z2, d, jg.g(), itVar, hashMap);
                        if ("flurry.session_end".equals(str)) {
                            String str5 = a;
                            kn.a(3, str5, "Storing Pulse callbacks for event: " + str);
                            this.f.add(ipVar);
                            return;
                        }
                        String str6 = a;
                        kn.a(3, str6, "Firing Pulse callbacks for event: " + str);
                        io.c().a(ipVar);
                    }
                }
            }
        }
    }

    private byte[] f() {
        try {
            hu huVar = new hu();
            huVar.a = jy.a().d;
            huVar.b = lv.a(jy.a().a);
            huVar.c = lv.b(jy.a().a);
            huVar.d = jz.b();
            huVar.e = 3;
            jr.a();
            huVar.f = jr.b();
            huVar.g = !ji.a().c();
            huVar.h = new hx();
            huVar.h.a = new hr();
            huVar.h.a.a = Build.MODEL;
            huVar.h.a.b = Build.BRAND;
            huVar.h.a.c = Build.ID;
            huVar.h.a.d = Build.DEVICE;
            huVar.h.a.e = Build.PRODUCT;
            huVar.h.a.f = Build.VERSION.RELEASE;
            huVar.i = new ArrayList();
            for (Map.Entry entry : Collections.unmodifiableMap(ji.a().a).entrySet()) {
                hw hwVar = new hw();
                hwVar.a = ((jq) entry.getKey()).d;
                if (((jq) entry.getKey()).e) {
                    hwVar.b = new String((byte[]) entry.getValue());
                } else {
                    hwVar.b = ly.b((byte[]) entry.getValue());
                }
                huVar.i.add(hwVar);
            }
            Location g = jm.a().g();
            if (g != null) {
                int d = jm.d();
                huVar.j = new ib();
                huVar.j.a = new ia();
                huVar.j.a.a = ly.a(g.getLatitude(), d);
                huVar.j.a.b = ly.a(g.getLongitude(), d);
                huVar.j.a.c = (float) ly.a(g.getAccuracy(), d);
            }
            String str = (String) ls.a().a("UserId");
            if (!str.equals("")) {
                huVar.k = new ie();
                huVar.k.a = str;
            }
            return this.b.a((ks<hu>) huVar);
        } catch (Exception e) {
            String str2 = a;
            kn.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;
        }
        kn.a(4, a, "Saving proton config response");
        ig igVar = new ig();
        igVar.a = j;
        igVar.b = z;
        igVar.c = bArr;
        this.g.a(igVar);
    }

    public static boolean b(hv hvVar) {
        boolean z;
        boolean z2;
        if (hvVar == null) {
            return false;
        }
        ht htVar = hvVar.e;
        if (htVar != null && htVar.a != null) {
            for (int i = 0; i < htVar.a.size(); i++) {
                hs hsVar = htVar.a.get(i);
                if (hsVar != null) {
                    if (!hsVar.b.equals("") && hsVar.a != -1 && !hsVar.e.equals("")) {
                        List<hy> list = hsVar.c;
                        if (list != null) {
                            for (hy hyVar : list) {
                                if (hyVar.a.equals("")) {
                                    kn.a(3, a, "An event is missing a name");
                                } else if ((hyVar instanceof hz) && ((hz) hyVar).c.equals("")) {
                                    kn.a(3, a, "An event trigger is missing a param name");
                                }
                                z2 = false;
                            }
                        }
                        z2 = true;
                        if (!z2) {
                        }
                    }
                    kn.a(3, a, "A callback template is missing required values");
                    z = false;
                    break;
                }
            }
        }
        z = true;
        if (z && (hvVar.e == null || hvVar.e.e == null || !hvVar.e.e.equals(""))) {
            return true;
        }
        kn.a(3, a, "Config response is missing required values.");
        return false;
    }

    public void g() {
        List<hs> list;
        List<hy> list2;
        if (this.p == null) {
            return;
        }
        kn.a(5, a, "Processing config response");
        io.a(this.p.e.c);
        io.b(this.p.e.d * 1000);
        iq a2 = iq.a();
        String str = this.p.e.e;
        if (str != null && !str.endsWith(".do")) {
            kn.a(5, iq.a, "overriding analytics agent report URL without an endpoint, are you sure?");
        }
        a2.b = str;
        if (this.i) {
            ls.a().a("analyticsEnabled", Boolean.valueOf(this.p.f.b));
        }
        this.e.a();
        ht htVar = this.p.e;
        if (htVar == null || (list = htVar.a) == null) {
            return;
        }
        for (hs hsVar : list) {
            if (hsVar != null && (list2 = hsVar.c) != null) {
                for (hy hyVar : list2) {
                    if (hyVar != null && !TextUtils.isEmpty(hyVar.a)) {
                        hyVar.b = hsVar;
                        this.e.a((kd<String, hy>) hyVar.a, (String) hyVar);
                    }
                }
            }
        }
    }

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

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

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

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

    public final synchronized void a(long j) {
        if (this.i) {
            ly.b();
            b(j);
            b("flurry.session_end", (Map<String, String>) null);
            jy.a().b(new ma() {
                @Override
                public final void a() {
                    ii.this.k();
                }
            });
        }
    }

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

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

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

    public synchronized void l() {
        hv hvVar;
        ig a2 = this.g.a();
        if (a2 != null) {
            hv hvVar2 = null;
            try {
                hvVar = this.c.b(a2.c);
            } catch (Exception e) {
                String str = a;
                kn.a(5, str, "Failed to decode saved proton config response: " + e);
                this.g.b();
                hvVar = null;
            }
            if (b(hvVar)) {
                hvVar2 = hvVar;
            }
            if (hvVar2 != null) {
                kn.a(4, a, "Loaded saved proton config response");
                this.m = 10000L;
                this.n = a2.a;
                this.o = a2.b;
                this.p = hvVar2;
                g();
            }
        }
        this.l = true;
        jy.a().b(new ma() {
            @Override
            public final void a() {
                ii.this.e();
            }
        });
    }

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