导航菜单

页面标题

页面副标题

Oolka v2.4.42 - a.java 源代码

正在查看: Oolka v2.4.42 应用的 a.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.mixpanel.android.mpmetrics;

import android.content.Context;
import android.os.Build;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.util.DisplayMetrics;
import com.mixpanel.android.mpmetrics.i;
import com.mixpanel.android.util.HttpService;
import com.mixpanel.android.util.LegacyVersionUtils;
import com.mixpanel.android.util.MPLog;
import com.mixpanel.android.util.RemoteService;
import com.singular.sdk.internal.Constants;
import in.juspay.hyper.constants.LogSubCategory;
import java.io.File;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;

public class a {
    public static final Map<String, a> e = new HashMap();
    public final h a = d();
    public final String b;
    public final Context c;
    public final com.mixpanel.android.mpmetrics.h d;

    public static class C0003a extends d {
        public final String c;
        public final JSONObject d;
        public final boolean e;

        public C0003a(String str, JSONObject jSONObject, String str2, boolean z, JSONObject jSONObject2) {
            super(str2, jSONObject);
            this.c = str;
            this.e = z;
            this.d = jSONObject2;
        }

        public String c() {
            return this.c;
        }

        public JSONObject d() {
            return b();
        }

        public JSONObject e() {
            return this.d;
        }
    }

    public static class b extends d {
        public b(JSONObject jSONObject, String str) {
            super(str, jSONObject);
        }

        public String toString() {
            return b().toString();
        }
    }

    public static class c {
        public final String a;

        public c(String str) {
            this.a = str;
        }

        public String a() {
            return this.a;
        }
    }

    public static class d extends c {
        public final JSONObject b;

        public d(String str, JSONObject jSONObject) {
            super(str);
            if (jSONObject != null && jSONObject.length() > 0) {
                Iterator<String> keys = jSONObject.keys();
                while (keys.hasNext()) {
                    String next = keys.next();
                    try {
                        jSONObject.get(next).toString();
                    } catch (AssertionError e) {
                        jSONObject.remove(next);
                        MPLog.d("MixpanelAPI.Messages", "Removing people profile property from update (see https://github.com/mixpanel/mixpanel-android/issues/567)", e);
                    } catch (JSONException unused) {
                    }
                }
            }
            this.b = jSONObject;
        }

        public JSONObject b() {
            return this.b;
        }
    }

    public static class e extends d {
        public e(JSONObject jSONObject, String str) {
            super(str, jSONObject);
        }

        public boolean c() {
            return !b().has("$distinct_id");
        }

        public String toString() {
            return b().toString();
        }
    }

    public static class f extends c {
        public final String b;

        public f(String str, String str2) {
            super(str2);
            this.b = str;
        }

        public String b() {
            return this.b;
        }

        public String toString() {
            return this.b;
        }
    }

    public static class g extends c {
        public final Map<String, String> b;

        public Map<String, String> b() {
            return this.b;
        }
    }

    public class h {
        public u f;
        public final Object a = new Object();
        public long c = 0;
        public long d = 0;
        public long e = -1;
        public Handler b = f();

        public class HandlerC0004a extends Handler {
            public i a;
            public final long b;
            public long c;
            public int d;

            public HandlerC0004a(Looper looper) {
                super(looper);
                this.a = null;
                h.this.f = u.f(a.this.c);
                this.b = a.this.d.i();
            }

