package com.kwad.sdk.utils; import android.app.ActivityManager; import android.content.Context; import android.os.Build; import android.os.Process; import android.text.TextUtils; import com.bytedance.sdk.openadsdk.downloadnew.core.TTDownloadField; import com.kuaishou.weapon.p0.h; import com.kwad.sdk.crash.utils.b; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.RandomAccessFile; public final class SystemUtil { private static long bCo; private static long bCp; private static int bCq; private static LEVEL bCr; public enum LEVEL { BEST(5), HIGH(4), MIDDLE(3), LOW(2), BAD(1), UN_KNOW(-1); int value; private LEVEL(int i) { this.value = i; } public final int getValue() { return this.value; } } public static class a { public long bCs; public long bCt; public long bCu; public long bCv; public long bCw; public int mThreadsCount; } public static long Zx() { BufferedReader bufferedReader; Throwable th; String readLine; BufferedReader bufferedReader2 = null; try { bufferedReader = new BufferedReader(new FileReader("/proc/meminfo"), 8192); do { try { readLine = bufferedReader.readLine(); if (readLine == null) { b.closeQuietly(bufferedReader); return 0; } } catch (Exception unused) { bufferedReader2 = bufferedReader; b.closeQuietly(bufferedReader2); return 0; } catch (Throwable th2) { th = th2; b.closeQuietly(bufferedReader); throw th; } } while (!readLine.contains("MemTotal")); long longValue = Long.valueOf(readLine.split("\\s+")[1]).longValue() << 10; b.closeQuietly(bufferedReader); return longValue; } catch (Exception unused2) { b.closeQuietly(bufferedReader2); return 0; } catch (Throwable th3) { bufferedReader = null; th = th3; b.closeQuietly(bufferedReader); throw th; } } public static a Zy() { Throwable th; String ak; a aVar = new a(); RandomAccessFile randomAccessFile = null; try { RandomAccessFile randomAccessFile2 = new RandomAccessFile("/proc/self/status", "r"); while (true) { try { String readLine = randomAccessFile2.readLine(); if (readLine == null) { break; } else if (!TextUtils.isEmpty(readLine)) { if (readLine.startsWith("VmSize") && readLine.contains("kB")) { String ak2 = ak(readLine, "VmSize"); if (ak2 != null) { aVar.bCt = Long.valueOf(ak2).longValue(); } } else if (readLine.startsWith("VmRSS:") && readLine.contains("kB")) { String ak3 = ak(readLine, "VmRSS:"); if (ak3 != null) { aVar.bCu = Long.valueOf(ak3).longValue(); } } else if (readLine.startsWith("Threads:") && (ak = ak(readLine, "Threads:")) != null) { aVar.mThreadsCount = Integer.valueOf(ak).intValue(); } } } catch (IOException unused) { randomAccessFile = randomAccessFile2; b.closeQuietly(randomAccessFile); return aVar; } catch (Throwable th2) { th = th2; randomAccessFile = randomAccessFile2; b.closeQuietly(randomAccessFile); throw th; } } b.closeQuietly(randomAccessFile2); } catch (IOException unused2) { b.closeQuietly(randomAccessFile); return aVar; } catch (Throwable th3) { th = th3; b.closeQuietly(randomAccessFile); throw th; } return aVar; } private static String ak(String str, String str2) { int length = str2.length(); int i = -1; while (true) { if (length >= str.length()) { length = -1; break; } char charAt = str.charAt(length); if (charAt < '0' || charAt > '9') { if (i != -1) { break; } } else if (i == -1) { i = length; } length++; } if (i == -1) { return null; } return length == -1 ? str.substring(i) : str.substring(i, length); } public static boolean b(Context context, String... strArr) { if (context == null) { return false; } for (int i = 0; i <= 0; i++) { if (context.checkPermission(strArr[0], Process.myPid(), Process.myUid()) == -1) { return false; } } return true; } public static void checkUiThread() { } public static boolean dR(Context context) { if (Build.VERSION.SDK_INT >= 29) { return false; } return b(context, h.c); } public static long dS(Context context) { ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo(); ((ActivityManager) context.getSystemService(TTDownloadField.TT_ACTIVITY)).getMemoryInfo(memoryInfo); return memoryInfo.availMem; } public static boolean eg(int i) { return getApiLevel() >= i; } private static int getApiLevel() { return Build.VERSION.SDK_INT; } public static String getProcessName(Context context) { return ao.getProcessName(context); } public static boolean isInMainProcess(Context context) { return ao.isInMainProcess(context); } }