QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685

以下内容为反编译后的 CrashReport.java 源代码,内容仅作参考


package com.tencent.feedback.eup;

import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import com.tencent.bugly.BuglyStrategy;
import com.tencent.bugly.a;
import com.tencent.bugly.b;
import com.tencent.bugly.crashreport.common.info.PlugInBean;
import com.tencent.bugly.crashreport.common.strategy.StrategyBean;
import com.tencent.bugly.crashreport.crash.c;
import com.tencent.bugly.crashreport.crash.d;
import com.tencent.bugly.crashreport.crash.f;
import com.tencent.bugly.crashreport.crash.jni.NativeCrashHandler;
import com.tencent.bugly.proguard.an;
import com.tencent.bugly.proguard.p;
import com.tencent.bugly.proguard.t;
import com.tencent.bugly.proguard.u;
import com.tencent.bugly.proguard.w;
import com.tencent.bugly.proguard.x;
import com.tencent.bugly.proguard.z;
import com.tencent.feedback.eup.jni.NativeExceptionHandlerRqdImp;
import com.tencent.feedback.eup.jni.NativeExceptionUpload;
import com.tencent.feedback.upload.UploadHandleListener;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ScheduledExecutorService;

public class CrashReport extends a {
    public static final int MODULE_ID = 1003;

    private static boolean f11080a;

    private static CrashStrategyBean f11081b;

    private static f f11082c;

    private static CrashHandleListener f11083d;
    private static t e;
    private static CrashReport f = new CrashReport();
    private static boolean g = false;
    private static boolean h = false;
    private static boolean i = false;

    public static boolean addPlugin(Context context, String str, String str2, String str3) {
        return com.tencent.bugly.crashreport.common.info.a.a(context).a(str, str2, str3);
    }

    public static void addSoFiles(Context context, List<SoFile> list) {
        if (context == null) {
            x.d("addSoFiles args context should not be null", new Object[0]);
            return;
        }
        if (list == null || list.size() == 0) {
            return;
        }
        com.tencent.bugly.crashreport.common.info.a a2 = com.tencent.bugly.crashreport.common.info.a.a(context);
        HashMap hashMap = new HashMap(list.size());
        for (SoFile soFile : list) {
            hashMap.put("sosha1_" + soFile.sha1, new PlugInBean(soFile.fileName, soFile.arch, soFile.sha1));
        }
        a2.b(hashMap);
    }

    public static void clearSDKTotalConsume(Context context) {
        u a2 = u.a();
        if (a2 != null) {
            a2.b();
            a2.c();
        }
    }

    public static int countExceptionDatas(Context context) {
        c a2 = c.a();
        if (a2 != null) {
            return a2.j();
        }
        return 0;
    }

    @Deprecated
    public static int countStoredRecord(Context context) {
        return countExceptionDatas(context);
    }

    public static boolean doUploadExceptionDatas() {
        c a2 = c.a();
        if (a2 == null) {
            return false;
        }
        a2.a(0L);
        return true;
    }

    public static void filterSysLog(boolean z, boolean z2) {
        NativeCrashHandler nativeCrashHandler;
        if (z && (nativeCrashHandler = NativeCrashHandler.getInstance()) != null) {
            nativeCrashHandler.filterSigabrtSysLog();
        }
        c.m = z2;
    }

    public static Set<String> getAllUserDataKeys(Context context) {
        if (context != null) {
            return com.tencent.bugly.crashreport.common.info.a.a(context).A();
        }
        x.d("getAllUserDataKeys args context should not be null", new Object[0]);
        return null;
    }

    public static CrashHandleListener getCrashHandler() {
        return f11083d;
    }

    public static CrashStrategyBean getCrashRuntimeStrategy() {
        return f11081b;
    }

    public static byte[] getExceptionDatas(Context context) {
        if (c.a() != null) {
            return c.a().i();
        }
        return null;
    }

    public static CrashReport getInstance() {
        return f;
    }

