TikTok.apk(点击下载) / C56162Jh.java


package X;

import android.content.ClipboardManager;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.abmock.SettingsManager;
import com.bytedance.liko.memoryexplorer.MemoryConfig;
import com.bytedance.tailor.Tailor;
import com.google.gson.Gson;
import java.io.File;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;
import kotlin.g.b.m;

/* renamed from: X.2Jh  reason: invalid class name and case insensitive filesystem */
public final class C56162Jh {
    public static final C56212Jm LIZ = new C56212Jm((byte) 0);

    static {
        Covode.recordClassIndex(29650);
    }

    private final AbstractC24610yI LIZ(C24780yZ r2, File file) {
        return new C39069FVy(r2, file);
    }

    public static NetworkInfo LIZ(ConnectivityManager connectivityManager) {
        try {
            return connectivityManager.getActiveNetworkInfo();
        } catch (Exception e) {
            C16210kk.LIZ((Throwable) e);
            return C17800nJ.LIZ();
        }
    }

    private final Map<String, String> LIZ() {
        MemoryConfig memoryConfig = MemoryConfig.getMemoryConfig();
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        linkedHashMap.put("aid", String.valueOf(memoryConfig.aid));
        String str = memoryConfig.channel;
        m.LIZ((Object) str, "");
        linkedHashMap.put("channel", str);
        String str2 = memoryConfig.device_id;
        m.LIZ((Object) str2, "");
        linkedHashMap.put("device_id", str2);
        String str3 = memoryConfig.app_version;
        m.LIZ((Object) str3, "");
        linkedHashMap.put("app_version", str3);
        String str4 = memoryConfig.update_versioncode;
        m.LIZ((Object) str4, "");
        linkedHashMap.put("update_version_code", str4);
        String str5 = memoryConfig.update_versioncode;
        m.LIZ((Object) str5, "");
        linkedHashMap.put("current_update_version_code", str5);
        String str6 = memoryConfig.os_version;
        m.LIZ((Object) str6, "");
        linkedHashMap.put("os_version", str6);
        linkedHashMap.put("os_api", String.valueOf(memoryConfig.os_api));
        String str7 = memoryConfig.device_model;
        m.LIZ((Object) str7, "");
        linkedHashMap.put("device_model", str7);
        String str8 = memoryConfig.device_brand;
        m.LIZ((Object) str8, "");
        linkedHashMap.put("device_brand", str8);
        String str9 = memoryConfig.device_manufacturer;
        m.LIZ((Object) str9, "");
        linkedHashMap.put("device_manufacturer", str9);
        String str10 = memoryConfig.packageName;
        m.LIZ((Object) str10, "");
        linkedHashMap.put("process_name", str10);
        String str11 = memoryConfig.versionName;
        m.LIZ((Object) str11, "");
        linkedHashMap.put("version_name", str11);
        linkedHashMap.put("version_code", String.valueOf(memoryConfig.versioncode));
        String str12 = memoryConfig.region;
        m.LIZ((Object) str12, "");
        linkedHashMap.put("region", str12);
        String str13 = memoryConfig.release_build;
        m.LIZ((Object) str13, "");
        linkedHashMap.put("release_build", str13);
        return linkedHashMap;
    }

    private final boolean LIZ(Context context) {
        if (context != null) {
            try {
                Object LIZIZ = LIZIZ(context, "connectivity");
                if (LIZIZ != null) {
                    NetworkInfo LIZ2 = LIZ((ConnectivityManager) LIZIZ);
                    if (LIZ2 != null) {
                        if (LIZ2.isAvailable()) {
                            if (1 == LIZ2.getType()) {
                                return true;
                            }
                        }
                    }
                    return false;
                }
            } catch (Exception unused) {
                return false;
            }
        }
        throw new C23830x2("null cannot be cast to non-null type android.net.ConnectivityManager");
    }

    public static boolean LIZ(File file) {
        try {
            C14490hy r3 = C12270eO.LIZ() ? (C14490hy) SettingsManager.LIZ().LIZ("storage_intercepter_key", C14490hy.class, AbstractC14530i2.LIZ) : AbstractC14530i2.LIZ;
            if (C14510i0.LIZIZ(file.getAbsolutePath(), r3)) {
                C14510i0.LIZ(file, new RuntimeException(), "exception_delete_log", C14510i0.LIZ(r3));
            }
            if (C14510i0.LIZJ(file.getAbsolutePath(), r3)) {
                C14510i0.LIZ(file, new RuntimeException(), "exception_handle", C14510i0.LIZ(r3));
                return false;
            }
        } catch (Throwable unused) {
        }
        return file.delete();
    }