            public final JSONObject a() throws JSONException {
                JSONObject jSONObject = new JSONObject();
                jSONObject.put("mp_lib", LogSubCategory.LifeCycle.ANDROID);
                jSONObject.put("$lib_version", "8.2.0");
                jSONObject.put("$os", Constants.PLATFORM);
                String str = Build.VERSION.RELEASE;
                if (str == null) {
                    str = "UNKNOWN";
                }
                jSONObject.put("$os_version", str);
                String str2 = Build.MANUFACTURER;
                if (str2 == null) {
                    str2 = "UNKNOWN";
                }
                jSONObject.put("$manufacturer", str2);
                String str3 = Build.BRAND;
                if (str3 == null) {
                    str3 = "UNKNOWN";
                }
                jSONObject.put("$brand", str3);
                String str4 = Build.MODEL;
                jSONObject.put("$model", str4 != null ? str4 : "UNKNOWN");
                DisplayMetrics e = h.this.f.e();
                jSONObject.put("$screen_dpi", e.densityDpi);
                jSONObject.put("$screen_height", e.heightPixels);
                jSONObject.put("$screen_width", e.widthPixels);
                String b = h.this.f.b();
                if (b != null) {
                    jSONObject.put("$app_version", b);
                    jSONObject.put("$app_version_string", b);
                }
                Integer a = h.this.f.a();
                if (a != null) {
                    String valueOf = String.valueOf(a);
                    jSONObject.put("$app_release", valueOf);
                    jSONObject.put("$app_build_number", valueOf);
                }
                Boolean valueOf2 = Boolean.valueOf(h.this.f.g());
                if (valueOf2 != null) {
                    jSONObject.put("$has_nfc", valueOf2.booleanValue());
                }
                Boolean valueOf3 = Boolean.valueOf(h.this.f.h());
                if (valueOf3 != null) {
                    jSONObject.put("$has_telephone", valueOf3.booleanValue());
                }
                String d = h.this.f.d();
                if (d != null && !d.trim().isEmpty()) {
                    jSONObject.put("$carrier", d);
                }
                Boolean j = h.this.f.j();
                if (j != null) {
                    jSONObject.put("$wifi", j.booleanValue());
                }
                Boolean i = h.this.f.i();
                if (i != null) {
                    jSONObject.put("$bluetooth_enabled", i);
                }
                String c = h.this.f.c();
                if (c != null) {
                    jSONObject.put("$bluetooth_version", c);
                }
                return jSONObject;
            }

            public final JSONObject b(C0003a c0003a) throws JSONException {
                JSONObject jSONObject = new JSONObject();
                JSONObject d = c0003a.d();
                JSONObject a = a();
                a.put("token", c0003a.a());
                if (d != null) {
                    Iterator<String> keys = d.keys();
                    while (keys.hasNext()) {
                        String next = keys.next();
                        a.put(next, d.get(next));
                    }
                }
                jSONObject.put("event", c0003a.c());
                jSONObject.put("properties", a);
                jSONObject.put("$mp_metadata", c0003a.e());
                return jSONObject;
            }

            public final void c(i iVar, String str) {
                RemoteService h = a.this.h();
                a aVar = a.this;
                Context context = aVar.c;
                aVar.d.q();
                if (!h.b(context, null)) {
                    a.this.j("Not flushing data to Mixpanel because the device is not connected to the internet.");
                    return;
                }
                d(iVar, str, i.b.EVENTS, a.this.d.f());
                d(iVar, str, i.b.PEOPLE, a.this.d.r());
                d(iVar, str, i.b.GROUPS, a.this.d.k());
            }

            public final void d(com.mixpanel.android.mpmetrics.i r24, java.lang.String r25, com.mixpanel.android.mpmetrics.i.b r26, java.lang.String r27) {
                throw new UnsupportedOperationException("Method not decompiled: com.mixpanel.android.mpmetrics.a.h.HandlerC0004a.d(com.mixpanel.android.mpmetrics.i, java.lang.String, com.mixpanel.android.mpmetrics.i$b, java.lang.String):void");
            }

