Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,122 @@
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;
}
}

View File

@@ -0,0 +1,295 @@
package com.tencent.bugly.crashreport.crash;
import android.os.Parcel;
import android.os.Parcelable;
import com.tencent.bugly.crashreport.common.info.PlugInBean;
import com.tencent.bugly.proguard.z;
import java.util.Map;
import java.util.UUID;
/* compiled from: BUGLY */
/* loaded from: classes.dex */
public class CrashDetailBean implements Parcelable, Comparable<CrashDetailBean> {
public static final Parcelable.Creator<CrashDetailBean> CREATOR = new Parcelable.Creator<CrashDetailBean>() { // from class: com.tencent.bugly.crashreport.crash.CrashDetailBean.1
@Override // android.os.Parcelable.Creator
public final /* synthetic */ CrashDetailBean createFromParcel(Parcel parcel) {
return new CrashDetailBean(parcel);
}
@Override // android.os.Parcelable.Creator
public final /* bridge */ /* synthetic */ CrashDetailBean[] newArray(int i) {
return new CrashDetailBean[i];
}
};
public String A;
public String B;
public long C;
public long D;
public long E;
public long F;
public long G;
public long H;
public String I;
public String J;
public String K;
public String L;
public long M;
public boolean N;
public Map<String, String> O;
public int P;
public int Q;
public Map<String, String> R;
public Map<String, String> S;
public byte[] T;
public String U;
public String V;
private String W;
public long a;
public int b;
public String c;
public boolean d;
public String e;
public String f;
public String g;
public Map<String, PlugInBean> h;
public Map<String, PlugInBean> i;
public boolean j;
public boolean k;
public int l;
public String m;
public String n;
public String o;
public String p;
public String q;
public long r;
public String s;
public int t;
public String u;
public String v;
public String w;
public String x;
public byte[] y;
public Map<String, String> z;
public CrashDetailBean() {
this.a = -1L;
this.b = 0;
this.c = UUID.randomUUID().toString();
this.d = false;
this.e = "";
this.f = "";
this.g = "";
this.h = null;
this.i = null;
this.j = false;
this.k = false;
this.l = 0;
this.m = "";
this.n = "";
this.o = "";
this.p = "";
this.q = "";
this.r = -1L;
this.s = null;
this.t = 0;
this.u = "";
this.v = "";
this.w = null;
this.x = null;
this.y = null;
this.z = null;
this.A = "";
this.B = "";
this.C = -1L;
this.D = -1L;
this.E = -1L;
this.F = -1L;
this.G = -1L;
this.H = -1L;
this.I = "";
this.W = "";
this.J = "";
this.K = "";
this.L = "";
this.M = -1L;
this.N = false;
this.O = null;
this.P = -1;
this.Q = -1;
this.R = null;
this.S = null;
this.T = null;
this.U = null;
this.V = null;
}
@Override // java.lang.Comparable
public /* bridge */ /* synthetic */ int compareTo(CrashDetailBean crashDetailBean) {
CrashDetailBean crashDetailBean2 = crashDetailBean;
if (crashDetailBean2 == null) {
return 1;
}
long j = this.r - crashDetailBean2.r;
if (j <= 0) {
return j < 0 ? -1 : 0;
}
return 1;
}
@Override // android.os.Parcelable
public int describeContents() {
return 0;
}
@Override // android.os.Parcelable
public void writeToParcel(Parcel parcel, int i) {
parcel.writeInt(this.b);
parcel.writeString(this.c);
parcel.writeByte(this.d ? (byte) 1 : (byte) 0);
parcel.writeString(this.e);
parcel.writeString(this.f);
parcel.writeString(this.g);
parcel.writeByte(this.j ? (byte) 1 : (byte) 0);
parcel.writeByte(this.k ? (byte) 1 : (byte) 0);
parcel.writeInt(this.l);
parcel.writeString(this.m);
parcel.writeString(this.n);
parcel.writeString(this.o);
parcel.writeString(this.p);
parcel.writeString(this.q);
parcel.writeLong(this.r);
parcel.writeString(this.s);
parcel.writeInt(this.t);
parcel.writeString(this.u);
parcel.writeString(this.v);
parcel.writeString(this.w);
z.b(parcel, this.z);
parcel.writeString(this.A);
parcel.writeString(this.B);
parcel.writeLong(this.C);
parcel.writeLong(this.D);
parcel.writeLong(this.E);
parcel.writeLong(this.F);
parcel.writeLong(this.G);
parcel.writeLong(this.H);
parcel.writeString(this.I);
parcel.writeString(this.W);
parcel.writeString(this.J);
parcel.writeString(this.K);
parcel.writeString(this.L);
parcel.writeLong(this.M);
parcel.writeByte(this.N ? (byte) 1 : (byte) 0);
z.b(parcel, this.O);
z.a(parcel, this.h);
z.a(parcel, this.i);
parcel.writeInt(this.P);
parcel.writeInt(this.Q);
z.b(parcel, this.R);
z.b(parcel, this.S);
parcel.writeByteArray(this.T);
parcel.writeByteArray(this.y);
parcel.writeString(this.U);
parcel.writeString(this.V);
parcel.writeString(this.x);
}
public CrashDetailBean(Parcel parcel) {
this.a = -1L;
this.b = 0;
this.c = UUID.randomUUID().toString();
this.d = false;
this.e = "";
this.f = "";
this.g = "";
this.h = null;
this.i = null;
this.j = false;
this.k = false;
this.l = 0;
this.m = "";
this.n = "";
this.o = "";
this.p = "";
this.q = "";
this.r = -1L;
this.s = null;
this.t = 0;
this.u = "";
this.v = "";
this.w = null;
this.x = null;
this.y = null;
this.z = null;
this.A = "";
this.B = "";
this.C = -1L;
this.D = -1L;
this.E = -1L;
this.F = -1L;
this.G = -1L;
this.H = -1L;
this.I = "";
this.W = "";
this.J = "";
this.K = "";
this.L = "";
this.M = -1L;
this.N = false;
this.O = null;
this.P = -1;
this.Q = -1;
this.R = null;
this.S = null;
this.T = null;
this.U = null;
this.V = null;
this.b = parcel.readInt();
this.c = parcel.readString();
this.d = parcel.readByte() == 1;
this.e = parcel.readString();
this.f = parcel.readString();
this.g = parcel.readString();
this.j = parcel.readByte() == 1;
this.k = parcel.readByte() == 1;
this.l = parcel.readInt();
this.m = parcel.readString();
this.n = parcel.readString();
this.o = parcel.readString();
this.p = parcel.readString();
this.q = parcel.readString();
this.r = parcel.readLong();
this.s = parcel.readString();
this.t = parcel.readInt();
this.u = parcel.readString();
this.v = parcel.readString();
this.w = parcel.readString();
this.z = z.b(parcel);
this.A = parcel.readString();
this.B = parcel.readString();
this.C = parcel.readLong();
this.D = parcel.readLong();
this.E = parcel.readLong();
this.F = parcel.readLong();
this.G = parcel.readLong();
this.H = parcel.readLong();
this.I = parcel.readString();
this.W = parcel.readString();
this.J = parcel.readString();
this.K = parcel.readString();
this.L = parcel.readString();
this.M = parcel.readLong();
this.N = parcel.readByte() == 1;
this.O = z.b(parcel);
this.h = z.a(parcel);
this.i = z.a(parcel);
this.P = parcel.readInt();
this.Q = parcel.readInt();
this.R = z.b(parcel);
this.S = z.b(parcel);
this.T = parcel.createByteArray();
this.y = parcel.createByteArray();
this.U = parcel.readString();
this.V = parcel.readString();
this.x = parcel.readString();
}
}

View File

@@ -0,0 +1,25 @@
package com.tencent.bugly.crashreport.crash;
/* compiled from: BUGLY */
/* loaded from: classes.dex */
public final class a implements Comparable<a> {
public long a = -1;
public long b = -1;
public String c = null;
public boolean d = false;
public boolean e = false;
public int f = 0;
@Override // java.lang.Comparable
public final /* bridge */ /* synthetic */ int compareTo(a aVar) {
a aVar2 = aVar;
if (aVar2 == null) {
return 1;
}
long j = this.b - aVar2.b;
if (j <= 0) {
return j < 0 ? -1 : 0;
}
return 1;
}
}

View File

@@ -0,0 +1,308 @@
package com.tencent.bugly.crashreport.crash.anr;
import com.tencent.bugly.proguard.x;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/* compiled from: BUGLY */
/* loaded from: classes.dex */
public class TraceFileHelper {
/* compiled from: BUGLY */
public static class a {
public long a;
public String b;
public long c;
public Map<String, String[]> d;
}
/* compiled from: BUGLY */
public interface b {
boolean a(long j);
boolean a(long j, long j2, String str);
boolean a(String str, int i, String str2, String str3);
}
private static Object[] a(BufferedReader bufferedReader, Pattern... patternArr) throws IOException {
if (bufferedReader != null && patternArr != null) {
while (true) {
String readLine = bufferedReader.readLine();
if (readLine == null) {
break;
}
for (Pattern pattern : patternArr) {
if (pattern.matcher(readLine).matches()) {
return new Object[]{pattern, readLine};
}
}
}
}
return null;
}
private static String b(BufferedReader bufferedReader) throws IOException {
StringBuffer stringBuffer = new StringBuffer();
while (true) {
String readLine = bufferedReader.readLine();
if (readLine == null || readLine.trim().length() <= 0) {
break;
}
stringBuffer.append(readLine + "\n");
}
return stringBuffer.toString();
}
public static a readFirstDumpInfo(String str, final boolean z) {
if (str == null) {
x.e("path:%s", str);
return null;
}
final a aVar = new a();
readTraceFile(str, new b() { // from class: com.tencent.bugly.crashreport.crash.anr.TraceFileHelper.2
@Override // com.tencent.bugly.crashreport.crash.anr.TraceFileHelper.b
public final boolean a(String str2, int i, String str3, String str4) {
x.c("new thread %s", str2);
a aVar2 = a.this;
if (aVar2.d == null) {
aVar2.d = new HashMap();
}
Map<String, String[]> map = a.this.d;
StringBuilder sb = new StringBuilder();
sb.append(i);
map.put(str2, new String[]{str3, str4, sb.toString()});
return true;
}
@Override // com.tencent.bugly.crashreport.crash.anr.TraceFileHelper.b
public final boolean a(long j, long j2, String str2) {
x.c("new process %s", str2);
a aVar2 = a.this;
aVar2.a = j;
aVar2.b = str2;
aVar2.c = j2;
return z;
}
@Override // com.tencent.bugly.crashreport.crash.anr.TraceFileHelper.b
public final boolean a(long j) {
x.c("process end %d", Long.valueOf(j));
return false;
}
});
if (aVar.a > 0 && aVar.c > 0 && aVar.b != null) {
return aVar;
}
x.e("first dump error %s", aVar.a + " " + aVar.c + " " + aVar.b);
return null;
}
public static a readTargetDumpInfo(final String str, String str2, final boolean z) {
if (str != null && str2 != null) {
final a aVar = new a();
readTraceFile(str2, new b() { // from class: com.tencent.bugly.crashreport.crash.anr.TraceFileHelper.1
@Override // com.tencent.bugly.crashreport.crash.anr.TraceFileHelper.b
public final boolean a(String str3, int i, String str4, String str5) {
x.c("new thread %s", str3);
a aVar2 = a.this;
if (aVar2.a > 0 && aVar2.c > 0 && aVar2.b != null) {
if (aVar2.d == null) {
aVar2.d = new HashMap();
}
Map<String, String[]> map = a.this.d;
StringBuilder sb = new StringBuilder();
sb.append(i);
map.put(str3, new String[]{str4, str5, sb.toString()});
}
return true;
}
@Override // com.tencent.bugly.crashreport.crash.anr.TraceFileHelper.b
public final boolean a(long j, long j2, String str3) {
x.c("new process %s", str3);
if (!str3.equals(str)) {
return true;
}
a aVar2 = a.this;
aVar2.a = j;
aVar2.b = str3;
aVar2.c = j2;
return z;
}
@Override // com.tencent.bugly.crashreport.crash.anr.TraceFileHelper.b
public final boolean a(long j) {
x.c("process end %d", Long.valueOf(j));
a aVar2 = a.this;
return aVar2.a <= 0 || aVar2.c <= 0 || aVar2.b == null;
}
});
if (aVar.a > 0 && aVar.c > 0 && aVar.b != null) {
return aVar;
}
}
return null;
}
public static void readTraceFile(String str, b bVar) {
Throwable th;
BufferedReader bufferedReader;
if (str == null || bVar == null) {
return;
}
File file = new File(str);
if (!file.exists()) {
return;
}
file.lastModified();
file.length();
BufferedReader bufferedReader2 = null;
try {
try {
bufferedReader = new BufferedReader(new FileReader(file));
try {
Pattern compile = Pattern.compile("-{5}\\spid\\s\\d+\\sat\\s\\d+-\\d+-\\d+\\s\\d{2}:\\d{2}:\\d{2}\\s-{5}");
Pattern compile2 = Pattern.compile("-{5}\\send\\s\\d+\\s-{5}");
Pattern compile3 = Pattern.compile("Cmd\\sline:\\s(\\S+)");
Pattern compile4 = Pattern.compile("\".+\"\\s(daemon\\s){0,1}prio=\\d+\\stid=\\d+\\s.*");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
while (true) {
Object[] a2 = a(bufferedReader, compile);
if (a2 == null) {
try {
bufferedReader.close();
return;
} catch (IOException e) {
if (x.a(e)) {
return;
}
e.printStackTrace();
return;
}
}
String[] split = a2[1].toString().split("\\s");
long parseLong = Long.parseLong(split[2]);
long time = simpleDateFormat.parse(split[4] + " " + split[5]).getTime();
Object[] a3 = a(bufferedReader, compile3);
if (a3 == null) {
try {
bufferedReader.close();
return;
} catch (IOException e2) {
if (x.a(e2)) {
return;
}
e2.printStackTrace();
return;
}
}
Matcher matcher = compile3.matcher(a3[1].toString());
matcher.find();
matcher.group(1);
SimpleDateFormat simpleDateFormat2 = simpleDateFormat;
if (!bVar.a(parseLong, time, matcher.group(1))) {
try {
bufferedReader.close();
return;
} catch (IOException e3) {
if (x.a(e3)) {
return;
}
e3.printStackTrace();
return;
}
}
while (true) {
Object[] a4 = a(bufferedReader, compile4, compile2);
if (a4 == null) {
break;
}
if (a4[0] == compile4) {
String obj = a4[1].toString();
Matcher matcher2 = Pattern.compile("\".+\"").matcher(obj);
matcher2.find();
String group = matcher2.group();
String substring = group.substring(1, group.length() - 1);
obj.contains("NATIVE");
Matcher matcher3 = Pattern.compile("tid=\\d+").matcher(obj);
matcher3.find();
String group2 = matcher3.group();
bVar.a(substring, Integer.parseInt(group2.substring(group2.indexOf("=") + 1)), a(bufferedReader), b(bufferedReader));
} else if (!bVar.a(Long.parseLong(a4[1].toString().split("\\s")[2]))) {
try {
bufferedReader.close();
return;
} catch (IOException e4) {
if (x.a(e4)) {
return;
}
e4.printStackTrace();
return;
}
}
}
simpleDateFormat = simpleDateFormat2;
}
} catch (Exception e5) {
e = e5;
bufferedReader2 = bufferedReader;
if (!x.a(e)) {
e.printStackTrace();
}
x.d("trace open fail:%s : %s", e.getClass().getName(), e.getMessage());
if (bufferedReader2 != null) {
try {
bufferedReader2.close();
} catch (IOException e6) {
if (x.a(e6)) {
return;
}
e6.printStackTrace();
}
}
} catch (Throwable th2) {
th = th2;
if (bufferedReader == null) {
throw th;
}
try {
bufferedReader.close();
throw th;
} catch (IOException e7) {
if (x.a(e7)) {
throw th;
}
e7.printStackTrace();
throw th;
}
}
} catch (Exception e8) {
e = e8;
}
} catch (Throwable th3) {
th = th3;
bufferedReader = null;
}
}
private static String a(BufferedReader bufferedReader) throws IOException {
StringBuffer stringBuffer = new StringBuffer();
for (int i = 0; i < 3; i++) {
String readLine = bufferedReader.readLine();
if (readLine == null) {
return null;
}
stringBuffer.append(readLine + "\n");
}
return stringBuffer.toString();
}
}

