123 lines
4.4 KiB
Java
123 lines
4.4 KiB
Java
package com.tencent.bugly.crashreport.crash;
|
|
|
|
import android.content.BroadcastReceiver;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.content.IntentFilter;
|
|
import com.tencent.bugly.proguard.u;
|
|
import com.tencent.bugly.proguard.x;
|
|
import com.tencent.bugly.proguard.z;
|
|
|
|
/* compiled from: BUGLY */
|
|
/* loaded from: classes.dex */
|
|
public class BuglyBroadcastReceiver extends BroadcastReceiver {
|
|
private static BuglyBroadcastReceiver d;
|
|
private Context b;
|
|
private String c;
|
|
private boolean e = true;
|
|
private IntentFilter a = new IntentFilter();
|
|
|
|
public static synchronized BuglyBroadcastReceiver getInstance() {
|
|
BuglyBroadcastReceiver buglyBroadcastReceiver;
|
|
synchronized (BuglyBroadcastReceiver.class) {
|
|
if (d == null) {
|
|
d = new BuglyBroadcastReceiver();
|
|
}
|
|
buglyBroadcastReceiver = d;
|
|
}
|
|
return buglyBroadcastReceiver;
|
|
}
|
|
|
|
public synchronized void addFilter(String str) {
|
|
if (!this.a.hasAction(str)) {
|
|
this.a.addAction(str);
|
|
}
|
|
x.c("add action %s", str);
|
|
}
|
|
|
|
@Override // android.content.BroadcastReceiver
|
|
public final void onReceive(Context context, Intent intent) {
|
|
try {
|
|
a(context, intent);
|
|
} catch (Throwable th) {
|
|
if (x.a(th)) {
|
|
return;
|
|
}
|
|
th.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public synchronized void register(Context context) {
|
|
this.b = context;
|
|
z.a(new Runnable() { // from class: com.tencent.bugly.crashreport.crash.BuglyBroadcastReceiver.1
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
try {
|
|
x.a(BuglyBroadcastReceiver.d.getClass(), "Register broadcast receiver of Bugly.", new Object[0]);
|
|
synchronized (this) {
|
|
BuglyBroadcastReceiver.this.b.registerReceiver(BuglyBroadcastReceiver.d, BuglyBroadcastReceiver.this.a);
|
|
}
|
|
} catch (Throwable th) {
|
|
th.printStackTrace();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
public synchronized void unregister(Context context) {
|
|
try {
|
|
x.a(getClass(), "Unregister broadcast receiver of Bugly.", new Object[0]);
|
|
context.unregisterReceiver(this);
|
|
this.b = context;
|
|
} catch (Throwable th) {
|
|
if (x.a(th)) {
|
|
return;
|
|
}
|
|
th.printStackTrace();
|
|
}
|
|
}
|
|
|
|
private synchronized boolean a(Context context, Intent intent) {
|
|
if (context != null && intent != null) {
|
|
if (intent.getAction().equals("android.net.conn.CONNECTIVITY_CHANGE")) {
|
|
if (this.e) {
|
|
this.e = false;
|
|
return true;
|
|
}
|
|
String c = com.tencent.bugly.crashreport.common.info.b.c(this.b);
|
|
x.c("is Connect BC " + c, new Object[0]);
|
|
x.a("network %s changed to %s", this.c, c);
|
|
if (c == null) {
|
|
this.c = null;
|
|
return true;
|
|
}
|
|
String str = this.c;
|
|
this.c = c;
|
|
long currentTimeMillis = System.currentTimeMillis();
|
|
com.tencent.bugly.crashreport.common.strategy.a a = com.tencent.bugly.crashreport.common.strategy.a.a();
|
|
u a2 = u.a();
|
|
com.tencent.bugly.crashreport.common.info.a a3 = com.tencent.bugly.crashreport.common.info.a.a(context);
|
|
if (a != null && a2 != null && a3 != null) {
|
|
if (!c.equals(str)) {
|
|
if (currentTimeMillis - a2.a(c.a) > 30000) {
|
|
x.a("try to upload crash on network changed.", new Object[0]);
|
|
c a4 = c.a();
|
|
if (a4 != null) {
|
|
a4.a(0L);
|
|
}
|
|
}
|
|
if (currentTimeMillis - a2.a(1001) > 30000) {
|
|
x.a("try to upload userinfo on network changed.", new Object[0]);
|
|
com.tencent.bugly.crashreport.biz.b.a.b();
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
x.d("not inited BC not work", new Object[0]);
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
}
|