Shandong video conference v3.2.10版本的 MD5 值为:e9e908f971313b4c4bca5737f96781ef

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


package com.tencent.wxop.stat;

import android.content.Context;
import com.ainemo.android.utils.Formatter;
import com.tencent.wxop.stat.common.StatConstants;
import com.tencent.wxop.stat.common.StatLogger;
import java.lang.Thread;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import org.json.JSONException;
import org.json.JSONObject;
public class StatServiceImpl {
    private static com.tencent.wxop.stat.common.e f13463d;
    private static volatile Map<com.tencent.wxop.stat.event.c, Long> f13464e = new ConcurrentHashMap();
    private static volatile Map<String, Properties> f13465f = new ConcurrentHashMap();
    private static volatile Map<Integer, Integer> f13466g = new ConcurrentHashMap(10);
    private static volatile long f13467h = 0;
    private static volatile long f13468i = 0;
    private static volatile long f13469j = 0;
    private static String f13470k = "";
    private static volatile int l = 0;
    private static volatile String m = "";
    private static volatile String n = "";
    private static Map<String, Long> o = new ConcurrentHashMap();
    private static Map<String, Long> p = new ConcurrentHashMap();
    private static StatLogger q = com.tencent.wxop.stat.common.l.b();
    private static Thread.UncaughtExceptionHandler r = null;
    private static volatile boolean s = true;
    static volatile int a = 0;
    static volatile long f13461b = 0;
    private static Context t = null;
    static volatile long f13462c = 0;

    public static int a(Context context, boolean z, StatSpecifyReportedInfo statSpecifyReportedInfo) {
        long currentTimeMillis = System.currentTimeMillis();
        boolean z2 = z && currentTimeMillis - f13468i >= ((long) StatConfig.getSessionTimoutMillis());
        f13468i = currentTimeMillis;
        if (f13469j == 0) {
            f13469j = com.tencent.wxop.stat.common.l.c();
        }
        if (currentTimeMillis >= f13469j) {
            f13469j = com.tencent.wxop.stat.common.l.c();
            if (au.a(context).b(context).d() != 1) {
                au.a(context).b(context).a(1);
            }
            StatConfig.b(0);
            a = 0;
            f13470k = com.tencent.wxop.stat.common.l.a(0);
            z2 = true;
        }
        String str = f13470k;
        if (com.tencent.wxop.stat.common.l.a(statSpecifyReportedInfo)) {
            str = statSpecifyReportedInfo.getAppKey() + f13470k;
        }
        if (p.containsKey(str) ? z2 : true) {
            if (com.tencent.wxop.stat.common.l.a(statSpecifyReportedInfo)) {
                a(context, statSpecifyReportedInfo);
            } else if (StatConfig.c() < StatConfig.getMaxDaySessionNumbers()) {
                com.tencent.wxop.stat.common.l.v(context);
                a(context, (StatSpecifyReportedInfo) null);
            } else {
                q.e("Exceed StatConfig.getMaxDaySessionNumbers().");
            }
            p.put(str, 1L);
        }
        if (s) {
            testSpeed(context);
            s = false;
        }
        return l;
    }

    static synchronized void a(Context context) {
        synchronized (StatServiceImpl.class) {
            if (context == null) {
                return;
            }
            if (f13463d == null) {
                if (!b(context)) {
                    return;
                }
                Context applicationContext = context.getApplicationContext();
                t = applicationContext;
                f13463d = new com.tencent.wxop.stat.common.e();
                f13470k = com.tencent.wxop.stat.common.l.a(0);
                f13467h = System.currentTimeMillis() + StatConfig.f13455i;
                f13463d.a(new l(applicationContext));
            }
        }
    }

    static void a(Context context, StatSpecifyReportedInfo statSpecifyReportedInfo) {
        if (c(context) != null) {
            if (StatConfig.isDebugEnable()) {
                q.d("start new session.");
            }
            if (statSpecifyReportedInfo == null || l == 0) {
                l = com.tencent.wxop.stat.common.l.a();
            }
            StatConfig.a(0);
            StatConfig.b();
            new aq(new com.tencent.wxop.stat.event.k(context, l, b(), statSpecifyReportedInfo)).a();
        }
    }