    public static long getSDKTotalConsume(Context context, boolean z) {
        u a2 = u.a();
        if (a2 != null) {
            return a2.a(false);
        }
        return -1L;
    }

    public static String getUserData(Context context, String str) {
        if (context == null) {
            x.d("getUserDataValue args context should not be null", new Object[0]);
            return null;
        }
        if (z.a(str)) {
            return null;
        }
        return com.tencent.bugly.crashreport.common.info.a.a(context).i(str);
    }

    public static int getUserDatasSize(Context context) {
        if (context != null) {
            return com.tencent.bugly.crashreport.common.info.a.a(context).z();
        }
        x.d("getUserDatasSize args context should not be null", new Object[0]);
        return -1;
    }

    public static int getUserSceneTagId(Context context) {
        if (context != null) {
            return com.tencent.bugly.crashreport.common.info.a.a(context).D();
        }
        x.d("getUserSceneTagId args context should not be null", new Object[0]);
        return -1;
    }

    public static boolean handleCatchException(Thread thread, Throwable th, String str, byte[] bArr) {
        c a2 = c.a();
        if (a2 == null) {
            return false;
        }
        a2.a(thread, th, false, str, bArr, false);
        return true;
    }

    public static void initCrashReport(Context context) {
        initCrashReport(context, null, null, true, null);
    }

    public static void initCrashReport(Context context, CrashHandleListener crashHandleListener, UploadHandleListener uploadHandleListener, boolean z, CrashStrategyBean crashStrategyBean) {
        initCrashReport(context, crashHandleListener, uploadHandleListener, z, crashStrategyBean, 0L);
    }

    public static void initCrashReport(Context context, CrashHandleListener crashHandleListener, final UploadHandleListener uploadHandleListener, boolean z, CrashStrategyBean crashStrategyBean, long j) {
        String str;
        if (context == null || f11080a) {
            return;
        }
        x.f9100b = "eup";
        x.f9099a = "eup";
        StrategyBean.f8915a = "https://android.rqd.qq.com/analytics/hsync";
        if (!i) {
            StrategyBean.f8916b = "https://android.rqd.qq.com/analytics/hsync";
            StrategyBean.f8917c = "https://android.rqd.qq.com/analytics/hsync";
        }
        f11081b = crashStrategyBean;
        setCrashHandler(crashHandleListener);
        if (uploadHandleListener != null) {
            e = new t() {
                @Override
                public final void a(int i2) {
                    UploadHandleListener.this.onUploadStart(i2);
                }

                @Override
                public final void a(int i2, an anVar, long j2, long j3, boolean z2, String str2) {
                    UploadHandleListener.this.onUploadEnd(i2, anVar == null ? -1 : anVar.f9029b, j2, j3, z2, str2);
                }
            };
            u a2 = u.a();
            if (a2 != null) {
                a2.f9085a = e;
            }
        }
        c.f8965c = 1;
        BuglyStrategy buglyStrategy = new BuglyStrategy();
        if (crashStrategyBean != null) {
            c.g = crashStrategyBean.getRecordOverDays() * 24 * 3600 * 1000;
            c.h = crashStrategyBean.getOnlyLogTag();
            c.i = crashStrategyBean.isStoreCrashSdcard();
            c.j = crashStrategyBean.getStoreDirectoryPath();
            c.k = crashStrategyBean.getCrashSdcardMaxSize();
            c.e = crashStrategyBean.getMaxLogLength();
            c.f = crashStrategyBean.getMaxStackLength();
            c.f8966d = crashStrategyBean.isMerged();
            c.l = crashStrategyBean.isUploadSpotCrash();
            buglyStrategy.setEnableANRCrashMonitor(crashStrategyBean.isOpenAnr());
        }
        buglyStrategy.setAppReportDelay(j);
        if (z.a(com.tencent.bugly.crashreport.common.info.a.a(context).e)) {
            com.tencent.bugly.crashreport.common.info.a.a(context).a(context.getPackageName());
        }
        if (!h && (str = com.tencent.bugly.crashreport.common.info.a.a(context).m) != null && !z.a(str)) {
            int i2 = 0;
            for (char c2 : str.toCharArray()) {
                if (c2 == '.') {
                    i2++;
                }
            }
            if (i2 < 3) {
                String str2 = str + "." + com.tencent.bugly.crashreport.common.info.a.a(context).y;
                com.tencent.bugly.crashreport.common.info.a.a(context).m = str2;
                x.a("rqdp{ RQD version: %s }", str2);
            }
        }
        com.tencent.bugly.crashreport.common.info.a.a(context).f = z;
        buglyStrategy.setUploadProcess(z);
        com.tencent.bugly.crashreport.common.info.a.a(context).D = true;
        c.f8964b = true;
        com.tencent.bugly.crashreport.common.strategy.a.f8920b = 21600000L;
        buglyStrategy.setEnableUserInfo(g);
        b.a(getInstance());
        b.a(context, context.getPackageName(), false, buglyStrategy);
        f11080a = true;
    }

