package com.umeng.umzid; import android.content.Context; import android.content.SharedPreferences; import android.content.res.Configuration; import android.os.Build; import android.provider.Settings; import android.text.TextUtils; import com.kuaishou.weapon.p0.u; import com.kwad.components.core.n.o; import com.ss.android.download.api.constant.BaseConstants; import com.umeng.analytics.pro.am; import java.lang.reflect.Method; import java.security.MessageDigest; import java.util.Calendar; import java.util.Locale; import java.util.UUID; import kotlin.UByte; import org.json.JSONException; import org.json.JSONObject; public class ZIDManager { public static ZIDManager d; public boolean a = false; public boolean b = false; public boolean c; public class a implements Runnable { public final /* synthetic */ Context a; public final /* synthetic */ IZIDCompletionCallback b; public a(Context context, IZIDCompletionCallback iZIDCompletionCallback) { this.a = context; this.b = iZIDCompletionCallback; } public void run() { String a2 = ZIDManager.a(ZIDManager.this, this.a); if (TextUtils.isEmpty(a2)) { IZIDCompletionCallback iZIDCompletionCallback = this.b; if (iZIDCompletionCallback != null) { iZIDCompletionCallback.onFailure("1002", "获取zid失败"); return; } return; } IZIDCompletionCallback iZIDCompletionCallback2 = this.b; if (iZIDCompletionCallback2 != null) { iZIDCompletionCallback2.onSuccess(a2); } } } public class b implements Runnable { public final /* synthetic */ Context a; public b(Context context) { this.a = context; } public void run() { ZIDManager.this.a(this.a); } } public class c implements Runnable { public final /* synthetic */ Context a; public c(Context context) { this.a = context; } public void run() { ZIDManager.a(ZIDManager.this, this.a); } } public static /* synthetic */ String a(ZIDManager zIDManager, Context context) { String str = null; if (!zIDManager.a) { zIDManager.a = true; JSONObject jSONObject = new JSONObject(); try { String id = Spy.getID(); jSONObject.put(am.aD, id); String b2 = d.b(context); jSONObject.put(am.A, b2); String c2 = d.c(context); jSONObject.put(o.TAG, c2); zIDManager.a(context, jSONObject); String a2 = a.a("https://utoken.umeng.com/api/postZdata/v4", jSONObject.toString()); if (!TextUtils.isEmpty(a2)) { JSONObject jSONObject2 = new JSONObject(a2); if (Boolean.valueOf(jSONObject2.optBoolean("suc")).booleanValue()) { d.f(context, id); d.a(context, b2); d.b(context, c2); str = jSONObject2.optString("aaid"); if (!TextUtils.isEmpty(str)) { d.e(context, str); } String string = jSONObject2.getString("uabc"); if (!TextUtils.isEmpty(string)) { d.d(context, string); } String string2 = jSONObject2.getString("resetToken"); if (!TextUtils.isEmpty(string2)) { d.c(context, string2); } } } } catch (Throwable unused) { } zIDManager.a = false; } return str; } public static synchronized ZIDManager getInstance() { ZIDManager zIDManager; synchronized (ZIDManager.class) { if (d == null) { d = new ZIDManager(); } zIDManager = d; } return zIDManager; } public static String getSDKVersion() { return "1.6.3"; } public synchronized String getZID(Context context) { if (context == null) { return ""; } Context applicationContext = context.getApplicationContext(); String a2 = d.a(applicationContext); if (!TextUtils.isEmpty(a2)) { return a2; } c.a(new c(applicationContext)); return ""; } public synchronized void init(Context context, String str, IZIDCompletionCallback iZIDCompletionCallback) { SharedPreferences a2; SharedPreferences.Editor edit; boolean d2 = d.d(context); this.c = d2; if (d2) { if (context == null) { if (iZIDCompletionCallback != null) { iZIDCompletionCallback.onFailure("1001", "传入参数Context为null"); } } else if (TextUtils.isEmpty(str)) { if (iZIDCompletionCallback != null) { iZIDCompletionCallback.onFailure("1003", "传入参数appkey为空"); } } else { Context applicationContext = context.getApplicationContext(); if (!(applicationContext == null || str == null || TextUtils.isEmpty(str) || (a2 = a.a(applicationContext)) == null || (edit = a2.edit()) == null)) { edit.putString("appkey", str).commit(); } String a3 = d.a(applicationContext); if (a3 == null || TextUtils.isEmpty(a3)) { c.a(new a(applicationContext, iZIDCompletionCallback)); } else { c.a(new b(applicationContext)); if (iZIDCompletionCallback != null) { iZIDCompletionCallback.onSuccess(a3); } } String str2 = ""; SharedPreferences a4 = a.a(context); if (a4 != null) { str2 = a4.getString("uuid", ""); } if (TextUtils.isEmpty(str2)) { String str3 = ""; SharedPreferences a5 = a.a(context); try { str3 = UUID.randomUUID().toString(); } catch (Throwable unused) { } if (a5 != null) { a5.edit().putString("uuid", str3).commit(); } } } } } /* JADX WARNING: Removed duplicated region for block: B:15:0x0048 A[SYNTHETIC, Splitter:B:15:0x0048] */ /* JADX WARNING: Removed duplicated region for block: B:42:0x00d5 A[SYNTHETIC, Splitter:B:42:0x00d5] */ /* JADX WARNING: Removed duplicated region for block: B:57:0x011b */ /* JADX WARNING: Removed duplicated region for block: B:58:0x011d */ /* JADX WARNING: Removed duplicated region for block: B:61:0x0133 */ /* JADX WARNING: Removed duplicated region for block: B:62:0x013a */ public final JSONObject a(Context context, JSONObject jSONObject) { Object obj; int i; Object obj2; String obj3; Object obj4; Object obj5; Object obj6; Class<?> cls; Method declaredMethod; Object invoke; SharedPreferences a2; Class<?> cls2; Method declaredMethod2; Object invoke2; Locale locale; Method declaredMethod3; String str = ""; jSONObject.putOpt("z_v", Spy.getVersion()); try { Class<?> cls3 = Class.forName("com.umeng.commonsdk.statistics.common.DeviceConfig"); if (!(cls3 == null || (declaredMethod3 = cls3.getDeclaredMethod("getAndroidId", Context.class)) == null)) { declaredMethod3.setAccessible(true); Object invoke3 = declaredMethod3.invoke(cls3, context); if (invoke3 != null && (invoke3 instanceof String)) { obj = (String) invoke3; jSONObject.putOpt("a_id", obj); jSONObject.putOpt("os_v", Build.VERSION.RELEASE); Object obj7 = null; if (context != null) { try { Configuration configuration = new Configuration(); configuration.setToDefaults(); Settings.System.getConfiguration(context.getContentResolver(), configuration); locale = configuration.locale; } catch (Throwable unused) { locale = null; } if (locale == null) { try { locale = Locale.getDefault(); } catch (Throwable unused2) { } } Calendar instance = Calendar.getInstance(locale); if (instance != null) { i = instance.getTimeZone().getRawOffset() / BaseConstants.Time.HOUR; jSONObject.putOpt("tz", Integer.valueOf(i)); jSONObject.putOpt(u.r, Build.MODEL); cls2 = Class.forName("com.umeng.commonsdk.statistics.common.DeviceConfig"); if (!(cls2 == null || (declaredMethod2 = cls2.getDeclaredMethod("getImeiNew", Context.class)) == null)) { declaredMethod2.setAccessible(true); invoke2 = declaredMethod2.invoke(cls2, context); if (invoke2 != null && (invoke2 instanceof String)) { obj2 = (String) invoke2; jSONObject.putOpt("im", obj2); Method declaredMethod4 = Build.class.getDeclaredMethod("getString", String.class); declaredMethod4.setAccessible(true); obj3 = declaredMethod4.invoke(null, "net.hostname").toString(); if (obj3 != null) { try { if (!obj3.equalsIgnoreCase(str)) { try { MessageDigest instance2 = MessageDigest.getInstance("MD5"); instance2.update(obj3.getBytes()); byte[] digest = instance2.digest(); StringBuffer stringBuffer = new StringBuffer(); for (byte b2 : digest) { stringBuffer.append(Integer.toHexString(b2 & UByte.MAX_VALUE)); } obj3 = stringBuffer.toString(); } catch (Throwable unused3) { obj3 = str; } } } catch (Exception unused4) { } } jSONObject.putOpt("hn", obj3); jSONObject.putOpt("s_v", "1.6.3"); jSONObject.putOpt("pkg", context != null ? null : context.getPackageName()); jSONObject.putOpt("s_t", "Android"); SharedPreferences a3 = a.a(context); jSONObject.putOpt("uid", a3 == null ? a3.getString("uuid", str) : str); jSONObject.putOpt("s_id", BaseConstants.CATEGORY_UMENG); obj4 = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; jSONObject.putOpt("a_v", obj4); obj5 = context.getResources().getString(context.getPackageManager().getPackageInfo(context.getPackageName(), 0).applicationInfo.labelRes); jSONObject.putOpt("a_n", obj5); obj6 = context.getResources().getConfiguration().locale.getCountry(); jSONObject.putOpt("c", obj6); if (!(context == null || (a2 = a.a(context)) == null)) { obj7 = a2.getString("appkey", null); } jSONObject.putOpt("ak", obj7); cls = Class.forName("com.umeng.commonsdk.statistics.common.DeviceConfig"); if (!(cls == null || (declaredMethod = cls.getDeclaredMethod("getIdfa", Context.class)) == null)) { declaredMethod.setAccessible(true); invoke = declaredMethod.invoke(cls, context); if (invoke != null && (invoke instanceof String)) { str = (String) invoke; } } jSONObject.putOpt("gd", str); return jSONObject; } } obj2 = str; jSONObject.putOpt("im", obj2); Method declaredMethod42 = Build.class.getDeclaredMethod("getString", String.class); declaredMethod42.setAccessible(true); obj3 = declaredMethod42.invoke(null, "net.hostname").toString(); if (obj3 != null) { } jSONObject.putOpt("hn", obj3); jSONObject.putOpt("s_v", "1.6.3"); if (context != null) { } jSONObject.putOpt("pkg", context != null ? null : context.getPackageName()); jSONObject.putOpt("s_t", "Android"); SharedPreferences a32 = a.a(context); jSONObject.putOpt("uid", a32 == null ? a32.getString("uuid", str) : str); jSONObject.putOpt("s_id", BaseConstants.CATEGORY_UMENG); obj4 = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; jSONObject.putOpt("a_v", obj4); obj5 = context.getResources().getString(context.getPackageManager().getPackageInfo(context.getPackageName(), 0).applicationInfo.labelRes); jSONObject.putOpt("a_n", obj5); obj6 = context.getResources().getConfiguration().locale.getCountry(); jSONObject.putOpt("c", obj6); obj7 = a2.getString("appkey", null); jSONObject.putOpt("ak", obj7); cls = Class.forName("com.umeng.commonsdk.statistics.common.DeviceConfig"); declaredMethod.setAccessible(true); invoke = declaredMethod.invoke(cls, context); str = (String) invoke; jSONObject.putOpt("gd", str); return jSONObject; } } i = 8; jSONObject.putOpt("tz", Integer.valueOf(i)); jSONObject.putOpt(u.r, Build.MODEL); cls2 = Class.forName("com.umeng.commonsdk.statistics.common.DeviceConfig"); declaredMethod2.setAccessible(true); invoke2 = declaredMethod2.invoke(cls2, context); obj2 = (String) invoke2; jSONObject.putOpt("im", obj2); Method declaredMethod422 = Build.class.getDeclaredMethod("getString", String.class); declaredMethod422.setAccessible(true); obj3 = declaredMethod422.invoke(null, "net.hostname").toString(); if (obj3 != null) { } jSONObject.putOpt("hn", obj3); jSONObject.putOpt("s_v", "1.6.3"); if (context != null) { } jSONObject.putOpt("pkg", context != null ? null : context.getPackageName()); jSONObject.putOpt("s_t", "Android"); SharedPreferences a322 = a.a(context); jSONObject.putOpt("uid", a322 == null ? a322.getString("uuid", str) : str); jSONObject.putOpt("s_id", BaseConstants.CATEGORY_UMENG); obj4 = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; jSONObject.putOpt("a_v", obj4); obj5 = context.getResources().getString(context.getPackageManager().getPackageInfo(context.getPackageName(), 0).applicationInfo.labelRes); jSONObject.putOpt("a_n", obj5); obj6 = context.getResources().getConfiguration().locale.getCountry(); jSONObject.putOpt("c", obj6); obj7 = a2.getString("appkey", null); jSONObject.putOpt("ak", obj7); cls = Class.forName("com.umeng.commonsdk.statistics.common.DeviceConfig"); declaredMethod.setAccessible(true); invoke = declaredMethod.invoke(cls, context); str = (String) invoke; jSONObject.putOpt("gd", str); return jSONObject; } } } catch (Throwable unused5) { } obj = str; jSONObject.putOpt("a_id", obj); jSONObject.putOpt("os_v", Build.VERSION.RELEASE); Object obj72 = null; if (context != null) { } i = 8; jSONObject.putOpt("tz", Integer.valueOf(i)); jSONObject.putOpt(u.r, Build.MODEL); try { cls2 = Class.forName("com.umeng.commonsdk.statistics.common.DeviceConfig"); declaredMethod2.setAccessible(true); invoke2 = declaredMethod2.invoke(cls2, context); obj2 = (String) invoke2; } catch (Throwable unused6) { } jSONObject.putOpt("im", obj2); Method declaredMethod4222 = Build.class.getDeclaredMethod("getString", String.class); declaredMethod4222.setAccessible(true); obj3 = declaredMethod4222.invoke(null, "net.hostname").toString(); if (obj3 != null) { } jSONObject.putOpt("hn", obj3); jSONObject.putOpt("s_v", "1.6.3"); if (context != null) { } jSONObject.putOpt("pkg", context != null ? null : context.getPackageName()); jSONObject.putOpt("s_t", "Android"); SharedPreferences a3222 = a.a(context); jSONObject.putOpt("uid", a3222 == null ? a3222.getString("uuid", str) : str); jSONObject.putOpt("s_id", BaseConstants.CATEGORY_UMENG); try { obj4 = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; } catch (Exception e) { e.printStackTrace(); obj4 = null; } jSONObject.putOpt("a_v", obj4); try { obj5 = context.getResources().getString(context.getPackageManager().getPackageInfo(context.getPackageName(), 0).applicationInfo.labelRes); } catch (Exception e2) { e2.printStackTrace(); obj5 = null; } jSONObject.putOpt("a_n", obj5); try { obj6 = context.getResources().getConfiguration().locale.getCountry(); } catch (Exception e3) { e3.printStackTrace(); obj6 = null; } jSONObject.putOpt("c", obj6); obj72 = a2.getString("appkey", null); jSONObject.putOpt("ak", obj72); try { cls = Class.forName("com.umeng.commonsdk.statistics.common.DeviceConfig"); declaredMethod.setAccessible(true); invoke = declaredMethod.invoke(cls, context); str = (String) invoke; } catch (Throwable unused7) { } jSONObject.putOpt("gd", str); return jSONObject; } /* JADX WARNING: Removed duplicated region for block: B:12:0x002b */ /* JADX WARNING: Removed duplicated region for block: B:17:0x0034 A[ADDED_TO_REGION, RETURN] */ /* JADX WARNING: Removed duplicated region for block: B:18:0x0035 */ /* JADX WARNING: Removed duplicated region for block: B:23:0x0043 A[SYNTHETIC, Splitter:B:23:0x0043] */ /* JADX WARNING: Removed duplicated region for block: B:30:0x0061 A[Catch:{ all -> 0x0138 }] */ /* JADX WARNING: Removed duplicated region for block: B:38:0x0089 A[Catch:{ all -> 0x0138 }] */ /* JADX WARNING: Removed duplicated region for block: B:46:0x00bb A[Catch:{ all -> 0x0138 }] */ /* JADX WARNING: Removed duplicated region for block: B:58:0x00de */ /* JADX WARNING: Removed duplicated region for block: B:61:0x00f3 */ public final String a(Context context) { boolean z; String str; Object obj; String str2; String str3; String a2; SharedPreferences a3; SharedPreferences a4; SharedPreferences a5; SharedPreferences a6; String str4; String str5 = ""; if (context != null) { try { SharedPreferences a7 = a.a(context); if (a7 != null) { str4 = a7.getString("uabc", str5); if (new JSONObject(str4).optLong("ets") > System.currentTimeMillis()) { z = false; str = null; if (!z || this.b) { return null; } this.b = true; JSONObject jSONObject = new JSONObject(); if (context != null) { try { SharedPreferences a8 = a.a(context); if (a8 != null) { obj = a8.getString("zdata", null); String id = Spy.getID(); jSONObject.put(am.aD, id); jSONObject.put("o_z", obj); if (context != null || (a6 = a.a(context)) == null) { str2 = str5; } else { str2 = a6.getString("oaid", str5); if (d.c(str2)) { str2 = d.a(str2); } } String c2 = d.c(context); jSONObject.put("o_o", str2); jSONObject.put(o.TAG, c2); if (context != null || (a5 = a.a(context)) == null) { str3 = str5; } else { str3 = a5.getString("mac", str5); if (d.c(str3)) { str3 = d.a(str3); } } String b2 = d.b(context); jSONObject.put(am.A, b2); jSONObject.put("o_mc", str3); a(context, jSONObject); jSONObject.put("aaid", d.a(context)); jSONObject.put("uabc", (context != null || (a4 = a.a(context)) == null) ? str5 : a4.getString("uabc", str5)); if (!(context == null || (a3 = a.a(context)) == null)) { str5 = a3.getString("resetToken", str5); } if (!TextUtils.isEmpty(str5)) { jSONObject.put("rt", str5); } a2 = a.a("https://utoken.umeng.com/api/updateZdata/v4", jSONObject.toString()); if (!TextUtils.isEmpty(a2)) { JSONObject jSONObject2 = new JSONObject(a2); if (Boolean.valueOf(jSONObject2.optBoolean("suc")).booleanValue()) { d.f(context, id); d.a(context, b2); d.b(context, c2); str = jSONObject2.optString("aaid"); if (!TextUtils.isEmpty(str)) { d.e(context, str); } String string = jSONObject2.getString("uabc"); if (!TextUtils.isEmpty(string)) { d.d(context, string); } String string2 = jSONObject2.getString("resetToken"); if (!TextUtils.isEmpty(string2)) { d.c(context, string2); } } } this.b = false; return str; } } catch (Throwable unused) { } } obj = str5; String id2 = Spy.getID(); jSONObject.put(am.aD, id2); jSONObject.put("o_z", obj); if (context != null) { } str2 = str5; String c22 = d.c(context); jSONObject.put("o_o", str2); jSONObject.put(o.TAG, c22); if (context != null) { } str3 = str5; String b22 = d.b(context); jSONObject.put(am.A, b22); jSONObject.put("o_mc", str3); a(context, jSONObject); jSONObject.put("aaid", d.a(context)); jSONObject.put("uabc", (context != null || (a4 = a.a(context)) == null) ? str5 : a4.getString("uabc", str5)); str5 = a3.getString("resetToken", str5); if (!TextUtils.isEmpty(str5)) { } a2 = a.a("https://utoken.umeng.com/api/updateZdata/v4", jSONObject.toString()); if (!TextUtils.isEmpty(a2)) { } this.b = false; return str; } z = true; str = null; if (!z) { return null; } this.b = true; JSONObject jSONObject3 = new JSONObject(); if (context != null) { } obj = str5; String id22 = Spy.getID(); jSONObject3.put(am.aD, id22); jSONObject3.put("o_z", obj); if (context != null) { } str2 = str5; String c222 = d.c(context); jSONObject3.put("o_o", str2); jSONObject3.put(o.TAG, c222); if (context != null) { } str3 = str5; String b222 = d.b(context); jSONObject3.put(am.A, b222); jSONObject3.put("o_mc", str3); a(context, jSONObject3); jSONObject3.put("aaid", d.a(context)); jSONObject3.put("uabc", (context != null || (a4 = a.a(context)) == null) ? str5 : a4.getString("uabc", str5)); str5 = a3.getString("resetToken", str5); if (!TextUtils.isEmpty(str5)) { } a2 = a.a("https://utoken.umeng.com/api/updateZdata/v4", jSONObject3.toString()); if (!TextUtils.isEmpty(a2)) { } this.b = false; return str; } } catch (JSONException e) { e.printStackTrace(); } } str4 = str5; if (new JSONObject(str4).optLong("ets") > System.currentTimeMillis()) { } z = true; str = null; if (!z) { } } }