    public static void a(Context context, Throwable th) {
        if (StatConfig.isEnableStatService()) {
            Context context2 = getContext(context);
            if (context2 == null) {
                q.error("The Context of StatService.reportSdkSelfException() can not be null!");
            } else if (c(context2) != null) {
                f13463d.a(new q(context2, th));
            }
        }
    }

    public static boolean a() {
        if (a >= 2) {
            f13461b = System.currentTimeMillis();
            return true;
        }
        return false;
    }

    public static boolean a(String str) {
        return str == null || str.length() == 0;
    }

    static JSONObject b() {
        JSONObject jSONObject = new JSONObject();
        try {
            JSONObject jSONObject2 = new JSONObject();
            if (StatConfig.f13448b.f13606d != 0) {
                jSONObject2.put(com.umeng.analytics.pro.ai.aC, StatConfig.f13448b.f13606d);
            }
            jSONObject.put(Integer.toString(StatConfig.f13448b.a), jSONObject2);
            JSONObject jSONObject3 = new JSONObject();
            if (StatConfig.a.f13606d != 0) {
                jSONObject3.put(com.umeng.analytics.pro.ai.aC, StatConfig.a.f13606d);
            }
            jSONObject.put(Integer.toString(StatConfig.a.a), jSONObject3);
        } catch (JSONException e2) {
            q.e((Throwable) e2);
        }
        return jSONObject;
    }

    public static void b(Context context, StatAccount statAccount, StatSpecifyReportedInfo statSpecifyReportedInfo) {
        try {
            new aq(new com.tencent.wxop.stat.event.a(context, a(context, false, statSpecifyReportedInfo), statAccount, statSpecifyReportedInfo)).a();
        } catch (Throwable th) {
            q.e(th);
            a(context, th);
        }
    }

    static boolean b(Context context) {
        boolean z;
        long a2 = com.tencent.wxop.stat.common.q.a(context, StatConfig.f13449c, 0L);
        long b2 = com.tencent.wxop.stat.common.l.b(StatConstants.VERSION);
        boolean z2 = false;
        if (b2 <= a2) {
            StatLogger statLogger = q;
            statLogger.error("MTA is disable for current version:" + b2 + ",wakeup version:" + a2);
            z = false;
        } else {
            z = true;
        }
        long a3 = com.tencent.wxop.stat.common.q.a(context, StatConfig.f13450d, 0L);
        if (a3 > System.currentTimeMillis()) {
            StatLogger statLogger2 = q;
            statLogger2.error("MTA is disable for current time:" + System.currentTimeMillis() + ",wakeup time:" + a3);
        } else {
            z2 = z;
        }
        StatConfig.setEnableStatService(z2);
        return z2;
    }

    static com.tencent.wxop.stat.common.e c(Context context) {
        if (f13463d == null) {
            synchronized (StatServiceImpl.class) {
                if (f13463d == null) {
                    a(context);
                }
            }
        }
        return f13463d;
    }

    public static void c() {
        a = 0;
        f13461b = 0L;
    }

    public static void commitEvents(Context context, int i2) {
        StatLogger statLogger;
        String str;
        if (StatConfig.isEnableStatService()) {
            if (StatConfig.isDebugEnable()) {
                StatLogger statLogger2 = q;
                statLogger2.i("commitEvents, maxNumber=" + i2);
            }
            Context context2 = getContext(context);
            if (context2 == null) {
                statLogger = q;
                str = "The Context of StatService.commitEvents() can not be null!";
            } else if (i2 >= -1 && i2 != 0) {
                if (a.a(t).f() && c(context2) != null) {
                    f13463d.a(new ad(context2, i2));
                    return;
                }
                return;
            } else {
                statLogger = q;
                str = "The maxNumber of StatService.commitEvents() should be -1 or bigger than 0.";
            }
            statLogger.error(str);
        }
    }

    public static void d() {
        a++;
        f13461b = System.currentTimeMillis();
        flushDataToDB(t);
    }