    public static void initCrashReport(Context context, boolean z) {
        initCrashReport(context, null, null, z, null, 0L);
    }

    public static void initNativeCrashReport(Context context, String str, boolean z) {
        initNativeCrashReport(context, str, z, null, null);
    }

    public static void initNativeCrashReport(Context context, String str, boolean z, List<File> list) {
        initNativeCrashReport(context, str, z, list, null, 0L);
    }

    public static void initNativeCrashReport(Context context, String str, boolean z, List<File> list, File file) {
        initNativeCrashReport(context, str, z, list, file, 0L);
    }

    public static void initNativeCrashReport(Context context, String str, boolean z, List<File> list, File file, long j) {
        if (f11080a) {
            com.tencent.bugly.crashreport.common.info.a a2 = com.tencent.bugly.crashreport.common.info.a.a(context);
            if (file != null) {
                String absolutePath = file.getAbsolutePath();
                if (!z.a(absolutePath)) {
                    a2.p = absolutePath;
                }
            }
            if (file != null) {
                if (list == null) {
                    list = new ArrayList<>();
                }
                list.add(file);
            }
            NativeCrashHandler nativeCrashHandler = NativeCrashHandler.getInstance();
            if (nativeCrashHandler != null && !z.a(str)) {
                nativeCrashHandler.setDumpFilePath(str);
            }
            NativeExceptionHandlerRqdImp nativeExceptionHandlerRqdImp = NativeExceptionHandlerRqdImp.getInstance(context);
            nativeExceptionHandlerRqdImp.setTombDir(str);
            NativeExceptionUpload.setmHandler(nativeExceptionHandlerRqdImp);
            c a3 = c.a();
            if (a3 != null) {
                a3.e();
                a3.a(j);
                a3.l();
            }
        }
    }

    public static boolean needUploadCrash(Context context) {
        return countExceptionDatas(context) > 0;
    }

    public static void postException(int i2, String str, String str2, String str3, Map<String, String> map) {
        Thread currentThread = Thread.currentThread();
        if (b.f8876a) {
            d.a(currentThread, i2, str, str2, str3, map);
        } else {
            Log.w(x.f9100b, "Can not post crash caught because bugly is disable.");
        }
    }

    public static void postException(Thread thread, int i2, String str, String str2, String str3, Map<String, String> map) {
        if (b.f8876a) {
            d.a(thread, i2, str, str2, str3, map);
        } else {
            Log.w(x.f9100b, "Can not post crash caught because bugly is disable.");
        }
    }

    public static void putUploadRequestData(Context context, String str, String str2) {
        if (context == null) {
            x.d("putUploadRequestData args context should not be null", new Object[0]);
            return;
        }
        if (z.a(str)) {
            x.d("putUploadRequestData args key should not be null", new Object[0]);
            return;
        }
        if (z.a(str2)) {
            x.d("putUploadRequestData args value should not be null", new Object[0]);
            return;
        }
        if (!str.matches("[a-zA-Z[0-9]]+")) {
            x.d("putUploadRequestData args key should match [a-zA-Z[0-9]_]+  {" + str + "}", new Object[0]);
            return;
        }
        if (str2.length() > 200) {
            x.d("upload request data value length over limit %d , has been cutted!", 200);
            str2 = str2.substring(0, 200);
        }
        if (str.length() > 50) {
            x.d("upload request data key length over limit %d , will drop this new key %s", 50, str);
        } else {
            com.tencent.bugly.crashreport.common.info.a.a(context).b(str, str2);
            x.b("[param] put upload request data: %s - %s", str, str2);
        }
    }

