package com.ubt.jimu.utils; import android.annotation.SuppressLint; import android.app.Activity; import android.app.ActivityManager; import android.app.KeyguardManager; import android.content.Context; import android.os.Build; import android.provider.Settings; import android.telephony.TelephonyManager; import com.ubt.jimu.base.cache.Cache; import com.ubtech.utils.PermissionHelper; import com.ubtech.utils.XLog; import com.ubtrobot.log.ALog; import java.io.File; import java.io.FileFilter; import java.util.regex.Pattern; /* loaded from: classes2.dex */ public class DeviceUtils { private static String a; @SuppressLint({"MissingPermission"}) public static String a(Context context) { String str; if (!android.text.TextUtils.isEmpty(a)) { return a; } ALog.a("DeviceUtils").d("getDeviceId"); if (!PermissionHelper.a(context, "android.permission.READ_PHONE_STATE")) { String b = b(context); a = b; return b; } TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone"); if (telephonyManager == null) { String b2 = b(context); a = b2; return b2; } try { str = telephonyManager.getDeviceId(); try { if ((android.text.TextUtils.isEmpty(str) || str.length() <= 8) && Build.VERSION.SDK_INT >= 23) { str = telephonyManager.getDeviceId(0); } XLog.a("woo", "get hardware DeviceId:" + str); } catch (Exception e) { e = e; ALog.a(e, "get phone deviceId fail!", new Object[0]); if (!android.text.TextUtils.isEmpty(str)) { } str = b(context); a = str; return str; } } catch (Exception e2) { e = e2; str = ""; } if (!android.text.TextUtils.isEmpty(str) || str.length() <= 8) { str = b(context); } a = str; return str; } public static void a(Activity activity) { } private static String b(Context context) { android.text.TextUtils.isEmpty(""); String string = Settings.Secure.getString(context.getContentResolver(), "android_id"); if (android.text.TextUtils.isEmpty(string) || string.length() <= 8) { return Cache.getInstance().getUuid(); } XLog.d("woo", "androidId :" + string, new Object[0]); return string; } public static ActivityManager.MemoryInfo c(Context context) { ActivityManager activityManager = (ActivityManager) context.getSystemService("activity"); ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo(); activityManager.getMemoryInfo(memoryInfo); return memoryInfo; } public static boolean d(Context context) { ALog.a("DeviceUtils").d("isBackground"); ActivityManager activityManager = (ActivityManager) context.getSystemService("activity"); KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService("keyguard"); for (ActivityManager.RunningAppProcessInfo runningAppProcessInfo : activityManager.getRunningAppProcesses()) { if (runningAppProcessInfo.processName.equals(context.getPackageName())) { int i = runningAppProcessInfo.importance; return (i != 100 && i != 200) || keyguardManager.inKeyguardRestrictedInputMode(); } } return false; } public static int a() { try { File[] listFiles = new File("/sys/devices/system/cpu/").listFiles(new FileFilter() { // from class: com.ubt.jimu.utils.DeviceUtils.1CpuFilter @Override // java.io.FileFilter public boolean accept(File file) { return Pattern.matches("cpu[0-9]", file.getName()); } }); ALog.a("DeviceUtils").d("CPU Count: " + listFiles.length); return listFiles.length; } catch (Exception e) { ALog.a("DeviceUtils").d("CPU Count: Failed."); e.printStackTrace(); return 1; } } }