198 lines
6.5 KiB
Java
198 lines
6.5 KiB
Java
package com.tencent.wxop.stat;
|
|
|
|
import android.content.Context;
|
|
import com.tencent.wxop.stat.common.StatLogger;
|
|
import java.util.Map;
|
|
|
|
/* loaded from: classes.dex */
|
|
class aq {
|
|
private static volatile long f;
|
|
private com.tencent.wxop.stat.event.e a;
|
|
private StatReportStrategy b;
|
|
private boolean c;
|
|
private Context d;
|
|
private long e = System.currentTimeMillis();
|
|
|
|
public aq(com.tencent.wxop.stat.event.e eVar) {
|
|
this.b = null;
|
|
this.c = false;
|
|
this.d = null;
|
|
this.a = eVar;
|
|
this.b = StatConfig.getStatSendStrategy();
|
|
this.c = eVar.f();
|
|
this.d = eVar.e();
|
|
}
|
|
|
|
private void a(h hVar) {
|
|
Context context;
|
|
context = StatServiceImpl.t;
|
|
i.b(context).a(this.a, hVar);
|
|
}
|
|
|
|
private void b() {
|
|
StatLogger statLogger;
|
|
StatLogger statLogger2;
|
|
Context context;
|
|
StatLogger statLogger3;
|
|
StatLogger statLogger4;
|
|
Context context2;
|
|
if (this.a.d() != null && this.a.d().isSendImmediately()) {
|
|
this.b = StatReportStrategy.INSTANT;
|
|
}
|
|
if (StatConfig.j) {
|
|
context2 = StatServiceImpl.t;
|
|
if (a.a(context2).e()) {
|
|
this.b = StatReportStrategy.INSTANT;
|
|
}
|
|
}
|
|
if (StatConfig.isDebugEnable()) {
|
|
statLogger4 = StatServiceImpl.q;
|
|
statLogger4.i("strategy=" + this.b.name());
|
|
}
|
|
switch (ag.a[this.b.ordinal()]) {
|
|
case 1:
|
|
c();
|
|
break;
|
|
case 2:
|
|
au.a(this.d).a(this.a, (h) null, this.c, false);
|
|
if (StatConfig.isDebugEnable()) {
|
|
statLogger2 = StatServiceImpl.q;
|
|
statLogger2.i("PERIOD currTime=" + this.e + ",nextPeriodSendTs=" + StatServiceImpl.c + ",difftime=" + (StatServiceImpl.c - this.e));
|
|
}
|
|
if (StatServiceImpl.c == 0) {
|
|
StatServiceImpl.c = com.tencent.wxop.stat.common.q.a(this.d, "last_period_ts", 0L);
|
|
if (this.e > StatServiceImpl.c) {
|
|
StatServiceImpl.e(this.d);
|
|
}
|
|
long sendPeriodMinutes = this.e + (StatConfig.getSendPeriodMinutes() * 60 * 1000);
|
|
if (StatServiceImpl.c > sendPeriodMinutes) {
|
|
StatServiceImpl.c = sendPeriodMinutes;
|
|
}
|
|
d.a(this.d).a();
|
|
}
|
|
if (StatConfig.isDebugEnable()) {
|
|
statLogger = StatServiceImpl.q;
|
|
statLogger.i("PERIOD currTime=" + this.e + ",nextPeriodSendTs=" + StatServiceImpl.c + ",difftime=" + (StatServiceImpl.c - this.e));
|
|
}
|
|
if (this.e > StatServiceImpl.c) {
|
|
StatServiceImpl.e(this.d);
|
|
break;
|
|
}
|
|
break;
|
|
case 3:
|
|
case 4:
|
|
au.a(this.d).a(this.a, (h) null, this.c, false);
|
|
break;
|
|
case 5:
|
|
au.a(this.d).a(this.a, (h) new ar(this), this.c, true);
|
|
break;
|
|
case 6:
|
|
context = StatServiceImpl.t;
|
|
if (a.a(context).c() != 1) {
|
|
au.a(this.d).a(this.a, (h) null, this.c, false);
|
|
break;
|
|
} else {
|
|
c();
|
|
break;
|
|
}
|
|
case 7:
|
|
if (com.tencent.wxop.stat.common.l.e(this.d)) {
|
|
a(new as(this));
|
|
break;
|
|
}
|
|
break;
|
|
default:
|
|
statLogger3 = StatServiceImpl.q;
|
|
statLogger3.error("Invalid stat strategy:" + StatConfig.getStatSendStrategy());
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void c() {
|
|
if (au.b().a <= 0 || !StatConfig.l) {
|
|
a(new at(this));
|
|
} else {
|
|
au.b().a(this.a, (h) null, this.c, true);
|
|
au.b().a(-1);
|
|
}
|
|
}
|
|
|
|
private boolean d() {
|
|
long j;
|
|
Map map;
|
|
Map map2;
|
|
Map map3;
|
|
StatLogger statLogger;
|
|
Map map4;
|
|
StatLogger statLogger2;
|
|
long j2;
|
|
if (StatConfig.h <= 0) {
|
|
return false;
|
|
}
|
|
long j3 = this.e;
|
|
j = StatServiceImpl.h;
|
|
if (j3 > j) {
|
|
map4 = StatServiceImpl.g;
|
|
map4.clear();
|
|
long unused = StatServiceImpl.h = this.e + StatConfig.i;
|
|
if (StatConfig.isDebugEnable()) {
|
|
statLogger2 = StatServiceImpl.q;
|
|
StringBuilder sb = new StringBuilder("clear methodsCalledLimitMap, nextLimitCallClearTime=");
|
|
j2 = StatServiceImpl.h;
|
|
sb.append(j2);
|
|
statLogger2.i(sb.toString());
|
|
}
|
|
}
|
|
Integer valueOf = Integer.valueOf(this.a.a().a());
|
|
map = StatServiceImpl.g;
|
|
Integer num = (Integer) map.get(valueOf);
|
|
if (num == null) {
|
|
map2 = StatServiceImpl.g;
|
|
map2.put(valueOf, 1);
|
|
return false;
|
|
}
|
|
map3 = StatServiceImpl.g;
|
|
map3.put(valueOf, Integer.valueOf(num.intValue() + 1));
|
|
if (num.intValue() <= StatConfig.h) {
|
|
return false;
|
|
}
|
|
if (StatConfig.isDebugEnable()) {
|
|
statLogger = StatServiceImpl.q;
|
|
statLogger.e("event " + this.a.g() + " was discard, cause of called limit, current:" + num + ", limit:" + StatConfig.h + ", period:" + StatConfig.i + " ms");
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public void a() {
|
|
StatLogger statLogger;
|
|
StatLogger statLogger2;
|
|
if (d()) {
|
|
return;
|
|
}
|
|
if (StatConfig.m > 0 && this.e >= f) {
|
|
StatServiceImpl.flushDataToDB(this.d);
|
|
f = this.e + StatConfig.n;
|
|
if (StatConfig.isDebugEnable()) {
|
|
statLogger2 = StatServiceImpl.q;
|
|
statLogger2.i("nextFlushTime=" + f);
|
|
}
|
|
}
|
|
if (!a.a(this.d).f()) {
|
|
au.a(this.d).a(this.a, (h) null, this.c, false);
|
|
return;
|
|
}
|
|
if (StatConfig.isDebugEnable()) {
|
|
statLogger = StatServiceImpl.q;
|
|
statLogger.i("sendFailedCount=" + StatServiceImpl.a);
|
|
}
|
|
if (!StatServiceImpl.a()) {
|
|
b();
|
|
return;
|
|
}
|
|
au.a(this.d).a(this.a, (h) null, this.c, false);
|
|
if (this.e - StatServiceImpl.b > 1800000) {
|
|
StatServiceImpl.d(this.d);
|
|
}
|
|
}
|
|
}
|