    public static void putUserData(Context context, String str, String str2) {
        if (context == null) {
            x.d("putUserData args context should not be null", new Object[0]);
            return;
        }
        if (z.a(str)) {
            x.d("putUserData args key should not be null", new Object[0]);
            return;
        }
        if (z.a(str2)) {
            x.d("putUserData args value should not be null", new Object[0]);
            return;
        }
        if (!str.matches("[a-zA-Z[0-9]_]+")) {
            x.d("putUserData args key should match [a-zA-Z[0-9]_]+  {" + str + "}", new Object[0]);
            return;
        }
        if (str2.length() > 200) {
            x.d("user data value length over limit %d , has been cutted!", 200);
            str2 = str2.substring(0, 200);
        }
        com.tencent.bugly.crashreport.common.info.a a2 = com.tencent.bugly.crashreport.common.info.a.a(context);
        if (a2.A().contains(str)) {
            com.tencent.bugly.crashreport.common.info.a.a(context).a(str, str2);
            x.c("replace KV %s %s", str, str2);
            return;
        }
        if (a2.z() >= 500) {
            x.d("user data size is over limit %d , will drop this new key %s", 50, str);
            return;
        }
        if (str.length() > 50) {
            x.d("user data key length over limit %d , will drop this new key %s", 50, str);
            return;
        }
        NativeCrashHandler nativeCrashHandler = NativeCrashHandler.getInstance();
        if (nativeCrashHandler != null) {
            nativeCrashHandler.putKeyValueToNative(str, str2);
        }
        com.tencent.bugly.crashreport.common.info.a.a(context).a(str, str2);
        x.b("[param] set user data: %s - %s", str, str2);
    }

    public static void removePlugin(Context context, String str) {
        com.tencent.bugly.crashreport.common.info.a.a(context).f(str);
    }

    public static String removeUserData(Context context, String str) {
        if (context == null) {
            x.d("removeUserData args context should not be null", new Object[0]);
            return null;
        }
        if (z.a(str)) {
            return null;
        }
        x.b("[param] remove user data: %s", str);
        return com.tencent.bugly.crashreport.common.info.a.a(context).h(str);
    }

    public static void setAPKSHa1(Context context, String str) {
        com.tencent.bugly.crashreport.common.info.a.a(context).k = str;
        x.c("set sha1 %s", str);
    }

    public static void setAppChannel(Context context, String str) {
        String str2;
        String str3;
        if (context == null) {
            str2 = x.f9100b;
            str3 = "setAppChannel args context should not be null";
        } else {
            if (str != null) {
                com.tencent.bugly.crashreport.common.info.a.a(context).o = str;
                NativeCrashHandler nativeCrashHandler = NativeCrashHandler.getInstance();
                if (nativeCrashHandler != null) {
                    nativeCrashHandler.setNativeAppChannel(str);
                    return;
                }
                return;
            }
            str2 = x.f9100b;
            str3 = "App channel is null, will not set";
        }
        Log.w(str2, str3);
    }

    public static void setCountryName(Context context, String str) {
        com.tencent.bugly.crashreport.common.info.a.a(context).g(str);
    }

    public static void setCrashFilter(String str) {
        if (!b.f8876a) {
            Log.w(x.f9100b, "Can not set App package because bugly is disable.");
            return;
        }
        Log.i(x.f9100b, "Set crash stack filter: " + str);
        c.n = str;
    }

