package cn.jiguang.u; import android.app.Activity; import android.app.ActivityManager; import android.content.Context; import android.graphics.Point; import android.os.Build; import android.os.Environment; import android.os.StatFs; import android.text.TextUtils; import android.util.Base64; import android.util.DisplayMetrics; import android.view.Display; import cn.jiguang.f.f; import cn.jiguang.g.b; import cn.jiguang.o.d; import cn.jpush.android.api.JThirdPlatFormInterface; import java.io.BufferedReader; import java.io.File; import java.io.FileFilter; import java.io.FileInputStream; import java.io.FileReader; import java.util.List; import me.leolin.shortcutbadger.impl.NewHtcHomeBadger; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; public class a { private static String a = ""; private static String b = ""; private static final FileFilter c = new FileFilter() { /* class cn.jiguang.u.a.AnonymousClass1 */ public 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; } }; public static int a(String str) { if (f.a(str)) { return -1; } if (str.equalsIgnoreCase("ChinaTelecom")) { return 2; } if (str.equalsIgnoreCase("ChinaMobile")) { return 0; } return str.equalsIgnoreCase("ChinaUnicom") ? 1 : -1; } private static int a(String str, FileInputStream fileInputStream) { byte[] bArr = new byte[1024]; try { int read = fileInputStream.read(bArr); int i = 0; while (i < read) { if (bArr[i] == 10 || i == 0) { if (bArr[i] == 10) { i++; } int i2 = i; while (true) { if (i2 >= read) { continue; break; } int i3 = i2 - i; if (bArr[i2] != str.charAt(i3)) { break; } else if (i3 == str.length() - 1) { return a(bArr, i2); } else { i2++; } } } i++; } return -1; } catch (Throwable unused) { return -1; } } private static int a(byte[] bArr, int i) { while (i < bArr.length && bArr[i] != 10) { if (bArr[i] < 48 || bArr[i] > 57) { i++; } else { int i2 = i + 1; while (i2 < bArr.length && bArr[i2] >= 48 && bArr[i2] <= 57) { i2++; } return Integer.parseInt(new String(bArr, 0, i, i2 - i)); } } return -1; } public static String a() { if (!TextUtils.isEmpty(a)) { return a; } e(); return a; } public static String a(Context context) { DisplayMetrics displayMetrics; if (context == null || context.getResources() == null || (displayMetrics = context.getResources().getDisplayMetrics()) == null) { return "0*0"; } int i = displayMetrics.widthPixels; int i2 = displayMetrics.heightPixels; return i + "*" + i2; } public static String a(Context context, int i) { if (i != 53) { return null; } try { String g = g(context); if (TextUtils.isEmpty(g)) { g = f(context); } JSONObject jSONObject = new JSONObject(g); JSONObject jSONObject2 = new JSONObject(); jSONObject2.put("rom_type", (int) d.o(context)); jSONObject2.put("regid", d.p(context)); jSONObject.put("rom_info", jSONObject2); JSONObject jSONObject3 = new JSONObject(); jSONObject3.put("cmd", 53); jSONObject3.put("content", jSONObject); return jSONObject3.toString(); } catch (JSONException unused) { return null; } } public static void a(Context context, String str) { b.a(context, new cn.jiguang.g.a("cn.jpush.preferences.v2", "n_udp_report_device_info", "").a((Object) Base64.encodeToString(str.getBytes(), 2))); cn.jiguang.af.a.a("JDeviceHelper", "save device info:" + str); } public static double b(Context context) { double d; int i; Point point = new Point(); boolean z = context instanceof Activity; if (z) { Display defaultDisplay = ((Activity) context).getWindowManager().getDefaultDisplay(); if (Build.VERSION.SDK_INT >= 17) { defaultDisplay.getRealSize(point); } else if (Build.VERSION.SDK_INT >= 13) { defaultDisplay.getSize(point); } else { point.x = defaultDisplay.getWidth(); point.y = defaultDisplay.getHeight(); } } DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); if (z) { d = Math.pow((double) (((float) point.x) / displayMetrics.xdpi), 2.0d); i = point.y; } else { d = Math.pow((double) (((float) displayMetrics.widthPixels) / displayMetrics.xdpi), 2.0d); i = displayMetrics.heightPixels; } return Math.sqrt(d + Math.pow((double) (((float) i) / displayMetrics.ydpi), 2.0d)); } private static long b(String str) { String readLine; try { BufferedReader bufferedReader = new BufferedReader(new FileReader("/proc/meminfo"), 4096); do { readLine = bufferedReader.readLine(); if (readLine == null) { break; } } while (!readLine.contains(str)); bufferedReader.close(); return (long) Integer.valueOf(readLine.split("\\s+")[1]).intValue(); } catch (Throwable unused) { return -1; } } public static String b() { if (!TextUtils.isEmpty(b)) { return b; } e(); return b; } public static int c() { if (Build.VERSION.SDK_INT <= 10) { return 1; } try { return new File("/sys/devices/system/cpu/").listFiles(c).length; } catch (Throwable unused) { return -1; } } public static long c(Context context) { try { if (Build.VERSION.SDK_INT >= 16) { ActivityManager activityManager = (ActivityManager) context.getSystemService("activity"); activityManager.getProcessMemoryInfo(new int[]{0}); ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo(); activityManager.getMemoryInfo(memoryInfo); return memoryInfo.totalMem / 1024; } } catch (Throwable unused) { } return b("MemTotal"); } public static int d() { int i = -1; for (int i2 = 0; i2 < c(); i2++) { try { File file = new File("/sys/devices/system/cpu/cpu" + i2 + "/cpufreq/cpuinfo_max_freq"); if (file.exists()) { byte[] bArr = new byte[128]; FileInputStream fileInputStream = new FileInputStream(file); try { fileInputStream.read(bArr); int i3 = 0; while (bArr[i3] >= 48 && bArr[i3] <= 57 && i3 < bArr.length) { i3++; } Integer valueOf = Integer.valueOf(Integer.parseInt(new String(bArr, 0, i3))); if (valueOf.intValue() > i) { i = valueOf.intValue(); } } catch (Throwable th) { fileInputStream.close(); throw th; } fileInputStream.close(); } } catch (Throwable unused) { return -1; } } if (i != -1) { return i; } FileInputStream fileInputStream2 = new FileInputStream("/proc/cpuinfo"); try { int a2 = a("cpu MHz", fileInputStream2) * 1000; if (a2 <= i) { a2 = i; } return a2; } finally { fileInputStream2.close(); } } public static long d(Context context) { try { StatFs statFs = new StatFs(Environment.getDataDirectory().getPath()); return (((long) statFs.getBlockCount()) * ((long) statFs.getBlockSize())) / 1024; } catch (Throwable unused) { return -1; } } public static JSONArray e(Context context) { JSONObject a2; List<cn.jiguang.t.b> b2 = d.b(context.getApplicationContext()); if (b2 == null) { return null; } JSONArray jSONArray = new JSONArray(); for (cn.jiguang.t.b bVar : b2) { if (!(bVar == null || (a2 = bVar.a()) == null)) { jSONArray.put(a2); } } return jSONArray; } private static void e() { StringBuffer stringBuffer = new StringBuffer(); try { if (new File("/proc/cpuinfo").exists()) { BufferedReader bufferedReader = new BufferedReader(new FileReader(new File("/proc/cpuinfo"))); String str = null; while (true) { String readLine = bufferedReader.readLine(); if (readLine == null) { break; } if (readLine.contains("Processor")) { int indexOf = readLine.indexOf(":"); if (indexOf >= 0 && indexOf < readLine.length() - 1) { str = readLine.substring(indexOf + 1).trim(); } if (str != null && !stringBuffer.toString().contains(str)) { stringBuffer.append(str); } } if (readLine.contains("Hardware")) { try { String trim = readLine.substring(readLine.indexOf(":") + 1).trim(); if (!TextUtils.isEmpty(trim)) { b = trim; } } catch (Throwable unused) { } } } bufferedReader.close(); } } catch (Throwable unused2) { } a = stringBuffer.toString(); } public static String f(Context context) { try { cn.jiguang.bb.a a2 = cn.jiguang.bb.a.a(context); JSONObject jSONObject = new JSONObject(); jSONObject.put("sim_slots", e(context)); jSONObject.put(NewHtcHomeBadger.PACKAGENAME, context.getPackageName()); jSONObject.put("appkey", d.b(context)); jSONObject.put(JThirdPlatFormInterface.KEY_PLATFORM, 0); jSONObject.put("apkversion", a2.a); jSONObject.put("systemversion", a2.b); jSONObject.put("modelnumber", a2.c); jSONObject.put("basebandversion", a2.d); jSONObject.put("buildnumber", a2.e); jSONObject.put("channel", a2.f); JSONObject jSONObject2 = new JSONObject(); jSONObject2.put("PushSDKVer", d.b(0)); jSONObject2.put("StatisticSDKVer", d.b(1)); jSONObject2.put("ShareSDKVer", d.b(2)); jSONObject2.put("CoreSDKVer", d.b(3)); jSONObject2.put("SspSDKVer", d.b(4)); jSONObject2.put("VerificationSDKVer", d.b(5)); jSONObject.put("sdkver", jSONObject2); jSONObject.put("installation", a2.g); jSONObject.put("resolution", a2.h); jSONObject.put("business", d.e()); jSONObject.put("device_id_status", d.i(context)); jSONObject.put("device_id", d.g(context)); jSONObject.put("android_id", a2.i); jSONObject.put("mac_address", d.c(context, "")); jSONObject.put("serial_number", a2.j); return jSONObject.toString(); } catch (JSONException unused) { return null; } } public static String g(Context context) { String str; String str2 = (String) b.b(context, new cn.jiguang.g.a("cn.jpush.preferences.v2", "n_udp_report_device_info", "")); if (TextUtils.isEmpty(str2)) { String str3 = (String) b.b(context, new cn.jiguang.g.a("cn.jpush.preferences.v2", "udp_report_device_info", "")); if (!TextUtils.isEmpty(str3)) { a(context, str3); } str = str3; } else { str = new String(Base64.decode(str2, 2)); } cn.jiguang.af.a.a("JDeviceHelper", "read deviceinfo:" + str); return str; } }