package com.xiaomi.push.service; import android.content.Context; import android.content.SharedPreferences; import android.content.pm.PackageInfo; import android.os.Build; import android.text.TextUtils; import com.huawei.hms.support.hianalytics.HiAnalyticsConstant; import com.just.agentweb.DefaultWebClient; import com.meizu.cloud.pushsdk.constants.PushConstants; import com.xiaomi.channel.commonutils.logger.b; import com.xiaomi.mipush.sdk.Constants; import com.xiaomi.push.ab; import com.xiaomi.push.au; import com.xiaomi.push.ax; import com.xiaomi.push.az; import com.xiaomi.push.bf; import com.xiaomi.push.fv; import com.xiaomi.push.i; import com.xiaomi.push.o; import java.util.TreeMap; import org.json.JSONObject; public class l { private static k a; /* renamed from: a reason: collision with other field name */ private static a f909a; public interface a { void a(); } public static synchronized k a(Context context) { synchronized (l.class) { k kVar = a; if (kVar != null) { return kVar; } SharedPreferences sharedPreferences = context.getSharedPreferences("mipush_account", 0); String string = sharedPreferences.getString("uuid", null); String string2 = sharedPreferences.getString("token", null); String string3 = sharedPreferences.getString("security", null); String string4 = sharedPreferences.getString("app_id", null); String string5 = sharedPreferences.getString("app_token", null); String string6 = sharedPreferences.getString(Constants.PACKAGE_NAME, null); String string7 = sharedPreferences.getString("device_id", null); int i = sharedPreferences.getInt("env_type", 1); if (!TextUtils.isEmpty(string7) && i.m383a(string7)) { string7 = i.k(context); sharedPreferences.edit().putString("device_id", string7).commit(); } if (TextUtils.isEmpty(string) || TextUtils.isEmpty(string2) || TextUtils.isEmpty(string3)) { return null; } String k = i.k(context); if (!"com.xiaomi.xmsf".equals(context.getPackageName()) && !TextUtils.isEmpty(k) && !TextUtils.isEmpty(string7) && !string7.equals(k)) { b.m4a("read_phone_state permission changes."); } k kVar2 = new k(string, string2, string3, string4, string5, string6, i); a = kVar2; return kVar2; } } /* JADX WARNING: Removed duplicated region for block: B:13:0x006b */ /* JADX WARNING: Removed duplicated region for block: B:16:0x007a */ /* JADX WARNING: Removed duplicated region for block: B:19:0x0085 */ /* JADX WARNING: Removed duplicated region for block: B:22:0x008e */ /* JADX WARNING: Removed duplicated region for block: B:25:0x0097 */ /* JADX WARNING: Removed duplicated region for block: B:33:0x00b8 */ /* JADX WARNING: Removed duplicated region for block: B:34:0x00bf */ /* JADX WARNING: Removed duplicated region for block: B:37:0x00e8 */ /* JADX WARNING: Removed duplicated region for block: B:50:0x0159 */ /* JADX WARNING: Removed duplicated region for block: B:53:0x016c */ /* JADX WARNING: Removed duplicated region for block: B:56:0x01b4 */ /* JADX WARNING: Removed duplicated region for block: B:59:0x01be */ public static synchronized k a(Context context, String str, String str2, String str3) { String str4; String c; String b; PackageInfo packageInfo; int a2; String n; ax a3; String str5; synchronized (l.class) { TreeMap treeMap = new TreeMap(); String a4 = i.a(context, false); b.m4a("account register:" + a4); treeMap.put("devid", a4); treeMap.put("devid1", i.a(context)); k kVar = a; if (kVar != null && !TextUtils.isEmpty(kVar.f908a)) { treeMap.put("uuid", a.f908a); int lastIndexOf = a.f908a.lastIndexOf("/"); if (lastIndexOf != -1) { str4 = a.f908a.substring(lastIndexOf + 1); au.a(context).a(treeMap); c = i.c(context); if (c != null) { treeMap.put("vdevid", c); } b = i.b(context); if (!TextUtils.isEmpty(b)) { treeMap.put("gaid", b); } if (m615a(context)) { str2 = "1000271"; } if (m615a(context)) { str3 = "420100086271"; } if (m615a(context)) { str = "com.xiaomi.xmsf"; } treeMap.put(HiAnalyticsConstant.HaKey.BI_KEY_APPID, str2); treeMap.put("apptoken", str3); packageInfo = context.getPackageManager().getPackageInfo(str, 16384); treeMap.put("appversion", packageInfo == null ? String.valueOf(packageInfo.versionCode) : PushConstants.PUSH_TYPE_NOTIFY); treeMap.put("sdkversion", Integer.toString(30700)); treeMap.put("packagename", str); treeMap.put("model", Build.MODEL); treeMap.put("board", Build.BOARD); if (!com.xiaomi.push.l.d()) { String str6 = ""; String f = i.f(context); if (!TextUtils.isEmpty(f)) { str6 = str6 + bf.a(f); } String h = i.h(context); if (!TextUtils.isEmpty(str6) && !TextUtils.isEmpty(h)) { str6 = str6 + Constants.ACCEPT_TIME_SEPARATOR_SP + h; } if (!TextUtils.isEmpty(str6)) { treeMap.put(Constants.EXTRA_KEY_IMEI_MD5, str6); } } treeMap.put("os", Build.VERSION.RELEASE + Constants.ACCEPT_TIME_SEPARATOR_SERVER + Build.VERSION.INCREMENTAL); a2 = i.a(); if (a2 >= 0) { treeMap.put("space_id", Integer.toString(a2)); } n = i.n(context); if (!TextUtils.isEmpty(n)) { treeMap.put("mac_address", bf.a(n)); } treeMap.put("android_id", i.e(context)); treeMap.put(Constants.PHONE_BRAND, Build.BRAND + ""); treeMap.put("ram", i.m384b()); treeMap.put("rom", i.c()); a3 = az.a(context, m613a(context), treeMap); str5 = ""; if (a3 != null) { str5 = a3.a(); } if (!TextUtils.isEmpty(str5)) { JSONObject jSONObject = new JSONObject(str5); if (jSONObject.getInt(com.heytap.mcssdk.a.a.j) == 0) { JSONObject jSONObject2 = jSONObject.getJSONObject("data"); String string = jSONObject2.getString("ssecurity"); String string2 = jSONObject2.getString("token"); String string3 = jSONObject2.getString("userId"); if (TextUtils.isEmpty(str4)) { str4 = "an" + bf.a(6); } k kVar2 = new k(string3 + "@xiaomi.com/" + str4, string2, string, str2, str3, str, ab.a()); a(context, kVar2); i.a(context, jSONObject2.optString("vdevid")); a = kVar2; return kVar2; } o.a(context, jSONObject.getInt(com.heytap.mcssdk.a.a.j), jSONObject.optString(com.heytap.mcssdk.a.a.h)); b.m4a(str5); } return null; } } str4 = null; au.a(context).a(treeMap); c = i.c(context); if (c != null) { } b = i.b(context); if (!TextUtils.isEmpty(b)) { } if (m615a(context)) { } if (m615a(context)) { } if (m615a(context)) { } treeMap.put(HiAnalyticsConstant.HaKey.BI_KEY_APPID, str2); treeMap.put("apptoken", str3); try { packageInfo = context.getPackageManager().getPackageInfo(str, 16384); } catch (Exception e) { b.a(e); packageInfo = null; } treeMap.put("appversion", packageInfo == null ? String.valueOf(packageInfo.versionCode) : PushConstants.PUSH_TYPE_NOTIFY); treeMap.put("sdkversion", Integer.toString(30700)); treeMap.put("packagename", str); treeMap.put("model", Build.MODEL); treeMap.put("board", Build.BOARD); if (!com.xiaomi.push.l.d()) { } treeMap.put("os", Build.VERSION.RELEASE + Constants.ACCEPT_TIME_SEPARATOR_SERVER + Build.VERSION.INCREMENTAL); a2 = i.a(); if (a2 >= 0) { } n = i.n(context); if (!TextUtils.isEmpty(n)) { } treeMap.put("android_id", i.e(context)); treeMap.put(Constants.PHONE_BRAND, Build.BRAND + ""); treeMap.put("ram", i.m384b()); treeMap.put("rom", i.c()); a3 = az.a(context, m613a(context), treeMap); str5 = ""; if (a3 != null) { } if (!TextUtils.isEmpty(str5)) { } return null; } } /* renamed from: a reason: collision with other method in class */ public static String m613a(Context context) { StringBuilder sb; String str; String a2 = a.a(context).a(); if (ab.b()) { sb = new StringBuilder(); sb.append(DefaultWebClient.HTTP_SCHEME); sb.append(fv.b); str = ":9085"; } else if (o.China.name().equals(a2)) { sb = new StringBuilder(); str = "https://cn.register.xmpush.xiaomi.com"; } else if (o.Global.name().equals(a2)) { sb = new StringBuilder(); str = "https://register.xmpush.global.xiaomi.com"; } else if (o.Europe.name().equals(a2)) { sb = new StringBuilder(); str = "https://fr.register.xmpush.global.xiaomi.com"; } else if (o.Russia.name().equals(a2)) { sb = new StringBuilder(); str = "https://ru.register.xmpush.global.xiaomi.com"; } else if (o.India.name().equals(a2)) { sb = new StringBuilder(); str = "https://idmb.register.xmpush.global.xiaomi.com"; } else { sb = new StringBuilder(); sb.append(DefaultWebClient.HTTPS_SCHEME); str = ab.m62a() ? "sandbox.xmpush.xiaomi.com" : "register.xmpush.xiaomi.com"; } sb.append(str); sb.append("/pass/v2/register"); return sb.toString(); } public static void a() { a aVar = f909a; if (aVar != null) { aVar.a(); } } /* renamed from: a reason: collision with other method in class */ public static void m614a(Context context) { context.getSharedPreferences("mipush_account", 0).edit().clear().commit(); a = null; a(); } public static void a(Context context, k kVar) { SharedPreferences.Editor edit = context.getSharedPreferences("mipush_account", 0).edit(); edit.putString("uuid", kVar.f908a); edit.putString("security", kVar.c); edit.putString("token", kVar.b); edit.putString("app_id", kVar.f2002d); edit.putString(Constants.PACKAGE_NAME, kVar.f); edit.putString("app_token", kVar.e); edit.putString("device_id", i.k(context)); edit.putInt("env_type", kVar.a); edit.commit(); a(); } public static void a(a aVar) { f909a = aVar; } /* renamed from: a reason: collision with other method in class */ private static boolean m615a(Context context) { return context.getPackageName().equals("com.xiaomi.xmsf"); } }