翰林优商.apk(点击下载) / bt.java


package com.baidu.mobads.sdk.internal;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.util.Log;
import com.baidu.mobads.sdk.api.IXAdContainerFactory;
import java.lang.Thread;
import java.util.ArrayList;
import java.util.List;

public class bt implements Thread.UncaughtExceptionHandler {
    public static String a = "";
    private static final String b = "remote";
    private static final String c = "proxy";
    private static final String d = "third-mtj";
    private static final String e = "third-novel";
    private static Thread.UncaughtExceptionHandler f = null;
    private static volatile bt g = null;
    private static final String j = "key_crash_source";
    private static final String k = "key_crash_trace";
    private static final String l = "key_crash_ad";
    private Context h;
    private a i;

    /* access modifiers changed from: package-private */
    public interface a {
        void a(String str);
    }

    public static bt a(Context context) {
        if (g == null) {
            synchronized (bt.class) {
                if (g == null) {
                    g = new bt(context);
                }
            }
        }
        return g;
    }

    private bt(Context context) {
        this.h = context.getApplicationContext();
        f = Thread.getDefaultUncaughtExceptionHandler();
    }

    public void a() {
        am.a().a((h) new bu(this));
    }

    public void b() {
        if (!(Thread.getDefaultUncaughtExceptionHandler() instanceof bt)) {
            Thread.setDefaultUncaughtExceptionHandler(this);
        }
    }

    public void uncaughtException(Thread thread, Throwable th) {
        try {
            String a2 = a(th);
            if (a2 != null) {
                a(a2, Log.getStackTraceString(th));
                a aVar = this.i;
                if (aVar != null) {
                    aVar.a(a2);
                }
            }
            Thread.UncaughtExceptionHandler uncaughtExceptionHandler = f;
            if (uncaughtExceptionHandler != null) {
                uncaughtExceptionHandler.uncaughtException(thread, th);
            }
        } catch (Exception e2) {
            az.a().c(e2);
        }
    }

    public void a(a aVar) {
        this.i = aVar;
    }

    public void c() {
        this.i = null;
    }

    private String a(Throwable th) {
        Throwable cause = th.getCause();
        if (cause != null) {
            th = cause;
        }
        StackTraceElement[] stackTrace = th.getStackTrace();
        if (stackTrace != null && stackTrace.length > 0) {
            List<String> d2 = d();
            for (StackTraceElement stackTraceElement : stackTrace) {
                String className = stackTraceElement.getClassName();
                if (className.startsWith("junit.framework")) {
                    break;
                } else if (className.startsWith(r.ai) || className.startsWith(r.aj) || className.startsWith(r.ak)) {
                    return b;
                } else {
                    if (className.startsWith(r.al) || className.startsWith(r.am) || className.startsWith(r.an)) {
                        return c;
                    }
                    if (className.startsWith(r.ao)) {
                        return d;
                    }
                    if (className.startsWith(r.ap) || className.startsWith(r.aq)) {
                        if (bs.g.booleanValue()) {
                            return e;
                        }
                    } else if (a(className, d2)) {
                        return b;
                    }
                }
            }
        }
        return null;
    }

    private List<String> d() {
        IXAdContainerFactory c2;
        ArrayList arrayList = new ArrayList();
        try {
            u a2 = u.a();
            if (!(a2 == null || (c2 = a2.c()) == null)) {
                Object remoteParam = c2.getRemoteParam("appCommonConfig", "getCrashPackage");
                if (remoteParam instanceof List) {
                    arrayList.addAll((List) remoteParam);
                }
            }
        } catch (Throwable unused) {
        }
        return arrayList;
    }

    private boolean a(String str, List<String> list) {
        for (String str2 : list) {
            if (str.startsWith(str2)) {
                return true;
            }
        }
        return false;
    }

    private SharedPreferences e() {
        return this.h.getSharedPreferences("baidu_mobads_crash", 0);
    }

    private SharedPreferences.Editor f() {
        return e().edit();
    }

    public void a(String str, String str2) {
        SharedPreferences.Editor f2 = f();
        f2.putString(j, str);
        f2.putString(k, ("crashtime:" + System.currentTimeMillis() + " ") + str2);
        f2.putString(l, a);
        f2.commit();
    }

    /* access modifiers changed from: private */
    public String a(String str) {
        return e().getString(str, "");
    }

    /* access modifiers changed from: private */
    public void g() {
        SharedPreferences.Editor f2 = f();
        f2.clear();
        if (Build.VERSION.SDK_INT >= 9) {
            f2.apply();
        } else {
            f2.commit();
        }
    }
}