94 lines
2.6 KiB
Java
94 lines
2.6 KiB
Java
package com.huawei.hms.stats;
|
|
|
|
import android.os.Handler;
|
|
import android.os.Looper;
|
|
import com.huawei.hms.support.hianalytics.HiAnalyticsUtils;
|
|
import com.huawei.hms.support.log.HMSLog;
|
|
import java.util.ArrayList;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class a {
|
|
private static final a f = new a();
|
|
private final Object a = new Object();
|
|
private boolean b = false;
|
|
private final List<Runnable> c = new ArrayList();
|
|
private final Handler d = new Handler(Looper.getMainLooper());
|
|
private final Runnable e = new RunnableC0050a(this);
|
|
|
|
/* renamed from: com.huawei.hms.stats.a$a, reason: collision with other inner class name */
|
|
/* loaded from: classes2.dex */
|
|
class RunnableC0050a implements Runnable {
|
|
final a a;
|
|
|
|
RunnableC0050a(a aVar) {
|
|
this.a = aVar;
|
|
}
|
|
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
HMSLog.i("AnalyticsCacheManager", "Timeout execCacheBi.");
|
|
if (!HiAnalyticsUtils.getInstance().getInitFlag()) {
|
|
this.a.a();
|
|
} else {
|
|
this.a.b();
|
|
}
|
|
}
|
|
}
|
|
|
|
private a() {
|
|
}
|
|
|
|
public void a(Runnable runnable) {
|
|
synchronized (this.a) {
|
|
if (runnable == null) {
|
|
return;
|
|
}
|
|
if (this.b) {
|
|
return;
|
|
}
|
|
if (this.c.size() >= 60) {
|
|
return;
|
|
}
|
|
this.c.add(runnable);
|
|
this.d.removeCallbacks(this.e);
|
|
this.d.postDelayed(this.e, 10000L);
|
|
}
|
|
}
|
|
|
|
public void b() {
|
|
synchronized (this.a) {
|
|
StringBuilder sb = new StringBuilder("execCacheBi: cache size: ");
|
|
sb.append(this.c.size());
|
|
HMSLog.i("AnalyticsCacheManager", sb.toString());
|
|
this.b = true;
|
|
try {
|
|
Iterator<Runnable> it = this.c.iterator();
|
|
while (it.hasNext()) {
|
|
it.next().run();
|
|
it.remove();
|
|
}
|
|
} catch (Throwable th) {
|
|
StringBuilder sb2 = new StringBuilder();
|
|
sb2.append("<execCacheBi> failed. ");
|
|
sb2.append(th.getMessage());
|
|
HMSLog.e("AnalyticsCacheManager", sb2.toString());
|
|
a();
|
|
}
|
|
this.b = false;
|
|
}
|
|
}
|
|
|
|
public void a() {
|
|
synchronized (this.a) {
|
|
HMSLog.i("AnalyticsCacheManager", "clear AnalyticsCache.");
|
|
this.c.clear();
|
|
}
|
|
}
|
|
|
|
public static a c() {
|
|
return f;
|
|
}
|
|
}
|