package com.baidu.uaq.agent.android.util; import android.annotation.SuppressLint; import android.content.Context; import android.os.Environment; import android.telephony.TelephonyManager; import android.text.TextUtils; import java.io.File; import java.util.UUID; /* compiled from: DeviceUtil.java */ /* loaded from: classes.dex */ public class d { private static final com.baidu.uaq.agent.android.logging.a a = com.baidu.uaq.agent.android.logging.b.a(); private static String b = null; private static File c = new File(Environment.getDataDirectory(), "uaq_installation"); /* compiled from: DeviceUtil.java */ public enum a { UNKNOWN, SMALL, NORMAL, LARGE, XLARGE } public static a a(Context context) { int i = context.getResources().getConfiguration().screenLayout & 15; return i != 1 ? i != 2 ? i != 3 ? i > 3 ? a.XLARGE : a.UNKNOWN : a.LARGE : a.NORMAL : a.SMALL; } @SuppressLint({"HardwareIds", "MissingPermission"}) public static String b(Context context) { StringBuilder sb; if (TextUtils.isEmpty(b)) { b = c(context); try { try { if (TextUtils.isEmpty(b) || "000000000000000".equals(b)) { b = d(context); } } catch (Exception e) { a.a("Caught error while getPersistentUUID: ", e); com.baidu.uaq.agent.android.harvest.health.a.a(e); if (TextUtils.isEmpty(b)) { sb = new StringBuilder(); } } if (TextUtils.isEmpty(b)) { sb = new StringBuilder(); sb.append("TS"); sb.append(System.currentTimeMillis()); b = sb.toString(); } } catch (Throwable th) { if (TextUtils.isEmpty(b)) { b = "TS" + System.currentTimeMillis(); } throw th; } } return b; } @SuppressLint({"HardwareIds", "MissingPermission"}) private static String c(Context context) { try { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone"); if (telephonyManager != null) { b = telephonyManager.getDeviceId(); } } catch (SecurityException unused) { a.a("Neither user nor current process has android.permission.READ_PHONE_STATE."); } catch (Exception e) { a.a("Caught error while getDeviceId: ", e); com.baidu.uaq.agent.android.harvest.health.a.a(e); } return b; } public static String d(Context context) { c = new File(context.getFilesDir(), "uaq_installation"); String a2 = a(); if (!TextUtils.isEmpty(a2)) { b("UUIDRecovered"); return a2; } String uuid = UUID.randomUUID().toString(); a.d("Created random UUID: " + uuid); com.baidu.uaq.agent.android.stats.a.b().a("Mobile/App/Install"); a(uuid); return uuid; } /* JADX WARN: Removed duplicated region for block: B:20:0x0057 A[EXC_TOP_SPLITTER, SYNTHETIC] */ /* JADX WARN: Removed duplicated region for block: B:31:0x006c A[EXC_TOP_SPLITTER, SYNTHETIC] */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct code enable 'Show inconsistent code' option in preferences */ private static java.lang.String a() { /* java.io.File r0 = com.baidu.uaq.agent.android.util.d.c boolean r0 = r0.exists() if (r0 == 0) goto L7e r0 = 0 java.io.BufferedReader r1 = new java.io.BufferedReader // Catch: java.lang.Throwable -> L3c java.lang.NullPointerException -> L41 org.json.JSONException -> L43 java.io.IOException -> L45 java.io.FileReader r2 = new java.io.FileReader // Catch: java.lang.Throwable -> L3c java.lang.NullPointerException -> L41 org.json.JSONException -> L43 java.io.IOException -> L45 java.io.File r3 = com.baidu.uaq.agent.android.util.d.c // Catch: java.lang.Throwable -> L3c java.lang.NullPointerException -> L41 org.json.JSONException -> L43 java.io.IOException -> L45 r2.(r3) // Catch: java.lang.Throwable -> L3c java.lang.NullPointerException -> L41 org.json.JSONException -> L43 java.io.IOException -> L45 r1.(r2) // Catch: java.lang.Throwable -> L3c java.lang.NullPointerException -> L41 org.json.JSONException -> L43 java.io.IOException -> L45 java.lang.String r0 = r1.readLine() // Catch: java.lang.NullPointerException -> L36 org.json.JSONException -> L38 java.io.IOException -> L3a java.lang.Throwable -> L69 org.json.JSONObject r2 = new org.json.JSONObject // Catch: java.lang.NullPointerException -> L36 org.json.JSONException -> L38 java.io.IOException -> L3a java.lang.Throwable -> L69 r2.(r0) // Catch: java.lang.NullPointerException -> L36 org.json.JSONException -> L38 java.io.IOException -> L3a java.lang.Throwable -> L69 java.lang.String r0 = "uaq_uuid" java.lang.String r0 = r2.getString(r0) // Catch: java.lang.NullPointerException -> L36 org.json.JSONException -> L38 java.io.IOException -> L3a java.lang.Throwable -> L69 r1.close() // Catch: java.io.IOException -> L28 goto L80 L28: r1 = move-exception com.baidu.uaq.agent.android.logging.a r2 = com.baidu.uaq.agent.android.util.d.a java.lang.String r3 = r1.getMessage() r2.a(r3) com.baidu.uaq.agent.android.harvest.health.a.a(r1) goto L80 L36: r0 = move-exception goto L49 L38: r0 = move-exception goto L49 L3a: r0 = move-exception goto L49 L3c: r1 = move-exception r4 = r1 r1 = r0 r0 = r4 goto L6a L41: r1 = move-exception goto L46 L43: r1 = move-exception goto L46 L45: r1 = move-exception L46: r4 = r1 r1 = r0 r0 = r4 L49: com.baidu.uaq.agent.android.logging.a r2 = com.baidu.uaq.agent.android.util.d.a // Catch: java.lang.Throwable -> L69 java.lang.String r3 = r0.getMessage() // Catch: java.lang.Throwable -> L69 r2.a(r3) // Catch: java.lang.Throwable -> L69 com.baidu.uaq.agent.android.harvest.health.a.a(r0) // Catch: java.lang.Throwable -> L69 if (r1 == 0) goto L7e r1.close() // Catch: java.io.IOException -> L5b goto L7e L5b: r0 = move-exception com.baidu.uaq.agent.android.logging.a r1 = com.baidu.uaq.agent.android.util.d.a java.lang.String r2 = r0.getMessage() r1.a(r2) com.baidu.uaq.agent.android.harvest.health.a.a(r0) goto L7e L69: r0 = move-exception L6a: if (r1 == 0) goto L7d r1.close() // Catch: java.io.IOException -> L70 goto L7d L70: r1 = move-exception com.baidu.uaq.agent.android.logging.a r2 = com.baidu.uaq.agent.android.util.d.a java.lang.String r3 = r1.getMessage() r2.a(r3) com.baidu.uaq.agent.android.harvest.health.a.a(r1) L7d: throw r0 L7e: java.lang.String r0 = "" L80: return r0 */ throw new UnsupportedOperationException("Method not decompiled: com.baidu.uaq.agent.android.util.d.a():java.lang.String"); } private static void b(String str) { com.baidu.uaq.agent.android.stats.a b2 = com.baidu.uaq.agent.android.stats.a.b(); if (b2 != null) { b2.a("Supportability/AgentHealth/" + str); return; } a.a("StatsEngine is null. " + str + " not recorded."); } /* JADX WARN: Multi-variable type inference failed */ /* JADX WARN: Removed duplicated region for block: B:20:0x0044 A[Catch: IOException -> 0x0048, TRY_ENTER, TRY_LEAVE, TryCatch #2 {IOException -> 0x0048, blocks: (B:8:0x0021, B:20:0x0044), top: B:2:0x0001 }] */ /* JADX WARN: Type inference failed for: r0v0 */ /* JADX WARN: Type inference failed for: r0v16 */ /* JADX WARN: Type inference failed for: r0v17 */ /* JADX WARN: Type inference failed for: r0v18 */ /* JADX WARN: Type inference failed for: r0v19 */ /* JADX WARN: Type inference failed for: r0v2 */ /* JADX WARN: Type inference failed for: r0v3, types: [java.io.BufferedWriter] */ /* JADX WARN: Type inference failed for: r0v5 */ /* JADX WARN: Type inference failed for: r0v8 */ /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:35:0x0049 -> B:9:0x0055). Please report as a decompilation issue!!! */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct code enable 'Show inconsistent code' option in preferences */ private static void a(java.lang.String r5) { /* r0 = 0 org.json.JSONObject r1 = new org.json.JSONObject // Catch: java.lang.Throwable -> L31 org.json.JSONException -> L33 java.io.IOException -> L35 r1.() // Catch: java.lang.Throwable -> L31 org.json.JSONException -> L33 java.io.IOException -> L35 java.lang.String r2 = "uaq_uuid" r1.put(r2, r5) // Catch: java.lang.Throwable -> L31 org.json.JSONException -> L33 java.io.IOException -> L35 java.io.BufferedWriter r5 = new java.io.BufferedWriter // Catch: java.lang.Throwable -> L31 org.json.JSONException -> L33 java.io.IOException -> L35 java.io.FileWriter r2 = new java.io.FileWriter // Catch: java.lang.Throwable -> L31 org.json.JSONException -> L33 java.io.IOException -> L35 java.io.File r3 = com.baidu.uaq.agent.android.util.d.c // Catch: java.lang.Throwable -> L31 org.json.JSONException -> L33 java.io.IOException -> L35 r2.(r3) // Catch: java.lang.Throwable -> L31 org.json.JSONException -> L33 java.io.IOException -> L35 r5.(r2) // Catch: java.lang.Throwable -> L31 org.json.JSONException -> L33 java.io.IOException -> L35 java.lang.String r0 = r1.toString() // Catch: java.lang.Throwable -> L25 org.json.JSONException -> L2a java.io.IOException -> L2c r5.write(r0) // Catch: java.lang.Throwable -> L25 org.json.JSONException -> L2a java.io.IOException -> L2c r5.flush() // Catch: java.lang.Throwable -> L25 org.json.JSONException -> L2a java.io.IOException -> L2c r5.close() // Catch: java.io.IOException -> L48 goto L55 L25: r0 = move-exception r4 = r0 r0 = r5 r5 = r4 goto L56 L2a: r0 = move-exception goto L2d L2c: r0 = move-exception L2d: r4 = r0 r0 = r5 r5 = r4 goto L36 L31: r5 = move-exception goto L56 L33: r5 = move-exception goto L36 L35: r5 = move-exception L36: com.baidu.uaq.agent.android.logging.a r1 = com.baidu.uaq.agent.android.util.d.a // Catch: java.lang.Throwable -> L31 java.lang.String r2 = r5.getMessage() // Catch: java.lang.Throwable -> L31 r1.a(r2) // Catch: java.lang.Throwable -> L31 com.baidu.uaq.agent.android.harvest.health.a.a(r5) // Catch: java.lang.Throwable -> L31 if (r0 == 0) goto L55 r0.close() // Catch: java.io.IOException -> L48 goto L55 L48: r5 = move-exception com.baidu.uaq.agent.android.logging.a r0 = com.baidu.uaq.agent.android.util.d.a java.lang.String r1 = r5.getMessage() r0.a(r1) com.baidu.uaq.agent.android.harvest.health.a.a(r5) L55: return L56: if (r0 == 0) goto L69 r0.close() // Catch: java.io.IOException -> L5c goto L69 L5c: r0 = move-exception com.baidu.uaq.agent.android.logging.a r1 = com.baidu.uaq.agent.android.util.d.a java.lang.String r2 = r0.getMessage() r1.a(r2) com.baidu.uaq.agent.android.harvest.health.a.a(r0) L69: throw r5 */ throw new UnsupportedOperationException("Method not decompiled: com.baidu.uaq.agent.android.util.d.a(java.lang.String):void"); } }