View File

@@ -0,0 +1,15 @@
package com.tencent.bugly.crashreport.crash.anr;
import java.util.Map;
/* compiled from: BUGLY */
/* loaded from: classes.dex */
public final class a {
public String a = null;
public Map<String, String> b = null;
public long c = -1;
public String d = null;
public String e = null;
public String f = null;
public String g = null;
}

View File

@@ -0,0 +1,548 @@
package com.tencent.bugly.crashreport.crash.anr;
import android.app.ActivityManager;
import android.content.Context;
import android.os.Build;
import android.os.FileObserver;
import android.os.Process;
import com.tencent.bugly.crashreport.common.strategy.StrategyBean;
import com.tencent.bugly.crashreport.crash.CrashDetailBean;
import com.tencent.bugly.crashreport.crash.anr.TraceFileHelper;
import com.tencent.bugly.crashreport.crash.c;
import com.tencent.bugly.proguard.ab;
import com.tencent.bugly.proguard.ac;
import com.tencent.bugly.proguard.w;
import com.tencent.bugly.proguard.x;
import com.tencent.bugly.proguard.y;
import com.tencent.bugly.proguard.z;
import com.thoughtworks.xstream.XStream;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
/* compiled from: BUGLY */
/* loaded from: classes.dex */
public final class b implements ac {
private final Context c;
private final com.tencent.bugly.crashreport.common.info.a d;
private final w e;
private final com.tencent.bugly.crashreport.common.strategy.a f;
private final String g;
private final com.tencent.bugly.crashreport.crash.b h;
private FileObserver i;
private ab k;
private int l;
private AtomicInteger a = new AtomicInteger(0);
private long b = -1;
private boolean j = true;
public b(Context context, com.tencent.bugly.crashreport.common.strategy.a aVar, com.tencent.bugly.crashreport.common.info.a aVar2, w wVar, com.tencent.bugly.crashreport.crash.b bVar) {
this.c = z.a(context);
this.g = context.getDir("bugly", 0).getAbsolutePath();
this.d = aVar2;
this.e = wVar;
this.f = aVar;
this.h = bVar;
}
private static ActivityManager.ProcessErrorStateInfo a(Context context, long j) {
try {
x.c("to find!", new Object[0]);
ActivityManager activityManager = (ActivityManager) context.getSystemService("activity");
int i = 0;
while (true) {
x.c("waiting!", new Object[0]);
List<ActivityManager.ProcessErrorStateInfo> processesInErrorState = activityManager.getProcessesInErrorState();
if (processesInErrorState != null) {
for (ActivityManager.ProcessErrorStateInfo processErrorStateInfo : processesInErrorState) {
if (processErrorStateInfo.condition == 2) {
x.c("found!", new Object[0]);
return processErrorStateInfo;
}
}
}
z.b(500L);
int i2 = i + 1;
if (i >= 20) {
x.c("end!", new Object[0]);
return null;
}
i = i2;
}
} catch (Exception e) {
x.b(e);
return null;
}
}
private synchronized void b(boolean z) {
if (z) {
e();
} else {
f();
}
}
private synchronized void c(boolean z) {
if (this.j != z) {
x.a("user change anr %b", Boolean.valueOf(z));
this.j = z;
}
}
private synchronized void e() {
if (g()) {
x.d("start when started!", new Object[0]);
return;
}
this.i = new FileObserver("/data/anr/", 8) { // from class: com.tencent.bugly.crashreport.crash.anr.b.1
@Override // android.os.FileObserver
public final void onEvent(int i, String str) {
if (str == null) {
return;
}
String str2 = "/data/anr/" + str;
if (str2.contains("trace")) {
b.this.a(str2);
} else {
x.d("not anr file %s", str2);
}
}
};
try {
this.i.startWatching();
x.a("start anr monitor!", new Object[0]);
this.e.a(new Runnable() { // from class: com.tencent.bugly.crashreport.crash.anr.b.2
@Override // java.lang.Runnable
public final void run() {
b.this.b();
}
});
} catch (Throwable th) {
this.i = null;
x.d("start anr monitor failed!", new Object[0]);
if (x.a(th)) {
return;
}
th.printStackTrace();
}
}
private synchronized void f() {
if (!g()) {
x.d("close when closed!", new Object[0]);
return;
}
try {
this.i.stopWatching();
this.i = null;
x.d("close anr monitor!", new Object[0]);
} catch (Throwable th) {
x.d("stop anr monitor failed!", new Object[0]);
if (x.a(th)) {
return;
}
th.printStackTrace();
}
}
private synchronized boolean g() {
return this.i != null;
}
private synchronized boolean h() {
return this.j;
}
public final boolean d() {
ab abVar = this.k;
if (abVar == null) {
return false;
}
abVar.b();
this.k.b(this);
boolean c = this.k.c();
this.k = null;
return c;
}
protected final void b() {
long b = z.b() - c.g;
File file = new File(this.g);
if (file.exists() && file.isDirectory()) {
try {
File[] listFiles = file.listFiles();
if (listFiles != null && listFiles.length != 0) {
int i = 0;
for (File file2 : listFiles) {
String name = file2.getName();
if (name.startsWith("bugly_trace_")) {
try {
int indexOf = name.indexOf(".txt");
if (indexOf > 0 && Long.parseLong(name.substring(12, indexOf)) >= b) {
}
} catch (Throwable unused) {
x.c("Trace file that has invalid format: " + name, new Object[0]);
}
if (file2.delete()) {
i++;
}
}
}
x.c("Number of overdue trace files that has deleted: " + i, new Object[0]);
}
} catch (Throwable th) {
x.a(th);
}
}
}
public final boolean c() {
ab abVar = this.k;
if (abVar != null && abVar.isAlive()) {
return false;
}
this.k = new ab();
ab abVar2 = this.k;
StringBuilder sb = new StringBuilder("Bugly-ThreadMonitor");
int i = this.l;
this.l = i + 1;
sb.append(i);
abVar2.setName(sb.toString());
this.k.a();
this.k.a(this);
return this.k.d();
}
private CrashDetailBean a(a aVar) {
CrashDetailBean crashDetailBean = new CrashDetailBean();
try {
crashDetailBean.C = com.tencent.bugly.crashreport.common.info.b.k();
crashDetailBean.D = com.tencent.bugly.crashreport.common.info.b.i();
crashDetailBean.E = com.tencent.bugly.crashreport.common.info.b.m();
crashDetailBean.F = this.d.p();
crashDetailBean.G = this.d.o();
crashDetailBean.H = this.d.q();
crashDetailBean.w = z.a(this.c, c.e, (String) null);
crashDetailBean.b = 3;
crashDetailBean.e = this.d.h();
crashDetailBean.f = this.d.j;
crashDetailBean.g = this.d.w();
crashDetailBean.m = this.d.g();
crashDetailBean.n = "ANR_EXCEPTION";
crashDetailBean.o = aVar.f;
crashDetailBean.q = aVar.g;
crashDetailBean.O = new HashMap();
crashDetailBean.O.put("BUGLY_CR_01", aVar.e);
int indexOf = crashDetailBean.q != null ? crashDetailBean.q.indexOf("\n") : -1;
crashDetailBean.p = indexOf > 0 ? crashDetailBean.q.substring(0, indexOf) : "GET_FAIL";
crashDetailBean.r = aVar.c;
if (crashDetailBean.q != null) {
crashDetailBean.u = z.b(crashDetailBean.q.getBytes());
}
crashDetailBean.z = aVar.b;
crashDetailBean.A = aVar.a;
crashDetailBean.B = "main(1)";
crashDetailBean.I = this.d.y();
crashDetailBean.h = this.d.v();
crashDetailBean.i = this.d.J();
crashDetailBean.v = aVar.d;
crashDetailBean.L = this.d.n;
crashDetailBean.M = this.d.a;
crashDetailBean.N = this.d.a();
crashDetailBean.P = this.d.H();
crashDetailBean.Q = this.d.I();
crashDetailBean.R = this.d.B();
crashDetailBean.S = this.d.G();
this.h.c(crashDetailBean);
crashDetailBean.y = y.a();
} catch (Throwable th) {
if (!x.a(th)) {
th.printStackTrace();
}
}
return crashDetailBean;
}
private static boolean a(String str, String str2, String str3) {
Map<String, String[]> map;
BufferedWriter bufferedWriter;
TraceFileHelper.a readTargetDumpInfo = TraceFileHelper.readTargetDumpInfo(str3, str, true);
if (readTargetDumpInfo != null && (map = readTargetDumpInfo.d) != null && map.size() > 0) {
File file = new File(str2);
try {
if (!file.exists()) {
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
file.createNewFile();
}
if (file.exists() && file.canWrite()) {
BufferedWriter bufferedWriter2 = null;
try {
try {
bufferedWriter = new BufferedWriter(new FileWriter(file, false));
try {
String[] strArr = readTargetDumpInfo.d.get("main");
int i = 3;
if (strArr != null && strArr.length >= 3) {
String str4 = strArr[0];
String str5 = strArr[1];
bufferedWriter.write("\"main\" tid=" + strArr[2] + " :\n" + str4 + "\n" + str5 + "\n\n");
bufferedWriter.flush();
}
for (Map.Entry<String, String[]> entry : readTargetDumpInfo.d.entrySet()) {
if (!entry.getKey().equals("main")) {
if (entry.getValue() != null && entry.getValue().length >= i) {
String str6 = entry.getValue()[0];
String str7 = entry.getValue()[1];
bufferedWriter.write("\"" + entry.getKey() + "\" tid=" + entry.getValue()[2] + " :\n" + str6 + "\n" + str7 + "\n\n");
bufferedWriter.flush();
}
i = 3;
}
}
try {
bufferedWriter.close();
} catch (IOException e) {
if (!x.a(e)) {
e.printStackTrace();
}
}
return true;
} catch (IOException e2) {
e = e2;
bufferedWriter2 = bufferedWriter;
if (!x.a(e)) {
e.printStackTrace();
}
x.e("dump trace fail %s", e.getClass().getName() + ":" + e.getMessage());
if (bufferedWriter2 != null) {
try {
bufferedWriter2.close();
} catch (IOException e3) {
if (!x.a(e3)) {
e3.printStackTrace();
}
}
}
return false;
} catch (Throwable th) {
th = th;
Throwable th2 = th;
if (bufferedWriter != null) {
try {
bufferedWriter.close();
throw th2;
} catch (IOException e4) {
if (!x.a(e4)) {
e4.printStackTrace();
throw th2;
}
throw th2;
}
}
throw th2;
}
} catch (Throwable th3) {
th = th3;
bufferedWriter = bufferedWriter2;
}
} catch (IOException e5) {
e = e5;
}
} else {
x.e("backup file create fail %s", str2);
return false;
}
} catch (Exception e6) {
if (!x.a(e6)) {
e6.printStackTrace();
}
x.e("backup file create error! %s %s", e6.getClass().getName() + ":" + e6.getMessage(), str2);
return false;
}
} else {
x.e("not found trace dump for %s", str3);
return false;
}
}
public final boolean a() {
return this.a.get() != 0;
}
private boolean a(Context context, String str, ActivityManager.ProcessErrorStateInfo processErrorStateInfo, long j, Map<String, String> map) {
File file = new File(context.getFilesDir(), "bugly/bugly_trace_" + j + ".txt");
a aVar = new a();
aVar.c = j;
aVar.d = file.getAbsolutePath();
aVar.a = processErrorStateInfo != null ? processErrorStateInfo.processName : "";
aVar.f = processErrorStateInfo != null ? processErrorStateInfo.shortMsg : "";
aVar.e = processErrorStateInfo != null ? processErrorStateInfo.longMsg : "";
aVar.b = map;
if (map != null) {
for (String str2 : map.keySet()) {
if (str2.startsWith("main(")) {
aVar.g = map.get(str2);
}
}
}
Object[] objArr = new Object[6];
objArr[0] = Long.valueOf(aVar.c);
objArr[1] = aVar.d;
objArr[2] = aVar.a;
objArr[3] = aVar.f;
objArr[4] = aVar.e;
Map<String, String> map2 = aVar.b;
objArr[5] = Integer.valueOf(map2 == null ? 0 : map2.size());
x.c("anr tm:%d\ntr:%s\nproc:%s\nsMsg:%s\n lMsg:%s\n threads:%d", objArr);
if (!this.f.b()) {
x.e("crash report sync remote fail, will not upload to Bugly , print local for helpful!", new Object[0]);
com.tencent.bugly.crashreport.crash.b.a("ANR", z.a(), aVar.a, "main", aVar.e, null);
return false;
}
if (!this.f.c().j) {
x.d("ANR Report is closed!", new Object[0]);
return false;
}
x.a("found visiable anr , start to upload!", new Object[0]);
CrashDetailBean a = a(aVar);
if (a == null) {
x.e("pack anr fail!", new Object[0]);
return false;
}
c.a().a(a);
if (a.a >= 0) {
x.a("backup anr record success!", new Object[0]);
} else {
x.d("backup anr record fail!", new Object[0]);
}
if (str != null && new File(str).exists()) {
this.a.set(3);
if (a(str, aVar.d, aVar.a)) {
x.a("backup trace success", new Object[0]);
}
}
com.tencent.bugly.crashreport.crash.b.a("ANR", z.a(), aVar.a, "main", aVar.e, a);
if (!this.h.a(a)) {
this.h.a(a, 3000L, true);
}
this.h.b(a);
return true;
}
public final void a(String str) {
synchronized (this) {
if (this.a.get() != 0) {
x.c("trace started return ", new Object[0]);
return;
}
this.a.set(1);
try {
x.c("read trace first dump for create time!", new Object[0]);
TraceFileHelper.a readFirstDumpInfo = TraceFileHelper.readFirstDumpInfo(str, false);
long j = readFirstDumpInfo != null ? readFirstDumpInfo.c : -1L;
if (j == -1) {
x.d("trace dump fail could not get time!", new Object[0]);
j = System.currentTimeMillis();
}
long j2 = j;
if (Math.abs(j2 - this.b) < 10000) {
x.d("should not process ANR too Fre in %d", Integer.valueOf(XStream.PRIORITY_VERY_HIGH));
} else {
this.b = j2;
this.a.set(1);
try {
Map<String, String> a = z.a(c.f, false);
if (a != null && a.size() > 0) {
ActivityManager.ProcessErrorStateInfo a2 = a(this.c, 10000L);
if (a2 == null) {
x.c("proc state is unvisiable!", new Object[0]);
} else if (a2.pid != Process.myPid()) {
x.c("not mind proc!", a2.processName);
} else {
x.a("found visiable anr , start to process!", new Object[0]);
a(this.c, str, a2, j2, a);
}
}
x.d("can't get all thread skip this anr", new Object[0]);
} catch (Throwable th) {
x.a(th);
x.e("get all thread stack fail!", new Object[0]);
}
}
} finally {
try {
} finally {
}
}
}
}
public final void a(boolean z) {
c(z);
boolean h = h();
com.tencent.bugly.crashreport.common.strategy.a a = com.tencent.bugly.crashreport.common.strategy.a.a();
if (a != null) {
h = h && a.c().g;
}
if (h != g()) {
x.a("anr changed to %b", Boolean.valueOf(h));
b(h);
}
}
public final synchronized void a(StrategyBean strategyBean) {
if (strategyBean == null) {
return;
}
if (strategyBean.j != g()) {
x.d("server anr changed to %b", Boolean.valueOf(strategyBean.j));
}
if (Build.VERSION.SDK_INT <= 19) {
boolean z = strategyBean.j && h();
if (z != g()) {
x.a("anr changed to %b", Boolean.valueOf(z));
b(z);
}
return;
}
if (strategyBean.j) {
c();
} else {
d();
}
}
@Override // com.tencent.bugly.proguard.ac
public final boolean a(Thread thread) {
new HashMap();
if (thread.getName().contains("main")) {
ActivityManager.ProcessErrorStateInfo a = a(this.c, 10000L);
if (a == null) {
x.c("anr handler onThreadBlock proc state is unvisiable!", new Object[0]);
return false;
}
if (a.pid != Process.myPid()) {
x.c("onThreadBlock not mind proc!", a.processName);
return false;
}
try {
Map<String, String> a2 = z.a(200000, false);
x.a("onThreadBlock found visiable anr , start to process!", new Object[0]);
a(this.c, "", a, System.currentTimeMillis(), a2);
} catch (Throwable unused) {
return false;
}
} else {
x.c("anr handler onThreadBlock only care main thread", new Object[0]);
}
return true;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,260 @@
package com.tencent.bugly.crashreport.crash;
import android.content.Context;
import android.os.Build;
import com.tencent.bugly.BuglyStrategy;
import com.tencent.bugly.crashreport.common.info.AppInfo;
import com.tencent.bugly.crashreport.common.strategy.StrategyBean;
import com.tencent.bugly.crashreport.crash.jni.NativeCrashHandler;
import com.tencent.bugly.proguard.o;
import com.tencent.bugly.proguard.p;
import com.tencent.bugly.proguard.r;
import com.tencent.bugly.proguard.u;
import com.tencent.bugly.proguard.w;
import com.tencent.bugly.proguard.x;
import com.tencent.bugly.proguard.z;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/* compiled from: BUGLY */
/* loaded from: classes.dex */
public final class c {
public static int a = 0;
public static boolean b = false;
public static int c = 2;
public static boolean d = true;
public static int e = 20480;
public static int f = 20480;
public static long g = 604800000;
public static String h = null;
public static boolean i = false;
public static String j = null;
public static int k = 5000;
public static boolean l = true;
public static boolean m = false;
public static String n;
public static String o;
private static c r;
public final b p;
private final Context q;
private final e s;
private final NativeCrashHandler t;
private com.tencent.bugly.crashreport.common.strategy.a u;
private w v;
private final com.tencent.bugly.crashreport.crash.anr.b w;
private Boolean x;
/* compiled from: BUGLY */
/* renamed from: com.tencent.bugly.crashreport.crash.c$2, reason: invalid class name */
final class AnonymousClass2 extends Thread {
AnonymousClass2() {
}
@Override // java.lang.Thread, java.lang.Runnable
public final void run() {
List<CrashDetailBean> list;
if (z.a(c.this.q, "local_crash_lock", 10000L)) {
List<CrashDetailBean> a = c.this.p.a();
if (a != null && a.size() > 0) {
x.c("Size of crash list: %s", Integer.valueOf(a.size()));
int size = a.size();
if (size > 20) {
ArrayList arrayList = new ArrayList();
Collections.sort(a);
for (int i = 0; i < 20; i++) {
arrayList.add(a.get((size - 1) - i));
}
list = arrayList;
} else {
list = a;
}
c.this.p.a(list, 0L, false, false, false);
}
z.b(c.this.q, "local_crash_lock");
}
}
}
private c(int i2, Context context, w wVar, boolean z, BuglyStrategy.a aVar, o oVar, String str) {
a = i2;
Context a2 = z.a(context);
this.q = a2;
this.u = com.tencent.bugly.crashreport.common.strategy.a.a();
this.v = wVar;
this.p = new b(i2, a2, u.a(), p.a(), this.u, aVar, oVar);
com.tencent.bugly.crashreport.common.info.a a3 = com.tencent.bugly.crashreport.common.info.a.a(a2);
this.s = new e(a2, this.p, this.u, a3);
this.t = NativeCrashHandler.getInstance(a2, a3, this.p, this.u, wVar, z, str);
a3.D = this.t;
this.w = new com.tencent.bugly.crashreport.crash.anr.b(a2, this.u, a3, wVar, this.p);
}
public final synchronized void c() {
this.s.a();
this.t.setUserOpened(true);
if (Build.VERSION.SDK_INT <= 19) {
this.w.a(true);
} else {
this.w.c();
}
}
public final synchronized void d() {
this.s.b();
this.t.setUserOpened(false);
if (Build.VERSION.SDK_INT < 19) {
this.w.a(false);
} else {
this.w.d();
}
}
public final void e() {
this.s.a();
}
public final void f() {
this.t.setUserOpened(false);
}
public final void g() {
this.t.setUserOpened(true);
}
public final void h() {
if (Build.VERSION.SDK_INT <= 19) {
this.w.a(true);
} else {
this.w.c();
}
}
public final void i() {
if (Build.VERSION.SDK_INT < 19) {
this.w.a(false);
} else {
this.w.d();
}
}
public final synchronized void j() {
int i2 = 0;
while (true) {
int i3 = i2 + 1;
if (i2 < 30) {
try {
x.a("try main sleep for make a test anr! try:%d/30 , kill it if you don't want to wait!", Integer.valueOf(i3));
z.b(5000L);
i2 = i3;
} catch (Throwable th) {
if (x.a(th)) {
return;
}
th.printStackTrace();
return;
}
}
}
}
public final boolean k() {
return this.w.a();
}
public final void l() {
this.t.checkUploadRecordCrash();
}
public final void m() {
if (com.tencent.bugly.crashreport.common.info.a.b().d.equals(AppInfo.a(this.q))) {
this.t.removeEmptyNativeRecordFiles();
}
}
public static synchronized c a(int i2, Context context, boolean z, BuglyStrategy.a aVar, o oVar, String str) {
c cVar;
synchronized (c.class) {
if (r == null) {
r = new c(1004, context, w.a(), z, aVar, null, null);
}
cVar = r;
}
return cVar;
}
public final boolean b() {
Boolean bool = this.x;
if (bool != null) {
return bool.booleanValue();
}
String str = com.tencent.bugly.crashreport.common.info.a.b().d;
List<r> a2 = p.a().a(1);
ArrayList arrayList = new ArrayList();
if (a2 == null || a2.size() <= 0) {
this.x = false;
return false;
}
for (r rVar : a2) {
if (str.equals(rVar.c)) {
this.x = true;
arrayList.add(rVar);
}
}
if (arrayList.size() > 0) {
p.a().a(arrayList);
}
return true;
}
public static synchronized c a() {
c cVar;
synchronized (c.class) {
cVar = r;
}
return cVar;
}
public final void a(StrategyBean strategyBean) {
this.s.a(strategyBean);
this.t.onStrategyChanged(strategyBean);
this.w.a(strategyBean);
w.a().a(new AnonymousClass2(), 3000L);
}
public final synchronized void a(boolean z, boolean z2, boolean z3) {
this.t.testNativeCrash(z, z2, z3);
}
public final void a(final Thread thread, final Throwable th, boolean z, String str, byte[] bArr, final boolean z2) {
final boolean z3 = false;
final String str2 = null;
final byte[] bArr2 = null;
this.v.a(new Runnable() { // from class: com.tencent.bugly.crashreport.crash.c.1
@Override // java.lang.Runnable
public final void run() {
try {
x.c("post a throwable %b", Boolean.valueOf(z3));
c.this.s.a(thread, th, false, str2, bArr2);
if (z2) {
x.a("clear user datas", new Object[0]);
com.tencent.bugly.crashreport.common.info.a.a(c.this.q).C();
}
} catch (Throwable th2) {
if (!x.b(th2)) {
th2.printStackTrace();
}
x.e("java catch error: %s", th.toString());
}
}
});
}
public final void a(CrashDetailBean crashDetailBean) {
this.p.d(crashDetailBean);
}
public final void a(long j2) {
w.a().a(new AnonymousClass2(), j2);
}
}

View File

@@ -0,0 +1,91 @@
package com.tencent.bugly.crashreport.crash;
import android.content.Context;
import com.tencent.bugly.proguard.w;
import com.tencent.bugly.proguard.x;
import com.tencent.bugly.proguard.z;
import java.util.Map;
/* compiled from: BUGLY */
/* loaded from: classes.dex */
public final class d {
private static d a;
private com.tencent.bugly.crashreport.common.strategy.a b;
private com.tencent.bugly.crashreport.common.info.a c;
private b d;
private Context e;
private d(Context context) {
c a2 = c.a();
if (a2 == null) {
return;
}
this.b = com.tencent.bugly.crashreport.common.strategy.a.a();
this.c = com.tencent.bugly.crashreport.common.info.a.a(context);
this.d = a2.p;
this.e = context;
w.a().a(new Runnable() { // from class: com.tencent.bugly.crashreport.crash.d.1
@Override // java.lang.Runnable
public final void run() {
d.a(d.this);
}
});
}
static /* synthetic */ void a(d dVar) {
x.c("[ExtraCrashManager] Trying to notify Bugly agents.", new Object[0]);
try {
Class<?> cls = Class.forName("com.tencent.bugly.agent.GameAgent");
dVar.c.getClass();
z.a(cls, "sdkPackageName", "com.tencent.bugly", (Object) null);
x.c("[ExtraCrashManager] Bugly game agent has been notified.", new Object[0]);
} catch (Throwable unused) {
x.a("[ExtraCrashManager] no game agent", new Object[0]);
}
}
/* JADX WARN: Removed duplicated region for block: B:38:0x00df */
/* JADX WARN: Removed duplicated region for block: B:42:0x015a A[Catch: all -> 0x0250, TRY_ENTER, TryCatch #1 {all -> 0x0250, blocks: (B:15:0x0045, B:17:0x004d, B:18:0x0054, B:21:0x0060, B:23:0x0068, B:32:0x00b6, B:34:0x00ba, B:39:0x00e0, B:42:0x015a, B:44:0x0161, B:46:0x0166, B:48:0x01fa, B:50:0x0203, B:51:0x0208, B:53:0x0243, B:57:0x00c8, B:59:0x00cc), top: B:14:0x0045 }] */
/* JADX WARN: Removed duplicated region for block: B:48:0x01fa A[Catch: all -> 0x0250, TryCatch #1 {all -> 0x0250, blocks: (B:15:0x0045, B:17:0x004d, B:18:0x0054, B:21:0x0060, B:23:0x0068, B:32:0x00b6, B:34:0x00ba, B:39:0x00e0, B:42:0x015a, B:44:0x0161, B:46:0x0166, B:48:0x01fa, B:50:0x0203, B:51:0x0208, B:53:0x0243, B:57:0x00c8, B:59:0x00cc), top: B:14:0x0045 }] */
/* JADX WARN: Removed duplicated region for block: B:50:0x0203 A[Catch: all -> 0x0250, TryCatch #1 {all -> 0x0250, blocks: (B:15:0x0045, B:17:0x004d, B:18:0x0054, B:21:0x0060, B:23:0x0068, B:32:0x00b6, B:34:0x00ba, B:39:0x00e0, B:42:0x015a, B:44:0x0161, B:46:0x0166, B:48:0x01fa, B:50:0x0203, B:51:0x0208, B:53:0x0243, B:57:0x00c8, B:59:0x00cc), top: B:14:0x0045 }] */
/* JADX WARN: Removed duplicated region for block: B:53:0x0243 A[Catch: all -> 0x0250, TRY_LEAVE, TryCatch #1 {all -> 0x0250, blocks: (B:15:0x0045, B:17:0x004d, B:18:0x0054, B:21:0x0060, B:23:0x0068, B:32:0x00b6, B:34:0x00ba, B:39:0x00e0, B:42:0x015a, B:44:0x0161, B:46:0x0166, B:48:0x01fa, B:50:0x0203, B:51:0x0208, B:53:0x0243, B:57:0x00c8, B:59:0x00cc), top: B:14:0x0045 }] */
/* JADX WARN: Removed duplicated region for block: B:56:0x0165 */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
static /* synthetic */ void a(com.tencent.bugly.crashreport.crash.d r16, java.lang.Thread r17, int r18, java.lang.String r19, java.lang.String r20, java.lang.String r21, java.util.Map r22) {
/*
Method dump skipped, instructions count: 615
To view this dump change 'Code comments level' option to 'DEBUG'
*/
throw new UnsupportedOperationException("Method not decompiled: com.tencent.bugly.crashreport.crash.d.a(com.tencent.bugly.crashreport.crash.d, java.lang.Thread, int, java.lang.String, java.lang.String, java.lang.String, java.util.Map):void");
}
public static d a(Context context) {
if (a == null) {
a = new d(context);
}
return a;
}
public static void a(final Thread thread, final int i, final String str, final String str2, final String str3, final Map<String, String> map) {
w.a().a(new Runnable() { // from class: com.tencent.bugly.crashreport.crash.d.2
@Override // java.lang.Runnable
public final void run() {
try {
if (d.a == null) {
x.e("[ExtraCrashManager] Extra crash manager has not been initialized.", new Object[0]);
} else {
d.a(d.a, thread, i, str, str2, str3, map);
}
} catch (Throwable th) {
if (!x.b(th)) {
th.printStackTrace();
}
x.e("[ExtraCrashManager] Crash error %s %s %s", str, str2, str3);
}
}
});
}
}

View File

@@ -0,0 +1,430 @@
package com.tencent.bugly.crashreport.crash;
import android.content.Context;
import android.os.Process;
import com.tencent.bugly.crashreport.common.strategy.StrategyBean;
import com.tencent.bugly.proguard.x;
import com.tencent.bugly.proguard.y;
import com.tencent.bugly.proguard.z;
import java.lang.Thread;
import java.util.HashMap;
/* compiled from: BUGLY */
/* loaded from: classes.dex */
public final class e implements Thread.UncaughtExceptionHandler {
private static String h;
private static final Object i = new Object();
private Context a;
private b b;
private com.tencent.bugly.crashreport.common.strategy.a c;
private com.tencent.bugly.crashreport.common.info.a d;
private Thread.UncaughtExceptionHandler e;
private Thread.UncaughtExceptionHandler f;
private boolean g = false;
private int j;
public e(Context context, b bVar, com.tencent.bugly.crashreport.common.strategy.a aVar, com.tencent.bugly.crashreport.common.info.a aVar2) {
this.a = context;
this.b = bVar;
this.c = aVar;
this.d = aVar2;
}
public final synchronized void a() {
if (this.j >= 10) {
x.a("java crash handler over %d, no need set.", 10);
return;
}
this.g = true;
Thread.UncaughtExceptionHandler defaultUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
if (defaultUncaughtExceptionHandler != null) {
if (getClass().getName().equals(defaultUncaughtExceptionHandler.getClass().getName())) {
return;
}
if ("com.android.internal.os.RuntimeInit$UncaughtHandler".equals(defaultUncaughtExceptionHandler.getClass().getName())) {
x.a("backup system java handler: %s", defaultUncaughtExceptionHandler.toString());
this.f = defaultUncaughtExceptionHandler;
this.e = defaultUncaughtExceptionHandler;
} else {
x.a("backup java handler: %s", defaultUncaughtExceptionHandler.toString());
this.e = defaultUncaughtExceptionHandler;
}
}
Thread.setDefaultUncaughtExceptionHandler(this);
this.j++;
x.a("registered java monitor: %s", toString());
}
public final synchronized void b() {
this.g = false;
x.a("close java monitor!", new Object[0]);
if (Thread.getDefaultUncaughtExceptionHandler().getClass().getName().contains("bugly")) {
x.a("Java monitor to unregister: %s", toString());
Thread.setDefaultUncaughtExceptionHandler(this.e);
this.j--;
}
}
@Override // java.lang.Thread.UncaughtExceptionHandler
public final void uncaughtException(Thread thread, Throwable th) {
synchronized (i) {
a(thread, th, true, null, null);
}
}
private CrashDetailBean b(Thread thread, Throwable th, boolean z, String str, byte[] bArr) {
String a;
boolean z2 = false;
if (th == null) {
x.d("We can do nothing with a null throwable.", new Object[0]);
return null;
}
boolean k = c.a().k();
String str2 = (k && z) ? " This Crash Caused By ANR , PLS To Fix ANR , This Trace May Be Not Useful![Bugly]" : "";
if (k && z) {
x.e("This Crash Caused By ANR , PLS To Fix ANR , This Trace May Be Not Useful!", new Object[0]);
}
CrashDetailBean crashDetailBean = new CrashDetailBean();
crashDetailBean.C = com.tencent.bugly.crashreport.common.info.b.k();
crashDetailBean.D = com.tencent.bugly.crashreport.common.info.b.i();
crashDetailBean.E = com.tencent.bugly.crashreport.common.info.b.m();
crashDetailBean.F = this.d.p();
crashDetailBean.G = this.d.o();
crashDetailBean.H = this.d.q();
crashDetailBean.w = z.a(this.a, c.e, (String) null);
crashDetailBean.y = y.a();
Object[] objArr = new Object[1];
byte[] bArr2 = crashDetailBean.y;
objArr[0] = Integer.valueOf(bArr2 == null ? 0 : bArr2.length);
x.a("user log size:%d", objArr);
crashDetailBean.b = z ? 0 : 2;
crashDetailBean.e = this.d.h();
com.tencent.bugly.crashreport.common.info.a aVar = this.d;
crashDetailBean.f = aVar.j;
crashDetailBean.g = aVar.w();
crashDetailBean.m = this.d.g();
String name = th.getClass().getName();
String b = b(th, 1000);
if (b == null) {
b = "";
}
Object[] objArr2 = new Object[2];
objArr2[0] = Integer.valueOf(th.getStackTrace().length);
objArr2[1] = Boolean.valueOf(th.getCause() != null);
x.e("stack frame :%d, has cause %b", objArr2);
String stackTraceElement = th.getStackTrace().length > 0 ? th.getStackTrace()[0].toString() : "";
Throwable th2 = th;
while (th2 != null && th2.getCause() != null) {
th2 = th2.getCause();
}
if (th2 != null && th2 != th) {
crashDetailBean.n = th2.getClass().getName();
crashDetailBean.o = b(th2, 1000);
if (crashDetailBean.o == null) {
crashDetailBean.o = "";
}
if (th2.getStackTrace().length > 0) {
crashDetailBean.p = th2.getStackTrace()[0].toString();
}
StringBuilder sb = new StringBuilder();
sb.append(name);
sb.append(":");
sb.append(b);
sb.append("\n");
sb.append(stackTraceElement);
sb.append("\n......");
sb.append("\nCaused by:\n");
sb.append(crashDetailBean.n);
sb.append(":");
sb.append(crashDetailBean.o);
sb.append("\n");
a = a(th2, c.f);
sb.append(a);
crashDetailBean.q = sb.toString();
} else {
crashDetailBean.n = name;
crashDetailBean.o = b + str2;
if (crashDetailBean.o == null) {
crashDetailBean.o = "";
}
crashDetailBean.p = stackTraceElement;
a = a(th, c.f);
crashDetailBean.q = a;
}
crashDetailBean.r = System.currentTimeMillis();
crashDetailBean.u = z.b(crashDetailBean.q.getBytes());
try {
crashDetailBean.z = z.a(c.f, false);
crashDetailBean.A = this.d.d;
crashDetailBean.B = thread.getName() + "(" + thread.getId() + ")";
crashDetailBean.z.put(crashDetailBean.B, a);
crashDetailBean.I = this.d.y();
crashDetailBean.h = this.d.v();
crashDetailBean.i = this.d.J();
crashDetailBean.M = this.d.a;
crashDetailBean.N = this.d.a();
crashDetailBean.P = this.d.H();
crashDetailBean.Q = this.d.I();
crashDetailBean.R = this.d.B();
crashDetailBean.S = this.d.G();
} catch (Throwable th3) {
x.e("handle crash error %s", th3.toString());
}
if (z) {
this.b.c(crashDetailBean);
} else {
boolean z3 = str != null && str.length() > 0;
if (bArr != null && bArr.length > 0) {
z2 = true;
}
if (z3) {
crashDetailBean.O = new HashMap(1);
crashDetailBean.O.put("UserData", str);
}
if (z2) {
crashDetailBean.T = bArr;
}
}
return crashDetailBean;
}
private static boolean a(Thread thread) {
synchronized (i) {
if (h != null && thread.getName().equals(h)) {
return true;
}
h = thread.getName();
return false;
}
}
public final void a(Thread thread, Throwable th, boolean z, String str, byte[] bArr) {
if (z) {
x.e("Java Crash Happen cause by %s(%d)", thread.getName(), Long.valueOf(thread.getId()));
if (a(thread)) {
x.a("this class has handled this exception", new Object[0]);
if (this.f != null) {
x.a("call system handler", new Object[0]);
this.f.uncaughtException(thread, th);
} else {
x.e("current process die", new Object[0]);
Process.killProcess(Process.myPid());
System.exit(1);
}
}
} else {
x.e("Java Catch Happen", new Object[0]);
}
try {
if (!this.g) {
x.c("Java crash handler is disable. Just return.", new Object[0]);
if (z) {
Thread.UncaughtExceptionHandler uncaughtExceptionHandler = this.e;
if (uncaughtExceptionHandler != null && a(uncaughtExceptionHandler)) {
x.e("sys default last handle start!", new Object[0]);
this.e.uncaughtException(thread, th);
x.e("sys default last handle end!", new Object[0]);
return;
} else if (this.f != null) {
x.e("system handle start!", new Object[0]);
this.f.uncaughtException(thread, th);
x.e("system handle end!", new Object[0]);
return;
} else {
x.e("crashreport last handle start!", new Object[0]);
x.e("current process die", new Object[0]);
Process.killProcess(Process.myPid());
System.exit(1);
x.e("crashreport last handle end!", new Object[0]);
return;
}
}
return;
}
if (!this.c.b()) {
x.d("no remote but still store!", new Object[0]);
}
if (!this.c.c().g && this.c.b()) {
x.e("crash report was closed by remote , will not upload to Bugly , print local for helpful!", new Object[0]);
b.a(z ? "JAVA_CRASH" : "JAVA_CATCH", z.a(), this.d.d, thread.getName(), z.a(th), null);
if (z) {
Thread.UncaughtExceptionHandler uncaughtExceptionHandler2 = this.e;
if (uncaughtExceptionHandler2 != null && a(uncaughtExceptionHandler2)) {
x.e("sys default last handle start!", new Object[0]);
this.e.uncaughtException(thread, th);
x.e("sys default last handle end!", new Object[0]);
return;
} else if (this.f != null) {
x.e("system handle start!", new Object[0]);
this.f.uncaughtException(thread, th);
x.e("system handle end!", new Object[0]);
return;
} else {
x.e("crashreport last handle start!", new Object[0]);
x.e("current process die", new Object[0]);
Process.killProcess(Process.myPid());
System.exit(1);
x.e("crashreport last handle end!", new Object[0]);
return;
}
}
return;
}
CrashDetailBean b = b(thread, th, z, str, bArr);
if (b == null) {
x.e("pkg crash datas fail!", new Object[0]);
if (z) {
Thread.UncaughtExceptionHandler uncaughtExceptionHandler3 = this.e;
if (uncaughtExceptionHandler3 != null && a(uncaughtExceptionHandler3)) {
x.e("sys default last handle start!", new Object[0]);
this.e.uncaughtException(thread, th);
x.e("sys default last handle end!", new Object[0]);
return;
} else if (this.f != null) {
x.e("system handle start!", new Object[0]);
this.f.uncaughtException(thread, th);
x.e("system handle end!", new Object[0]);
return;
} else {
x.e("crashreport last handle start!", new Object[0]);
x.e("current process die", new Object[0]);
Process.killProcess(Process.myPid());
System.exit(1);
x.e("crashreport last handle end!", new Object[0]);
return;
}
}
return;
}
b.a(z ? "JAVA_CRASH" : "JAVA_CATCH", z.a(), this.d.d, thread.getName(), z.a(th), b);
if (!this.b.a(b)) {
this.b.a(b, 3000L, z);
}
if (z) {
this.b.b(b);
}
if (z) {
Thread.UncaughtExceptionHandler uncaughtExceptionHandler4 = this.e;
if (uncaughtExceptionHandler4 != null && a(uncaughtExceptionHandler4)) {
x.e("sys default last handle start!", new Object[0]);
this.e.uncaughtException(thread, th);
x.e("sys default last handle end!", new Object[0]);
} else if (this.f != null) {
x.e("system handle start!", new Object[0]);
this.f.uncaughtException(thread, th);
x.e("system handle end!", new Object[0]);
} else {
x.e("crashreport last handle start!", new Object[0]);
x.e("current process die", new Object[0]);
Process.killProcess(Process.myPid());
System.exit(1);
x.e("crashreport last handle end!", new Object[0]);
}
}
} catch (Throwable th2) {
try {
if (!x.a(th2)) {
th2.printStackTrace();
}
if (z) {
Thread.UncaughtExceptionHandler uncaughtExceptionHandler5 = this.e;
if (uncaughtExceptionHandler5 != null && a(uncaughtExceptionHandler5)) {
x.e("sys default last handle start!", new Object[0]);
this.e.uncaughtException(thread, th);
x.e("sys default last handle end!", new Object[0]);
} else if (this.f != null) {
x.e("system handle start!", new Object[0]);
this.f.uncaughtException(thread, th);
x.e("system handle end!", new Object[0]);
} else {
x.e("crashreport last handle start!", new Object[0]);
x.e("current process die", new Object[0]);
Process.killProcess(Process.myPid());
System.exit(1);
x.e("crashreport last handle end!", new Object[0]);
}
}
} catch (Throwable th3) {
if (z) {
Thread.UncaughtExceptionHandler uncaughtExceptionHandler6 = this.e;
if (uncaughtExceptionHandler6 != null && a(uncaughtExceptionHandler6)) {
x.e("sys default last handle start!", new Object[0]);
this.e.uncaughtException(thread, th);
x.e("sys default last handle end!", new Object[0]);
} else if (this.f != null) {
x.e("system handle start!", new Object[0]);
this.f.uncaughtException(thread, th);
x.e("system handle end!", new Object[0]);
} else {
x.e("crashreport last handle start!", new Object[0]);
x.e("current process die", new Object[0]);
Process.killProcess(Process.myPid());
System.exit(1);
x.e("crashreport last handle end!", new Object[0]);
}
}
throw th3;
}
}
}
private static String b(Throwable th, int i2) {
if (th.getMessage() == null) {
return "";
}
if (th.getMessage().length() <= 1000) {
return th.getMessage();
}
return th.getMessage().substring(0, 1000) + "\n[Message over limit size:1000, has been cutted!]";
}
private static boolean a(Thread.UncaughtExceptionHandler uncaughtExceptionHandler) {
if (uncaughtExceptionHandler == null) {
return true;
}
String name = uncaughtExceptionHandler.getClass().getName();
for (StackTraceElement stackTraceElement : Thread.currentThread().getStackTrace()) {
String className = stackTraceElement.getClassName();
String methodName = stackTraceElement.getMethodName();
if (name.equals(className) && "uncaughtException".equals(methodName)) {
return false;
}
}
return true;
}
public final synchronized void a(StrategyBean strategyBean) {
if (strategyBean != null) {
if (strategyBean.g != this.g) {
x.a("java changed to %b", Boolean.valueOf(strategyBean.g));
if (strategyBean.g) {
a();
return;
}
b();
}
}
}
private static String a(Throwable th, int i2) {
if (th == null) {
return null;
}
StringBuilder sb = new StringBuilder();
try {
if (th.getStackTrace() != null) {
for (StackTraceElement stackTraceElement : th.getStackTrace()) {
if (i2 > 0 && sb.length() >= i2) {
sb.append("\n[Stack over limit size :" + i2 + " , has been cutted !]");
return sb.toString();
}
sb.append(stackTraceElement.toString());
sb.append("\n");
}
}
} catch (Throwable th2) {
x.e("gen stack error %s", th2.toString());
}
return sb.toString();
}
}

View File

@@ -0,0 +1,190 @@
package com.tencent.bugly.crashreport.crash.h5;
import android.webkit.JavascriptInterface;
import com.tencent.bugly.crashreport.CrashReport;
import com.tencent.bugly.crashreport.inner.InnerApi;
import com.tencent.bugly.proguard.x;
import com.tencent.bugly.proguard.z;
import com.unity3d.ads.metadata.MediationMetaData;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import org.json.JSONObject;
/* compiled from: BUGLY */
/* loaded from: classes.dex */
public class H5JavaScriptInterface {
private static HashSet<Integer> a = new HashSet<>();
private String b = null;
private Thread c = null;
private String d = null;
private Map<String, String> e = null;
private H5JavaScriptInterface() {
}
private static a a(String str) {
String string;
if (str != null && str.length() > 0) {
try {
JSONObject jSONObject = new JSONObject(str);
a aVar = new a();
aVar.a = jSONObject.getString("projectRoot");
if (aVar.a == null) {
return null;
}
aVar.b = jSONObject.getString("context");
if (aVar.b == null) {
return null;
}
aVar.c = jSONObject.getString("url");
if (aVar.c == null) {
return null;
}
aVar.d = jSONObject.getString("userAgent");
if (aVar.d == null) {
return null;
}
aVar.e = jSONObject.getString("language");
if (aVar.e == null) {
return null;
}
aVar.f = jSONObject.getString(MediationMetaData.KEY_NAME);
if (aVar.f == null || aVar.f.equals("null") || (string = jSONObject.getString("stacktrace")) == null) {
return null;
}
int indexOf = string.indexOf("\n");
if (indexOf < 0) {
x.d("H5 crash stack's format is wrong!", new Object[0]);
return null;
}
aVar.h = string.substring(indexOf + 1);
aVar.g = string.substring(0, indexOf);
int indexOf2 = aVar.g.indexOf(":");
if (indexOf2 > 0) {
aVar.g = aVar.g.substring(indexOf2 + 1);
}
aVar.i = jSONObject.getString("file");
if (aVar.f == null) {
return null;
}
aVar.j = jSONObject.getLong("lineNumber");
if (aVar.j < 0) {
return null;
}
aVar.k = jSONObject.getLong("columnNumber");
if (aVar.k < 0) {
return null;
}
x.a("H5 crash information is following: ", new Object[0]);
x.a("[projectRoot]: " + aVar.a, new Object[0]);
x.a("[context]: " + aVar.b, new Object[0]);
x.a("[url]: " + aVar.c, new Object[0]);
x.a("[userAgent]: " + aVar.d, new Object[0]);
x.a("[language]: " + aVar.e, new Object[0]);
x.a("[name]: " + aVar.f, new Object[0]);
x.a("[message]: " + aVar.g, new Object[0]);
x.a("[stacktrace]: \n" + aVar.h, new Object[0]);
x.a("[file]: " + aVar.i, new Object[0]);
x.a("[lineNumber]: " + aVar.j, new Object[0]);
x.a("[columnNumber]: " + aVar.k, new Object[0]);
return aVar;
} catch (Throwable th) {
if (!x.a(th)) {
th.printStackTrace();
}
}
}
return null;
}
public static H5JavaScriptInterface getInstance(CrashReport.WebViewInterface webViewInterface) {
String str = null;
if (webViewInterface == null || a.contains(Integer.valueOf(webViewInterface.hashCode()))) {
return null;
}
H5JavaScriptInterface h5JavaScriptInterface = new H5JavaScriptInterface();
a.add(Integer.valueOf(webViewInterface.hashCode()));
h5JavaScriptInterface.c = Thread.currentThread();
Thread thread = h5JavaScriptInterface.c;
if (thread != null) {
StringBuilder sb = new StringBuilder();
sb.append("\n");
for (int i = 2; i < thread.getStackTrace().length; i++) {
StackTraceElement stackTraceElement = thread.getStackTrace()[i];
if (!stackTraceElement.toString().contains("crashreport")) {
sb.append(stackTraceElement.toString());
sb.append("\n");
}
}
str = sb.toString();
}
h5JavaScriptInterface.d = str;
HashMap hashMap = new HashMap();
StringBuilder sb2 = new StringBuilder();
sb2.append((Object) webViewInterface.getContentDescription());
hashMap.put("[WebView] ContentDescription", sb2.toString());
h5JavaScriptInterface.e = hashMap;
return h5JavaScriptInterface;
}
@JavascriptInterface
public void printLog(String str) {
x.d("Log from js: %s", str);
}
@JavascriptInterface
public void reportJSException(String str) {
if (str == null) {
x.d("Payload from JS is null.", new Object[0]);
return;
}
String b = z.b(str.getBytes());
String str2 = this.b;
if (str2 != null && str2.equals(b)) {
x.d("Same payload from js. Please check whether you've injected bugly.js more than one times.", new Object[0]);
return;
}
this.b = b;
x.d("Handling JS exception ...", new Object[0]);
a a2 = a(str);
if (a2 == null) {
x.d("Failed to parse payload.", new Object[0]);
return;
}
LinkedHashMap linkedHashMap = new LinkedHashMap();
LinkedHashMap linkedHashMap2 = new LinkedHashMap();
String str3 = a2.a;
if (str3 != null) {
linkedHashMap2.put("[JS] projectRoot", str3);
}
String str4 = a2.b;
if (str4 != null) {
linkedHashMap2.put("[JS] context", str4);
}
String str5 = a2.c;
if (str5 != null) {
linkedHashMap2.put("[JS] url", str5);
}
String str6 = a2.d;
if (str6 != null) {
linkedHashMap2.put("[JS] userAgent", str6);
}
String str7 = a2.i;
if (str7 != null) {
linkedHashMap2.put("[JS] file", str7);
}
long j = a2.j;
if (j != 0) {
linkedHashMap2.put("[JS] lineNumber", Long.toString(j));
}
linkedHashMap.putAll(linkedHashMap2);
linkedHashMap.putAll(this.e);
linkedHashMap.put("Java Stack", this.d);
Thread thread = this.c;
if (a2 != null) {
InnerApi.postH5CrashAsync(thread, a2.f, a2.g, a2.h, linkedHashMap);
}
}
}

View File

@@ -0,0 +1,17 @@
package com.tencent.bugly.crashreport.crash.h5;
/* compiled from: BUGLY */
/* loaded from: classes.dex */
public final class a {
public String a = null;
public String b = null;
public String c = null;
public String d = null;
public String e = null;
public String f = null;
public String g = null;
public String h = null;
public String i = null;
public long j = 0;
public long k = 0;
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,458 @@
package com.tencent.bugly.crashreport.crash.jni;
import android.annotation.SuppressLint;
import android.content.Context;
import com.tencent.bugly.Bugly;
import com.tencent.bugly.crashreport.common.strategy.StrategyBean;
import com.tencent.bugly.crashreport.crash.CrashDetailBean;
import com.tencent.bugly.crashreport.crash.c;
import com.tencent.bugly.proguard.w;
import com.tencent.bugly.proguard.x;
import com.tencent.bugly.proguard.z;
import java.io.File;
/* compiled from: BUGLY */
/* loaded from: classes.dex */
public class NativeCrashHandler implements com.tencent.bugly.crashreport.a {
private static NativeCrashHandler a = null;
private static boolean l = false;
private static boolean m = false;
private static boolean o = true;
private final Context b;
private final com.tencent.bugly.crashreport.common.info.a c;
private final w d;
private NativeExceptionHandler e;
private String f;
private final boolean g;
private boolean h = false;
private boolean i = false;
private boolean j = false;
private boolean k = false;
private com.tencent.bugly.crashreport.crash.b n;
@SuppressLint({"SdCardPath"})
private NativeCrashHandler(Context context, com.tencent.bugly.crashreport.common.info.a aVar, com.tencent.bugly.crashreport.crash.b bVar, w wVar, boolean z, String str) {
this.b = z.a(context);
try {
if (z.a(str)) {
str = context.getDir("bugly", 0).getAbsolutePath();
}
} catch (Throwable unused) {
str = "/data/data/" + com.tencent.bugly.crashreport.common.info.a.a(context).c + "/app_bugly";
}
this.n = bVar;
this.f = str;
this.c = aVar;
this.d = wVar;
this.g = z;
this.e = new a(context, aVar, bVar, com.tencent.bugly.crashreport.common.strategy.a.a());
}
public static synchronized NativeCrashHandler getInstance(Context context, com.tencent.bugly.crashreport.common.info.a aVar, com.tencent.bugly.crashreport.crash.b bVar, com.tencent.bugly.crashreport.common.strategy.a aVar2, w wVar, boolean z, String str) {
NativeCrashHandler nativeCrashHandler;
synchronized (NativeCrashHandler.class) {
if (a == null) {
a = new NativeCrashHandler(context, aVar, bVar, wVar, z, str);
}
nativeCrashHandler = a;
}
return nativeCrashHandler;
}
public static boolean isShouldHandleInJava() {
return o;
}
public static void setShouldHandleInJava(boolean z) {
o = z;
NativeCrashHandler nativeCrashHandler = a;
if (nativeCrashHandler != null) {
StringBuilder sb = new StringBuilder();
sb.append(z);
nativeCrashHandler.a(999, sb.toString());
}
}
@Override // com.tencent.bugly.crashreport.a
public boolean appendLogToNative(String str, String str2, String str3) {
if ((this.h || this.i) && l && str != null && str2 != null && str3 != null) {
try {
if (this.i) {
return appendNativeLog(str, str2, str3);
}
Boolean bool = (Boolean) z.a("com.tencent.feedback.eup.jni.NativeExceptionUpload", "appendNativeLog", null, new Class[]{String.class, String.class, String.class}, new Object[]{str, str2, str3});
if (bool != null) {
return bool.booleanValue();
}
return false;
} catch (UnsatisfiedLinkError unused) {
l = false;
} catch (Throwable th) {
if (!x.a(th)) {
th.printStackTrace();
}
return false;
}
}
return false;
}
protected native boolean appendNativeLog(String str, String str2, String str3);
protected native boolean appendWholeNativeLog(String str);
public void checkUploadRecordCrash() {
this.d.a(new Runnable() { // from class: com.tencent.bugly.crashreport.crash.jni.NativeCrashHandler.1
@Override // java.lang.Runnable
public final void run() {
if (!z.a(NativeCrashHandler.this.b, "native_record_lock", 10000L)) {
x.a("[Native] Failed to lock file for handling native crash record.", new Object[0]);
return;
}
if (!NativeCrashHandler.o) {
NativeCrashHandler.a(NativeCrashHandler.this, 999, Bugly.SDK_IS_DEV);
}
CrashDetailBean a2 = b.a(NativeCrashHandler.this.b, NativeCrashHandler.this.f, NativeCrashHandler.this.e);
if (a2 != null) {
x.a("[Native] Get crash from native record.", new Object[0]);
if (!NativeCrashHandler.this.n.a(a2)) {
NativeCrashHandler.this.n.a(a2, 3000L, false);
}
b.a(false, NativeCrashHandler.this.f);
}
NativeCrashHandler.this.a();
z.b(NativeCrashHandler.this.b, "native_record_lock");
}
});
}
public boolean filterSigabrtSysLog() {
return a(998, "true");
}
public synchronized String getDumpFilePath() {
return this.f;
}
@Override // com.tencent.bugly.crashreport.a
public String getLogFromNative() {
if ((!this.h && !this.i) || !l) {
return null;
}
try {
return this.i ? getNativeLog() : (String) z.a("com.tencent.feedback.eup.jni.NativeExceptionUpload", "getNativeLog", null, null, null);
} catch (UnsatisfiedLinkError unused) {
l = false;
return null;
} catch (Throwable th) {
if (!x.a(th)) {
th.printStackTrace();
}
return null;
}
}
public NativeExceptionHandler getNativeExceptionHandler() {
return this.e;
}
protected native String getNativeKeyValueList();
protected native String getNativeLog();
public synchronized boolean isUserOpened() {
return this.k;
}
public synchronized void onStrategyChanged(StrategyBean strategyBean) {
if (strategyBean != null) {
if (strategyBean.g != this.j) {
x.d("server native changed to %b", Boolean.valueOf(strategyBean.g));
}
}
boolean z = com.tencent.bugly.crashreport.common.strategy.a.a().c().g && this.k;
if (z != this.j) {
x.a("native changed to %b", Boolean.valueOf(z));
b(z);
}
}
public boolean putKeyValueToNative(String str, String str2) {
if ((this.h || this.i) && l && str != null && str2 != null) {
try {
if (this.i) {
return putNativeKeyValue(str, str2);
}
Boolean bool = (Boolean) z.a("com.tencent.feedback.eup.jni.NativeExceptionUpload", "putNativeKeyValue", null, new Class[]{String.class, String.class}, new Object[]{str, str2});
if (bool != null) {
return bool.booleanValue();
}
return false;
} catch (UnsatisfiedLinkError unused) {
l = false;
} catch (Throwable th) {
if (!x.a(th)) {
th.printStackTrace();
}
return false;
}
}
return false;
}
protected native boolean putNativeKeyValue(String str, String str2);
protected native String regist(String str, boolean z, int i);
public void removeEmptyNativeRecordFiles() {
b.c(this.f);
}
protected native String removeNativeKeyValue(String str);
public synchronized void setDumpFilePath(String str) {
this.f = str;
}
public boolean setNativeAppChannel(String str) {
return a(12, str);
}
public boolean setNativeAppPackage(String str) {
return a(13, str);
}
public boolean setNativeAppVersion(String str) {
return a(10, str);
}
protected native void setNativeInfo(int i, String str);
@Override // com.tencent.bugly.crashreport.a
public boolean setNativeIsAppForeground(boolean z) {
return a(14, z ? "true" : Bugly.SDK_IS_DEV);
}
public boolean setNativeLaunchTime(long j) {
try {
return a(15, String.valueOf(j));
} catch (NumberFormatException e) {
if (x.a(e)) {
return false;
}
e.printStackTrace();
return false;
}
}
public boolean setNativeUserId(String str) {
return a(11, str);
}
public synchronized void setUserOpened(boolean z) {
c(z);
boolean isUserOpened = isUserOpened();
com.tencent.bugly.crashreport.common.strategy.a a2 = com.tencent.bugly.crashreport.common.strategy.a.a();
if (a2 != null) {
isUserOpened = isUserOpened && a2.c().g;
}
if (isUserOpened != this.j) {
x.a("native changed to %b", Boolean.valueOf(isUserOpened));
b(isUserOpened);
}
}
public synchronized void startNativeMonitor() {
if (!this.i && !this.h) {
String str = "Bugly";
boolean z = !z.a(this.c.m);
String str2 = this.c.m;
if (z) {
str = str2;
} else {
this.c.getClass();
}
this.i = a(str, z);
if (this.i || this.h) {
a(this.g);
if (l) {
setNativeAppVersion(this.c.j);
setNativeAppChannel(this.c.l);
setNativeAppPackage(this.c.c);
setNativeUserId(this.c.g());
setNativeIsAppForeground(this.c.a());
setNativeLaunchTime(this.c.a);
}
return;
}
return;
}
a(this.g);
}
protected native void testCrash();
public void testNativeCrash() {
if (this.i) {
testCrash();
} else {
x.d("[Native] Bugly SO file has not been load.", new Object[0]);
}
}
protected native String unregist();
static /* synthetic */ boolean a(NativeCrashHandler nativeCrashHandler, int i, String str) {
return nativeCrashHandler.a(999, str);
}
private synchronized void c() {
if (!this.j) {
x.d("[Native] Native crash report has already unregistered.", new Object[0]);
return;
}
try {
if (unregist() != null) {
x.a("[Native] Successfully closed native crash report.", new Object[0]);
this.j = false;
return;
}
} catch (Throwable unused) {
x.c("[Native] Failed to close native crash report.", new Object[0]);
}
try {
z.a("com.tencent.feedback.eup.jni.NativeExceptionUpload", "enableHandler", null, new Class[]{Boolean.TYPE}, new Object[]{false});
this.j = false;
x.a("[Native] Successfully closed native crash report.", new Object[0]);
} catch (Throwable unused2) {
x.c("[Native] Failed to close native crash report.", new Object[0]);
this.i = false;
this.h = false;
}
}
/* JADX WARN: Can't wrap try/catch for region: R(15:40|(1:42)(14:65|(1:67)|44|45|(1:47)|48|(1:50)|52|(1:54)(1:63)|55|(1:57)(1:62)|58|59|60)|43|44|45|(0)|48|(0)|52|(0)(0)|55|(0)(0)|58|59|60) */
/* JADX WARN: Removed duplicated region for block: B:47:0x007c A[Catch: all -> 0x008a, TryCatch #1 {all -> 0x008a, blocks: (B:45:0x0072, B:47:0x007c, B:48:0x007e, B:50:0x0088), top: B:44:0x0072 }] */
/* JADX WARN: Removed duplicated region for block: B:50:0x0088 A[Catch: all -> 0x008a, TRY_LEAVE, TryCatch #1 {all -> 0x008a, blocks: (B:45:0x0072, B:47:0x007c, B:48:0x007e, B:50:0x0088), top: B:44:0x0072 }] */
/* JADX WARN: Removed duplicated region for block: B:54:0x008e A[Catch: all -> 0x00bd, TryCatch #3 {all -> 0x00bd, blocks: (B:38:0x0015, B:40:0x001d, B:42:0x004f, B:43:0x0059, B:52:0x008a, B:54:0x008e, B:55:0x009d, B:57:0x00a1, B:58:0x00b0, B:62:0x00a9, B:63:0x0096, B:65:0x0061, B:67:0x0067), top: B:37:0x0015, outer: #2 }] */
/* JADX WARN: Removed duplicated region for block: B:57:0x00a1 A[Catch: all -> 0x00bd, TryCatch #3 {all -> 0x00bd, blocks: (B:38:0x0015, B:40:0x001d, B:42:0x004f, B:43:0x0059, B:52:0x008a, B:54:0x008e, B:55:0x009d, B:57:0x00a1, B:58:0x00b0, B:62:0x00a9, B:63:0x0096, B:65:0x0061, B:67:0x0067), top: B:37:0x0015, outer: #2 }] */
/* JADX WARN: Removed duplicated region for block: B:62:0x00a9 A[Catch: all -> 0x00bd, TryCatch #3 {all -> 0x00bd, blocks: (B:38:0x0015, B:40:0x001d, B:42:0x004f, B:43:0x0059, B:52:0x008a, B:54:0x008e, B:55:0x009d, B:57:0x00a1, B:58:0x00b0, B:62:0x00a9, B:63:0x0096, B:65:0x0061, B:67:0x0067), top: B:37:0x0015, outer: #2 }] */
/* JADX WARN: Removed duplicated region for block: B:63:0x0096 A[Catch: all -> 0x00bd, TryCatch #3 {all -> 0x00bd, blocks: (B:38:0x0015, B:40:0x001d, B:42:0x004f, B:43:0x0059, B:52:0x008a, B:54:0x008e, B:55:0x009d, B:57:0x00a1, B:58:0x00b0, B:62:0x00a9, B:63:0x0096, B:65:0x0061, B:67:0x0067), top: B:37:0x0015, outer: #2 }] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
private synchronized void a(boolean r11) {
/*
Method dump skipped, instructions count: 415
To view this dump change 'Code comments level' option to 'DEBUG'
*/
throw new UnsupportedOperationException("Method not decompiled: com.tencent.bugly.crashreport.crash.jni.NativeCrashHandler.a(boolean):void");
}
private synchronized void b(boolean z) {
if (z) {
startNativeMonitor();
} else {
c();
}
}
public static synchronized NativeCrashHandler getInstance() {
NativeCrashHandler nativeCrashHandler;
synchronized (NativeCrashHandler.class) {
nativeCrashHandler = a;
}
return nativeCrashHandler;
}
public void testNativeCrash(boolean z, boolean z2, boolean z3) {
StringBuilder sb = new StringBuilder();
sb.append(z);
a(16, sb.toString());
StringBuilder sb2 = new StringBuilder();
sb2.append(z2);
a(17, sb2.toString());
StringBuilder sb3 = new StringBuilder();
sb3.append(z3);
a(18, sb3.toString());
testNativeCrash();
}
private synchronized void c(boolean z) {
if (this.k != z) {
x.a("user change native %b", Boolean.valueOf(z));
this.k = z;
}
}
private static boolean a(String str, boolean z) {
boolean z2;
try {
x.a("[Native] Trying to load so: %s", str);
if (z) {
System.load(str);
} else {
System.loadLibrary(str);
}
try {
x.a("[Native] Successfully loaded SO: %s", str);
return true;
} catch (Throwable th) {
th = th;
z2 = true;
x.d(th.getMessage(), new Object[0]);
x.d("[Native] Failed to load so: %s", str);
return z2;
}
} catch (Throwable th2) {
th = th2;
z2 = false;
}
}
protected final void a() {
long b = z.b() - c.g;
long b2 = z.b() + 86400000;
File file = new File(this.f);
if (file.exists() && file.isDirectory()) {
try {
File[] listFiles = file.listFiles();
if (listFiles != null && listFiles.length != 0) {
int i = 0;
int i2 = 0;
for (File file2 : listFiles) {
long lastModified = file2.lastModified();
if (lastModified < b || lastModified >= b2) {
x.a("[Native] Delete record file: %s", file2.getAbsolutePath());
i++;
if (file2.delete()) {
i2++;
}
}
}
x.c("[Native] Number of record files overdue: %d, has deleted: %d", Integer.valueOf(i), Integer.valueOf(i2));
}
} catch (Throwable th) {
x.a(th);
}
}
}
private boolean a(int i, String str) {
if (this.i && m) {
try {
setNativeInfo(i, str);
return true;
} catch (UnsatisfiedLinkError unused) {
m = false;
} catch (Throwable th) {
if (!x.a(th)) {
th.printStackTrace();
}
return false;
}
}
return false;
}
}

View File

@@ -0,0 +1,14 @@
package com.tencent.bugly.crashreport.crash.jni;
import com.tencent.bugly.crashreport.crash.CrashDetailBean;
import java.util.Map;
/* compiled from: BUGLY */
/* loaded from: classes.dex */
public interface NativeExceptionHandler {
void handleNativeException(int i, int i2, long j, long j2, String str, String str2, String str3, String str4, int i3, String str5, int i4, int i5, int i6, String str6, String str7);
void handleNativeException2(int i, int i2, long j, long j2, String str, String str2, String str3, String str4, int i3, String str5, int i4, int i5, int i6, String str6, String str7, String[] strArr);
CrashDetailBean packageCrashDatas(String str, String str2, long j, String str3, String str4, String str5, String str6, String str7, String str8, String str9, String str10, String str11, byte[] bArr, Map<String, String> map, boolean z, boolean z2);
}

View File

@@ -0,0 +1,149 @@
package com.tencent.bugly.crashreport.crash.jni;
import android.content.Context;
import com.tencent.bugly.crashreport.crash.CrashDetailBean;
import com.tencent.bugly.crashreport.crash.c;
import com.tencent.bugly.proguard.x;
import com.tencent.bugly.proguard.y;
import com.tencent.bugly.proguard.z;
import java.util.Map;
/* compiled from: BUGLY */
/* loaded from: classes.dex */
public final class a implements NativeExceptionHandler {
private final Context a;
private final com.tencent.bugly.crashreport.crash.b b;
private final com.tencent.bugly.crashreport.common.info.a c;
private final com.tencent.bugly.crashreport.common.strategy.a d;
public a(Context context, com.tencent.bugly.crashreport.common.info.a aVar, com.tencent.bugly.crashreport.crash.b bVar, com.tencent.bugly.crashreport.common.strategy.a aVar2) {
this.a = context;
this.b = bVar;
this.c = aVar;
this.d = aVar2;
}
@Override // com.tencent.bugly.crashreport.crash.jni.NativeExceptionHandler
public final void handleNativeException(int i, int i2, long j, long j2, String str, String str2, String str3, String str4, int i3, String str5, int i4, int i5, int i6, String str6, String str7) {
x.a("Native Crash Happen v1", new Object[0]);
handleNativeException2(i, i2, j, j2, str, str2, str3, str4, i3, str5, i4, i5, i6, str6, str7, null);
}
/* JADX WARN: Removed duplicated region for block: B:42:0x0122 A[Catch: all -> 0x029d, TryCatch #2 {all -> 0x029d, blocks: (B:3:0x0012, B:6:0x001e, B:7:0x006e, B:10:0x0076, B:12:0x0079, B:14:0x007d, B:16:0x0098, B:19:0x00a1, B:18:0x00ab, B:23:0x00b5, B:25:0x00bf, B:27:0x00c7, B:28:0x00d3, B:30:0x00dd, B:33:0x00e4, B:34:0x00f3, B:36:0x00ff, B:39:0x0106, B:40:0x011c, B:42:0x0122, B:45:0x0132, B:47:0x0152, B:49:0x0191, B:51:0x01b4, B:52:0x01bb, B:55:0x01c7, B:57:0x01cf, B:94:0x016d, B:95:0x00ef, B:97:0x00ae, B:100:0x0044, B:101:0x0048, B:103:0x0052), top: B:2:0x0012 }] */
/* JADX WARN: Removed duplicated region for block: B:47:0x0152 A[Catch: all -> 0x029d, TryCatch #2 {all -> 0x029d, blocks: (B:3:0x0012, B:6:0x001e, B:7:0x006e, B:10:0x0076, B:12:0x0079, B:14:0x007d, B:16:0x0098, B:19:0x00a1, B:18:0x00ab, B:23:0x00b5, B:25:0x00bf, B:27:0x00c7, B:28:0x00d3, B:30:0x00dd, B:33:0x00e4, B:34:0x00f3, B:36:0x00ff, B:39:0x0106, B:40:0x011c, B:42:0x0122, B:45:0x0132, B:47:0x0152, B:49:0x0191, B:51:0x01b4, B:52:0x01bb, B:55:0x01c7, B:57:0x01cf, B:94:0x016d, B:95:0x00ef, B:97:0x00ae, B:100:0x0044, B:101:0x0048, B:103:0x0052), top: B:2:0x0012 }] */
/* JADX WARN: Removed duplicated region for block: B:51:0x01b4 A[Catch: all -> 0x029d, TryCatch #2 {all -> 0x029d, blocks: (B:3:0x0012, B:6:0x001e, B:7:0x006e, B:10:0x0076, B:12:0x0079, B:14:0x007d, B:16:0x0098, B:19:0x00a1, B:18:0x00ab, B:23:0x00b5, B:25:0x00bf, B:27:0x00c7, B:28:0x00d3, B:30:0x00dd, B:33:0x00e4, B:34:0x00f3, B:36:0x00ff, B:39:0x0106, B:40:0x011c, B:42:0x0122, B:45:0x0132, B:47:0x0152, B:49:0x0191, B:51:0x01b4, B:52:0x01bb, B:55:0x01c7, B:57:0x01cf, B:94:0x016d, B:95:0x00ef, B:97:0x00ae, B:100:0x0044, B:101:0x0048, B:103:0x0052), top: B:2:0x0012 }] */
/* JADX WARN: Removed duplicated region for block: B:55:0x01c7 A[Catch: all -> 0x029d, TRY_ENTER, TryCatch #2 {all -> 0x029d, blocks: (B:3:0x0012, B:6:0x001e, B:7:0x006e, B:10:0x0076, B:12:0x0079, B:14:0x007d, B:16:0x0098, B:19:0x00a1, B:18:0x00ab, B:23:0x00b5, B:25:0x00bf, B:27:0x00c7, B:28:0x00d3, B:30:0x00dd, B:33:0x00e4, B:34:0x00f3, B:36:0x00ff, B:39:0x0106, B:40:0x011c, B:42:0x0122, B:45:0x0132, B:47:0x0152, B:49:0x0191, B:51:0x01b4, B:52:0x01bb, B:55:0x01c7, B:57:0x01cf, B:94:0x016d, B:95:0x00ef, B:97:0x00ae, B:100:0x0044, B:101:0x0048, B:103:0x0052), top: B:2:0x0012 }] */
/* JADX WARN: Removed duplicated region for block: B:65:0x022f A[Catch: all -> 0x0299, TryCatch #1 {all -> 0x0299, blocks: (B:63:0x0229, B:65:0x022f, B:67:0x0238), top: B:62:0x0229 }] */
/* JADX WARN: Removed duplicated region for block: B:67:0x0238 A[Catch: all -> 0x0299, TRY_LEAVE, TryCatch #1 {all -> 0x0299, blocks: (B:63:0x0229, B:65:0x022f, B:67:0x0238), top: B:62:0x0229 }] */
/* JADX WARN: Removed duplicated region for block: B:90:0x016a */
/* JADX WARN: Removed duplicated region for block: B:92:0x014e A[SYNTHETIC] */
@Override // com.tencent.bugly.crashreport.crash.jni.NativeExceptionHandler
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
public final void handleNativeException2(int r28, int r29, long r30, long r32, java.lang.String r34, java.lang.String r35, java.lang.String r36, java.lang.String r37, int r38, java.lang.String r39, int r40, int r41, int r42, java.lang.String r43, java.lang.String r44, java.lang.String[] r45) {
/*
Method dump skipped, instructions count: 681
To view this dump change 'Code comments level' option to 'DEBUG'
*/
throw new UnsupportedOperationException("Method not decompiled: com.tencent.bugly.crashreport.crash.jni.a.handleNativeException2(int, int, long, long, java.lang.String, java.lang.String, java.lang.String, java.lang.String, int, java.lang.String, int, int, int, java.lang.String, java.lang.String, java.lang.String[]):void");
}
@Override // com.tencent.bugly.crashreport.crash.jni.NativeExceptionHandler
public final CrashDetailBean packageCrashDatas(String str, String str2, long j, String str3, String str4, String str5, String str6, String str7, String str8, String str9, String str10, String str11, byte[] bArr, Map<String, String> map, boolean z, boolean z2) {
int i;
String str12;
int indexOf;
boolean k = c.a().k();
if (k) {
x.e("This Crash Caused By ANR , PLS To Fix ANR , This Trace May Be Not Useful!", new Object[0]);
}
CrashDetailBean crashDetailBean = new CrashDetailBean();
crashDetailBean.b = 1;
crashDetailBean.e = this.c.h();
com.tencent.bugly.crashreport.common.info.a aVar = this.c;
crashDetailBean.f = aVar.j;
crashDetailBean.g = aVar.w();
crashDetailBean.m = this.c.g();
crashDetailBean.n = str3;
crashDetailBean.o = k ? " This Crash Caused By ANR , PLS To Fix ANR , This Trace May Be Not Useful![Bugly]" : "";
crashDetailBean.p = str4;
crashDetailBean.q = str5 != null ? str5 : "";
crashDetailBean.r = j;
crashDetailBean.u = z.b(crashDetailBean.q.getBytes());
crashDetailBean.A = str;
crashDetailBean.B = str2;
crashDetailBean.I = this.c.y();
crashDetailBean.h = this.c.v();
crashDetailBean.i = this.c.J();
crashDetailBean.v = str8;
NativeCrashHandler nativeCrashHandler = NativeCrashHandler.getInstance();
String dumpFilePath = nativeCrashHandler != null ? nativeCrashHandler.getDumpFilePath() : null;
String a = b.a(dumpFilePath, str8);
if (!z.a(a)) {
crashDetailBean.U = a;
}
crashDetailBean.V = b.b(dumpFilePath);
crashDetailBean.w = b.a(str9, c.e, null, false);
crashDetailBean.x = b.a(str10, c.e, null, true);
crashDetailBean.J = str7;
crashDetailBean.K = str6;
crashDetailBean.L = str11;
crashDetailBean.F = this.c.p();
crashDetailBean.G = this.c.o();
crashDetailBean.H = this.c.q();
if (z) {
crashDetailBean.C = com.tencent.bugly.crashreport.common.info.b.k();
crashDetailBean.D = com.tencent.bugly.crashreport.common.info.b.i();
crashDetailBean.E = com.tencent.bugly.crashreport.common.info.b.m();
if (crashDetailBean.w == null) {
crashDetailBean.w = z.a(this.a, c.e, (String) null);
}
crashDetailBean.y = y.a();
com.tencent.bugly.crashreport.common.info.a aVar2 = this.c;
crashDetailBean.M = aVar2.a;
crashDetailBean.N = aVar2.a();
crashDetailBean.P = this.c.H();
crashDetailBean.Q = this.c.I();
crashDetailBean.R = this.c.B();
crashDetailBean.S = this.c.G();
crashDetailBean.z = z.a(c.f, false);
int indexOf2 = crashDetailBean.q.indexOf("java:\n");
if (indexOf2 > 0 && (i = indexOf2 + 6) < crashDetailBean.q.length()) {
String str13 = crashDetailBean.q;
String substring = str13.substring(i, str13.length() - 1);
if (substring.length() > 0 && crashDetailBean.z.containsKey(crashDetailBean.B) && (indexOf = (str12 = crashDetailBean.z.get(crashDetailBean.B)).indexOf(substring)) > 0) {
String substring2 = str12.substring(indexOf);
crashDetailBean.z.put(crashDetailBean.B, substring2);
crashDetailBean.q = crashDetailBean.q.substring(0, i);
crashDetailBean.q += substring2;
}
}
if (str == null) {
crashDetailBean.A = this.c.d;
}
this.b.c(crashDetailBean);
} else {
crashDetailBean.C = -1L;
crashDetailBean.D = -1L;
crashDetailBean.E = -1L;
if (crashDetailBean.w == null) {
crashDetailBean.w = "this crash is occurred at last process! Log is miss, when get an terrible ABRT Native Exception etc.";
}
crashDetailBean.M = -1L;
crashDetailBean.P = -1;
crashDetailBean.Q = -1;
crashDetailBean.R = map;
crashDetailBean.S = this.c.G();
crashDetailBean.z = null;
if (str == null) {
crashDetailBean.A = "unknown(record)";
}
if (bArr != null) {
crashDetailBean.y = bArr;
}
}
return crashDetailBean;
}
}

View File

@@ -0,0 +1,693 @@
package com.tencent.bugly.crashreport.crash.jni;
import android.content.Context;
import com.ijm.dataencryption.de.DataDecryptTool;
import com.tencent.bugly.crashreport.crash.CrashDetailBean;
import com.tencent.bugly.proguard.x;
import com.tencent.bugly.proguard.z;
import com.ubt.jimu.diy.model.CategoryModel;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
/* compiled from: BUGLY */
/* loaded from: classes.dex */
public final class b {
private static List<File> a = new ArrayList();
protected static String a(String str) {
if (str == null) {
return "";
}
String[] split = str.split("\n");
if (split == null || split.length == 0) {
return str;
}
StringBuilder sb = new StringBuilder();
for (String str2 : split) {
if (!str2.contains("java.lang.Thread.getStackTrace(")) {
sb.append(str2);
sb.append("\n");
}
}
return sb.toString();
}
/* JADX WARN: Code restructure failed: missing block: B:40:0x006d, code lost:
r9.close();
*/
/* JADX WARN: Code restructure failed: missing block: B:42:0x0071, code lost:
r9 = move-exception;
*/
/* JADX WARN: Code restructure failed: missing block: B:43:0x0072, code lost:
com.tencent.bugly.proguard.x.a(r9);
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
private static java.lang.String b(java.lang.String r9, java.lang.String r10) {
/*
java.lang.String r0 = "reg_record.txt"
java.io.BufferedReader r9 = com.tencent.bugly.proguard.z.a(r9, r0)
r0 = 0
if (r9 != 0) goto La
return r0
La:
java.lang.StringBuilder r1 = new java.lang.StringBuilder // Catch: java.lang.Throwable -> L76
r1.<init>() // Catch: java.lang.Throwable -> L76
java.lang.String r2 = r9.readLine() // Catch: java.lang.Throwable -> L76
if (r2 == 0) goto L6b
boolean r10 = r2.startsWith(r10) // Catch: java.lang.Throwable -> L76
if (r10 != 0) goto L1c
goto L6b
L1c:
java.lang.String r10 = " "
r2 = 18
r3 = 0
r2 = 0
r4 = 18
r5 = 0
L25:
java.lang.String r6 = r9.readLine() // Catch: java.lang.Throwable -> L76
java.lang.String r7 = "\n"
if (r6 == 0) goto L59
int r8 = r2 % 4
if (r8 != 0) goto L3c
if (r2 <= 0) goto L36
r1.append(r7) // Catch: java.lang.Throwable -> L76
L36:
java.lang.String r5 = " "
r1.append(r5) // Catch: java.lang.Throwable -> L76
goto L4f
L3c:
int r7 = r6.length() // Catch: java.lang.Throwable -> L76
r8 = 16
if (r7 <= r8) goto L46
r4 = 28
L46:
int r5 = r4 - r5
java.lang.String r5 = r10.substring(r3, r5) // Catch: java.lang.Throwable -> L76
r1.append(r5) // Catch: java.lang.Throwable -> L76
L4f:
int r5 = r6.length() // Catch: java.lang.Throwable -> L76
r1.append(r6) // Catch: java.lang.Throwable -> L76
int r2 = r2 + 1
goto L25
L59:
r1.append(r7) // Catch: java.lang.Throwable -> L76
java.lang.String r10 = r1.toString() // Catch: java.lang.Throwable -> L76
if (r9 == 0) goto L6a
r9.close() // Catch: java.lang.Exception -> L66
goto L6a
L66:
r9 = move-exception
com.tencent.bugly.proguard.x.a(r9)
L6a:
return r10
L6b:
if (r9 == 0) goto L75
r9.close() // Catch: java.lang.Exception -> L71
goto L75
L71:
r9 = move-exception
com.tencent.bugly.proguard.x.a(r9)
L75:
return r0
L76:
r10 = move-exception
com.tencent.bugly.proguard.x.a(r10) // Catch: java.lang.Throwable -> L85
if (r9 == 0) goto L84
r9.close() // Catch: java.lang.Exception -> L80
goto L84
L80:
r9 = move-exception
com.tencent.bugly.proguard.x.a(r9)
L84:
return r0
L85:
r10 = move-exception
if (r9 == 0) goto L90
r9.close() // Catch: java.lang.Exception -> L8c
goto L90
L8c:
r9 = move-exception
com.tencent.bugly.proguard.x.a(r9)
L90:
throw r10
*/
throw new UnsupportedOperationException("Method not decompiled: com.tencent.bugly.crashreport.crash.jni.b.b(java.lang.String, java.lang.String):java.lang.String");
}
/* JADX WARN: Code restructure failed: missing block: B:27:0x0041, code lost:
r3.close();
*/
/* JADX WARN: Code restructure failed: missing block: B:29:0x0045, code lost:
r3 = move-exception;
*/
/* JADX WARN: Code restructure failed: missing block: B:30:0x0046, code lost:
com.tencent.bugly.proguard.x.a(r3);
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
private static java.lang.String c(java.lang.String r3, java.lang.String r4) {
/*
java.lang.String r0 = "map_record.txt"
java.io.BufferedReader r3 = com.tencent.bugly.proguard.z.a(r3, r0)
r0 = 0
if (r3 != 0) goto La
return r0
La:
java.lang.StringBuilder r1 = new java.lang.StringBuilder // Catch: java.lang.Throwable -> L4a
r1.<init>() // Catch: java.lang.Throwable -> L4a
java.lang.String r2 = r3.readLine() // Catch: java.lang.Throwable -> L4a
if (r2 == 0) goto L3f
boolean r4 = r2.startsWith(r4) // Catch: java.lang.Throwable -> L4a
if (r4 != 0) goto L1c
goto L3f
L1c:
java.lang.String r4 = r3.readLine() // Catch: java.lang.Throwable -> L4a
if (r4 == 0) goto L30
java.lang.String r2 = " "
r1.append(r2) // Catch: java.lang.Throwable -> L4a
r1.append(r4) // Catch: java.lang.Throwable -> L4a
java.lang.String r4 = "\n"
r1.append(r4) // Catch: java.lang.Throwable -> L4a
goto L1c
L30:
java.lang.String r4 = r1.toString() // Catch: java.lang.Throwable -> L4a
if (r3 == 0) goto L3e
r3.close() // Catch: java.lang.Exception -> L3a
goto L3e
L3a:
r3 = move-exception
com.tencent.bugly.proguard.x.a(r3)
L3e:
return r4
L3f:
if (r3 == 0) goto L49
r3.close() // Catch: java.lang.Exception -> L45
goto L49
L45:
r3 = move-exception
com.tencent.bugly.proguard.x.a(r3)
L49:
return r0
L4a:
r4 = move-exception
com.tencent.bugly.proguard.x.a(r4) // Catch: java.lang.Throwable -> L59
if (r3 == 0) goto L58
r3.close() // Catch: java.lang.Exception -> L54
goto L58
L54:
r3 = move-exception
com.tencent.bugly.proguard.x.a(r3)
L58:
return r0
L59:
r4 = move-exception
if (r3 == 0) goto L64
r3.close() // Catch: java.lang.Exception -> L60
goto L64
L60:
r3 = move-exception
com.tencent.bugly.proguard.x.a(r3)
L64:
throw r4
*/
throw new UnsupportedOperationException("Method not decompiled: com.tencent.bugly.crashreport.crash.jni.b.c(java.lang.String, java.lang.String):java.lang.String");
}
private static Map<String, Integer> d(String str) {
if (str == null) {
return null;
}
try {
HashMap hashMap = new HashMap();
for (String str2 : str.split(",")) {
String[] split = str2.split(":");
if (split.length != 2) {
x.e("error format at %s", str2);
return null;
}
hashMap.put(split[0], Integer.valueOf(Integer.parseInt(split[1])));
}
return hashMap;
} catch (Exception e) {
x.e("error format intStateStr %s", str);
e.printStackTrace();
return null;
}
}
private static CrashDetailBean a(Context context, Map<String, String> map, NativeExceptionHandler nativeExceptionHandler) {
String str;
String str2;
HashMap hashMap;
if (map == null) {
return null;
}
if (com.tencent.bugly.crashreport.common.info.a.a(context) == null) {
x.e("abnormal com info not created", new Object[0]);
return null;
}
String str3 = map.get("intStateStr");
if (str3 != null && str3.trim().length() > 0) {
Map<String, Integer> d = d(str3);
if (d == null) {
x.e("parse intSateMap fail", Integer.valueOf(map.size()));
return null;
}
try {
d.get("sino").intValue();
d.get("sud").intValue();
String str4 = map.get("soVersion");
if (str4 == null) {
x.e("error format at version", new Object[0]);
return null;
}
String str5 = map.get("errorAddr");
String str6 = CategoryModel.unknown;
String str7 = str5 == null ? CategoryModel.unknown : str5;
String str8 = map.get("codeMsg");
if (str8 == null) {
str8 = CategoryModel.unknown;
}
String str9 = map.get("tombPath");
String str10 = str9 == null ? CategoryModel.unknown : str9;
String str11 = map.get("signalName");
if (str11 == null) {
str11 = CategoryModel.unknown;
}
map.get("errnoMsg");
String str12 = map.get("stack");
if (str12 == null) {
str12 = CategoryModel.unknown;
}
String str13 = map.get("jstack");
if (str13 != null) {
str12 = str12 + "java:\n" + str13;
}
Integer num = d.get("sico");
if (num == null || num.intValue() <= 0) {
str = str8;
str2 = str11;
} else {
str2 = str11 + "(" + str8 + ")";
str = "KERNEL";
}
String str14 = map.get("nativeLog");
byte[] a2 = (str14 == null || str14.isEmpty()) ? null : z.a((File) null, str14, "BuglyNativeLog.txt");
String str15 = map.get("sendingProcess");
if (str15 == null) {
str15 = CategoryModel.unknown;
}
Integer num2 = d.get("spd");
if (num2 != null) {
str15 = str15 + "(" + num2 + ")";
}
String str16 = str15;
String str17 = map.get("threadName");
if (str17 == null) {
str17 = CategoryModel.unknown;
}
Integer num3 = d.get("et");
if (num3 != null) {
str17 = str17 + "(" + num3 + ")";
}
String str18 = str17;
String str19 = map.get("processName");
if (str19 != null) {
str6 = str19;
}
Integer num4 = d.get("ep");
if (num4 != null) {
str6 = str6 + "(" + num4 + ")";
}
String str20 = str6;
String str21 = map.get("key-value");
if (str21 != null) {
HashMap hashMap2 = new HashMap();
String[] split = str21.split("\n");
int length = split.length;
int i = 0;
while (i < length) {
String[] split2 = split[i].split("=");
String[] strArr = split;
if (split2.length == 2) {
hashMap2.put(split2[0], split2[1]);
}
i++;
split = strArr;
}
hashMap = hashMap2;
} else {
hashMap = null;
}
CrashDetailBean packageCrashDatas = nativeExceptionHandler.packageCrashDatas(str20, str18, (d.get("etms").intValue() / 1000) + (d.get("ets").intValue() * 1000), str2, str7, a(str12), str, str16, str10, map.get("sysLogPath"), map.get("jniLogPath"), str4, a2, hashMap, false, false);
if (packageCrashDatas != null) {
String str22 = map.get("userId");
if (str22 != null) {
x.c("[Native record info] userId: %s", str22);
packageCrashDatas.m = str22;
}
String str23 = map.get("sysLog");
if (str23 != null) {
packageCrashDatas.w = str23;
}
String str24 = map.get("appVersion");
if (str24 != null) {
x.c("[Native record info] appVersion: %s", str24);
packageCrashDatas.f = str24;
}
String str25 = map.get("isAppForeground");
if (str25 != null) {
x.c("[Native record info] isAppForeground: %s", str25);
packageCrashDatas.N = str25.equalsIgnoreCase("true");
}
String str26 = map.get("launchTime");
if (str26 != null) {
x.c("[Native record info] launchTime: %s", str26);
try {
packageCrashDatas.M = Long.parseLong(str26);
} catch (NumberFormatException e) {
if (!x.a(e)) {
e.printStackTrace();
}
}
}
packageCrashDatas.z = null;
packageCrashDatas.k = true;
}
return packageCrashDatas;
} catch (Throwable th) {
x.e("error format", new Object[0]);
th.printStackTrace();
return null;
}
}
x.e("no intStateStr", new Object[0]);
return null;
}
public static void c(String str) {
File[] listFiles;
if (str == null) {
return;
}
try {
File file = new File(str);
if (file.canRead() && file.isDirectory() && (listFiles = file.listFiles()) != null) {
for (File file2 : listFiles) {
if (file2.canRead() && file2.canWrite() && file2.length() == 0) {
file2.delete();
x.c("Delete empty record file %s", file2.getAbsoluteFile());
}
}
}
} catch (Throwable th) {
x.a(th);
}
}
public static String b(String str) {
if (str == null) {
return null;
}
File file = new File(str, "backup_record.txt");
if (file.exists()) {
return file.getAbsolutePath();
}
return null;
}
private static String a(BufferedInputStream bufferedInputStream) throws IOException {
ByteArrayOutputStream byteArrayOutputStream;
if (bufferedInputStream == null) {
return null;
}
try {
byteArrayOutputStream = new ByteArrayOutputStream(DataDecryptTool.DECRYPT_SP_FILE);
while (true) {
try {
int read = bufferedInputStream.read();
if (read == -1) {
byteArrayOutputStream.close();
break;
}
if (read == 0) {
String str = new String(byteArrayOutputStream.toByteArray(), "UTf-8");
byteArrayOutputStream.close();
return str;
}
byteArrayOutputStream.write(read);
} catch (Throwable th) {
th = th;
try {
x.a(th);
return null;
} finally {
if (byteArrayOutputStream != null) {
byteArrayOutputStream.close();
}
}
}
}
} catch (Throwable th2) {
th = th2;
byteArrayOutputStream = null;
}
}
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARN: Type inference failed for: r7v3, types: [boolean] */
/* JADX WARN: Type inference failed for: r7v6 */
public static CrashDetailBean a(Context context, String str, NativeExceptionHandler nativeExceptionHandler) {
BufferedInputStream bufferedInputStream;
String str2;
String a2;
if (context != null && str != null && nativeExceptionHandler != null) {
File file = new File(str, "rqd_record.eup");
if (file.exists()) {
BufferedInputStream canRead = file.canRead();
try {
if (canRead != 0) {
try {
bufferedInputStream = new BufferedInputStream(new FileInputStream(file));
} catch (IOException e) {
e = e;
bufferedInputStream = null;
} catch (Throwable th) {
th = th;
canRead = 0;
if (canRead != 0) {
try {
canRead.close();
} catch (IOException e2) {
e2.printStackTrace();
}
}
throw th;
}
try {
String a3 = a(bufferedInputStream);
if (a3 != null && a3.equals("NATIVE_RQD_REPORT")) {
HashMap hashMap = new HashMap();
loop0: while (true) {
str2 = null;
while (true) {
a2 = a(bufferedInputStream);
if (a2 == null) {
break loop0;
}
if (str2 == null) {
str2 = a2;
}
}
hashMap.put(str2, a2);
}
if (str2 != null) {
x.e("record not pair! drop! %s", str2);
try {
bufferedInputStream.close();
} catch (IOException e3) {
e3.printStackTrace();
}
return null;
}
CrashDetailBean a4 = a(context, hashMap, nativeExceptionHandler);
try {
bufferedInputStream.close();
} catch (IOException e4) {
e4.printStackTrace();
}
return a4;
}
x.e("record read fail! %s", a3);
try {
bufferedInputStream.close();
} catch (IOException e5) {
e5.printStackTrace();
}
return null;
} catch (IOException e6) {
e = e6;
e.printStackTrace();
if (bufferedInputStream != null) {
try {
bufferedInputStream.close();
} catch (IOException e7) {
e7.printStackTrace();
}
}
return null;
}
}
} catch (Throwable th2) {
th = th2;
}
}
return null;
}
x.e("get eup record file args error", new Object[0]);
return null;
}
public static String a(String str, String str2) {
if (str == null || str2 == null) {
return null;
}
StringBuilder sb = new StringBuilder();
String b = b(str, str2);
if (b != null && !b.isEmpty()) {
sb.append("Register infos:\n");
sb.append(b);
}
String c = c(str, str2);
if (c != null && !c.isEmpty()) {
if (sb.length() > 0) {
sb.append("\n");
}
sb.append("System SO infos:\n");
sb.append(c);
}
return sb.toString();
}
public static void a(boolean z, String str) {
if (str != null) {
a.add(new File(str, "rqd_record.eup"));
a.add(new File(str, "reg_record.txt"));
a.add(new File(str, "map_record.txt"));
a.add(new File(str, "backup_record.txt"));
if (z) {
c(str);
}
}
List<File> list = a;
if (list == null || list.size() <= 0) {
return;
}
for (File file : a) {
if (file.exists() && file.canWrite()) {
file.delete();
x.c("Delete record file %s", file.getAbsoluteFile());
}
}
}
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARN: Type inference failed for: r6v1, types: [java.lang.StringBuilder] */
/* JADX WARN: Type inference failed for: r6v10 */
/* JADX WARN: Type inference failed for: r6v11 */
/* JADX WARN: Type inference failed for: r6v6, types: [java.lang.String] */
public static String a(String str, int i, String str2, boolean z) {
BufferedReader bufferedReader;
if (str != null && i > 0) {
File file = new File(str);
if (file.exists() && file.canRead()) {
x.a("Read system log from native record file(length: %s bytes): %s", Long.valueOf(file.length()), file.getAbsolutePath());
a.add(file);
x.c("Add this record file to list for cleaning lastly.", new Object[0]);
if (str2 == null) {
return z.a(new File(str), i, z);
}
String sb = new StringBuilder();
try {
try {
bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "utf-8"));
while (true) {
try {
String readLine = bufferedReader.readLine();
if (readLine == null) {
break;
}
if (Pattern.compile(str2 + "[ ]*:").matcher(readLine).find()) {
sb.append(readLine);
sb.append("\n");
}
if (i > 0 && sb.length() > i) {
if (z) {
sb.delete(i, sb.length());
break;
}
sb.delete(0, sb.length() - i);
}
} catch (Throwable th) {
th = th;
try {
x.a(th);
sb.append("\n[error:" + th.toString() + "]");
String sb2 = sb.toString();
if (bufferedReader == null) {
return sb2;
}
bufferedReader.close();
sb = sb2;
return sb;
} catch (Throwable th2) {
if (bufferedReader != null) {
try {
bufferedReader.close();
} catch (Exception e) {
x.a(e);
}
}
throw th2;
}
}
}
String sb3 = sb.toString();
bufferedReader.close();
sb = sb3;
} catch (Throwable th3) {
th = th3;
bufferedReader = null;
}
return sb;
} catch (Exception e2) {
x.a(e2);
return sb;
}
}
}
return null;
}
}