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


package com.baidu.idl.main.facesdk.statistic;

import android.app.ActivityManager;
import android.content.Context;
import android.os.Build;
import android.os.Environment;
import android.os.StatFs;
import android.os.storage.StorageManager;
import com.bytedance.sdk.openadsdk.downloadnew.core.TTDownloadField;
import com.kuaishou.weapon.p0.k1;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileFilter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class DeviceInfoUtil {
    private static final FileFilter CPU_FILTER = new FileFilter() {
        /* class com.baidu.idl.main.facesdk.statistic.DeviceInfoUtil.AnonymousClass1 */

        public final boolean accept(File file) {
            String name = file.getName();
            if (!name.startsWith("cpu")) {
                return false;
            }
            for (int i = 3; i < name.length(); i++) {
                if (name.charAt(i) < '0' || name.charAt(i) > '9') {
                    return false;
                }
            }
            return true;
        }
    };
    private static final String CurPath = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq";

    public static Integer getCPUBit() {
        String str;
        try {
            str = getFieldFromCpuinfo("Processor");
        } catch (IOException e) {
            e.printStackTrace();
            str = null;
        }
        if (str == null) {
            return 0;
        }
        return Integer.valueOf(str.contains("aarch64") ? 64 : 32);
    }

    /* JADX WARNING: Code restructure failed: missing block: B:35:0x0056, code lost:
        if (r2 == null) goto L_0x0074;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:44:0x006a, code lost:
        if (r2 == null) goto L_0x0074;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:46:?, code lost:
        r2.close();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:47:0x0070, code lost:
        r0 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:48:0x0071, code lost:
        r0.printStackTrace();
     */
    /* JADX WARNING: Removed duplicated region for block: B:31:0x004e A[SYNTHETIC, Splitter:B:31:0x004e] */
    /* JADX WARNING: Removed duplicated region for block: B:40:0x0062 A[SYNTHETIC, Splitter:B:40:0x0062] */
    /* JADX WARNING: Removed duplicated region for block: B:53:0x007c A[SYNTHETIC, Splitter:B:53:0x007c] */
    /* JADX WARNING: Removed duplicated region for block: B:58:0x0086 A[SYNTHETIC, Splitter:B:58:0x0086] */
    public static int getDeviceBasicFrequency() {
        BufferedReader bufferedReader;
        Throwable th;
        FileReader fileReader;
        FileNotFoundException e;
        IOException e2;
        FileReader fileReader2 = null;
        try {
            fileReader = new FileReader(CurPath);
            try {
                bufferedReader = new BufferedReader(fileReader);
                try {
                    int parseInt = Integer.parseInt(bufferedReader.readLine().trim());
                    try {
                        fileReader.close();
                    } catch (IOException e3) {
                        e3.printStackTrace();
                    }
                    try {
                        bufferedReader.close();
                        return parseInt;
                    } catch (IOException e4) {
                        e4.printStackTrace();
                        return parseInt;
                    }
                } catch (FileNotFoundException e5) {
                    e = e5;
                    e.printStackTrace();
                    if (fileReader != null) {
                    }
                } catch (IOException e6) {
                    e2 = e6;
                    try {
                        e2.printStackTrace();
                        if (fileReader != null) {
                        }
                    } catch (Throwable th2) {
                        th = th2;
                        fileReader2 = fileReader;
                        if (fileReader2 != null) {
                        }
                        if (bufferedReader != null) {
                        }
                        throw th;
                    }
                }
            } catch (FileNotFoundException e7) {
                bufferedReader = null;
                e = e7;
                e.printStackTrace();
                if (fileReader != null) {
                }
            } catch (IOException e8) {
                bufferedReader = null;
                e2 = e8;
                e2.printStackTrace();
                if (fileReader != null) {
                }
            } catch (Throwable th3) {
                bufferedReader = null;
                fileReader2 = fileReader;
                th = th3;
                if (fileReader2 != null) {
                }
                if (bufferedReader != null) {
                }
                throw th;
            }
        } catch (FileNotFoundException e9) {
            bufferedReader = null;
            e = e9;
            fileReader = null;
            e.printStackTrace();
            if (fileReader != null) {
                try {
                    fileReader.close();
                } catch (IOException e10) {
                    e10.printStackTrace();
                }
            }
        } catch (IOException e11) {
            bufferedReader = null;
            e2 = e11;
            fileReader = null;
            e2.printStackTrace();
            if (fileReader != null) {
                try {
                    fileReader.close();
                } catch (IOException e12) {
                    e12.printStackTrace();
                }
            }
        } catch (Throwable th4) {
            th = th4;
            bufferedReader = null;
            if (fileReader2 != null) {
                try {
                    fileReader2.close();
                } catch (IOException e13) {
                    e13.printStackTrace();
                }
            }
            if (bufferedReader != null) {
                try {
                    bufferedReader.close();
                } catch (IOException e14) {
                    e14.printStackTrace();
                }
            }
            throw th;
        }
        return 0;
    }

    public static String getDeviceBoard() {
        return Build.BOARD;
    }

    public static String getDeviceBrand() {
        return Build.BRAND;
    }

    public static String getDeviceDevice() {
        return Build.DEVICE;
    }

    public static String getDeviceManufacturer() {
        return Build.MANUFACTURER;
    }

    public static String getDeviceModel() {
        return Build.MODEL;
    }

    public static String getDeviceProcessor() {
        try {
            return new BufferedReader(new FileReader(k1.a)).readLine().split(":\\s+", 2)[1];
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            return null;
        } catch (IOException e2) {
            e2.printStackTrace();
            return null;
        }
    }

    public static String getDeviceProduct() {
        return Build.PRODUCT;
    }

    public static int getDeviceSDK() {
        return Build.VERSION.SDK_INT;
    }

    public static String getDeviceSerial() {
        return Build.SERIAL;
    }

    public static String getFieldFromCpuinfo(String str) {
        Matcher matcher;
        BufferedReader bufferedReader = new BufferedReader(new FileReader(k1.a));
        Pattern compile = Pattern.compile(str + "\\s*:\\s*(.*)");
        do {
            try {
                String readLine = bufferedReader.readLine();
                if (readLine != null) {
                    matcher = compile.matcher(readLine);
                } else {
                    bufferedReader.close();
                    return null;
                }
            } finally {
                bufferedReader.close();
            }
        } while (!matcher.matches());
        return matcher.group(1);
    }

    public static int getNumberOfCPUCores() {
        if (Build.VERSION.SDK_INT <= 10) {
            return 1;
        }
        try {
            return new File("/sys/devices/system/cpu/").listFiles(CPU_FILTER).length;
        } catch (NullPointerException | SecurityException unused) {
            return 0;
        }
    }

    public static long getRamInfo(Context context) {
        ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
        ((ActivityManager) context.getSystemService(TTDownloadField.TT_ACTIVITY)).getMemoryInfo(memoryInfo);
        return memoryInfo.totalMem;
    }

    public static String getStorageInfo(Context context, int i) {
        String storagePath = getStoragePath(context, i);
        if (!isSDCardMount() || storagePath == null || storagePath.toString().equals("")) {
            return "无外置SD卡";
        }
        StatFs statFs = new StatFs(new File(storagePath).getPath());
        long blockCountLong = statFs.getBlockCountLong();
        long blockSizeLong = statFs.getBlockSizeLong();
        long j = blockCountLong * blockSizeLong;
        long availableBlocksLong = statFs.getAvailableBlocksLong() * blockSizeLong;
        return "可用/总共:" + Long.toString(availableBlocksLong) + "/" + Long.toString(j);
    }

    public static String getStoragePath(Context context, int i) {
        StorageManager storageManager = (StorageManager) context.getSystemService("storage");
        try {
            String[] strArr = (String[]) storageManager.getClass().getMethod("getVolumePaths", new Class[0]).invoke(storageManager, new Object[0]);
            if (i == 0) {
                return strArr[i];
            }
            if (i != 1 || strArr.length <= 1) {
                return null;
            }
            return strArr[i];
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public static String getSystemVersion() {
        return Build.VERSION.RELEASE;
    }

    public static boolean isSDCardMount() {
        return Environment.getExternalStorageState().equals("mounted");
    }
}