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.netease.nimlib.sdk.avchat.constant.AVChatControlCommand; import com.umeng.analytics.pro.ai; 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 { /* renamed from: c reason: collision with root package name */ public static ZIDManager f14524c; /* renamed from: a reason: collision with root package name */ public boolean f14525a = false; /* renamed from: b reason: collision with root package name */ public boolean f14526b = false; public class a implements Runnable { /* renamed from: a reason: collision with root package name */ public final /* synthetic */ Context f14527a; /* renamed from: b reason: collision with root package name */ public final /* synthetic */ IZIDCompletionCallback f14528b; public a(Context context, IZIDCompletionCallback iZIDCompletionCallback) { this.f14527a = context; this.f14528b = iZIDCompletionCallback; } public void run() { String a2 = ZIDManager.a(ZIDManager.this, this.f14527a); if (TextUtils.isEmpty(a2)) { IZIDCompletionCallback iZIDCompletionCallback = this.f14528b; if (iZIDCompletionCallback != null) { iZIDCompletionCallback.onFailure("1002", "获取zid失败"); return; } return; } IZIDCompletionCallback iZIDCompletionCallback2 = this.f14528b; if (iZIDCompletionCallback2 != null) { iZIDCompletionCallback2.onSuccess(a2); } } } public class b implements Runnable { /* renamed from: a reason: collision with root package name */ public final /* synthetic */ Context f14530a; public b(Context context) { this.f14530a = context; } public void run() { ZIDManager.b(ZIDManager.this, this.f14530a); } } public class c implements Runnable { /* renamed from: a reason: collision with root package name */ public final /* synthetic */ Context f14532a; public c(Context context) { this.f14532a = context; } public void run() { ZIDManager.a(ZIDManager.this, this.f14532a); } } public class d implements Runnable { /* renamed from: a reason: collision with root package name */ public final /* synthetic */ Context f14534a; public d(Context context) { this.f14534a = context; } public void run() { ZIDManager.b(ZIDManager.this, this.f14534a); } } public static /* synthetic */ String a(ZIDManager zIDManager, Context context) { String str = null; if (!zIDManager.f14525a) { zIDManager.f14525a = true; JSONObject jSONObject = new JSONObject(); try { String id = Spy.getID(); jSONObject.put("zdata", id); String c2 = c.c(context); jSONObject.put("mac", c2); String d2 = c.d(context); jSONObject.put("oaid", d2); 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, c2); c.b(context, d2); 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.f14525a = false; } return str; } public static /* synthetic */ String b(ZIDManager zIDManager, Context context) { String str; String str2; SharedPreferences a2; SharedPreferences a3; SharedPreferences a4; SharedPreferences a5; String str3 = null; if (!zIDManager.f14526b) { zIDManager.f14526b = true; JSONObject jSONObject = new JSONObject(); try { Object b2 = c.b(context); String id = Spy.getID(); jSONObject.put("zdata", id); jSONObject.put("old_zdata", b2); String str4 = ""; if (context == null || (a5 = a.a(context)) == null) { str = str4; } else { str = a5.getString("oaid", str4); if (c.c(str)) { str = c.a(str); } } String d2 = c.d(context); jSONObject.put("old_oaid", str); jSONObject.put("oaid", d2); if (context == null || (a4 = a.a(context)) == null) { str2 = str4; } else { str2 = a4.getString("mac", str4); if (c.c(str2)) { str2 = c.a(str2); } } String c2 = c.c(context); jSONObject.put("mac", c2); jSONObject.put("old_mac", str2); zIDManager.a(context, jSONObject); jSONObject.put("aaid", c.a(context)); jSONObject.put("uabc", (context == null || (a3 = a.a(context)) == null) ? str4 : a3.getString("uabc", str4)); if (!(context == null || (a2 = a.a(context)) == null)) { str4 = a2.getString("resetToken", str4); } if (!TextUtils.isEmpty(str4)) { jSONObject.put("resetToken", str4); } String a6 = a.a("https://aaid.umeng.com/api/updateZdata", jSONObject.toString()); if (!TextUtils.isEmpty(a6)) { JSONObject jSONObject2 = new JSONObject(a6); if (Boolean.valueOf(jSONObject2.optBoolean("suc")).booleanValue()) { c.f(context, id); c.a(context, c2); c.b(context, d2); str3 = jSONObject2.optString("aaid"); if (!TextUtils.isEmpty(str3)) { c.e(context, str3); } 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.f14526b = false; } return str3; } public static synchronized ZIDManager getInstance() { ZIDManager zIDManager; synchronized (ZIDManager.class) { if (f14524c == null) { f14524c = new ZIDManager(); } zIDManager = f14524c; } return zIDManager; } public static String getSDKVersion() { return "1.2.3"; } /* 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:0x010a A[SYNTHETIC, Splitter:B:52:0x010a] */ /* JADX WARNING: Removed duplicated region for block: B:67:0x0150 */ /* JADX WARNING: Removed duplicated region for block: B:68:0x0152 */ /* JADX WARNING: Removed duplicated region for block: B:71:0x016a */ public final JSONObject a(Context context, JSONObject jSONObject) { Object obj; int i; Object obj2; String obj3; SharedPreferences a2; Object obj4; Object obj5; Object obj6; SharedPreferences a3; Class<?> cls; Method declaredMethod; Object invoke; Locale locale; Method declaredMethod2; String str = ""; jSONObject.putOpt("zdata_ver", Spy.getVersion()); try { Class<?> cls2 = Class.forName("com.umeng.commonsdk.statistics.common.DeviceConfig"); if (!(cls2 == null || (declaredMethod2 = cls2.getDeclaredMethod("getAndroidId", Context.class)) == null)) { declaredMethod2.setAccessible(true); Object invoke2 = declaredMethod2.invoke(cls2, context); if (invoke2 != null && (invoke2 instanceof String)) { obj = (String) invoke2; 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(ai.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(ai.M, Integer.valueOf(i)); jSONObject.putOpt("model", Build.MODEL); cls = Class.forName("com.umeng.commonsdk.statistics.common.DeviceConfig"); if (!(cls == null || (declaredMethod = cls.getDeclaredMethod("getImeiNew", Context.class)) == null)) { declaredMethod.setAccessible(true); invoke = declaredMethod.invoke(cls, context); if (invoke != null && (invoke instanceof String)) { obj2 = (String) invoke; jSONObject.putOpt("imei", obj2); Method declaredMethod3 = Build.class.getDeclaredMethod("getString", String.class); declaredMethod3.setAccessible(true); obj3 = declaredMethod3.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 & AVChatControlCommand.UNKNOWN)); } obj3 = stringBuffer.toString(); } catch (Throwable unused3) { obj3 = str; } } } catch (Exception unused4) { } } jSONObject.putOpt("hostname", obj3); jSONObject.putOpt("sdk_version", "1.2.3"); jSONObject.putOpt(ai.o, context != null ? null : context.getPackageName()); jSONObject.putOpt(ai.u, "Android"); a2 = a.a(context); if (a2 != null) { str = a2.getString("uuid", str); } jSONObject.putOpt("uuid", 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(ai.O, obj6); if (!(context == null || (a3 = a.a(context)) == null)) { obj7 = a3.getString("appkey", null); } jSONObject.putOpt("appkey", obj7); return jSONObject; } } obj2 = str; jSONObject.putOpt("imei", obj2); Method declaredMethod32 = Build.class.getDeclaredMethod("getString", String.class); declaredMethod32.setAccessible(true); obj3 = declaredMethod32.invoke(null, "net.hostname").toString(); if (obj3 != null) { } jSONObject.putOpt("hostname", obj3); jSONObject.putOpt("sdk_version", "1.2.3"); jSONObject.putOpt(ai.o, context != null ? null : context.getPackageName()); jSONObject.putOpt(ai.u, "Android"); a2 = a.a(context); if (a2 != null) { } jSONObject.putOpt("uuid", 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(ai.O, obj6); obj7 = a3.getString("appkey", null); jSONObject.putOpt("appkey", obj7); return jSONObject; } } i = 8; jSONObject.putOpt(ai.M, Integer.valueOf(i)); jSONObject.putOpt("model", Build.MODEL); cls = Class.forName("com.umeng.commonsdk.statistics.common.DeviceConfig"); declaredMethod.setAccessible(true); invoke = declaredMethod.invoke(cls, context); obj2 = (String) invoke; jSONObject.putOpt("imei", obj2); Method declaredMethod322 = Build.class.getDeclaredMethod("getString", String.class); declaredMethod322.setAccessible(true); obj3 = declaredMethod322.invoke(null, "net.hostname").toString(); if (obj3 != null) { } jSONObject.putOpt("hostname", obj3); jSONObject.putOpt("sdk_version", "1.2.3"); jSONObject.putOpt(ai.o, context != null ? null : context.getPackageName()); jSONObject.putOpt(ai.u, "Android"); a2 = a.a(context); if (a2 != null) { } jSONObject.putOpt("uuid", 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(ai.O, obj6); obj7 = a3.getString("appkey", null); jSONObject.putOpt("appkey", obj7); 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(ai.y, Build.VERSION.RELEASE); Object obj72 = null; if (context != null) { } i = 8; jSONObject.putOpt(ai.M, Integer.valueOf(i)); jSONObject.putOpt("model", Build.MODEL); try { cls = Class.forName("com.umeng.commonsdk.statistics.common.DeviceConfig"); declaredMethod.setAccessible(true); invoke = declaredMethod.invoke(cls, context); obj2 = (String) invoke; } catch (Throwable unused6) { } jSONObject.putOpt("imei", obj2); Method declaredMethod3222 = Build.class.getDeclaredMethod("getString", String.class); declaredMethod3222.setAccessible(true); obj3 = declaredMethod3222.invoke(null, "net.hostname").toString(); if (obj3 != null) { } jSONObject.putOpt("hostname", obj3); jSONObject.putOpt("sdk_version", "1.2.3"); jSONObject.putOpt(ai.o, context != null ? null : context.getPackageName()); jSONObject.putOpt(ai.u, "Android"); a2 = a.a(context); if (a2 != null) { } jSONObject.putOpt("uuid", str); jSONObject.putOpt("source_id", "umeng"); try { obj4 = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; } catch (Exception e2) { e2.printStackTrace(); obj4 = null; } jSONObject.putOpt("app_version", obj4); try { obj5 = context.getResources().getString(context.getPackageManager().getPackageInfo(context.getPackageName(), 0).applicationInfo.labelRes); } catch (Exception e3) { e3.printStackTrace(); obj5 = null; } jSONObject.putOpt("app_name", obj5); try { obj6 = context.getResources().getConfiguration().locale.getCountry(); } catch (Exception e4) { e4.printStackTrace(); obj6 = null; } jSONObject.putOpt(ai.O, obj6); obj72 = a3.getString("appkey", null); jSONObject.putOpt("appkey", obj72); return jSONObject; } public synchronized String getZID(Context context) { SharedPreferences a2; if (context == null) { return ""; } Context applicationContext = context.getApplicationContext(); String a3 = c.a(applicationContext); if (TextUtils.isEmpty(a3)) { b.a(new c(applicationContext)); return ""; } if (!((applicationContext == null || (a2 = a.a(applicationContext)) == null) ? "" : a2.getString("zdata", null)).equals(Spy.getID())) { b.a(new d(applicationContext)); } return a3; } 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(); } } } } }