    public static void d(Context context) {
        if (StatConfig.isEnableStatService()) {
            Context context2 = getContext(context);
            if (context2 == null) {
                q.error("The Context of StatService.sendNetworkDetector() can not be null!");
                return;
            }
            try {
                i.b(context2).a(new com.tencent.wxop.stat.event.h(context2), new t());
            } catch (Throwable th) {
                q.e(th);
            }
        }
    }

    public static void e(Context context) {
        f13462c = System.currentTimeMillis() + (StatConfig.getSendPeriodMinutes() * Formatter.MINUTE);
        com.tencent.wxop.stat.common.q.b(context, "last_period_ts", f13462c);
        commitEvents(context, -1);
    }

    public static void flushDataToDB(Context context) {
        if (StatConfig.isEnableStatService() && StatConfig.m > 0) {
            Context context2 = getContext(context);
            if (context2 == null) {
                q.error("The Context of StatService.testSpeed() can not be null!");
            } else {
                au.a(context2).c();
            }
        }
    }

    public static Properties getCommonKeyValueForKVEvent(String str) {
        return f13465f.get(str);
    }

    public static Context getContext(Context context) {
        return context != null ? context : t;
    }

    public static void onLowMemory(Context context) {
        if (StatConfig.isEnableStatService() && c(getContext(context)) != null) {
            f13463d.a(new o(context));
        }
    }

    public static void onPause(Context context, StatSpecifyReportedInfo statSpecifyReportedInfo) {
        if (StatConfig.isEnableStatService() && c(context) != null) {
            f13463d.a(new m(context, statSpecifyReportedInfo));
        }
    }

    public static void onResume(Context context, StatSpecifyReportedInfo statSpecifyReportedInfo) {
        if (StatConfig.isEnableStatService() && c(context) != null) {
            f13463d.a(new aj(context, statSpecifyReportedInfo));
        }
    }

    public static void onStop(Context context, StatSpecifyReportedInfo statSpecifyReportedInfo) {
        if (StatConfig.isEnableStatService()) {
            Context context2 = getContext(context);
            if (c(context2) != null) {
                f13463d.a(new n(context2));
            }
        }
    }

    public static void reportAccount(Context context, StatAccount statAccount, StatSpecifyReportedInfo statSpecifyReportedInfo) {
        if (StatConfig.isEnableStatService()) {
            Context context2 = getContext(context);
            if (context2 == null) {
                q.e("context is null in reportAccount.");
            } else if (c(context2) != null) {
                f13463d.a(new al(statAccount, context2, statSpecifyReportedInfo));
            }
        }
    }

    public static void reportAppMonitorStat(Context context, StatAppMonitor statAppMonitor, StatSpecifyReportedInfo statSpecifyReportedInfo) {
        StatLogger statLogger;
        String str;
        if (StatConfig.isEnableStatService()) {
            Context context2 = getContext(context);
            if (context2 == null) {
                statLogger = q;
                str = "The Context of StatService.reportAppMonitorStat() can not be null!";
            } else if (statAppMonitor == null) {
                statLogger = q;
                str = "The StatAppMonitor of StatService.reportAppMonitorStat() can not be null!";
            } else if (statAppMonitor.getInterfaceName() != null) {
                StatAppMonitor m13clone = statAppMonitor.m13clone();
                if (c(context2) != null) {
                    f13463d.a(new aa(context2, statSpecifyReportedInfo, m13clone));
                    return;
                }
                return;
            } else {
                statLogger = q;
                str = "The interfaceName of StatAppMonitor on StatService.reportAppMonitorStat() can not be null!";
            }
            statLogger.error(str);
        }
    }

    public static void reportError(Context context, String str, StatSpecifyReportedInfo statSpecifyReportedInfo) {
        if (StatConfig.isEnableStatService()) {
            Context context2 = getContext(context);
            if (context2 == null) {
                q.error("The Context of StatService.reportError() can not be null!");
            } else if (c(context2) != null) {
                f13463d.a(new p(str, context2, statSpecifyReportedInfo));
            }
        }
    }

