正在查看: bbinstant v6.24.0 应用的 SimplAirbrakeNotifier.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: bbinstant v6.24.0 应用的 SimplAirbrakeNotifier.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.simpl.android.fingerprint.commons.exception;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Build;
import android.util.Xml;
import com.google.crypto.tink.shaded.protobuf.i;
import com.moengage.core.internal.storage.database.contract.h;
import in.juspay.hyper.constants.LogCategory;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.Thread;
import java.lang.ref.WeakReference;
import java.net.URL;
import java.util.Map;
import java.util.Random;
import javax.net.ssl.HttpsURLConnection;
import org.xmlpull.v1.XmlSerializer;
abstract class SimplAirbrakeNotifier {
private static String a = "production";
private static String b = "unknown";
private static String c = "unknown";
private static Map<String, String> f91d = null;
private static String f92e = null;
private static boolean f93f = false;
private static String f94g = null;
private static boolean f95h = false;
public static class SimplAsyncTask extends AsyncTask<Void, Void, Void> {
private WeakReference<Context> contextRef;
public SimplAsyncTask(Context context) {
this.contextRef = new WeakReference<>(context);
}
@Override
public Void doInBackground(Void... voidArr) {
try {
Context context = this.contextRef.get();
if (context != null) {
String unused = SimplAirbrakeNotifier.f94g = context.getFilesDir().getAbsolutePath() + "/unsent_airbrake_exceptions/";
File file = new File(SimplAirbrakeNotifier.f94g);
file.mkdirs();
boolean unused2 = SimplAirbrakeNotifier.f95h = file.exists();
}
SimplAirbrakeNotifier.b((String) null, (Map<String, String>) null);
} catch (Exception unused3) {
}
return null;
}
}
static class a extends AsyncTask {
final Throwable a;
final Map b;
a(Throwable th, Map map) {
this.a = th;
this.b = map;
}
@Override
protected final Object doInBackground(Object[] objArr) {
SimplAirbrakeNotifier.c(this.a, this.b);
SimplAirbrakeNotifier.b(this.a.getMessage(), (Map<String, String>) this.b);
return null;
}
}
static class b implements Thread.UncaughtExceptionHandler {
private Thread.UncaughtExceptionHandler a;
b(Thread.UncaughtExceptionHandler uncaughtExceptionHandler) {
this.a = uncaughtExceptionHandler;
}
@Override
public final void uncaughtException(Thread thread, Throwable th) {
if (SimplAirbrakeNotifier.b(th)) {
SimplAirbrakeNotifier.a(th);
}
this.a.uncaughtException(thread, th);
}
}
public static void c(Throwable th, Map<String, String> map) {
String str;
String str2 = "notice";
try {
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(f94g + c + "-" + String.valueOf(new Random().nextInt(99999)) + ".xml"));
XmlSerializer newSerializer = Xml.newSerializer();
newSerializer.setOutput(bufferedWriter);
newSerializer.startDocument("UTF-8", Boolean.TRUE);
newSerializer.startTag("", "notice");
newSerializer.attribute("", "version", "2.0");
newSerializer.startTag("", "api-key");
newSerializer.text(f92e);
newSerializer.endTag("", "api-key");
newSerializer.startTag("", "notifier");
newSerializer.startTag("", "name");
newSerializer.text("Android Airbrake Notifier");
newSerializer.endTag("", "name");
newSerializer.startTag("", "version");
newSerializer.text("1.3.0");
newSerializer.endTag("", "version");
newSerializer.startTag("", "url");
newSerializer.text("http://loopj.com");
newSerializer.endTag("", "url");
newSerializer.endTag("", "notifier");
newSerializer.startTag("", "error");
newSerializer.startTag("", "class");
newSerializer.text(th.getClass().getName());
newSerializer.endTag("", "class");
newSerializer.startTag("", "message");
newSerializer.text("[" + c + "] " + th.toString());
newSerializer.endTag("", "message");
newSerializer.startTag("", "backtrace");
Throwable th2 = th;
while (th2 != null) {
try {
StackTraceElement[] stackTrace = th2.getStackTrace();
int length = stackTrace.length;
int i2 = 0;
while (i2 < length) {
StackTraceElement stackTraceElement = stackTrace[i2];
newSerializer.startTag("", "line");
StackTraceElement[] stackTraceElementArr = stackTrace;
int i3 = length;
try {
StringBuilder sb = new StringBuilder();
str = str2;
try {
sb.append(stackTraceElement.getClassName());
sb.append(".");
sb.append(stackTraceElement.getMethodName());
newSerializer.attribute("", "method", sb.toString());
newSerializer.attribute("", "file", stackTraceElement.getFileName() == null ? "Unknown" : stackTraceElement.getFileName());
newSerializer.attribute("", "number", String.valueOf(stackTraceElement.getLineNumber()));
} catch (Throwable unused) {
}
} catch (Throwable unused2) {
str = str2;
}
try {
newSerializer.endTag("", "line");
i2++;
stackTrace = stackTraceElementArr;
length = i3;
str2 = str;
} catch (Throwable unused3) {
}
}
String str3 = str2;
th2 = th2.getCause();
if (th2 != null) {
newSerializer.startTag("", "line");
try {
newSerializer.attribute("", "file", "### CAUSED BY ###: " + th2.toString());
newSerializer.attribute("", "number", "");
} catch (Throwable unused4) {
}
newSerializer.endTag("", "line");
}
str2 = str3;
} catch (Throwable unused5) {
}
}
str = str2;
newSerializer.endTag("", "backtrace");
newSerializer.endTag("", "error");
newSerializer.startTag("", "request");
newSerializer.startTag("", "url");
newSerializer.endTag("", "url");
newSerializer.startTag("", "component");
newSerializer.endTag("", "component");
newSerializer.startTag("", LogCategory.ACTION);
newSerializer.endTag("", LogCategory.ACTION);
newSerializer.startTag("", "cgi-data");
newSerializer.startTag("", "var");
newSerializer.attribute("", h.KEY_VALUE_STORE_COLUMN_NAME_KEY, "Device");
newSerializer.text(Build.MODEL);
newSerializer.endTag("", "var");
newSerializer.startTag("", "var");
newSerializer.attribute("", h.KEY_VALUE_STORE_COLUMN_NAME_KEY, "Android Version");
newSerializer.text(Build.VERSION.RELEASE);
newSerializer.endTag("", "var");
newSerializer.startTag("", "var");
newSerializer.attribute("", h.KEY_VALUE_STORE_COLUMN_NAME_KEY, "App Version");
newSerializer.text(c);
newSerializer.endTag("", "var");
newSerializer.startTag("", "var");
newSerializer.attribute("", h.KEY_VALUE_STORE_COLUMN_NAME_KEY, "Parent App");
newSerializer.text(b);
newSerializer.endTag("", "var");
Map<String, String> map2 = f91d;
if (map2 != null && !map2.isEmpty()) {
for (Map.Entry<String, String> entry : f91d.entrySet()) {
newSerializer.startTag("", "var");
newSerializer.attribute("", h.KEY_VALUE_STORE_COLUMN_NAME_KEY, entry.getKey());
newSerializer.text(entry.getValue());
newSerializer.endTag("", "var");
}
}
if (map != null && !map.isEmpty()) {
for (Map.Entry<String, String> entry2 : map.entrySet()) {
newSerializer.startTag("", "var");
newSerializer.attribute("", h.KEY_VALUE_STORE_COLUMN_NAME_KEY, entry2.getKey());
newSerializer.text(entry2.getValue());
newSerializer.endTag("", "var");
}
}
newSerializer.endTag("", "cgi-data");
newSerializer.endTag("", "request");
newSerializer.startTag("", "server-environment");
newSerializer.startTag("", "environment-name");
newSerializer.text(a);
newSerializer.endTag("", "environment-name");
newSerializer.startTag("", "app-version");
newSerializer.text(c);
newSerializer.endTag("", "app-version");
newSerializer.endTag("", "server-environment");
newSerializer.endTag("", str);
newSerializer.endDocument();
bufferedWriter.flush();
bufferedWriter.close();
StringBuilder sb2 = new StringBuilder("Writing new ");
sb2.append(th.getClass().getName());
sb2.append(" exception to disk.");
} catch (Exception unused6) {
}
}
static void a(Context context, String str, String str2) {
f92e = str;
if (context == null) {
throw new IllegalArgumentException("context cannot be null.");
}
a = str2;
f93f = true;
Thread.UncaughtExceptionHandler defaultUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
if (!(defaultUncaughtExceptionHandler instanceof b) && str2.equals("production")) {
Thread.setDefaultUncaughtExceptionHandler(new b(defaultUncaughtExceptionHandler));
}
try {
b = context.getPackageName();
String str3 = context.getPackageManager().getPackageInfo(b, 0).versionName;
if (str3 != null) {
c = str3;
}
new SimplAsyncTask(context).execute(new Void[0]);
} catch (Exception unused) {
}
}
public static synchronized void b(String str, Map<String, String> map) {
synchronized (SimplAirbrakeNotifier.class) {
try {
File file = new File(f94g);
if (file.exists() && file.isDirectory()) {
for (File file2 : file.listFiles()) {
if (file2.exists() && file2.isFile()) {
a(file2);
}
}
}
} catch (Throwable th) {
if (map != null) {
try {
map.put("message_caused_error", str);
} catch (Throwable th2) {
throw th2;
}
}
c(th, map);
}
}
}
private static void a(File file) {
try {
HttpsURLConnection httpsURLConnection = (HttpsURLConnection) new URL("https://airbrakeapp.com/notifier_api/v2/notices").openConnection();
try {
httpsURLConnection.setDoOutput(true);
httpsURLConnection.setRequestProperty("Content-Type", "text/xml; charset=utf-8");
FileInputStream fileInputStream = new FileInputStream(file);
OutputStream outputStream = httpsURLConnection.getOutputStream();
byte[] bArr = new byte[i.DEFAULT_BUFFER_SIZE];
while (true) {
int read = fileInputStream.read(bArr);
if (read < 0) {
outputStream.flush();
outputStream.close();
fileInputStream.close();
int responseCode = httpsURLConnection.getResponseCode();
StringBuilder sb = new StringBuilder("Sent exception file ");
sb.append(file.getName());
sb.append(" to airbrake. Got response code ");
sb.append(String.valueOf(responseCode));
file.delete();
httpsURLConnection.disconnect();
return;
}
outputStream.write(bArr, 0, read);
}
} catch (IOException unused) {
httpsURLConnection.disconnect();
} catch (Throwable th) {
httpsURLConnection.disconnect();
throw th;
}
} catch (Exception unused2) {
}
}
static void a(String str) {
a = str;
}
static boolean b(Throwable th) {
if (th != null) {
if (th.getMessage() != null && th.getMessage().contains("simpl")) {
return true;
}
for (StackTraceElement stackTraceElement : th.getStackTrace()) {
if (stackTraceElement != null && stackTraceElement.toString().contains("simpl")) {
return true;
}
}
}
return false;
}
public static void a(Throwable th) {
a(th, (Map<String, String>) null);
}
public static void a(Throwable th, Map<String, String> map) {
if (th == null || !f95h) {
return;
}
new a(th, map).execute(new Void[0]);
}
static void a(Map<String, String> map) {
f91d = map;
}
}