package com.oo.seex.oo_statistics_lib.utils.utdid.utils;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Build.VERSION;
import android.os.Environment;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class SystemUtils {
    public SystemUtils() {
    }

    public static String getCpuInfo() {
        String str = null;
        FileReader localFileReader = null;
        BufferedReader localBufferedReader = null;

        try {
            localFileReader = new FileReader("/proc/cpuinfo");
            if (localFileReader != null) {
                try {
                    localBufferedReader = new BufferedReader(localFileReader, 1024);
                    str = localBufferedReader.readLine();
                    localBufferedReader.close();
                    localFileReader.close();
                } catch (IOException var4) {
                }
            }
        } catch (FileNotFoundException var5) {
        }

        if (str != null) {
            int i = str.indexOf(58) + 1;
            str = str.substring(i);
            return str.trim();
        } else {
            return "";
        }
    }

    public static int getSystemVersion() {
        boolean SDK_INT = true;

        int SDK_INT1;
        try {
            SDK_INT1 = VERSION.class.getField("SDK_INT").getInt((Object) null);
        } catch (Exception var4) {
            try {
                SDK_INT1 = Integer.parseInt((String) VERSION.class.getField("SDK").get((Object) null));
            } catch (Exception var3) {
                SDK_INT1 = 2;
                var3.printStackTrace();
            }
        }

        return SDK_INT1;
    }

    public static File getRootFolder(String folderName) {
        File sdCardFile = Environment.getExternalStorageDirectory();
        if (sdCardFile != null) {
            File rootFolder = new File(String.format("%s%s%s", new Object[]{sdCardFile.getAbsolutePath(), File.separator, folderName}));
            if (rootFolder != null && !rootFolder.exists()) {
                rootFolder.mkdirs();
            }

            return rootFolder;
        } else {
            return null;
        }
    }

    public static String getAppLabel(Context pContext) {
        try {
            PackageManager e = pContext.getPackageManager();
            String lPackageName = pContext.getPackageName();
            if (null != e && null != lPackageName) {
                PackageInfo lPI = e.getPackageInfo(lPackageName, 1);
                String lLabelName = e.getApplicationLabel(lPI.applicationInfo).toString();
                return lLabelName;
            }
        } catch (NameNotFoundException var5) {
            var5.printStackTrace();
        }

        return null;
    }
}