    public static void setCrashHandler(final CrashHandleListener crashHandleListener) {
        if (crashHandleListener == null) {
            return;
        }
        f11083d = crashHandleListener;
        f11082c = new f() {
            @Override
            public final void a(boolean z) {
                CrashHandleListener.this.onCrashHandleStart(z);
            }

            @Override
            public final boolean a(boolean z, String str, String str2, String str3, int i2, long j, String str4, String str5, String str6, String str7) {
                return CrashHandleListener.this.onCrashSaving(z, str, str2, str3, -1234567890, j, str4, str5, str6, str7);
            }

            @Override
            public final byte[] a(boolean z, String str, String str2, String str3, int i2, long j) {
                return CrashHandleListener.this.getCrashExtraData(z, str, str2, str3, -1234567890, j);
            }

            @Override
            public final String b(boolean z, String str, String str2, String str3, int i2, long j) {
                return CrashHandleListener.this.getCrashExtraMessage(z, str, str2, str3, -1234567890, j);
            }

            @Override
            public final boolean b(boolean z) {
                return CrashHandleListener.this.onCrashHandleEnd(z);
            }
        };
        c a2 = c.a();
        if (a2 != null) {
            a2.a(f11082c);
        }
    }

    public static void setCrashRegularFilter(String str) {
        if (!b.f8876a) {
            Log.w(x.f9100b, "Can not set App package because bugly is disable.");
            return;
        }
        Log.i(x.f9100b, "Set crash stack filter: " + str);
        c.o = str;
    }

    public static void setCrashReportAble(boolean z) {
        c a2 = c.a();
        if (a2 != null) {
            if (z) {
                a2.c();
            } else {
                a2.b();
            }
        }
    }

    public static void setDatabaseCloseAfterUse(boolean z) {
        p.f9066a = z;
    }

    public static void setDengtaAppKey(Context context, String str) {
        com.tencent.bugly.crashreport.common.info.a.a(context).e = str;
    }

    public static void setDeviceId(Context context, String str) {
        if (str != null) {
            com.tencent.bugly.crashreport.common.info.a.a(context).c(str);
        }
    }

    public static void setDeviceRooted(Context context, boolean z) {
        com.tencent.bugly.crashreport.common.info.a.a(context).a(Boolean.valueOf(z));
    }

    public static void setIsDevelopmentDevice(Context context, boolean z) {
        if (context == null) {
            x.d("Context should not be null.", new Object[0]);
            return;
        }
        Object[] objArr = new Object[0];
        if (z) {
            x.c("This is a development device.", objArr);
        } else {
            x.c("This is not a development device.", objArr);
        }
        com.tencent.bugly.crashreport.common.info.a.a(context).A = z;
    }

    public static void setLogAble(boolean z, boolean z2) {
        if (!z) {
            x.f9101c = false;
            return;
        }
        x.f9100b = "eup";
        x.f9099a = "eup";
        x.f9101c = true;
        b.f8878c = true;
        x.d("'setLogAble(boolean)' is true , so running in debug model , close it when you release!", new Object[0]);
    }

    public static void setNativeCrashReportAble(boolean z) {
        c a2 = c.a();
        if (a2 != null) {
            if (z) {
                a2.e();
            }
            a2.d();
        }
    }

    public static void setProductID(Context context, String str) {
        com.tencent.bugly.crashreport.common.info.a.a(context).f8910c = str;
    }

    public static void setProductVersion(Context context, String str) {
        if (TextUtils.isEmpty(str)) {
            return;
        }
        if (str.length() > 100) {
            String substring = str.substring(0, 100);
            x.d("appVersion %s length is over limit %d substring to %s", str, 100, substring);
            str = substring;
        }
        h = true;
        com.tencent.bugly.crashreport.common.info.a.a(context).m = str;
    }

    public static void setRdmUuid(String str) {
        com.tencent.bugly.crashreport.common.info.a b2 = com.tencent.bugly.crashreport.common.info.a.b();
        if (b2 == null) {
            x.d("Can not set RDM UUID if RQD has not been initialized.", new Object[0]);
        } else {
            b2.z = str;
        }
    }

