导航菜单

页面标题

页面副标题

CityMall v1.42.1 - SimplAirbrakeNotifier.java 源代码

正在查看: CityMall v1.42.1 应用的 SimplAirbrakeNotifier.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.simpl.android.fingerprint.commons.exception;

import android.content.Context;
import android.os.AsyncTask;
import android.util.Log;
import java.io.File;
import java.io.FileInputStream;
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 javax.net.ssl.HttpsURLConnection;
import live.citymall.customer.BuildConfig;

abstract class SimplAirbrakeNotifier {
    private static String a = "production";
    private static String b = "unknown";
    private static String c = "unknown";
    private static Map d = null;
    private static String e = null;
    private static boolean f = false;
    private static String g = null;
    private static boolean h = 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.g = context.getFilesDir().getAbsolutePath() + "/unsent_airbrake_exceptions/";
                    File file = new File(SimplAirbrakeNotifier.g);
                    file.mkdirs();
                    boolean unused2 = SimplAirbrakeNotifier.h = file.exists();
                }
                SimplAirbrakeNotifier.k(null, 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.n(this.a, this.b);
            SimplAirbrakeNotifier.k(this.a.getMessage(), 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.m(th)) {
                SimplAirbrakeNotifier.f(th);
            }
            this.a.uncaughtException(thread, th);
        }
    }

    static void b(Context context, String str, String str2) {
        e = str;
        if (context == null) {
            throw new IllegalArgumentException("context cannot be null.");
        }
        a = str2;
        f = true;
        Thread.UncaughtExceptionHandler defaultUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
        if (!(defaultUncaughtExceptionHandler instanceof b) && str2.equals(BuildConfig.APP_ENV)) {
            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) {
        }
    }

    private static void c(File file) {
        try {
            HttpsURLConnection httpsURLConnection = (HttpsURLConnection) new URL("https://airbrakeapp.com/notifier_api/v2/notices").openConnection();
            try {
                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[4096];
                    while (true) {
                        int read = fileInputStream.read(bArr);
                        if (read < 0) {
                            outputStream.flush();
                            outputStream.close();
                            fileInputStream.close();
                            Log.d("AirbrakeNotifier", "Sent exception file " + file.getName() + " to airbrake. Got response code " + String.valueOf(httpsURLConnection.getResponseCode()));
                            file.delete();
                            httpsURLConnection.disconnect();
                            return;
                        }
                        outputStream.write(bArr, 0, read);
                    }
                } catch (Throwable th) {
                    httpsURLConnection.disconnect();
                    throw th;
                }
            } catch (IOException e2) {
                Log.v("AirbrakeNotifier", "Exception caught:", e2);
                httpsURLConnection.disconnect();
            }
        } catch (Exception e3) {
            Log.v("AirbrakeNotifier", "Exception caught:", e3);
        }
    }

    static void d(String str) {
        a = str;
    }

    public static void f(Throwable th) {
        g(th, null);
    }

    public static void g(Throwable th, Map map) {
        if (th == null || !h) {
            return;
        }
        new a(th, map).execute(new Void[0]);
    }

    static void h(Map map) {
        d = map;
    }

    public static synchronized void k(String str, Map map) {
        synchronized (SimplAirbrakeNotifier.class) {
            try {
                File file = new File(g);
                if (file.exists() && file.isDirectory()) {
                    for (File file2 : file.listFiles()) {
                        if (file2.exists() && file2.isFile()) {
                            c(file2);
                        }
                    }
                }
            } catch (Throwable th) {
                if (map != null) {
                    try {
                        map.put("message_caused_error", str);
                    } catch (Throwable th2) {
                        throw th2;
                    }
                }
                n(th, map);
            }
        }
    }

    static boolean m(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 n(java.lang.Throwable r26, java.util.Map r27) {
        throw new UnsupportedOperationException("Method not decompiled: com.simpl.android.fingerprint.commons.exception.SimplAirbrakeNotifier.n(java.lang.Throwable, java.util.Map):void");
    }
}