            @Override
            public void handleMessage(Message message) {
                String a;
                int i;
                String str;
                String str2;
                if (this.a == null) {
                    a aVar = a.this;
                    i l = aVar.l(aVar.c);
                    this.a = l;
                    l.l(System.currentTimeMillis() - a.this.d.b(), i.b.EVENTS);
                    this.a.l(System.currentTimeMillis() - a.this.d.b(), i.b.PEOPLE);
                }
                try {
                    int i2 = message.what;
                    if (i2 == 0) {
                        e eVar = (e) message.obj;
                        i.b bVar = eVar.c() ? i.b.ANONYMOUS_PEOPLE : i.b.PEOPLE;
                        a.this.j("Queuing people record for sending later");
                        a.this.j("    " + eVar.toString());
                        str = eVar.a();
                        i = this.a.j(eVar.b(), str, bVar);
                        if (eVar.c()) {
                            i = 0;
                        }
                    } else if (i2 == 3) {
                        b bVar2 = (b) message.obj;
                        a.this.j("Queuing group record for sending later");
                        a.this.j("    " + bVar2.toString());
                        str = bVar2.a();
                        i = this.a.j(bVar2.b(), str, i.b.GROUPS);
                    } else if (i2 == 1) {
                        C0003a c0003a = (C0003a) message.obj;
                        try {
                            JSONObject b = b(c0003a);
                            a.this.j("Queuing event for sending later");
                            a.this.j("    " + b.toString());
                            str2 = c0003a.a();
                            try {
                                i = this.a.j(b, str2, i.b.EVENTS);
                            } catch (JSONException e) {
                                e = e;
                                MPLog.d("MixpanelAPI.Messages", "Exception tracking event " + c0003a.c(), e);
                                i = -3;
                                str = str2;
                                if (i < a.this.d.a()) {
                                }
                                a.this.j("Flushing queue due to bulk upload limit (" + i + ") for project " + str);
                                h.this.h();
                                c(this.a, str);
                                return;
                            }
                        } catch (JSONException e2) {
                            e = e2;
                            str2 = null;
                        }
                        str = str2;
                    } else if (i2 == 4) {
                        f fVar = (f) message.obj;
                        String b2 = fVar.b();
                        str = fVar.a();
                        i = this.a.s(str, b2);
                    } else {
                        if (i2 == 7) {
                            a = ((c) message.obj).a();
                            this.a.k(i.b.ANONYMOUS_PEOPLE, a);
                        } else {
                            if (i2 == 8) {
                                g gVar = (g) message.obj;
                                MPLog.a("MixpanelAPI.Messages", this.a.t(gVar.b(), gVar.a()) + " stored events were updated with new properties.");
                            } else if (i2 == 2) {
                                a.this.j("Flushing queue due to scheduled or forced flush");
                                h.this.h();
                                a = (String) message.obj;
                                c(this.a, a);
                            } else if (i2 == 6) {
                                a = ((c) message.obj).a();
                                this.a.k(i.b.EVENTS, a);
                                this.a.k(i.b.PEOPLE, a);
                                this.a.k(i.b.GROUPS, a);
                                this.a.k(i.b.ANONYMOUS_PEOPLE, a);
                            } else if (i2 == 5) {
                                MPLog.k("MixpanelAPI.Messages", "Worker received a hard kill. Dumping all events and force-killing. Thread id " + Thread.currentThread().getId());
                                synchronized (h.this.a) {
                                    this.a.n();
                                    h.this.b = null;
                                    Looper.myLooper().quit();
                                }
                            } else if (i2 == 9) {
                                LegacyVersionUtils.a((File) message.obj);
                            } else {
                                MPLog.c("MixpanelAPI.Messages", "Unexpected message received by Mixpanel worker: " + message);
                            }
                            i = -3;
                            str = null;
                        }
                        i = -3;
                        str = a;
                    }
                    if ((i < a.this.d.a() || i == -2) && this.d <= 0 && str != null) {
                        a.this.j("Flushing queue due to bulk upload limit (" + i + ") for project " + str);
                        h.this.h();
                        c(this.a, str);
                        return;
                    }
                    if (i <= 0 || hasMessages(2, str)) {
                        return;
                    }
                    a.this.j("Queue depth " + i + " - Adding flush in " + this.b);
                    if (this.b >= 0) {
                        Message obtain = Message.obtain();
                        obtain.what = 2;
                        obtain.obj = str;
                        obtain.arg1 = 1;
                        sendMessageDelayed(obtain, this.b);
                    }
                } catch (RuntimeException e3) {
                    MPLog.d("MixpanelAPI.Messages", "Worker threw an unhandled exception", e3);
                    synchronized (h.this.a) {
                        h.this.b = null;
                        try {
                            Looper.myLooper().quit();
                            MPLog.d("MixpanelAPI.Messages", "Mixpanel will not process any more analytics messages", e3);
                        } catch (Exception e4) {
                            MPLog.d("MixpanelAPI.Messages", "Could not halt looper", e4);
                        }
                    }
                }
            }
        }

