package com.pgyersdk.f; import android.app.Activity; import android.content.Context; import android.widget.Toast; import com.pgyersdk.c.b; import com.pgyersdk.update.UpdateManagerListener; import com.pgyersdk.utils.d; import com.pgyersdk.utils.h; import com.pgyersdk.utils.j; import java.lang.ref.WeakReference; import java.net.HttpURLConnection; import java.util.HashMap; import org.json.JSONException; import org.json.JSONObject; /* compiled from: CheckUpdateTask */ public class a extends c<Void, String, HashMap<String, String>> { protected static String d; protected static String e; /* renamed from: a reason: collision with root package name */ protected String f2735a; protected String b; protected UpdateManagerListener c; protected boolean f; private Context g; private WeakReference<Context> h; /* access modifiers changed from: protected */ /* JADX WARNING: Removed duplicated region for block: B:13:0x0071 */ /* JADX WARNING: Removed duplicated region for block: B:23:0x0085 */ /* JADX WARNING: Removed duplicated region for block: B:26:0x008b */ /* renamed from: a */ public HashMap<String, String> doInBackground(Void... voidArr) { Throwable th; Exception e2; boolean z; HashMap<String, String> hashMap = new HashMap<>(); HttpURLConnection httpURLConnection = null; try { HashMap hashMap2 = new HashMap(); hashMap2.put("agKey", com.pgyersdk.c.a.l); hashMap2.put("versionNo", com.pgyersdk.c.a.b); hashMap2.put("buildNo", h.a(this.g, "buildNo")); hashMap2.put("_api_key", "305092bc73c180b55c26012a94809131"); HttpURLConnection a2 = new d("https://www.pgyer.com/apiv1/update/check").a("POST").a(hashMap2, this.g, null, null).a(); try { a2.connect(); int responseCode = a2.getResponseCode(); if (responseCode != 202) { if (responseCode != 200) { z = false; this.f = z; hashMap.put("status", String.valueOf(a2.getResponseCode())); hashMap.put("response", a(a2)); if (a2 != null) { a2.disconnect(); } return hashMap; } } z = true; this.f = z; hashMap.put("status", String.valueOf(a2.getResponseCode())); hashMap.put("response", a(a2)); if (a2 != null) { } } catch (Exception e3) { e2 = e3; httpURLConnection = a2; try { e2.printStackTrace(); if (httpURLConnection != null) { } return hashMap; } catch (Throwable th2) { th = th2; if (httpURLConnection != null) { } throw th; } } catch (Throwable th3) { th = th3; httpURLConnection = a2; if (httpURLConnection != null) { httpURLConnection.disconnect(); } throw th; } } catch (Exception e4) { e2 = e4; e2.printStackTrace(); if (httpURLConnection != null) { httpURLConnection.disconnect(); } return hashMap; } return hashMap; } /* access modifiers changed from: protected */ /* renamed from: a */ public void onPostExecute(HashMap<String, String> hashMap) { if (this.f) { String str = hashMap.get("response"); if (!j.a(str) && str.contains("releaseNote")) { if (this.c != null) { this.c.a(str); } try { JSONObject jSONObject = new JSONObject(str); if ("0".equals(jSONObject.getString("code"))) { JSONObject jSONObject2 = jSONObject.getJSONObject("data"); if (jSONObject2.has("lastBuild")) { d = jSONObject2.getString("lastBuild"); } } } catch (JSONException e2) { e2.printStackTrace(); } catch (Exception unused) { } if (j.a(h.a(this.h.get(), "buildNo"))) { h.a(this.g, "buildNo", d); } } else if (this.c != null) { this.c.a(); } } } /* access modifiers changed from: protected */ public void a() { this.f2735a = null; this.b = null; } public static void a(final Activity activity, final String str) { if (a((Context) new WeakReference(activity).get())) { com.pgyersdk.utils.a.a(new e(activity, str, e, new d() { /* class com.pgyersdk.f.a.AnonymousClass1 */ @Override // com.pgyersdk.f.d public void a(e eVar, Boolean bool) { if (bool.booleanValue()) { a.a(activity, str); } } @Override // com.pgyersdk.f.d public void a(e eVar) { h.a(activity, "buildNo", a.d); } })); } else { Toast.makeText(((Activity) new WeakReference(activity).get()).getApplicationContext(), b.a(1077), 0).show(); } } private static boolean a(Context context) { return context.checkCallingOrSelfPermission("android.permission.WRITE_EXTERNAL_STORAGE") == 0; } }