    public static void reportException(Context context, Throwable th, StatSpecifyReportedInfo statSpecifyReportedInfo) {
        if (StatConfig.isEnableStatService()) {
            Context context2 = getContext(context);
            if (context2 == null) {
                q.error("The Context of StatService.reportException() can not be null!");
            } else if (c(context2) != null) {
                f13463d.a(new r(th, context2, statSpecifyReportedInfo));
            }
        }
    }

    public static void reportGameUser(Context context, StatGameUser statGameUser, StatSpecifyReportedInfo statSpecifyReportedInfo) {
        if (StatConfig.isEnableStatService()) {
            Context context2 = getContext(context);
            if (context2 == null) {
                q.error("The Context of StatService.reportGameUser() can not be null!");
            } else if (c(context2) != null) {
                f13463d.a(new am(statGameUser, context2, statSpecifyReportedInfo));
            }
        }
    }

    public static void reportQQ(Context context, String str, StatSpecifyReportedInfo statSpecifyReportedInfo) {
        if (StatConfig.isEnableStatService()) {
            Context context2 = getContext(context);
            if (context2 == null) {
                q.error("context is null in reportQQ()");
            } else if (c(context2) != null) {
                f13463d.a(new ak(str, context2, statSpecifyReportedInfo));
            }
        }
    }

    public static void setCommonKeyValueForKVEvent(String str, Properties properties) {
        if (!com.tencent.wxop.stat.common.l.c(str)) {
            q.e("event_id or commonProp for setCommonKeyValueForKVEvent is invalid.");
        } else if (properties == null || properties.size() <= 0) {
            f13465f.remove(str);
        } else {
            f13465f.put(str, (Properties) properties.clone());
        }
    }

    public static void setContext(Context context) {
        if (context != null) {
            t = context.getApplicationContext();
        }
    }

    public static void setEnvAttributes(Context context, Map<String, String> map) {
        if (map == null || map.size() > 512) {
            q.error("The map in setEnvAttributes can't be null or its size can't exceed 512.");
            return;
        }
        try {
            com.tencent.wxop.stat.common.b.a(context, map);
        } catch (JSONException e2) {
            q.e((Throwable) e2);
        }
    }

    public static void startNewSession(Context context, StatSpecifyReportedInfo statSpecifyReportedInfo) {
        if (StatConfig.isEnableStatService()) {
            Context context2 = getContext(context);
            if (context2 == null) {
                q.error("The Context of StatService.startNewSession() can not be null!");
            } else if (c(context2) != null) {
                f13463d.a(new ai(context2, statSpecifyReportedInfo));
            }
        }
    }

    public static boolean startStatService(Context context, String str, String str2, StatSpecifyReportedInfo statSpecifyReportedInfo) {
        try {
            if (!StatConfig.isEnableStatService()) {
                q.error("MTA StatService is disable.");
                return false;
            }
            if (StatConfig.isDebugEnable()) {
                q.d("MTA SDK version, current: " + StatConstants.VERSION + " ,required: " + str2);
            }
            if (context != null && str2 != null) {
                if (com.tencent.wxop.stat.common.l.b(StatConstants.VERSION) >= com.tencent.wxop.stat.common.l.b(str2)) {
                    String installChannel = StatConfig.getInstallChannel(context);
                    if (installChannel == null || installChannel.length() == 0) {
                        StatConfig.setInstallChannel("-");
                    }
                    if (str != null) {
                        StatConfig.setAppKey(context, str);
                    }
                    if (c(context) != null) {
                        f13463d.a(new an(context, statSpecifyReportedInfo));
                        return true;
                    }
                    return true;
                }
                q.error(("MTA SDK version conflicted, current: " + StatConstants.VERSION + ",required: " + str2) + ". please delete the current SDK and download the latest one. official website: http://mta.qq.com/ or http://mta.oa.com/");
                StatConfig.setEnableStatService(false);
                return false;
            }
            q.error("Context or mtaSdkVersion in StatService.startStatService() is null, please check it!");
            StatConfig.setEnableStatService(false);
            return false;
        } catch (Throwable th) {
            q.e(th);
            return false;
        }
    }