    public static void setSOFile(Context context, List<SoFile> list) {
        if (context == null) {
            x.d("setSOFile args context should not be null", new Object[0]);
            return;
        }
        if (list == null || list.size() == 0) {
            return;
        }
        com.tencent.bugly.crashreport.common.info.a a2 = com.tencent.bugly.crashreport.common.info.a.a(context);
        HashMap hashMap = new HashMap(list.size());
        for (SoFile soFile : list) {
            hashMap.put("sosha1_" + soFile.sha1, new PlugInBean(soFile.fileName, soFile.arch, soFile.sha1));
        }
        a2.a(hashMap);
    }

    public static void setServerUrl(String str) {
        if (z.a(str) || !z.c(str)) {
            x.d("URL is invalid.", new Object[0]);
            return;
        }
        i = true;
        com.tencent.bugly.crashreport.common.strategy.a.a(str);
        StrategyBean.f8916b = str;
        StrategyBean.f8917c = str;
    }

    public static void setThreadPoolService(ScheduledExecutorService scheduledExecutorService) {
        if (scheduledExecutorService != null) {
            w.a().a(scheduledExecutorService);
        }
    }

    public static void setUserId(Context context, String str) {
        if (str == null) {
            return;
        }
        if (str.length() > 100) {
            String substring = str.substring(0, 100);
            x.d("userId %s length is over limit %d substring to %s", str, 100, substring);
            str = substring;
        }
        if (str.equals(com.tencent.bugly.crashreport.common.info.a.a(context).f())) {
            return;
        }
        com.tencent.bugly.crashreport.common.info.a.a(context).b(str);
        x.b("[user] set userId : %s", str);
        NativeCrashHandler nativeCrashHandler = NativeCrashHandler.getInstance();
        if (nativeCrashHandler != null) {
            nativeCrashHandler.setNativeUserId(str);
        }
        if (com.tencent.bugly.crashreport.biz.b.f8897a) {
            com.tencent.bugly.crashreport.biz.b.a();
        }
    }

    public static void setUserInfoEnable(boolean z) {
        g = z;
    }

    public static void setUserSceneTag(Context context, int i2) {
        if (context == null) {
            x.d("setTag args context should not be null", new Object[0]);
        } else if (i2 <= 0) {
            x.d("setTag args tagId should > 0", new Object[0]);
        } else {
            com.tencent.bugly.crashreport.common.info.a.a(context).a(i2);
            x.b("[param] set user scene tag: %d", Integer.valueOf(i2));
        }
    }

    public static void testNativeCrash() {
        testNativeCrash(false, false, false);
    }

    public static void testNativeCrash(boolean z, boolean z2, boolean z3) {
        if (!f11080a) {
            Log.e(x.f9100b, "NativeCrashReport has not been initialed! pls to call method 'initNativeCrashReport' first!");
        } else {
            x.a("start to create a native crash for test!", new Object[0]);
            c.a().a(z, z2, z3);
        }
    }

    @Override
    public String[] getTables() {
        return new String[]{"t_cr"};
    }

    @Override
    public void init(Context context, boolean z, BuglyStrategy buglyStrategy) {
        c a2 = c.a(1003, context, b.f8878c, (com.tencent.bugly.proguard.a) null, f11082c, (String) null);
        a2.c();
        a2.a(true);
        CrashStrategyBean crashStrategyBean = f11081b;
        if (crashStrategyBean != null) {
            a2.a(crashStrategyBean.getCallBackType());
            a2.a(f11081b.getCloseErrorCallback());
        }
        if (buglyStrategy == null || buglyStrategy.isEnableANRCrashMonitor()) {
            a2.f();
        } else {
            x.a("[crash] Closed ANR monitor!", new Object[0]);
            a2.g();
        }
        d.a(context);
        u.a().f9085a = e;
    }

    @Override
    public void onServerStrategyChanged(StrategyBean strategyBean) {
        c a2;
        if (strategyBean == null || (a2 = c.a()) == null) {
            return;
        }
        a2.a(strategyBean);
    }
}