        public h() {
        }

        public Handler f() {
            HandlerThread handlerThread = new HandlerThread("com.mixpanel.android.AnalyticsWorker", 10);
            handlerThread.start();
            return new HandlerC0004a(handlerThread.getLooper());
        }

        public void g(Message message) {
            synchronized (this.a) {
                Handler handler = this.b;
                if (handler == null) {
                    a.this.j("Dead mixpanel worker dropping a message: " + message.what);
                } else {
                    handler.sendMessage(message);
                }
            }
        }

        public final void h() {
            long currentTimeMillis = System.currentTimeMillis();
            long j = this.c;
            long j2 = 1 + j;
            long j3 = this.e;
            if (j3 > 0) {
                long j4 = ((currentTimeMillis - j3) + (this.d * j)) / j2;
                this.d = j4;
                a.this.j("Average send frequency approximately " + (j4 / 1000) + " seconds.");
            }
            this.e = currentTimeMillis;
            this.c = j2;
        }
    }

    public a(Context context, com.mixpanel.android.mpmetrics.h hVar) {
        this.c = context;
        this.d = hVar;
        this.b = hVar.m();
        h().c();
    }

    public static a g(Context context, com.mixpanel.android.mpmetrics.h hVar) {
        a aVar;
        Map<String, a> map = e;
        synchronized (map) {
            Context applicationContext = context.getApplicationContext();
            String m = hVar.m();
            if (map.containsKey(m)) {
                aVar = map.get(m);
            } else {
                aVar = new a(applicationContext, hVar);
                map.put(m, aVar);
            }
        }
        return aVar;
    }

    public void c(c cVar) {
        Message obtain = Message.obtain();
        obtain.what = 7;
        obtain.obj = cVar;
        this.a.g(obtain);
    }

    public h d() {
        return new h();
    }

    public void e(c cVar) {
        Message obtain = Message.obtain();
        obtain.what = 6;
        obtain.obj = cVar;
        this.a.g(obtain);
    }

    public void f(C0003a c0003a) {
        Message obtain = Message.obtain();
        obtain.what = 1;
        obtain.obj = c0003a;
        this.a.g(obtain);
    }

    public RemoteService h() {
        return new HttpService(this.d.M(), null);
    }

    public void i(b bVar) {
        Message obtain = Message.obtain();
        obtain.what = 3;
        obtain.obj = bVar;
        this.a.g(obtain);
    }

    public final void j(String str) {
        MPLog.i("MixpanelAPI.Messages", str + " (Thread " + Thread.currentThread().getId() + ")");
    }

    public final void k(String str, Throwable th) {
        MPLog.j("MixpanelAPI.Messages", str + " (Thread " + Thread.currentThread().getId() + ")", th);
    }

    public i l(Context context) {
        return i.r(context, this.d);
    }

    public void m(e eVar) {
        Message obtain = Message.obtain();
        obtain.what = 0;
        obtain.obj = eVar;
        this.a.g(obtain);
    }

    public void n(c cVar) {
        Message obtain = Message.obtain();
        obtain.what = 2;
        obtain.obj = cVar.a();
        obtain.arg1 = 0;
        this.a.g(obtain);
    }

    public void o(f fVar) {
        Message obtain = Message.obtain();
        obtain.what = 4;
        obtain.obj = fVar;
        this.a.g(obtain);
    }

    public void p(File file) {
        Message obtain = Message.obtain();
        obtain.what = 9;
        obtain.obj = file;
        this.a.g(obtain);
    }
}