    public static void stopSession() {
        f13468i = 0L;
    }

    public static void testSpeed(Context context) {
        if (StatConfig.isEnableStatService()) {
            Context context2 = getContext(context);
            if (context2 == null) {
                q.error("The Context of StatService.testSpeed() can not be null!");
            } else if (c(context2) != null) {
                f13463d.a(new ae(context2));
            }
        }
    }

    public static void testSpeed(Context context, Map<String, Integer> map, StatSpecifyReportedInfo statSpecifyReportedInfo) {
        StatLogger statLogger;
        String str;
        if (StatConfig.isEnableStatService()) {
            Context context2 = getContext(context);
            if (context2 == null) {
                statLogger = q;
                str = "The Context of StatService.testSpeed() can not be null!";
            } else if (map != null && map.size() != 0) {
                HashMap hashMap = new HashMap(map);
                if (c(context2) != null) {
                    f13463d.a(new af(context2, hashMap, statSpecifyReportedInfo));
                    return;
                }
                return;
            } else {
                statLogger = q;
                str = "The domainMap of StatService.testSpeed() can not be null or empty!";
            }
            statLogger.error(str);
        }
    }

    public static void trackBeginPage(Context context, String str, StatSpecifyReportedInfo statSpecifyReportedInfo) {
        if (StatConfig.isEnableStatService()) {
            Context context2 = getContext(context);
            if (context2 == null || str == null || str.length() == 0) {
                q.error("The Context or pageName of StatService.trackBeginPage() can not be null or empty!");
                return;
            }
            String str2 = new String(str);
            if (c(context2) != null) {
                f13463d.a(new w(str2, context2, statSpecifyReportedInfo));
            }
        }
    }

    public static void trackCustomBeginEvent(Context context, String str, StatSpecifyReportedInfo statSpecifyReportedInfo, String... strArr) {
        if (StatConfig.isEnableStatService()) {
            Context context2 = getContext(context);
            if (context2 == null) {
                q.error("The Context of StatService.trackCustomBeginEvent() can not be null!");
                return;
            }
            com.tencent.wxop.stat.event.c cVar = new com.tencent.wxop.stat.event.c(str, strArr, null);
            if (c(context2) != null) {
                f13463d.a(new v(str, cVar, context2));
            }
        }
    }

    public static void trackCustomBeginKVEvent(Context context, String str, Properties properties, StatSpecifyReportedInfo statSpecifyReportedInfo) {
        if (StatConfig.isEnableStatService()) {
            Context context2 = getContext(context);
            if (context2 == null) {
                q.error("The Context of StatService.trackCustomBeginEvent() can not be null!");
                return;
            }
            com.tencent.wxop.stat.event.c cVar = new com.tencent.wxop.stat.event.c(str, null, properties);
            if (c(context2) != null) {
                f13463d.a(new y(str, cVar, context2));
            }
        }
    }

    public static void trackCustomEndEvent(Context context, String str, StatSpecifyReportedInfo statSpecifyReportedInfo, String... strArr) {
        if (StatConfig.isEnableStatService()) {
            Context context2 = getContext(context);
            if (context2 == null) {
                q.error("The Context of StatService.trackCustomEndEvent() can not be null!");
                return;
            }
            com.tencent.wxop.stat.event.c cVar = new com.tencent.wxop.stat.event.c(str, strArr, null);
            if (c(context2) != null) {
                f13463d.a(new x(str, cVar, context2, statSpecifyReportedInfo));
            }
        }
    }

    public static void trackCustomEndKVEvent(Context context, String str, Properties properties, StatSpecifyReportedInfo statSpecifyReportedInfo) {
        if (StatConfig.isEnableStatService()) {
            Context context2 = getContext(context);
            if (context2 == null) {
                q.error("The Context of StatService.trackCustomEndEvent() can not be null!");
                return;
            }
            com.tencent.wxop.stat.event.c cVar = new com.tencent.wxop.stat.event.c(str, null, properties);
            if (c(context2) != null) {
                f13463d.a(new z(str, cVar, context2, statSpecifyReportedInfo));
            }
        }
    }

