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


package com.umeng.umcrash;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import com.baidu.idl.face.platform.FaceEnvironment;
import com.efs.sdk.base.EfsReporter;
import com.efs.sdk.base.core.util.NetworkUtil;
import com.efs.sdk.base.integrationtesting.IntegrationTestingUtil;
import com.efs.sdk.base.newsharedpreferences.SharedPreferencesUtils;
import com.efs.sdk.base.observer.IConfigCallback;
import com.efs.sdk.launch.LaunchManager;
import com.efs.sdk.memoryinfo.UMMemoryMonitor;
import com.efs.sdk.net.NetManager;
import com.efs.sdk.pa.PAFactory;
import com.efs.sdk.pa.config.IEfsReporter;
import com.efs.sdk.pa.config.PackageLevel;
import com.sigmob.sdk.base.h;
import com.sigmob.sdk.base.mta.PointCategory;
import com.uc.crashsdk.export.CrashApi;
import com.uc.crashsdk.export.CustomLogInfo;
import com.uc.crashsdk.export.ICrashClient;
import com.umeng.analytics.pro.am;
import com.umeng.commonsdk.statistics.idtracking.ImprintHandler;
import com.umeng.commonsdk.statistics.internal.UMImprintChangeCallback;
import com.umeng.commonsdk.utils.UMUtils;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.json.JSONArray;
import org.json.JSONObject;

public class UMCrash {
    private static final boolean DEFAULT_VALUE_CRASH_ANR = true;
    private static final boolean DEFAULT_VALUE_CRASH_JAVA = true;
    private static final boolean DEFAULT_VALUE_CRASH_NATIVE = true;
    private static final boolean DEFAULT_VALUE_CRASH_UNEXP = false;
    private static final boolean DEFAULT_VALUE_LAUNCH = true;
    private static final boolean DEFAULT_VALUE_MEM = true;
    private static final boolean DEFAULT_VALUE_NET = true;
    private static final boolean DEFAULT_VALUE_PA = true;
    private static final String INTEGRATIONTESTING_SP = "itconfig";
    private static final String IT_DEBUGKEY = "apm_debugkey";
    private static final String IT_SENDAGING = "apm_sendaging";
    private static final String KEY_ACTIITY_ON_CREATED = "onCreated";
    private static final String KEY_ACTIITY_ON_DESTROYED = "onDestroyed";
    private static final String KEY_ACTIITY_ON_PAUSED = "onPaused";
    private static final String KEY_ACTIITY_ON_RESUMED = "onResumed";
    private static final String KEY_ACTIITY_ON_STARTED = "onStarted";
    private static final String KEY_ACTIITY_ON_STOPPED = "onStopped";
    public static final String KEY_APM_DEFAULT_SECRET = "NEej8y@anWa*8hep";
    public static final String KEY_APM_ROOT_NAME = "UApm";
    public static final String KEY_CALLBACK_PAGE_ACTION = "um_action_log";
    public static final String KEY_CALLBACK_UMID = "um_umid";
    private static final String KEY_CALLBACK_USER_STRING = "um_user_string";
    public static final String KEY_DEBUGKEY = "um_dk";
    public static final String KEY_ENABLE_ANR = "enableANRLog";
    public static final String KEY_ENABLE_CRASH_JAVA = "enableJavaLog";
    public static final String KEY_ENABLE_CRASH_NATIVE = "enableNativeLog";
    public static final String KEY_ENABLE_CRASH_UNEXP = "enableUnexpLog";
    public static final String KEY_ENABLE_LAUNCH = "enableLaunchLog";
    public static final String KEY_ENABLE_MEM = "enableMemLog";
    public static final String KEY_ENABLE_NET = "enableNetLog";
    public static final String KEY_ENABLE_PA = "enablePaLog";
    public static final String KEY_HEADER_ACCESS = "um_access";
    public static final String KEY_HEADER_ACCESS_SUBTYPE = "um_access_subtype";
    public static final String KEY_HEADER_APPKEY = "um_app_key";
    public static final String KEY_HEADER_BESRIAL = "um_bserial";
    public static final String KEY_HEADER_BSVER = "um_bsver";
    public static final String KEY_HEADER_BVER = "um_bver";
    public static final String KEY_HEADER_CARRIER = "um_app_carrier";
    public static final String KEY_HEADER_CHANNEL = "um_app_channel";
    public static final String KEY_HEADER_CRASH_VERSION = "um_crash_sdk_version";
    public static final String KEY_HEADER_DEBUGKEY = "um_dk";
    public static final String KEY_HEADER_NETWORK_TYPE = "um_network_type";
    public static final String KEY_HEADER_OS = "um_os";
    public static final String KEY_HEADER_PROVIDER = "um_app_provider";
    public static final String KEY_HEADER_PUID = "um_app_puid";
    public static final String KEY_HEADER_START_TIME = "um_app_start_time";
    public static final String KEY_HEADER_UMID = "um_umid_header";
    private static final int KEY_MAX_LENGTH = 256;
    private static final int KEY_MAX_LENGTH_128 = 128;
    public static final String SP_KEY_DEBUG = "debugkey";
    public static final String SP_KEY_TIMESTAMP = "timestamp";
    private static final String TAG = "UMCrash";
    private static String crashSdkVersion = "1.5.2";
    private static boolean enableANRLog = true;
    private static boolean enableJavaLog = true;
    private static boolean enableLaunchLog = true;
    private static boolean enableMemLog = true;
    private static boolean enableNativeLog = true;
    private static boolean enableNetLog = true;
    private static boolean enablePaLog = true;
    private static int index = 0;
    private static boolean isDebug = true;
    private static boolean isEncrypt = false;
    private static boolean isIntl = false;
    private static boolean isLa = false;
    private static boolean isNet = false;
    private static boolean isPA = false;
    private static boolean isZip = true;
    private static ArrayList<String> mArrayList = new ArrayList<>(10);
    private static Context mContext;
    private static UMCrashCallback mUMCrashCallback;
    private static Object pageArrayLock = new Object();
    public static EfsReporter sReporter;
    private static String userBesrial;
    private static String userBsver;
    private static String userBver;

