package com.iBookStar.utils; import android.app.ActivityManager; import android.graphics.Point; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.Build; import android.os.Environment; import android.os.StatFs; import android.provider.Settings; import android.telephony.TelephonyManager; import android.util.DisplayMetrics; import android.view.WindowManager; import com.bytedance.sdk.openadsdk.downloadnew.core.TTDownloadField; import com.efs.sdk.base.core.util.NetworkUtil; import com.iBookStar.b.a; import com.iBookStar.c.b; import com.iBookStar.d.c; import com.kuaishou.weapon.p0.h; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.LineNumberReader; import java.net.InetAddress; import java.net.NetworkInterface; import java.util.Collections; import java.util.Enumeration; import java.util.UUID; import kotlin.UByte; public class d { private static String a; private static String b; private static Long c; private static Long d; private static Point e; private static Double f; public static String a() { try { return Settings.Secure.getString(a.k().getContentResolver(), "android_id"); } catch (Exception unused) { return ""; } } private static String a(String str) { StringBuffer stringBuffer = new StringBuffer(1000); BufferedReader bufferedReader = new BufferedReader(new FileReader(str)); char[] cArr = new char[1024]; while (true) { int read = bufferedReader.read(cArr); if (read != -1) { stringBuffer.append(String.valueOf(cArr, 0, read)); } else { bufferedReader.close(); return stringBuffer.toString(); } } } /* JADX WARNING: Code restructure failed: missing block: B:9:0x0029, code lost: if (com.iBookStar.utils.s.a(r2) != false) goto L_0x002b; */ public static String b() { String imei; String str = null; if (Build.VERSION.SDK_INT <= 28) { try { TelephonyManager telephonyManager = (TelephonyManager) a.k().getSystemService("phone"); if (Build.VERSION.SDK_INT < 26) { if (Build.VERSION.SDK_INT >= 23) { str = telephonyManager.getDeviceId(0); } imei = telephonyManager.getDeviceId(); } else { str = telephonyManager.getImei(0); if (s.a(str)) { imei = telephonyManager.getImei(); } } str = imei; } catch (Throwable th) { th.printStackTrace(); } } if (!s.a(str)) { return str; } String a2 = b.a("local_imei2", ""); if (!b.a("local_imei2_sync", false) && o()) { String k = b.k(); if (s.a(k)) { if (!s.c(a2)) { String e2 = e(); if (s.a(e2)) { e2 = UUID.randomUUID().toString(); } a2 = c.a(e2).substring(8, 22); } b.d(a2); k = a2; } b.b("local_imei2", k); b.b("local_imei2_sync", true); a2 = k; } if (!s.a(a2)) { return a2; } String e3 = e(); if (s.a(e3)) { e3 = UUID.randomUUID().toString(); } String substring = c.a(e3).substring(8, 22); b.b("local_imei2", substring); return substring; } private static boolean b(String str) { return !s.a(str) && !str.contains("00:00:00"); } public static String c() { String str = b; if (str != null) { return str; } try { String subscriberId = ((TelephonyManager) a.k().getSystemService("phone")).getSubscriberId(); b = subscriberId; return subscriberId; } catch (Throwable th) { th.printStackTrace(); return ""; } } public static String d() { String str = a; if (str != null) { return str; } String j = j(); a = j; if (j == null) { String k = k(); a = k; if (k == null) { String l = l(); a = l; if (l == null) { String m = m(); a = m; if (m == null) { String n = n(); a = n; if (n == null) { a = ""; } } } } } return a; } public static String e() { try { return q.a(); } catch (Throwable unused) { return null; } } public static Point f() { Point point = e; if (point != null) { return point; } e = new Point(); try { if (Build.VERSION.SDK_INT >= 17) { ((WindowManager) a.k().getSystemService("window")).getDefaultDisplay().getRealSize(e); } else if (Build.VERSION.SDK_INT >= 13) { ((WindowManager) a.k().getSystemService("window")).getDefaultDisplay().getSize(e); } else { DisplayMetrics displayMetrics = a.k().getResources().getDisplayMetrics(); e.set(displayMetrics.widthPixels, displayMetrics.heightPixels); } } catch (Exception unused) { } return e; } public static double g() { Double d2 = f; if (d2 != null) { return d2.doubleValue(); } try { DisplayMetrics displayMetrics = a.k().getResources().getDisplayMetrics(); Point f2 = f(); Double d3 = new Double(Math.sqrt(Math.pow((double) (((float) f2.x) / displayMetrics.xdpi), 2.0d) + Math.pow((double) (((float) f2.y) / displayMetrics.ydpi), 2.0d))); f = d3; return d3.doubleValue(); } catch (Exception unused) { return 0.0d; } } /* JADX WARNING: Removed duplicated region for block: B:36:0x008e A[SYNTHETIC, Splitter:B:36:0x008e] */ /* JADX WARNING: Removed duplicated region for block: B:42:? A[RETURN, SYNTHETIC] */ public static long h() { Throwable th; BufferedReader bufferedReader; Exception e2; Long l = c; if (l != null) { return l.longValue(); } BufferedReader bufferedReader2 = null; try { if (Build.VERSION.SDK_INT < 16) { bufferedReader = new BufferedReader(new FileReader("/proc/meminfo")); try { String readLine = bufferedReader.readLine(); if (s.c(readLine)) { String[] split = readLine.split("\\s+"); if (split.length > 1) { Long valueOf = Long.valueOf(Long.valueOf(split[1]).longValue() * 1024); c = valueOf; long longValue = valueOf.longValue(); try { bufferedReader.close(); } catch (IOException e3) { e3.printStackTrace(); } return longValue; } } } catch (Exception e4) { e2 = e4; try { e2.printStackTrace(); if (bufferedReader == null) { return 0; } bufferedReader.close(); return 0; } catch (Throwable th2) { th = th2; bufferedReader2 = bufferedReader; if (bufferedReader2 != null) { try { bufferedReader2.close(); } catch (IOException e5) { e5.printStackTrace(); } } throw th; } } try { bufferedReader.close(); return 0; } catch (IOException e6) { e6.printStackTrace(); return 0; } } else { ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo(); ((ActivityManager) a.k().getSystemService(TTDownloadField.TT_ACTIVITY)).getMemoryInfo(memoryInfo); Long valueOf2 = Long.valueOf(memoryInfo.totalMem); c = valueOf2; return valueOf2.longValue(); } } catch (Exception e7) { bufferedReader = null; e2 = e7; e2.printStackTrace(); if (bufferedReader == null) { } bufferedReader.close(); return 0; } catch (Throwable th3) { th = th3; if (bufferedReader2 != null) { } throw th; } } public static long i() { Long l = d; if (l != null) { return l.longValue(); } try { StatFs statFs = new StatFs(Environment.getDataDirectory().getPath()); Long valueOf = Build.VERSION.SDK_INT >= 18 ? Long.valueOf(statFs.getTotalBytes()) : Long.valueOf(((long) statFs.getBlockSize()) * ((long) statFs.getBlockCount())); d = valueOf; return valueOf.longValue(); } catch (Exception unused) { return 0; } } private static String j() { WifiInfo connectionInfo; try { if (a.k() == null || (connectionInfo = ((WifiManager) a.k().getSystemService(NetworkUtil.NETWORK_TYPE_WIFI)).getConnectionInfo()) == null) { return null; } String macAddress = connectionInfo.getMacAddress(); try { if (!b(macAddress)) { return null; } } catch (Exception unused) { } return macAddress; } catch (Exception unused2) { return null; } } private static String k() { String trim; try { LineNumberReader lineNumberReader = new LineNumberReader(new InputStreamReader(Runtime.getRuntime().exec("cat /sys/class/net/wlan0/address").getInputStream())); while (true) { String readLine = lineNumberReader.readLine(); if (!s.c(readLine)) { if (readLine == null) { trim = null; break; } } else { trim = readLine.trim(); break; } } lineNumberReader.close(); if (b(trim)) { return trim; } String substring = a("/sys/class/net/eth0/address").toUpperCase().substring(0, 17); if (!b(substring)) { return null; } return substring; } catch (Exception unused) { return null; } } private static String l() { byte[] hardwareAddress; try { for (NetworkInterface networkInterface : Collections.list(NetworkInterface.getNetworkInterfaces())) { if (networkInterface.getName().equalsIgnoreCase("wlan0") && (hardwareAddress = networkInterface.getHardwareAddress()) != null) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < hardwareAddress.length; i++) { sb.append(String.format("%02X:", Byte.valueOf(hardwareAddress[i]))); } if (sb.length() > 0) { sb.deleteCharAt(sb.length() - 1); } String sb2 = sb.toString(); if (b(sb2)) { return sb2; } } } return null; } catch (Exception unused) { return null; } } private static String m() { try { Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces(); InetAddress inetAddress = null; while (networkInterfaces.hasMoreElements()) { Enumeration<InetAddress> inetAddresses = networkInterfaces.nextElement().getInetAddresses(); while (true) { if (!inetAddresses.hasMoreElements()) { break; } inetAddress = inetAddresses.nextElement(); if (!inetAddress.isLoopbackAddress() && inetAddress.getHostAddress().indexOf(":") == -1) { continue; break; } inetAddress = null; } if (inetAddress != null) { break; } } if (inetAddress == null) { return null; } byte[] hardwareAddress = NetworkInterface.getByInetAddress(inetAddress).getHardwareAddress(); StringBuffer stringBuffer = new StringBuffer(); for (int i = 0; i < hardwareAddress.length; i++) { if (i != 0) { stringBuffer.append(':'); } String hexString = Integer.toHexString(hardwareAddress[i] & UByte.MAX_VALUE); if (hexString.length() == 1) { hexString = 0 + hexString; } stringBuffer.append(hexString); } String upperCase = stringBuffer.toString().toUpperCase(); if (!b(upperCase)) { return null; } return upperCase; } catch (Exception unused) { return null; } } private static String n() { String readLine; try { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec("busybox ifconfig").getInputStream())); String str = ""; while (true) { readLine = bufferedReader.readLine(); if (readLine != null && !readLine.contains("HWaddr")) { str = str + readLine; } } if (!s.c(readLine) || !readLine.contains("HWaddr")) { return null; } String substring = readLine.substring(readLine.indexOf("HWaddr") + 6, readLine.length() - 1); if (!b(substring)) { return null; } return substring; } catch (Exception e2) { e2.printStackTrace(); return null; } } private static boolean o() { if (Build.VERSION.SDK_INT < 23) { return true; } try { return a.k().checkSelfPermission(h.j) == 0; } catch (Throwable th) { th.printStackTrace(); return false; } } }