    public static void trackCustomEvent(Context context, String str, StatSpecifyReportedInfo statSpecifyReportedInfo, String... strArr) {
        StatLogger statLogger;
        String str2;
        if (StatConfig.isEnableStatService()) {
            Context context2 = getContext(context);
            if (context2 == null) {
                statLogger = q;
                str2 = "The Context of StatService.trackCustomEvent() can not be null!";
            } else if (!a(str)) {
                com.tencent.wxop.stat.event.c cVar = new com.tencent.wxop.stat.event.c(str, strArr, null);
                if (c(context2) != null) {
                    f13463d.a(new s(context2, statSpecifyReportedInfo, cVar));
                    return;
                }
                return;
            } else {
                statLogger = q;
                str2 = "The event_id of StatService.trackCustomEvent() can not be null or empty.";
            }
            statLogger.error(str2);
        }
    }

    public static void trackCustomKVEvent(Context context, String str, Properties properties, StatSpecifyReportedInfo statSpecifyReportedInfo) {
        StatLogger statLogger;
        String str2;
        if (StatConfig.isEnableStatService()) {
            Context context2 = getContext(context);
            if (context2 == null) {
                statLogger = q;
                str2 = "The Context of StatService.trackCustomEvent() can not be null!";
            } else if (!a(str)) {
                com.tencent.wxop.stat.event.c cVar = new com.tencent.wxop.stat.event.c(str, null, properties);
                if (c(context2) != null) {
                    f13463d.a(new u(context2, statSpecifyReportedInfo, cVar));
                    return;
                }
                return;
            } else {
                statLogger = q;
                str2 = "The event_id of StatService.trackCustomEvent() can not be null or empty.";
            }
            statLogger.error(str2);
        }
    }

    public static void trackCustomKVTimeIntervalEvent(Context context, String str, Properties properties, int i2, StatSpecifyReportedInfo statSpecifyReportedInfo) {
        StatLogger statLogger;
        String str2;
        if (StatConfig.isEnableStatService()) {
            Context context2 = getContext(context);
            if (context2 == null) {
                statLogger = q;
                str2 = "The Context of StatService.trackCustomEndEvent() can not be null!";
            } else if (!a(str)) {
                com.tencent.wxop.stat.event.c cVar = new com.tencent.wxop.stat.event.c(str, null, properties);
                if (c(context2) != null) {
                    f13463d.a(new ac(context2, statSpecifyReportedInfo, cVar, i2));
                    return;
                }
                return;
            } else {
                statLogger = q;
                str2 = "The event_id of StatService.trackCustomEndEvent() can not be null or empty.";
            }
            statLogger.error(str2);
        }
    }

    public static void trackCustomTimeIntervalEvent(Context context, int i2, String str, String... strArr) {
        StatLogger statLogger;
        String str2;
        if (StatConfig.isEnableStatService()) {
            if (i2 <= 0) {
                statLogger = q;
                str2 = "The intervalSecond of StatService.trackCustomTimeIntervalEvent() can must bigger than 0!";
            } else {
                Context context2 = getContext(context);
                if (context2 != null) {
                    if (c(context2) != null) {
                        f13463d.a(new ab());
                        return;
                    }
                    return;
                }
                statLogger = q;
                str2 = "The Context of StatService.trackCustomTimeIntervalEvent() can not be null!";
            }
            statLogger.error(str2);
        }
    }

    public static void trackEndPage(Context context, String str, StatSpecifyReportedInfo statSpecifyReportedInfo) {
        if (StatConfig.isEnableStatService()) {
            Context context2 = getContext(context);
            if (context2 == null || str == null || str.length() == 0) {
                q.error("The Context or pageName of StatService.trackEndPage() can not be null or empty!");
                return;
            }
            String str2 = new String(str);
            if (c(context2) != null) {
                f13463d.a(new ah(context2, str2, statSpecifyReportedInfo));
            }
        }
    }
}