    public static Object LIZIZ(Context context, String str) {
        Object obj;
        if (Build.VERSION.SDK_INT > 27 || !"clipboard".equals(str)) {
            if (!C16520lF.LIZIZ && "connectivity".equals(str)) {
                try {
                    new AnonymousClass1ME().LIZ();
                    C16520lF.LIZIZ = true;
                    obj = context.getSystemService(str);
                } catch (Throwable unused) {
                }
            }
            obj = context.getSystemService(str);
        } else if (C16520lF.LIZ) {
            synchronized (ClipboardManager.class) {
                try {
                    obj = context.getSystemService(str);
                    if (Thread.currentThread() != Looper.getMainLooper().getThread()) {
                        try {
                            Field declaredField = ClipboardManager.class.getDeclaredField("mHandler");
                            declaredField.setAccessible(true);
                            declaredField.set(obj, new HandlerC16510lE((Handler) declaredField.get(obj)));
                        } catch (Exception e) {
                            AnonymousClass0O2.LIZ(e, "ClipboardManager Handler Reflect Fail");
                        }
                    }
                    C16520lF.LIZ = false;
                } finally {
                }
            }
        } else {
            obj = context.getSystemService(str);
        }
        return obj;
    }

    private void LIZIZ(File file) {
        C21090sc.LIZ(file);
        C21090sc.LIZ("shouldUpload:" + C56222Jn.LIZ().LIZ());
        if (C56222Jn.LIZ().LIZ()) {
            LIZJ(file);
        }
    }

    private final void LIZJ(File file) {
        C24770yY LJFF = C24770yY.LJFF("https://api-va.tiktokv.com/monitor/collect/c/mom_dump_collect/");
        if (file.exists() && file.length() != 0 && LJFF != null) {
            AnonymousClass2IV r6 = new AnonymousClass2IV("memory_object_monitor", System.currentTimeMillis());
            C56182Jj LIZ2 = C56172Ji.LIZ.LIZ(LIZ());
            ArrayList arrayList = new ArrayList();
            String name = file.getName();
            C24780yZ r0 = C30701Jj.LJ;
            m.LIZ((Object) r0, "");
            C24800yb LIZ3 = C24800yb.LIZ("file", name, LIZ(r0, file));
            m.LIZ((Object) LIZ3, "");
            arrayList.add(LIZ3);
            C24800yb LIZ4 = C24800yb.LIZ("header", new Gson().toJson(LIZ2));
            m.LIZ((Object) LIZ4, "");
            arrayList.add(LIZ4);
            C24800yb LIZ5 = C24800yb.LIZ("data", new Gson().toJson(r6));
            m.LIZ((Object) LIZ5, "");
            arrayList.add(LIZ5);
            AbstractC56192Jk.LIZ.LIZ().LIZ("https://api-va.tiktokv.com/monitor/collect/c/mom_dump_collect/", arrayList, new C56152Jg(file));
        }
    }

    public final void LIZ(Context context, String str) {
        C21090sc.LIZ(str);
        if (LIZ(context)) {
            if (!TextUtils.isEmpty(str)) {
                try {
                    File file = new File(str);
                    if (file.exists() && Tailor.isHprofValid(str)) {
                        String parent = file.getParent();
                        String str2 = parent + "/.mini.hprof";
                        Tailor.tailorHprof(str, str2);
                        File file2 = new File(str2);
                        if (file2.exists()) {
                            LIZ(new File(str));
                        }
                        ArrayList arrayList = new ArrayList(4);
                        if (file2.exists()) {
                            arrayList.add(str2);
                        } else {
                            arrayList.add(str);
                        }
                        if (new File(parent + "/.maps").exists()) {
                            arrayList.add(parent + "/.maps");
                            arrayList.add(parent + "/.fds");
                            arrayList.add(parent + "/.threads");
                            arrayList.add(parent + "/.stacks");
                        }
                        AnonymousClass2DU.LIZ(parent, "dump.xzip", arrayList);
                        if (file.exists()) {
                            LIZ(file);
                        }
                        if (file2.exists()) {
                            LIZ(file2);
                        }
                        if (!TextUtils.isEmpty(parent)) {
                            File file3 = new File(parent + "/dump.xzip");
                            if (file3.exists()) {
                                LIZIZ(file3);
                            }
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }
}