Aqara Home v2.4.1版本的 MD5 值为:529779ac2bc0131db52a1fc3098d2b35
以下内容为反编译后的 StatServiceImpl.java 源代码,内容仅作参考
package com.tencent.wxop.stat;
import android.content.Context;
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 {
public static com.tencent.wxop.stat.common.e d;
public static volatile Map<com.tencent.wxop.stat.event.c, Long> f13899e = new ConcurrentHashMap();
public static volatile Map<String, Properties> f13900f = new ConcurrentHashMap();
public static volatile Map<Integer, Integer> f13901g = new ConcurrentHashMap(10);
public static volatile long f13902h = 0;
public static volatile long f13903i = 0;
public static volatile long f13904j = 0;
public static String f13905k = "";
public static volatile int f13906l = 0;
public static volatile String f13907m = "";
public static volatile String f13908n = "";
public static Map<String, Long> f13909o = new ConcurrentHashMap();
public static Map<String, Long> f13910p = new ConcurrentHashMap();
public static StatLogger f13911q = com.tencent.wxop.stat.common.l.b();
public static Thread.UncaughtExceptionHandler f13912r = null;
public static volatile boolean f13913s = true;
public static volatile int a = 0;
public static volatile long b = 0;
public static Context f13914t = null;
public static volatile long c = 0;
public static int a(Context context, boolean z2, StatSpecifyReportedInfo statSpecifyReportedInfo) {
long currentTimeMillis = System.currentTimeMillis();
boolean z3 = z2 && currentTimeMillis - f13903i >= ((long) StatConfig.getSessionTimoutMillis());
f13903i = currentTimeMillis;
if (f13904j == 0) {
f13904j = com.tencent.wxop.stat.common.l.c();
}
if (currentTimeMillis >= f13904j) {
f13904j = 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;
f13905k = com.tencent.wxop.stat.common.l.a(0);
z3 = true;
}
String str = f13905k;
if (com.tencent.wxop.stat.common.l.a(statSpecifyReportedInfo)) {
str = statSpecifyReportedInfo.getAppKey() + f13905k;
}
if (f13910p.containsKey(str) ? z3 : 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 {
f13911q.e("Exceed StatConfig.getMaxDaySessionNumbers().");
}
f13910p.put(str, 1L);
}
if (f13913s) {
testSpeed(context);
f13913s = false;
}
return f13906l;
}
public static synchronized void a(Context context) {
synchronized (StatServiceImpl.class) {
if (context == null) {
return;
}
if (d == null) {
if (!b(context)) {
return;
}
Context applicationContext = context.getApplicationContext();
f13914t = applicationContext;
d = new com.tencent.wxop.stat.common.e();
f13905k = com.tencent.wxop.stat.common.l.a(0);
f13902h = System.currentTimeMillis() + StatConfig.f13881i;
d.a(new l(applicationContext));
}
}
}
public static void a(Context context, StatSpecifyReportedInfo statSpecifyReportedInfo) {
if (c(context) != null) {
if (StatConfig.isDebugEnable()) {
f13911q.d("start new session.");
}
if (statSpecifyReportedInfo == null || f13906l == 0) {
f13906l = com.tencent.wxop.stat.common.l.a();
}
StatConfig.a(0);
StatConfig.b();
new aq(new com.tencent.wxop.stat.event.k(context, f13906l, b(), statSpecifyReportedInfo)).a();
}
}
public static void a(Context context, Throwable th) {
if (StatConfig.isEnableStatService()) {
Context context2 = getContext(context);
if (context2 == null) {
f13911q.error("The Context of StatService.reportSdkSelfException() can not be null!");
} else if (c(context2) != null) {
d.a(new q(context2, th));
}
}
}
public static boolean a() {
if (a >= 2) {
b = System.currentTimeMillis();
return true;
}
return false;
}
public static boolean a(String str) {
return str == null || str.length() == 0;
}
public static JSONObject b() {
JSONObject jSONObject = new JSONObject();
try {
JSONObject jSONObject2 = new JSONObject();
if (StatConfig.b.d != 0) {
jSONObject2.put("v", StatConfig.b.d);
}
jSONObject.put(Integer.toString(StatConfig.b.a), jSONObject2);
JSONObject jSONObject3 = new JSONObject();
if (StatConfig.a.d != 0) {
jSONObject3.put("v", StatConfig.a.d);
}
jSONObject.put(Integer.toString(StatConfig.a.a), jSONObject3);
} catch (JSONException e2) {
f13911q.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) {
f13911q.e(th);
a(context, th);
}
}
public static boolean b(Context context) {
boolean z2;
long a2 = com.tencent.wxop.stat.common.q.a(context, StatConfig.c, 0L);
long b2 = com.tencent.wxop.stat.common.l.b(StatConstants.VERSION);
boolean z3 = false;
if (b2 <= a2) {
StatLogger statLogger = f13911q;
statLogger.error("MTA is disable for current version:" + b2 + ",wakeup version:" + a2);
z2 = false;
} else {
z2 = true;
}
long a3 = com.tencent.wxop.stat.common.q.a(context, StatConfig.d, 0L);
if (a3 > System.currentTimeMillis()) {
StatLogger statLogger2 = f13911q;
statLogger2.error("MTA is disable for current time:" + System.currentTimeMillis() + ",wakeup time:" + a3);
} else {
z3 = z2;
}
StatConfig.setEnableStatService(z3);
return z3;
}
public static com.tencent.wxop.stat.common.e c(Context context) {
if (d == null) {
synchronized (StatServiceImpl.class) {
if (d == null) {
a(context);
}
}
}
return d;
}
public static void c() {
a = 0;
b = 0L;
}
public static void commitEvents(Context context, int i2) {
StatLogger statLogger;
String str;
if (StatConfig.isEnableStatService()) {
if (StatConfig.isDebugEnable()) {
StatLogger statLogger2 = f13911q;
statLogger2.i("commitEvents, maxNumber=" + i2);
}
Context context2 = getContext(context);
if (context2 == null) {
statLogger = f13911q;
str = "The Context of StatService.commitEvents() can not be null!";
} else if (i2 >= -1 && i2 != 0) {
if (a.a(f13914t).f() && c(context2) != null) {
d.a(new ad(context2, i2));
return;
}
return;
} else {
statLogger = f13911q;
str = "The maxNumber of StatService.commitEvents() should be -1 or bigger than 0.";
}
statLogger.error(str);
}
}
public static void d() {
a++;
b = System.currentTimeMillis();
flushDataToDB(f13914t);
}
public static void d(Context context) {
if (StatConfig.isEnableStatService()) {
Context context2 = getContext(context);
if (context2 == null) {
f13911q.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) {
f13911q.e(th);
}
}
}
public static void e(Context context) {
c = System.currentTimeMillis() + (StatConfig.getSendPeriodMinutes() * 60000);
com.tencent.wxop.stat.common.q.b(context, "last_period_ts", c);
commitEvents(context, -1);
}
public static void flushDataToDB(Context context) {
if (StatConfig.isEnableStatService() && StatConfig.f13885m > 0) {
Context context2 = getContext(context);
if (context2 == null) {
f13911q.error("The Context of StatService.testSpeed() can not be null!");
} else {
au.a(context2).c();
}
}
}
public static Properties getCommonKeyValueForKVEvent(String str) {
return f13900f.get(str);
}
public static Context getContext(Context context) {
return context != null ? context : f13914t;
}
public static void onLowMemory(Context context) {
if (StatConfig.isEnableStatService() && c(getContext(context)) != null) {
d.a(new o(context));
}
}
public static void onPause(Context context, StatSpecifyReportedInfo statSpecifyReportedInfo) {
if (StatConfig.isEnableStatService() && c(context) != null) {
d.a(new m(context, statSpecifyReportedInfo));
}
}
public static void onResume(Context context, StatSpecifyReportedInfo statSpecifyReportedInfo) {
if (StatConfig.isEnableStatService() && c(context) != null) {
d.a(new aj(context, statSpecifyReportedInfo));
}
}
public static void onStop(Context context, StatSpecifyReportedInfo statSpecifyReportedInfo) {
if (StatConfig.isEnableStatService()) {
Context context2 = getContext(context);
if (c(context2) != null) {
d.a(new n(context2));
}
}
}
public static void reportAccount(Context context, StatAccount statAccount, StatSpecifyReportedInfo statSpecifyReportedInfo) {
if (StatConfig.isEnableStatService()) {
Context context2 = getContext(context);
if (context2 == null) {
f13911q.e("context is null in reportAccount.");
} else if (c(context2) != null) {
d.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 = f13911q;
str = "The Context of StatService.reportAppMonitorStat() can not be null!";
} else if (statAppMonitor == null) {
statLogger = f13911q;
str = "The StatAppMonitor of StatService.reportAppMonitorStat() can not be null!";
} else if (statAppMonitor.getInterfaceName() != null) {
StatAppMonitor m95clone = statAppMonitor.m95clone();
if (c(context2) != null) {
d.a(new aa(context2, statSpecifyReportedInfo, m95clone));
return;
}
return;
} else {
statLogger = f13911q;
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) {
f13911q.error("The Context of StatService.reportError() can not be null!");
} else if (c(context2) != null) {
d.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) {
f13911q.error("The Context of StatService.reportException() can not be null!");
} else if (c(context2) != null) {
d.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) {
f13911q.error("The Context of StatService.reportGameUser() can not be null!");
} else if (c(context2) != null) {
d.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) {
f13911q.error("context is null in reportQQ()");
} else if (c(context2) != null) {
d.a(new ak(str, context2, statSpecifyReportedInfo));
}
}
}
public static void setCommonKeyValueForKVEvent(String str, Properties properties) {
if (!com.tencent.wxop.stat.common.l.c(str)) {
f13911q.e("event_id or commonProp for setCommonKeyValueForKVEvent is invalid.");
} else if (properties == null || properties.size() <= 0) {
f13900f.remove(str);
} else {
f13900f.put(str, (Properties) properties.clone());
}
}
public static void setContext(Context context) {
if (context != null) {
f13914t = context.getApplicationContext();
}
}
public static void setEnvAttributes(Context context, Map<String, String> map) {
if (map == null || map.size() > 512) {
f13911q.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) {
f13911q.e((Throwable) e2);
}
}
public static void startNewSession(Context context, StatSpecifyReportedInfo statSpecifyReportedInfo) {
if (StatConfig.isEnableStatService()) {
Context context2 = getContext(context);
if (context2 == null) {
f13911q.error("The Context of StatService.startNewSession() can not be null!");
} else if (c(context2) != null) {
d.a(new ai(context2, statSpecifyReportedInfo));
}
}
}
public static boolean startStatService(Context context, String str, String str2, StatSpecifyReportedInfo statSpecifyReportedInfo) {
try {
if (!StatConfig.isEnableStatService()) {
f13911q.error("MTA StatService is disable.");
return false;
}
if (StatConfig.isDebugEnable()) {
f13911q.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) {
d.a(new an(context, statSpecifyReportedInfo));
return true;
}
return true;
}
f13911q.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;
}
f13911q.error("Context or mtaSdkVersion in StatService.startStatService() is null, please check it!");
StatConfig.setEnableStatService(false);
return false;
} catch (Throwable th) {
f13911q.e(th);
return false;
}
}
public static void stopSession() {
f13903i = 0L;
}
public static void testSpeed(Context context) {
if (StatConfig.isEnableStatService()) {
Context context2 = getContext(context);
if (context2 == null) {
f13911q.error("The Context of StatService.testSpeed() can not be null!");
} else if (c(context2) != null) {
d.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 = f13911q;
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) {
d.a(new af(context2, hashMap, statSpecifyReportedInfo));
return;
}
return;
} else {
statLogger = f13911q;
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) {
f13911q.error("The Context or pageName of StatService.trackBeginPage() can not be null or empty!");
return;
}
String str2 = new String(str);
if (c(context2) != null) {
d.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) {
f13911q.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) {
d.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) {
f13911q.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) {
d.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) {
f13911q.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) {
d.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) {
f13911q.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) {
d.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 = f13911q;
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) {
d.a(new s(context2, statSpecifyReportedInfo, cVar));
return;
}
return;
} else {
statLogger = f13911q;
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 = f13911q;
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) {
d.a(new u(context2, statSpecifyReportedInfo, cVar));
return;
}
return;
} else {
statLogger = f13911q;
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 = f13911q;
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) {
d.a(new ac(context2, statSpecifyReportedInfo, cVar, i2));
return;
}
return;
} else {
statLogger = f13911q;
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 = f13911q;
str2 = "The intervalSecond of StatService.trackCustomTimeIntervalEvent() can must bigger than 0!";
} else {
Context context2 = getContext(context);
if (context2 != null) {
if (c(context2) != null) {
d.a(new ab());
return;
}
return;
}
statLogger = f13911q;
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) {
f13911q.error("The Context or pageName of StatService.trackEndPage() can not be null or empty!");
return;
}
String str2 = new String(str);
if (c(context2) != null) {
d.a(new ah(context2, str2, statSpecifyReportedInfo));
}
}
}
}