789娱乐城.apk(点击下载) / a.java


package com.pgyersdk.crash;

import android.content.Context;
import android.os.Process;
import android.util.Log;
import com.pgyersdk.utils.d;
import com.pgyersdk.utils.f;
import com.tencent.smtt.sdk.WebView;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.Thread;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

/* compiled from: ExceptionHandler */
public class a implements Thread.UncaughtExceptionHandler {

    /* renamed from: a  reason: collision with root package name */
    private boolean f2728a;
    private b b;
    private Thread.UncaughtExceptionHandler c;
    private String d;
    private Context e;

    public static void a(Throwable th, b bVar) {
        Date date = new Date();
        StringWriter stringWriter = new StringWriter();
        th.printStackTrace(new PrintWriter(stringWriter));
        try {
            String uuid = UUID.randomUUID().toString();
            String str = com.pgyersdk.c.a.f2723a + "/" + uuid + ".stacktrace";
            f.a("PgyerSDK", "Writing unhandled exception to: " + str);
            BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(str));
            bufferedWriter.write("Package: " + com.pgyersdk.c.a.c + "\n");
            bufferedWriter.write("Version Code: " + com.pgyersdk.c.a.b + "\n");
            bufferedWriter.write("Version Name: " + com.pgyersdk.c.a.d + "\n");
            if (bVar == null || bVar.a()) {
                bufferedWriter.write("Android: " + com.pgyersdk.c.a.e + "\n");
                bufferedWriter.write("Manufacturer: " + com.pgyersdk.c.a.g + "\n");
                bufferedWriter.write("Model: " + com.pgyersdk.c.a.f + "\n");
            }
            if (com.pgyersdk.c.a.h != null && (bVar == null || bVar.b())) {
                bufferedWriter.write("CrashReporter Key: " + com.pgyersdk.c.a.h + "\n");
            }
            bufferedWriter.write("Date: " + date + "\n");
            bufferedWriter.write("\n");
            bufferedWriter.write(stringWriter.toString());
            bufferedWriter.flush();
            bufferedWriter.close();
            if (bVar != null) {
                a(a(bVar.c()), uuid + ".user");
                a(a(bVar.d()), uuid + ".contact");
                a(bVar.e(), uuid + ".description");
            }
        } catch (Exception e2) {
            Log.e("PgyerSDK", "Error saving exception stacktrace!\n", e2);
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:34:0x027d, code lost:
        if (java.lang.Boolean.valueOf(r1).booleanValue() != false) goto L_0x028c;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:40:0x028a, code lost:
        if (r2.booleanValue() == false) goto L_0x0294;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:41:0x028c, code lost:
        com.pgyersdk.utils.f.a("PgyerSDK", "Transmission succeeded");
     */
    /* JADX WARNING: Code restructure failed: missing block: B:42:0x0294, code lost:
        com.pgyersdk.utils.f.a("PgyerSDK", "Transmission failed, will retry on next register() call");
        a(r9, r8.b);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:48:?, code lost:
        return;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:49:?, code lost:
        return;
     */
    public void a(Throwable th) {
        Date date = new Date();
        boolean z = false;
        Boolean bool = false;
        StringWriter stringWriter = new StringWriter();
        th.printStackTrace(new PrintWriter(stringWriter));
        try {
            StringBuffer stringBuffer = new StringBuffer();
            stringBuffer.append("Package: " + com.pgyersdk.c.a.c + "\n");
            stringBuffer.append("Version Code: " + com.pgyersdk.c.a.b + "\n");
            stringBuffer.append("Version Name: " + com.pgyersdk.c.a.d + "\n");
            if (this.b == null || this.b.a()) {
                stringBuffer.append("Android: " + com.pgyersdk.c.a.e + "\n");
                stringBuffer.append("Manufacturer: " + com.pgyersdk.c.a.g + "\n");
                stringBuffer.append("Model: " + com.pgyersdk.c.a.f + "\n");
            }
            if (com.pgyersdk.c.a.h != null && (this.b == null || this.b.b())) {
                stringBuffer.append("CrashReporter Key: " + com.pgyersdk.c.a.h + "\n");
            }
            stringBuffer.append("Date: " + date + "\n");
            stringBuffer.append("\n");
            stringBuffer.append(stringWriter.toString());
            f.a("PgyerSDK", "Transmitting crash data: \n" + stringWriter.toString());
            HashMap hashMap = new HashMap();
            hashMap.put("crashLog", stringBuffer.toString());
            hashMap.put("versionCode", com.pgyersdk.c.a.b);
            hashMap.put("version", com.pgyersdk.c.a.d);
            hashMap.put("agKey", this.d);
            hashMap.put("deviceId", com.pgyersdk.c.a.i);
            hashMap.put("deviceName", com.pgyersdk.c.a.g);
            hashMap.put("deviceModel", com.pgyersdk.c.a.f);
            hashMap.put("osVersion", com.pgyersdk.c.a.e);
            hashMap.put("resolution", com.pgyersdk.c.a.j);
            hashMap.put("osType", "2");
            hashMap.put("jailBroken", com.pgyersdk.c.a.a() ? "1" : "2");
            String[] a2 = com.pgyersdk.d.a.a();
            hashMap.put("freeSpace", a2[1] + " / " + a2[0]);
            if (com.pgyersdk.d.a.c()) {
                String[] b2 = com.pgyersdk.d.a.b();
                hashMap.put("freeSdc", b2[1] + " / " + b2[0]);
            }
            String[] b3 = com.pgyersdk.d.a.b(this.e);
            String str = "";
            if (b3.length == 2) {
                str = b3[1] + " / " + b3[0];
            }
            hashMap.put("freeRam", str);
            hashMap.put("protrait", this.e.getResources().getConfiguration().orientation + "");
            String str2 = "";
            Map<String, String> a3 = com.pgyersdk.d.a.a(this.e);
            if (a3.containsKey("network_type")) {
                str2 = a3.get("network_type");
            }
            hashMap.put("network", str2);
            hashMap.put("sdkVersion", com.pgyersdk.c.a.k);
            hashMap.put("_api_key", "305092bc73c180b55c26012a94809131");
            int responseCode = new d("https://www.pgyer.com/apiv1/crash/add").a("POST").a(hashMap, this.e, null, null).a().getResponseCode();
            if (responseCode == 202 || responseCode == 200) {
                z = true;
            }
        } catch (Exception e2) {
            e2.printStackTrace();
        } catch (Throwable th2) {
            if (bool.booleanValue()) {
                f.a("PgyerSDK", "Transmission succeeded");
            } else {
                f.a("PgyerSDK", "Transmission failed, will retry on next register() call");
                a(th, this.b);
            }
            throw th2;
        }
    }

    public void uncaughtException(Thread thread, final Throwable th) {
        if (com.pgyersdk.c.a.f2723a == null) {
            this.c.uncaughtException(thread, th);
            return;
        }
        new Thread() {
            /* class com.pgyersdk.crash.a.AnonymousClass1 */

            public void run() {
                try {
                    a.this.a(th);
                } catch (Exception unused) {
                }
            }
        }.start();
        if (!this.f2728a) {
            this.c.uncaughtException(thread, th);
            return;
        }
        Process.killProcess(Process.myPid());
        System.exit(10);
    }

    private static void a(String str, String str2) {
        try {
            String str3 = com.pgyersdk.c.a.f2723a + "/" + str2;
            if (str.trim().length() > 0) {
                BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(str3));
                bufferedWriter.write(str);
                bufferedWriter.flush();
                bufferedWriter.close();
            }
        } catch (Exception unused) {
        }
    }

    private static String a(String str) {
        return (str == null || str.length() <= 255) ? str : str.substring(0, WebView.NORMAL_MODE_ALPHA);
    }
}