package cn.jiguang.au; import android.content.Context; import android.content.SharedPreferences; import android.content.pm.ApplicationInfo; import android.text.TextUtils; import cn.jiguang.ax.d; import cn.jiguang.ax.f; import cn.jiguang.ax.h; import cn.jiguang.ax.i; import cn.jiguang.dy.b; import cn.jiguang.internal.JConstants; import java.io.File; import org.json.JSONArray; import org.json.JSONObject; public class c { /* renamed from: a reason: collision with root package name */ private static final String f13380a = "https://ce3e75d5.jpush.cn/wi/cjc4sa"; /* renamed from: b reason: collision with root package name */ private static final String f13381b = "https://ce3e75d5.jpush.cn/wi/d8n3hj"; /* renamed from: c reason: collision with root package name */ private static c f13382c; /* renamed from: d reason: collision with root package name */ private boolean f13383d = true; /* renamed from: e reason: collision with root package name */ private String f13384e = "I7MUZXCPZWRFZAJS"; /* renamed from: f reason: collision with root package name */ private String f13385f = "CBDHJXMDDVXH8THW"; public class a implements Runnable { /* renamed from: b reason: collision with root package name */ private int f13387b; /* renamed from: c reason: collision with root package name */ private String f13388c; /* renamed from: d reason: collision with root package name */ private Context f13389d; /* renamed from: e reason: collision with root package name */ private b.a f13390e; public a(Context context, int i10, String str, b.a aVar) { this.f13389d = context; this.f13387b = i10; this.f13388c = str; this.f13390e = aVar; } public void run() { try { if (TextUtils.isEmpty(this.f13388c)) { this.f13388c = c.this.f13383d ? c.f13381b : c.f13380a; } if (f.c() && !TextUtils.isEmpty(f.d())) { this.f13388c = f.d(); } File a14 = c.this.a((c) this.f13389d, (Context) this.f13387b, (int) this.f13388c); if (a14 == null) { cn.jiguang.aw.b.b("UPM", "pluginFile is null"); } b.a aVar = this.f13390e; if (aVar == null || aVar.a(a14)) { c.this.a((c) this.f13389d, (Context) this.f13387b, (int) System.currentTimeMillis()); } } catch (Throwable th3) { cn.jiguang.aw.b.e("UPM", "UpdateAction failed:" + th3.getMessage()); } } } private c() { } public static c a() { if (f13382c == null) { synchronized (c.class) { if (f13382c == null) { f13382c = new c(); } } } return f13382c; } /* JADX WARNING: Removed duplicated region for block: B:15:0x00a7 */ /* JADX WARNING: Removed duplicated region for block: B:17:0x00ad */ private File a(Context context, int i10, int i14, String str) { JSONObject jSONObject; String str2; int i15; cn.jiguang.av.a aVar; cn.jiguang.dy.c cVar; File a14; String str3; Throwable th3; File file = null; try { JSONObject jSONObject2 = new JSONObject(str); int i16 = jSONObject2.getInt("code"); if (i16 != 0) { cn.jiguang.aw.b.f("UPM", "dealUif ERR:" + i16); cn.jiguang.aw.b.f("UPM", "dealUif ERR:" + jSONObject2.getString("message")); cn.jiguang.dy.c.a().a(context, i10, i14, cn.jiguang.av.a.f13397g, 2, jSONObject2.getString("message")); return null; } jSONObject = jSONObject2.getJSONArray("data").optJSONObject(0); if (jSONObject == null) { try { cn.jiguang.dy.c.a().a(context, i10, i14, cn.jiguang.av.a.f13397g, 2, "reponseData is empty"); } catch (Throwable th4) { th3 = th4; } } if (jSONObject != null) { cn.jiguang.aw.b.f("UPM", "dealUif ERR"); return null; } cn.jiguang.av.c a15 = cn.jiguang.av.c.a(jSONObject); if (a15 != null) { int i17 = a15.f13430q; cn.jiguang.dy.c.a().a(context, a15.f13438y); cn.jiguang.dy.c.a().b(context, a15.f13439z); if (i17 == 2) { str3 = "l is newest."; } else if (i17 == 1) { str3 = "p not exist."; } else { if (i17 == 3) { c(context, i10); a.a(context, i10, "", false); } else if (i17 != 0) { cn.jiguang.aw.b.e("UPM", "p status is :" + i17); } else if (a(a15, context)) { cn.jiguang.dy.c a16 = cn.jiguang.dy.c.a(); cn.jiguang.av.a aVar2 = cn.jiguang.av.a.f13396f; a16.a(context, i10, i14, aVar2, 0, null); cn.jiguang.dy.c a17 = cn.jiguang.dy.c.a(); cn.jiguang.av.a aVar3 = cn.jiguang.av.a.f13398h; a17.a(context, i10, i14, aVar3, 0, null); if (TextUtils.isEmpty(a15.f13431r)) { cn.jiguang.aw.b.b("UPM", "p:" + i10 + " du is empty"); cn.jiguang.dy.c.a().a(context, i10, i14, aVar2, 2, "p:" + i10 + " du is empty"); cn.jiguang.dy.c.a().a(context, i10, i14, aVar3, 2, "p:" + i10 + " du is empty"); return null; } a14 = a(context, a15); if (a14 == null || !a14.exists()) { cn.jiguang.dy.c.a().a(context, i10, i14, aVar2, 2, "update plugin failed"); } file = a14; } if (i17 <= 3 || i17 < 0) { cVar = cn.jiguang.dy.c.a(); aVar = cn.jiguang.av.a.f13397g; i15 = 2; str2 = "unknown status " + i17; } else { cVar = cn.jiguang.dy.c.a(); aVar = cn.jiguang.av.a.f13397g; i15 = 1; str2 = null; } } cn.jiguang.aw.b.b("UPM", str3); a14 = a.a(context, a15, true); file = a14; if (i17 <= 3) { } cVar = cn.jiguang.dy.c.a(); aVar = cn.jiguang.av.a.f13397g; i15 = 2; str2 = "unknown status " + i17; } else { cn.jiguang.aw.b.b("UPM", "dUif error:" + str); cVar = cn.jiguang.dy.c.a(); aVar = cn.jiguang.av.a.f13397g; i15 = 2; str2 = "parsePluginInfo failed"; } cVar.a(context, i10, i14, aVar, i15, str2); return file; } catch (Throwable th5) { th3 = th5; jSONObject = null; cn.jiguang.aw.b.f("UPM", "dealUif e:" + th3); cn.jiguang.dy.c.a().a(context, i10, i14, cn.jiguang.av.a.f13397g, 2, th3.getMessage()); if (jSONObject != null) { } } } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private File a(Context context, int i10, String str) { StringBuilder sb3; int i14; Throwable th3; StringBuilder sb4; cn.jiguang.av.a aVar; long a14; String a15; String b14; String str2; String charSequence; JSONObject a16; JSONObject jSONObject; int i15 = i10; String str3 = " u finish"; try { cn.jiguang.aw.b.b("UPM", "u p:" + i15 + ",url:" + str); int a17 = a(context, i10); try { JSONObject jSONObject2 = new JSONObject(); jSONObject2.put(cn.jiguang.dy.a.f14217h, i15); jSONObject2.put(cn.jiguang.dy.a.f14218i, a17); String a18 = a.a(i15, 4); if (!TextUtils.isEmpty(a18)) { try { jSONObject2.put(cn.jiguang.dy.a.f14219j, Integer.parseInt(a18)); cn.jiguang.dy.c a19 = cn.jiguang.dy.c.a(); aVar = cn.jiguang.av.a.f13397g; a19.a(context, i10, a17, aVar, 0, null); JSONArray jSONArray = new JSONArray(); jSONArray.put(jSONObject2); a14 = f.a(context); a15 = h.a(context); b14 = h.b(context); str2 = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; ApplicationInfo applicationInfo = context.getApplicationInfo(); charSequence = applicationInfo != null ? context.getPackageManager().getApplicationLabel(applicationInfo).toString() : ""; a16 = cn.jiguang.ax.a.a(context); if (a16 == null) { a16 = null; } jSONObject = new JSONObject(); try { jSONObject.put(cn.jiguang.dy.a.f14220k, jSONArray); } catch (Throwable th4) { th3 = th4; a17 = a17; i14 = a17; try { cn.jiguang.aw.b.f("UPM", "sU error:" + th3.getMessage()); cn.jiguang.dy.c.a().a(context, i10, i14, cn.jiguang.av.a.f13397g, 2, th3.getMessage()); sb3 = new StringBuilder(); sb3.append("pI:"); sb3.append(i15); sb3.append(str3); cn.jiguang.aw.b.b("UPM", sb3.toString()); return null; } catch (Throwable th5) { cn.jiguang.aw.b.b("UPM", "pI:" + i15 + str3); throw th5; } } } catch (Throwable th6) { cn.jiguang.aw.b.e("UPM", "put l_version error, " + th6.getMessage()); sb4 = new StringBuilder(); } try { jSONObject.put(cn.jiguang.dy.a.f14210a, System.currentTimeMillis()); String str4 = cn.jiguang.dy.a.f14211b; if (a15 == null) { a15 = ""; } jSONObject.put(str4, a15); jSONObject.put(cn.jiguang.dy.a.f14212c, a14); String str5 = cn.jiguang.dy.a.f14213d; if (b14 == null) { b14 = ""; } jSONObject.put(str5, b14); String str6 = cn.jiguang.dy.a.f14214e; if (str2 == null) { str2 = ""; } jSONObject.put(str6, str2); jSONObject.put(cn.jiguang.dy.a.f14215f, charSequence); jSONObject.put(cn.jiguang.dy.a.f14216g, context.getPackageName()); String str7 = cn.jiguang.dy.a.f14221l; if (a16 == null) { a16 = ""; } jSONObject.put(str7, a16); cn.jiguang.aw.b.b("UPM", "u:" + str); String jSONObject3 = jSONObject.toString(); cn.jiguang.aw.b.b("UPM", "request p :" + jSONObject3); if (this.f13383d) { try { jSONObject3 = i.a(jSONObject.toString().getBytes(), this.f13384e, this.f13385f); cn.jiguang.aw.b.b("UPM", "request p after :" + jSONObject3); if (TextUtils.isEmpty(jSONObject3)) { sb4 = new StringBuilder(); sb4.append("pI:"); sb4.append(i10); str3 = str3; } } catch (Throwable th7) { th3 = th7; i15 = i10; str3 = str3; i14 = a17; cn.jiguang.aw.b.f("UPM", "sU error:" + th3.getMessage()); cn.jiguang.dy.c.a().a(context, i10, i14, cn.jiguang.av.a.f13397g, 2, th3.getMessage()); sb3 = new StringBuilder(); sb3.append("pI:"); sb3.append(i15); sb3.append(str3); cn.jiguang.aw.b.b("UPM", sb3.toString()); return null; } } i15 = i10; str3 = str3; String a24 = a(str, jSONObject3); cn.jiguang.aw.b.b("UPM", "request http response:" + a24); if (this.f13383d) { try { if (!TextUtils.isEmpty(a24)) { String str8 = new String(i.a(a24, this.f13384e, this.f13385f)); cn.jiguang.aw.b.b("UPM", "request http response after:" + str8); a24 = str8; } } catch (Throwable th8) { th3 = th8; i14 = a17; cn.jiguang.aw.b.f("UPM", "sU error:" + th3.getMessage()); cn.jiguang.dy.c.a().a(context, i10, i14, cn.jiguang.av.a.f13397g, 2, th3.getMessage()); sb3 = new StringBuilder(); sb3.append("pI:"); sb3.append(i15); sb3.append(str3); cn.jiguang.aw.b.b("UPM", sb3.toString()); return null; } } a17 = a17; if (!TextUtils.isEmpty(a24)) { try { File a25 = a(context, i15, a17, a24); cn.jiguang.aw.b.b("UPM", "pI:" + i15 + str3); return a25; } catch (Throwable th9) { th3 = th9; i14 = a17; cn.jiguang.aw.b.f("UPM", "sU error:" + th3.getMessage()); cn.jiguang.dy.c.a().a(context, i10, i14, cn.jiguang.av.a.f13397g, 2, th3.getMessage()); sb3 = new StringBuilder(); sb3.append("pI:"); sb3.append(i15); sb3.append(str3); cn.jiguang.aw.b.b("UPM", sb3.toString()); return null; } } else { cn.jiguang.dy.c.a().a(context, i10, a17, aVar, 2, "config response is empty"); sb3 = new StringBuilder(); sb3.append("pI:"); sb3.append(i15); sb3.append(str3); cn.jiguang.aw.b.b("UPM", sb3.toString()); return null; } } catch (Throwable th10) { th3 = th10; i15 = i10; str3 = str3; a17 = a17; i14 = a17; cn.jiguang.aw.b.f("UPM", "sU error:" + th3.getMessage()); cn.jiguang.dy.c.a().a(context, i10, i14, cn.jiguang.av.a.f13397g, 2, th3.getMessage()); sb3 = new StringBuilder(); sb3.append("pI:"); sb3.append(i15); sb3.append(str3); cn.jiguang.aw.b.b("UPM", sb3.toString()); return null; } } else { cn.jiguang.aw.b.b("UPM", "get l_version is null"); sb4 = new StringBuilder(); sb4.append("pI:"); sb4.append(i15); } sb4.append(str3); cn.jiguang.aw.b.b("UPM", sb4.toString()); return null; } catch (Throwable th11) { th3 = th11; i14 = a17; cn.jiguang.aw.b.f("UPM", "sU error:" + th3.getMessage()); cn.jiguang.dy.c.a().a(context, i10, i14, cn.jiguang.av.a.f13397g, 2, th3.getMessage()); sb3 = new StringBuilder(); sb3.append("pI:"); sb3.append(i15); sb3.append(str3); cn.jiguang.aw.b.b("UPM", sb3.toString()); return null; } } catch (Throwable th12) { th3 = th12; i14 = -1; cn.jiguang.aw.b.f("UPM", "sU error:" + th3.getMessage()); cn.jiguang.dy.c.a().a(context, i10, i14, cn.jiguang.av.a.f13397g, 2, th3.getMessage()); sb3 = new StringBuilder(); sb3.append("pI:"); sb3.append(i15); sb3.append(str3); cn.jiguang.aw.b.b("UPM", sb3.toString()); return null; } } /* JADX WARNING: Removed duplicated region for block: B:17:0x0114 A[ORIG_RETURN, RETURN, SYNTHETIC] */ /* JADX WARNING: Removed duplicated region for block: B:18:? A[RETURN, SYNTHETIC] */ private File a(Context context, cn.jiguang.av.c cVar) { String str; int i10; cn.jiguang.av.a aVar; int i14; int i15; Context context2; cn.jiguang.dy.c cVar2; int a14 = a(context, cVar.f13426m); File a15 = b.a(context, cVar.f13432s, cVar.f13426m, cVar.f13428o); if (d.b(cVar.f13431r, 10000, a15.getAbsolutePath()) != null) { cn.jiguang.aw.b.b("UPM", "d p :" + cVar.f13431r + " p:" + a15); cn.jiguang.dy.c.a().a(context, cVar.f13426m, a14, cn.jiguang.av.a.f13398h, 1, null); cn.jiguang.dy.c a16 = cn.jiguang.dy.c.a(); int i16 = cVar.f13426m; cn.jiguang.av.a aVar2 = cn.jiguang.av.a.f13399i; a16.a(context, i16, a14, aVar2, 0, null); String a17 = cn.jiguang.ax.c.a(a15.getAbsolutePath()); if (TextUtils.isEmpty(a17) || !a17.equalsIgnoreCase(cVar.f13432s)) { cn.jiguang.aw.b.b("UPM", "d p m not m, will d: file m:" + a17 + ",config m:" + cVar.f13432s); cn.jiguang.dy.c.a().a(context, cVar.f13426m, a14, aVar2, 2, "check plugin file md5 failed"); a15.delete(); if (!a15.exists()) { return a15; } return null; } File a18 = a.a(context, cVar.f13426m); a.a(context, cVar.f13426m, cVar.f13437x, true); if (a18 != null && a18.exists()) { cn.jiguang.aw.b.b("UPM", "delete old file:" + a18.getAbsolutePath()); a18.delete(); } cn.jiguang.aw.b.b("UPM", "d p val succ"); cVar2 = cn.jiguang.dy.c.a(); i15 = cVar.f13426m; i10 = 1; str = null; context2 = context; i14 = a14; aVar = aVar2; } else { cn.jiguang.aw.b.e("UPM", "d p :" + cVar.f13431r + " fail."); cVar2 = cn.jiguang.dy.c.a(); i15 = cVar.f13426m; aVar = cn.jiguang.av.a.f13398h; i10 = 2; str = "down load plugin fail."; context2 = context; i14 = a14; } cVar2.a(context2, i15, i14, aVar, i10, str); if (!a15.exists()) { } } private String a(String str, String str2) { return d.a(str, 10000, str2); } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void a(Context context, int i10, long j14) { try { SharedPreferences.Editor edit = context.getSharedPreferences("cn.jiguang.prefs", 0).edit(); edit.putLong("plugin_update_time_" + i10, j14).apply(); } catch (Throwable unused) { } } private void a(File file) { if (file != null && file.exists()) { file.delete(); } } private boolean a(cn.jiguang.av.c cVar, Context context) { cn.jiguang.aw.b.b("UPM", "c nU l p..."); File a14 = a.a(context, cVar, true); cn.jiguang.aw.b.b("UPM", "pII:" + a14); if (a14 == null) { return true; } a.a(context, cVar.f13426m, cVar.f13437x, false); cn.jiguang.aw.b.b("UPM", "p has exist, p is:" + a14.getAbsolutePath()); return false; } private boolean b(Context context, int i10) { boolean z14 = false; SharedPreferences sharedPreferences = context.getSharedPreferences("cn.jiguang.prefs", 0); long j14 = sharedPreferences.getLong("plugin_update_time_" + i10, 0); long j15 = sharedPreferences.getLong("plugin_update_interval_" + i10, 86400000); if (j14 <= 0 || System.currentTimeMillis() > j15 + j14) { z14 = true; } if (!z14) { cn.jiguang.aw.b.b("UPM", "no need update, last is " + cn.jiguang.ax.b.a(j14)); } return z14; } private void c(Context context, int i10) { a(a.a(context, i10)); } public int a(Context context, int i10) { cn.jiguang.av.c b14 = a.b(context, i10); if (a.a(context, i10) != null) { return b14.f13428o; } try { return Integer.parseInt(a.a(i10, 4)); } catch (Throwable unused) { return -1; } } public void a(Context context, int i10, String str, b.a aVar) { if (b(context, i10)) { f.a(context, JConstants.SDK_TYPE, 76, null, null, new a(context, i10, str, aVar)); } } }