package com.umeng.umzid; import android.content.Context; import android.content.SharedPreferences; import android.content.res.Configuration; import android.os.Build; import android.os.Environment; import android.provider.Settings; import android.text.TextUtils; import com.umeng.analytics.pro.ak; import java.lang.reflect.Method; import java.security.MessageDigest; import java.util.Calendar; import java.util.Locale; import java.util.UUID; import org.json.JSONObject; public class ZIDManager { public static ZIDManager c; public boolean a = false; public boolean b = false; 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; } /* JADX WARNING: Removed duplicated region for block: B:39:0x00b0 */ /* JADX WARNING: Removed duplicated region for block: B:42:0x00c3 */ public void run() { String str; String str2; String str3; String a2; SharedPreferences a3; SharedPreferences a4; SharedPreferences a5; SharedPreferences a6; ZIDManager zIDManager = ZIDManager.this; Context context = this.a; if (!zIDManager.b) { zIDManager.b = true; JSONObject jSONObject = new JSONObject(); String str4 = ""; if (context != null) { try { SharedPreferences a7 = a.a(context); if (a7 != null) { str = a7.getString("zdata", null); String id = Spy.getID(); jSONObject.put("zdata", id); jSONObject.put("old_zdata", str); if (context != null || (a6 = a.a(context)) == null) { str2 = str4; } else { str2 = a6.getString("oaid", str4); if (c.c(str2)) { str2 = c.a(str2); } } String c = c.c(context); jSONObject.put("old_oaid", str2); jSONObject.put("oaid", c); if (context != null || (a5 = a.a(context)) == null) { str3 = str4; } else { str3 = a5.getString("mac", str4); if (c.c(str3)) { str3 = c.a(str3); } } String b2 = c.b(context); jSONObject.put("mac", b2); jSONObject.put("old_mac", str3); zIDManager.a(context, jSONObject); jSONObject.put("aaid", c.a(context)); jSONObject.put("uabc", (context != null || (a4 = a.a(context)) == null) ? str4 : a4.getString("uabc", str4)); if (!(context == null || (a3 = a.a(context)) == null)) { str4 = a3.getString("resetToken", str4); } if (!TextUtils.isEmpty(str4)) { jSONObject.put("resetToken", str4); } a2 = a.a("https://aaid.umeng.com/api/updateZdata", jSONObject.toString()); if (!TextUtils.isEmpty(a2)) { JSONObject jSONObject2 = new JSONObject(a2); if (Boolean.valueOf(jSONObject2.optBoolean("suc")).booleanValue()) { c.f(context, id); c.a(context, b2); c.b(context, c); String optString = jSONObject2.optString("aaid"); if (!TextUtils.isEmpty(optString)) { c.e(context, optString); } String string = jSONObject2.getString("uabc"); if (!TextUtils.isEmpty(string)) { c.d(context, string); } String string2 = jSONObject2.getString("resetToken"); if (!TextUtils.isEmpty(string2)) { c.c(context, string2); } } } zIDManager.b = false; } } catch (Throwable unused) { } } str = str4; String id2 = Spy.getID(); jSONObject.put("zdata", id2); jSONObject.put("old_zdata", str); if (context != null) { } str2 = str4; String c2 = c.c(context); jSONObject.put("old_oaid", str2); jSONObject.put("oaid", c2); if (context != null) { } str3 = str4; String b22 = c.b(context); jSONObject.put("mac", b22); jSONObject.put("old_mac", str3); zIDManager.a(context, jSONObject); jSONObject.put("aaid", c.a(context)); jSONObject.put("uabc", (context != null || (a4 = a.a(context)) == null) ? str4 : a4.getString("uabc", str4)); str4 = a3.getString("resetToken", str4); if (!TextUtils.isEmpty(str4)) { } a2 = a.a("https://aaid.umeng.com/api/updateZdata", jSONObject.toString()); if (!TextUtils.isEmpty(a2)) { } zIDManager.b = false; } } } 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("zdata", id); String b2 = c.b(context); jSONObject.put("mac", b2); String c2 = c.c(context); jSONObject.put("oaid", c2); zIDManager.a(context, jSONObject); String a2 = a.a("https://aaid.umeng.com/api/postZdata", jSONObject.toString()); if (!TextUtils.isEmpty(a2)) { JSONObject jSONObject2 = new JSONObject(a2); if (Boolean.valueOf(jSONObject2.optBoolean("suc")).booleanValue()) { c.f(context, id); c.a(context, b2); c.b(context, c2); str = jSONObject2.optString("aaid"); if (!TextUtils.isEmpty(str)) { c.e(context, str); } String string = jSONObject2.getString("uabc"); if (!TextUtils.isEmpty(string)) { c.d(context, string); } String string2 = jSONObject2.getString("resetToken"); if (!TextUtils.isEmpty(string2)) { c.c(context, string2); } } } } catch (Throwable unused) { } zIDManager.a = false; } return str; } public static synchronized ZIDManager getInstance() { ZIDManager zIDManager; synchronized (ZIDManager.class) { if (c == null) { c = new ZIDManager(); } zIDManager = c; } return zIDManager; } public static String getSDKVersion() { return "1.4.1"; } public synchronized String getZID(Context context) { if (context == null) { return ""; } Context applicationContext = context.getApplicationContext(); String a2 = c.a(applicationContext); if (!TextUtils.isEmpty(a2)) { return a2; } b.a(new c(applicationContext)); return ""; } public synchronized void init(Context context, String str, IZIDCompletionCallback iZIDCompletionCallback) { SharedPreferences a2; SharedPreferences.Editor edit; 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 = c.a(applicationContext); if (a3 == null || TextUtils.isEmpty(a3)) { b.a(new a(applicationContext, iZIDCompletionCallback)); } else { b.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:25:0x007b A[SYNTHETIC, Splitter:B:25:0x007b] */ /* JADX WARNING: Removed duplicated region for block: B:52:0x0108 A[SYNTHETIC, Splitter:B:52:0x0108] */ /* JADX WARNING: Removed duplicated region for block: B:67:0x014e */ /* JADX WARNING: Removed duplicated region for block: B:68:0x0150 */ /* JADX WARNING: Removed duplicated region for block: B:71:0x0168 */ /* JADX WARNING: Removed duplicated region for block: B:72:0x016d */ 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("zdata_ver", 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("android_id", obj); long j = 0; String externalStorageState = Environment.getExternalStorageState(); if ((!"mounted".equals(externalStorageState) || "mounted_ro".equals(externalStorageState)) && Build.VERSION.SDK_INT >= 9) { j = Environment.getExternalStorageDirectory().getFreeSpace(); } jSONObject.putOpt("storage", Long.valueOf(j)); jSONObject.putOpt(ak.y, 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() / 3600000; jSONObject.putOpt(ak.M, Integer.valueOf(i)); jSONObject.putOpt("model", 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("imei", 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 & 255)); } obj3 = stringBuffer.toString(); } catch (Throwable unused3) { obj3 = str; } } } catch (Exception unused4) { } } jSONObject.putOpt("hostname", obj3); jSONObject.putOpt("sdk_version", "1.4.1"); jSONObject.putOpt("package_name", context != null ? null : context.getPackageName()); jSONObject.putOpt("sdk_type", "Android"); SharedPreferences a3 = a.a(context); jSONObject.putOpt("uuid", a3 == null ? a3.getString("uuid", str) : str); jSONObject.putOpt("source_id", "umeng"); obj4 = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; jSONObject.putOpt("app_version", obj4); obj5 = context.getResources().getString(context.getPackageManager().getPackageInfo(context.getPackageName(), 0).applicationInfo.labelRes); jSONObject.putOpt("app_name", obj5); obj6 = context.getResources().getConfiguration().locale.getCountry(); jSONObject.putOpt(ak.O, obj6); if (!(context == null || (a2 = a.a(context)) == null)) { obj7 = a2.getString("appkey", null); } jSONObject.putOpt("appkey", 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("gaid", str); return jSONObject; } } obj2 = str; jSONObject.putOpt("imei", obj2); Method declaredMethod42 = Build.class.getDeclaredMethod("getString", String.class); declaredMethod42.setAccessible(true); obj3 = declaredMethod42.invoke(null, "net.hostname").toString(); if (obj3 != null) { } jSONObject.putOpt("hostname", obj3); jSONObject.putOpt("sdk_version", "1.4.1"); if (context != null) { } jSONObject.putOpt("package_name", context != null ? null : context.getPackageName()); jSONObject.putOpt("sdk_type", "Android"); SharedPreferences a32 = a.a(context); jSONObject.putOpt("uuid", a32 == null ? a32.getString("uuid", str) : str); jSONObject.putOpt("source_id", "umeng"); obj4 = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; jSONObject.putOpt("app_version", obj4); obj5 = context.getResources().getString(context.getPackageManager().getPackageInfo(context.getPackageName(), 0).applicationInfo.labelRes); jSONObject.putOpt("app_name", obj5); obj6 = context.getResources().getConfiguration().locale.getCountry(); jSONObject.putOpt(ak.O, obj6); obj7 = a2.getString("appkey", null); jSONObject.putOpt("appkey", obj7); cls = Class.forName("com.umeng.commonsdk.statistics.common.DeviceConfig"); declaredMethod.setAccessible(true); invoke = declaredMethod.invoke(cls, context); str = (String) invoke; jSONObject.putOpt("gaid", str); return jSONObject; } } i = 8; jSONObject.putOpt(ak.M, Integer.valueOf(i)); jSONObject.putOpt("model", Build.MODEL); cls2 = Class.forName("com.umeng.commonsdk.statistics.common.DeviceConfig"); declaredMethod2.setAccessible(true); invoke2 = declaredMethod2.invoke(cls2, context); obj2 = (String) invoke2; jSONObject.putOpt("imei", obj2); Method declaredMethod422 = Build.class.getDeclaredMethod("getString", String.class); declaredMethod422.setAccessible(true); obj3 = declaredMethod422.invoke(null, "net.hostname").toString(); if (obj3 != null) { } jSONObject.putOpt("hostname", obj3); jSONObject.putOpt("sdk_version", "1.4.1"); if (context != null) { } jSONObject.putOpt("package_name", context != null ? null : context.getPackageName()); jSONObject.putOpt("sdk_type", "Android"); SharedPreferences a322 = a.a(context); jSONObject.putOpt("uuid", a322 == null ? a322.getString("uuid", str) : str); jSONObject.putOpt("source_id", "umeng"); obj4 = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; jSONObject.putOpt("app_version", obj4); obj5 = context.getResources().getString(context.getPackageManager().getPackageInfo(context.getPackageName(), 0).applicationInfo.labelRes); jSONObject.putOpt("app_name", obj5); obj6 = context.getResources().getConfiguration().locale.getCountry(); jSONObject.putOpt(ak.O, obj6); obj7 = a2.getString("appkey", null); jSONObject.putOpt("appkey", obj7); cls = Class.forName("com.umeng.commonsdk.statistics.common.DeviceConfig"); declaredMethod.setAccessible(true); invoke = declaredMethod.invoke(cls, context); str = (String) invoke; jSONObject.putOpt("gaid", str); return jSONObject; } } } catch (Throwable unused5) { } obj = str; jSONObject.putOpt("android_id", obj); long j2 = 0; String externalStorageState2 = Environment.getExternalStorageState(); j2 = Environment.getExternalStorageDirectory().getFreeSpace(); jSONObject.putOpt("storage", Long.valueOf(j2)); jSONObject.putOpt(ak.y, Build.VERSION.RELEASE); Object obj72 = null; if (context != null) { } i = 8; jSONObject.putOpt(ak.M, Integer.valueOf(i)); jSONObject.putOpt("model", 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("imei", obj2); Method declaredMethod4222 = Build.class.getDeclaredMethod("getString", String.class); declaredMethod4222.setAccessible(true); obj3 = declaredMethod4222.invoke(null, "net.hostname").toString(); if (obj3 != null) { } jSONObject.putOpt("hostname", obj3); jSONObject.putOpt("sdk_version", "1.4.1"); if (context != null) { } jSONObject.putOpt("package_name", context != null ? null : context.getPackageName()); jSONObject.putOpt("sdk_type", "Android"); SharedPreferences a3222 = a.a(context); jSONObject.putOpt("uuid", a3222 == null ? a3222.getString("uuid", str) : str); jSONObject.putOpt("source_id", "umeng"); try { obj4 = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; } catch (Exception e) { e.printStackTrace(); obj4 = null; } jSONObject.putOpt("app_version", obj4); try { obj5 = context.getResources().getString(context.getPackageManager().getPackageInfo(context.getPackageName(), 0).applicationInfo.labelRes); } catch (Exception e2) { e2.printStackTrace(); obj5 = null; } jSONObject.putOpt("app_name", obj5); try { obj6 = context.getResources().getConfiguration().locale.getCountry(); } catch (Exception e3) { e3.printStackTrace(); obj6 = null; } jSONObject.putOpt(ak.O, obj6); obj72 = a2.getString("appkey", null); jSONObject.putOpt("appkey", 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("gaid", str); return jSONObject; } }