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,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;
}
}