    static /* synthetic */ int access$808() {
        int i = index;
        index = i + 1;
        return i;
    }

    static /* synthetic */ int access$810() {
        int i = index;
        index = i - 1;
        return i;
    }

    public static EfsReporter getReporter() {
        return sReporter;
    }

    public static void setAppVersion(String str, String str2, String str3) {
        try {
            if (!TextUtils.isEmpty(str)) {
                if (str.trim().getBytes().length > 128) {
                    str = UMCrashUtils.splitByByte(str, 128);
                }
                userBver = str;
            } else if (isDebug) {
                Log.e(TAG, "version is null or empty !");
            }
            if (!TextUtils.isEmpty(str2)) {
                if (str2.trim().getBytes().length > 128) {
                    str2 = UMCrashUtils.splitByByte(str2, 128);
                }
                userBsver = str2;
            } else if (isDebug) {
                Log.e(TAG, "sub version is null or empty !");
            }
            if (!TextUtils.isEmpty(str3)) {
                if (str3.trim().getBytes().length > 128) {
                    str3 = UMCrashUtils.splitByByte(str3, 128);
                }
                userBesrial = str3;
            } else if (isDebug) {
                Log.e(TAG, "build id is null or empty !");
            }
            CrashApi instance = CrashApi.getInstance();
            if (instance != null) {
                if (!TextUtils.isEmpty(userBver)) {
                    instance.addHeaderInfo(KEY_HEADER_BVER, userBver);
                }
                if (!TextUtils.isEmpty(userBsver)) {
                    instance.addHeaderInfo(KEY_HEADER_BSVER, userBsver);
                }
                if (!TextUtils.isEmpty(userBesrial)) {
                    instance.addHeaderInfo(KEY_HEADER_BESRIAL, userBesrial);
                }
            } else if (isDebug) {
                Log.e(TAG, "set app version. crashApi is null");
            }
            HashMap hashMap = new HashMap(1);
            if (!TextUtils.isEmpty(userBver)) {
                hashMap.put(KEY_HEADER_BVER, userBver);
            }
            if (!TextUtils.isEmpty(userBsver)) {
                hashMap.put(KEY_HEADER_BSVER, userBsver);
            }
            if (!TextUtils.isEmpty(userBesrial)) {
                hashMap.put(KEY_HEADER_BESRIAL, userBesrial);
            }
            EfsReporter efsReporter = sReporter;
            if (efsReporter != null) {
                efsReporter.addPublicParams(hashMap);
            } else if (isDebug) {
                Log.e(TAG, "set app version.  sReporter is null");
            }
            if (!TextUtils.isEmpty(userBver)) {
                UMCrashUtils.setCommonTag(KEY_HEADER_BVER, userBver);
            }
            if (!TextUtils.isEmpty(userBsver)) {
                UMCrashUtils.setCommonTag(KEY_HEADER_BSVER, userBsver);
            }
            if (!TextUtils.isEmpty(userBesrial)) {
                UMCrashUtils.setCommonTag(KEY_HEADER_BESRIAL, userBesrial);
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    private static class CrashClientImpl implements ICrashClient {
        @Override // com.uc.crashsdk.export.ICrashClient
        public void onAddCrashStats(String str, int i, int i2) {
        }

        @Override // com.uc.crashsdk.export.ICrashClient
        public File onBeforeUploadLog(File file) {
            return file;
        }

        @Override // com.uc.crashsdk.export.ICrashClient
        public void onClientProcessLogGenerated(String str, File file, String str2) {
        }

        @Override // com.uc.crashsdk.export.ICrashClient
        public void onCrashRestarting(boolean z) {
        }

        @Override // com.uc.crashsdk.export.ICrashClient
        public void onLogGenerated(File file, String str) {
        }

        private CrashClientImpl() {
        }

        @Override // com.uc.crashsdk.export.ICrashClient
        public String onGetCallbackInfo(String str, boolean z) {
            String onCallback;
            String str2 = null;
            if (UMCrash.KEY_CALLBACK_PAGE_ACTION.equals(str)) {
                try {
                    if (UMCrash.mArrayList != null && UMCrash.mArrayList.size() > 0) {
                        JSONObject jSONObject = new JSONObject();
                        jSONObject.put(h.k, 0);
                        jSONObject.put("action_name", "page_view");
                        JSONArray jSONArray = new JSONArray();
                        for (int i = 0; i < UMCrash.mArrayList.size(); i++) {
                            String str3 = (String) UMCrash.mArrayList.get(i);
                            if (str3 != null) {
                                JSONObject jSONObject2 = new JSONObject();
                                jSONObject2.put("name", str3);
                                jSONArray.put(jSONObject2);
                            }
                        }
                        jSONObject.put("action_parameter", jSONArray);
                        str2 = jSONObject.toString();
                        if (UMCrash.isDebug) {
                            String str4 = UMCrash.TAG;
                            Log.i(str4, "page json is " + str2);
                        }
                    }
                } catch (Throwable unused) {
                }
                return str2;
            } else if (UMCrash.KEY_CALLBACK_UMID.equals(str)) {
                return UMCrash.getUMID(UMCrash.mContext);
            } else {
                if (!UMCrash.KEY_CALLBACK_USER_STRING.equals(str) || UMCrash.mUMCrashCallback == null || (onCallback = UMCrash.mUMCrashCallback.onCallback()) == null) {
                    return null;
                }
                return onCallback.trim().getBytes().length > 256 ? UMCrashUtils.splitByByte(onCallback, 256) : onCallback;
            }
        }
    }

    /* access modifiers changed from: private */
    /* JADX WARNING: Code restructure failed: missing block: B:10:0x0011, code lost:
        r2 = null;
     */
    /* JADX WARNING: Exception block dominator not found, dom blocks: [] */
    public static synchronized String getUMID(Context context) {
        Method method;
        synchronized (UMCrash.class) {
            String str = null;
            if (context == null) {
                return null;
            }
            Class<?> cls = Class.forName("com.umeng.commonsdk.UMConfigure");
            if (cls != null) {
                try {
                    method = cls.getMethod("getUMIDString", Context.class);
                } catch (NoSuchMethodException unused) {
                    method = null;
                }
                if (method != null) {
                    try {
                        Object invoke = method.invoke(null, context);
                        if (invoke != null) {
                            str = invoke.toString();
                        }
                    } catch (IllegalAccessException | InvocationTargetException unused2) {
                    }
                }
            }
            return str;
        }
    }

    public static String getUMAPMFlag() {
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("version", 0);
            jSONObject.put(PointCategory.CRASH, 1);
            if (enableNativeLog) {
                jSONObject.put("crashNative", 1);
            } else {
                jSONObject.put("crashNative", 0);
            }
            if (enableANRLog) {
                jSONObject.put("anr", 1);
            } else {
                jSONObject.put("anr", 0);
            }
            if (isPA) {
                jSONObject.put("pa", 1);
            } else {
                jSONObject.put("pa", 0);
            }
            if (isLa) {
                jSONObject.put("la", 1);
            } else {
                jSONObject.put("la", 0);
            }
            if (UMMemoryMonitor.get().isEnable()) {
                jSONObject.put("mem", 1);
            } else {
                jSONObject.put("mem", 0);
            }
            if (isNet) {
                jSONObject.put("net", 1);
            } else {
                jSONObject.put("net", 0);
            }
        } catch (Throwable unused) {
        }
        return jSONObject.toString();
    }

    public static void setDebug(boolean z) {
        isDebug = z;
        LaunchManager.isDebug = z;
    }

    private static void useIntlServices(boolean z) {
        isIntl = z;
        if (isDebug) {
            String str = TAG;
            Log.i(str, "useIntlServices is " + isIntl);
        }
    }

    public static void enableNativeLog(boolean z) {
        enableNativeLog = z;
    }

    public static void enableANRLog(boolean z) {
        enableANRLog = z;
    }

    public static void initConfig(Bundle bundle) {
        if (bundle != null) {
            if (bundle.getBoolean(KEY_ENABLE_CRASH_JAVA, true)) {
                enableJavaLog = true;
            } else {
                enableJavaLog = false;
            }
            if (bundle.getBoolean(KEY_ENABLE_CRASH_NATIVE, true)) {
                enableNativeLog = true;
            } else {
                enableNativeLog = false;
            }
            if (bundle.getBoolean(KEY_ENABLE_ANR, true)) {
                enableANRLog = true;
            } else {
                enableANRLog = false;
            }
            if (bundle.getBoolean(KEY_ENABLE_PA, true)) {
                enablePaLog = true;
            } else {
                enablePaLog = false;
            }
            if (bundle.getBoolean(KEY_ENABLE_LAUNCH, true)) {
                enableLaunchLog = true;
            } else {
                enableLaunchLog = false;
            }
            if (bundle.getBoolean(KEY_ENABLE_MEM, true)) {
                enableMemLog = true;
            } else {
                enableMemLog = false;
            }
            if (bundle.getBoolean(KEY_ENABLE_NET, true)) {
                enableNetLog = true;
            } else {
                enableNetLog = false;
            }
        }
    }

    public static void enableMemoryMonitor(boolean z) {
        UMMemoryMonitor.get().setEnable(z);
    }

    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing exception handler attribute for start block: B:53:0x016a */
    /* JADX WARNING: Removed duplicated region for block: B:102:0x023e A[Catch:{ all -> 0x0254 }] */
    /* JADX WARNING: Removed duplicated region for block: B:103:0x0248 A[Catch:{ all -> 0x0254 }] */
    /* JADX WARNING: Removed duplicated region for block: B:111:0x0267 A[Catch:{ all -> 0x02c5 }] */
    /* JADX WARNING: Removed duplicated region for block: B:113:0x027f A[Catch:{ all -> 0x02c5 }] */
    /* JADX WARNING: Removed duplicated region for block: B:116:0x028b A[Catch:{ all -> 0x02c5 }] */
    /* JADX WARNING: Removed duplicated region for block: B:70:0x01ad A[Catch:{ all -> 0x01e2 }] */
    /* JADX WARNING: Removed duplicated region for block: B:71:0x01d6 A[Catch:{ all -> 0x01e2 }] */
    /* JADX WARNING: Removed duplicated region for block: B:79:0x01ea A[Catch:{ all -> 0x0236 }] */
    /* JADX WARNING: Removed duplicated region for block: B:94:0x022a  */
    public static void init(final Context context, final String str, String str2) {
        if (context == null || str == null) {
            Log.e(TAG, "context is null or appkey is null, init failed.");
            return;
        }
        mContext = context;
        final SharedPreferences sharedPreferences = SharedPreferencesUtils.getSharedPreferences(context, INTEGRATIONTESTING_SP);
        Bundle bundle = new Bundle();
        bundle.putBoolean("mDebug", isDebug);
        bundle.putBoolean("mEncryptLog", isEncrypt);
        bundle.putBoolean("mZipLog", isZip);
        bundle.putBoolean(KEY_ENABLE_CRASH_JAVA, enableJavaLog);
        bundle.putBoolean(KEY_ENABLE_CRASH_NATIVE, enableNativeLog);
        bundle.putBoolean(KEY_ENABLE_ANR, enableANRLog);
        bundle.putBoolean(KEY_ENABLE_CRASH_UNEXP, false);
        bundle.putBoolean("mIsInternational", isIntl);
        CrashApi createInstanceEx = CrashApi.createInstanceEx(context, str, isDebug, bundle, new CrashClientImpl());
        if (createInstanceEx != null) {
            createInstanceEx.addHeaderInfo(KEY_HEADER_APPKEY, str);
            createInstanceEx.addHeaderInfo(KEY_HEADER_CHANNEL, str2);
            createInstanceEx.addHeaderInfo(KEY_HEADER_OS, FaceEnvironment.OS);
            createInstanceEx.addHeaderInfo(KEY_HEADER_CRASH_VERSION, crashSdkVersion);
            createInstanceEx.addHeaderInfo(KEY_HEADER_UMID, getUMID(context));
            try {
                String[] activeUser = UMCrashUtils.getActiveUser(context);
                if (activeUser != null && activeUser.length == 2) {
                    createInstanceEx.addHeaderInfo(KEY_HEADER_PUID, activeUser[1]);
                    createInstanceEx.addHeaderInfo(KEY_HEADER_PROVIDER, activeUser[0]);
                }
            } catch (Throwable unused) {
                createInstanceEx.addHeaderInfo(KEY_HEADER_PUID, "");
                createInstanceEx.addHeaderInfo(KEY_HEADER_PROVIDER, "");
            }
            createInstanceEx.addHeaderInfo(KEY_HEADER_CARRIER, UMCrashUtils.getNetworkOperatorName(context));
            if (!TextUtils.isEmpty(userBver)) {
                createInstanceEx.addHeaderInfo(KEY_HEADER_BVER, userBver);
            }
            if (!TextUtils.isEmpty(userBsver)) {
                createInstanceEx.addHeaderInfo(KEY_HEADER_BSVER, userBsver);
            }
            if (!TextUtils.isEmpty(userBesrial)) {
                createInstanceEx.addHeaderInfo(KEY_HEADER_BESRIAL, userBesrial);
            }
            try {
                String[] networkAccessMode = NetworkUtil.getNetworkAccessMode(context);
                if ("Wi-Fi".equals(networkAccessMode[0])) {
                    createInstanceEx.addHeaderInfo(KEY_HEADER_ACCESS, NetworkUtil.NETWORK_TYPE_WIFI);
                } else if ("2G/3G".equals(networkAccessMode[0])) {
                    createInstanceEx.addHeaderInfo(KEY_HEADER_ACCESS, "2G/3G");
                } else {
                    createInstanceEx.addHeaderInfo(KEY_HEADER_ACCESS, "unknow");
                }
                if (!"".equals(networkAccessMode[1])) {
                    createInstanceEx.addHeaderInfo(KEY_HEADER_ACCESS_SUBTYPE, networkAccessMode[1]);
                }
                int networkTypeUmeng = NetworkUtil.getNetworkTypeUmeng(context);
                createInstanceEx.addHeaderInfo(KEY_HEADER_NETWORK_TYPE, "" + networkTypeUmeng);
            } catch (Throwable th) {
                th.printStackTrace();
            }
            try {
                if (UMCrashUtils.isHarmony(context)) {
                    createInstanceEx.addHeaderInfo("others_OS", "harmony");
                } else {
                    createInstanceEx.addHeaderInfo("others_OS", "Android");
                }
            } catch (Throwable th2) {
                th2.printStackTrace();
            }
            if (context instanceof Application) {
                ((Application) context).registerActivityLifecycleCallbacks(new Application.ActivityLifecycleCallbacks() {
                    /* class com.umeng.umcrash.UMCrash.AnonymousClass1 */

                    public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
                    }

                    public void onActivityCreated(Activity activity, Bundle bundle) {
                        Intent intent;
                        Uri data;
                        String scheme;
                        long j;
                        UMCrash.saveActivityState(activity.getLocalClassName(), UMCrash.KEY_ACTIITY_ON_CREATED);
                        if (UMCrash.index == 0 && (intent = activity.getIntent()) != null && (data = intent.getData()) != null && (scheme = data.getScheme()) != null && !scheme.isEmpty()) {
                            if (scheme.contains("um." + str)) {
                                Set<String> queryParameterNames = data.getQueryParameterNames();
                                if (queryParameterNames.contains(UMCrash.IT_DEBUGKEY) && queryParameterNames.contains(UMCrash.IT_SENDAGING)) {
                                    String queryParameter = data.getQueryParameter(UMCrash.IT_DEBUGKEY);
                                    try {
                                        j = Long.parseLong(data.getQueryParameter(UMCrash.IT_SENDAGING));
                                    } catch (NumberFormatException unused) {
                                        j = 0;
                                    }
                                    if (j < 0) {
                                        sharedPreferences.edit().clear().apply();
                                        IntegrationTestingUtil.setIntegrationTestingInPeriod(false);
                                        return;
                                    }
                                    if (j > 6) {
                                        j = 6;
                                    }
                                    sharedPreferences.edit().putString("debugkey", queryParameter).apply();
                                    sharedPreferences.edit().putLong("timestamp", System.currentTimeMillis() + (j * 60 * 60 * 1000)).apply();
                                    UMCrashUtils.setIntegrationTesingParams(queryParameter);
                                    IntegrationTestingUtil.setIntegrationTestingInPeriod(true);
                                }
                            }
                        }
                    }

                    public void onActivityStarted(Activity activity) {
                        UMCrash.saveActivityState(activity.getLocalClassName(), UMCrash.KEY_ACTIITY_ON_STARTED);
                        UMMemoryMonitor.get().onActivityStarted(activity);
                    }

                    public void onActivityResumed(Activity activity) {
                        UMCrash.saveActivityState(activity.getLocalClassName(), UMCrash.KEY_ACTIITY_ON_RESUMED);
                        UMMemoryMonitor.get().onActivityResumed(activity);
                        UMCrash.access$808();
                    }

                    public void onActivityPaused(Activity activity) {
                        UMCrash.saveActivityState(activity.getLocalClassName(), UMCrash.KEY_ACTIITY_ON_PAUSED);
                        UMCrash.access$810();
                    }

                    public void onActivityStopped(Activity activity) {
                        UMCrash.saveActivityState(activity.getLocalClassName(), UMCrash.KEY_ACTIITY_ON_STOPPED);
                        UMMemoryMonitor.get().onActivityStopped(activity);
                    }

                    public void onActivityDestroyed(Activity activity) {
                        UMCrash.saveActivityState(activity.getLocalClassName(), UMCrash.KEY_ACTIITY_ON_DESTROYED);
                    }
                });
                createInstanceEx.registerInfoCallback(KEY_CALLBACK_UMID, 1048593);
                createInstanceEx.registerInfoCallback(KEY_CALLBACK_PAGE_ACTION, 1048593);
            } else {
                Log.e(TAG, "context not instanceof application.");
            }
        } else {
            Log.e(TAG, "create CrashAPI is null.");
        }
        try {
            initReporter(context, str, str2);
        } catch (Throwable th3) {
            th3.printStackTrace();
        }
        try {
            String string = sharedPreferences.getString("debugkey", "");
            if (sharedPreferences.getLong("timestamp", 0) - System.currentTimeMillis() >= 0 || TextUtils.isEmpty(string)) {
                sharedPreferences.edit().clear().apply();
                IntegrationTestingUtil.setIntegrationTestingInPeriod(false);
            } else {
                IntegrationTestingUtil.setIntegrationTestingInPeriod(true);
                UMCrashUtils.setIntegrationTesingParams(string);
            }
        } catch (Throwable th4) {
            th4.printStackTrace();
        }
        try {
            if (!enablePaLog) {
                PAFactory.Builder builder = new PAFactory.Builder(context.getApplicationContext(), new IEfsReporter() {
                    /* class com.umeng.umcrash.UMCrash.AnonymousClass2 */

                    @Override // com.efs.sdk.pa.config.IEfsReporter
                    public EfsReporter getReporter() {
                        return UMCrash.sReporter;
                    }
                });
                builder.packageLevel(PackageLevel.RELEASE);
                PAFactory build = builder.build();
                build.getPaInstance().start();
                isPA = build.getConfigManager().enableTracer();
            } else if (isDebug) {
                Log.e(TAG, "enablePaLog is false");
            }
        } catch (Throwable th5) {
            th5.printStackTrace();
        }
        try {
            if (!enableLaunchLog) {
                LaunchManager.init(context, sReporter);
                try {
                    if (LaunchManager.getLaunchConfigManager() != null) {
                        isLa = LaunchManager.getLaunchConfigManager().enableTracer();
                    }
                } catch (Throwable th6) {
                    th6.printStackTrace();
                }
                String uMId = UMUtils.getUMId(context);
                if (uMId == null || TextUtils.isEmpty(uMId)) {
                    if (isDebug) {
                        Log.i(TAG, "begin register common callback.  key is umid.");
                    }
                    ImprintHandler.getImprintService(context).registImprintCallback(am.g, new UMImprintChangeCallback() {
                        /* class com.umeng.umcrash.UMCrash.AnonymousClass3 */

                        @Override // com.umeng.commonsdk.statistics.internal.UMImprintChangeCallback
                        public void onImprintValueChanged(String str, String str2) {
                            if (UMCrash.isDebug) {
                                String str3 = UMCrash.TAG;
                                Log.i(str3, "common callback.  key is " + str + "; value is " + str2);
                            }
                            try {
                                if (am.g.equals(str)) {
                                    LaunchManager.sendLaunchCache(context, str2);
                                    ImprintHandler.getImprintService(context).unregistImprintCallback(am.g, this);
                                }
                            } catch (Throwable th) {
                                th.printStackTrace();
                            }
                        }
                    });
                }
            } else if (isDebug) {
                Log.e(TAG, "enableLaunchLog is false");
            }
        } catch (Throwable th7) {
            th7.printStackTrace();
        }
        try {
            if (!enableMemLog) {
                UMMemoryMonitor.get().start(context, sReporter);
            } else if (isDebug) {
                Log.e(TAG, "enableMemLog is false");
            }
        } catch (Throwable th8) {
            th8.printStackTrace();
        }
        try {
            int innerConfig = UMCrashUtils.getInnerConfig(context.getApplicationContext(), UMCrashContent.APM_STATE_NET, -1);
            if (isDebug) {
                String str3 = TAG;
                Log.i(str3, "inner config : net rate is " + innerConfig);
            }
            if (innerConfig != 0) {
                if (isDebug) {
                    Log.i(TAG, "inner config : net close.");
                }
            } else if (innerConfig == 100) {
                if (isDebug) {
                    Log.i(TAG, "inner config : net open.");
                }
                if (enableNetLog) {
                    NetManager.init(context, sReporter);
                    try {
                        if (NetManager.getNetConfigManager() != null) {
                            isNet = NetManager.getNetConfigManager().enableTracer();
                        }
                    } catch (Throwable th9) {
                        th9.printStackTrace();
                    }
                } else if (isDebug) {
                    Log.e(TAG, "enableNetLog is false");
                }
            }
        } catch (Throwable th10) {
            th10.printStackTrace();
        }
    }

    /* access modifiers changed from: private */
    public static void saveActivityState(String str, String str2) {
        try {
            ArrayList<String> arrayList = mArrayList;
            if (arrayList != null) {
                if (arrayList.size() >= 20) {
                    mArrayList.remove(0);
                }
                ArrayList<String> arrayList2 = mArrayList;
                arrayList2.add(str + "-" + System.currentTimeMillis() + "-" + str2);
            }
        } catch (Throwable unused) {
        }
    }

    private static void initReporter(final Context context, String str, String str2) {
        HashMap hashMap = new HashMap(1);
        hashMap.put(KEY_HEADER_UMID, getUMID(context));
        hashMap.put(KEY_HEADER_CHANNEL, str2);
        hashMap.put(KEY_HEADER_CARRIER, UMCrashUtils.getNetworkOperatorName(context));
        hashMap.put(KEY_HEADER_OS, FaceEnvironment.OS);
        hashMap.put(KEY_HEADER_CRASH_VERSION, crashSdkVersion);
        try {
            String[] activeUser = UMCrashUtils.getActiveUser(context);
            if (activeUser != null && activeUser.length == 2) {
                hashMap.put(KEY_HEADER_PUID, activeUser[1]);
                hashMap.put(KEY_HEADER_PROVIDER, activeUser[0]);
            }
        } catch (Throwable unused) {
            hashMap.put(KEY_HEADER_PUID, "");
            hashMap.put(KEY_HEADER_PROVIDER, "");
        }
        if (!TextUtils.isEmpty(userBver)) {
            hashMap.put(KEY_HEADER_BVER, userBver);
        }
        if (!TextUtils.isEmpty(userBsver)) {
            hashMap.put(KEY_HEADER_BSVER, userBsver);
        }
        if (!TextUtils.isEmpty(userBesrial)) {
            hashMap.put(KEY_HEADER_BESRIAL, userBesrial);
        }
        try {
            if (UMCrashUtils.isHarmony(context)) {
                hashMap.put("others_OS", "harmony");
            } else {
                hashMap.put("others_OS", "Android");
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
        EfsReporter build = new EfsReporter.Builder(context.getApplicationContext(), str, KEY_APM_DEFAULT_SECRET).debug(isDebug).efsDirRootName(KEY_APM_ROOT_NAME).printLogDetail(isDebug).intl(isIntl).enableWaStat(false).build();
        sReporter = build;
        build.addPublicParams(hashMap);
        try {
            sReporter.getAllSdkConfig(new String[]{UMCrashContent.APM_STATE_NET}, new IConfigCallback() {
                /* class com.umeng.umcrash.UMCrash.AnonymousClass4 */

                @Override // com.efs.sdk.base.observer.IConfigCallback
                public void onChange(Map<String, Object> map) {
                    try {
                        Object obj = map.get(UMCrashContent.APM_STATE_NET);
                        if (obj != null) {
                            if (UMCrash.isDebug) {
                                Log.i("efs.config", "callback net rate is " + obj.toString());
                            }
                            UMCrashUtils.saveInnerConfig(context.getApplicationContext(), UMCrashContent.APM_STATE_NET, obj);
                        }
                    } catch (Throwable th) {
                        th.printStackTrace();
                    }
                }
            });
        } catch (Throwable th2) {
            th2.printStackTrace();
        }
    }

    public static void registerUMCrashCallback(UMCrashCallback uMCrashCallback) {
        if (uMCrashCallback != null) {
            mUMCrashCallback = uMCrashCallback;
            if (CrashApi.getInstance() != null) {
                CrashApi.getInstance().registerInfoCallback(KEY_CALLBACK_USER_STRING, 1048593);
            } else {
                Log.e(TAG, "callback error, instance is null.");
            }
        } else {
            Log.e(TAG, "callback error.");
        }
    }

    public static void generateCustomLog(Throwable th, String str) {
        if (th == null || TextUtils.isEmpty(str)) {
            Log.e(TAG, "generate custom log failed ! e is null or type is empty");
            return;
        }
        try {
            CustomLogInfo build = new UMCustomLogInfoBuilder(str).stack(th).build();
            ArrayList<String> arrayList = new ArrayList<>();
            arrayList.add(KEY_CALLBACK_UMID);
            arrayList.add(KEY_CALLBACK_PAGE_ACTION);
            build.mCallbacks = arrayList;
            CrashApi instance = CrashApi.getInstance();
            if (instance == null) {
                Log.e(TAG, "CrashApi is null, not init .");
            } else {
                instance.generateCustomLog(build);
            }
        } catch (Throwable unused) {
        }
    }

    public static void generateCustomLog(String str, String str2) {
        if (TextUtils.isEmpty(str) || TextUtils.isEmpty(str2)) {
            Log.e(TAG, "generate custom log failed ! e is null or type is empty");
            return;
        }
        try {
            CustomLogInfo customLogInfo = new CustomLogInfo(null, "exception");
            ArrayList<String> arrayList = new ArrayList<>();
            arrayList.add(KEY_CALLBACK_UMID);
            arrayList.add(KEY_CALLBACK_PAGE_ACTION);
            customLogInfo.mCallbacks = arrayList;
            HashMap hashMap = new HashMap(20);
            hashMap.put(UMCustomLogInfoBuilder.LOG_KEY_CT, "exception");
            hashMap.put(UMCustomLogInfoBuilder.LOG_KEY_AC, str2);
            StringBuffer stringBuffer = new StringBuffer();
            for (Map.Entry entry : hashMap.entrySet()) {
                stringBuffer.append((String) entry.getKey());
                stringBuffer.append(":");
                stringBuffer.append((String) entry.getValue());
                stringBuffer.append("\n");
            }
            String str3 = "Exception message:\nBack traces starts.\n" + str + "\n" + "Back traces ends.";
            if (!TextUtils.isEmpty(str3)) {
                stringBuffer.append(str3);
                stringBuffer.append("\n");
            }
            customLogInfo.mData = stringBuffer;
            CrashApi instance = CrashApi.getInstance();
            if (instance == null) {
                Log.e(TAG, "CrashApi is null, not init .");
            } else {
                instance.generateCustomLog(customLogInfo);
            }
        } catch (Throwable unused) {
        }
    }
}