package com.xiaomi.push; import android.content.Context; import android.content.SharedPreferences; import com.meizu.cloud.pushsdk.constants.PushConstants; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import org.json.JSONObject; public class bl { /* renamed from: a reason: collision with root package name */ private static int f6619a; /* renamed from: a reason: collision with other field name */ private static bl f731a; /* renamed from: a reason: collision with other field name */ private static boolean f732a; /* renamed from: a reason: collision with other field name */ private Context f733a; /* renamed from: a reason: collision with other field name */ private SharedPreferences f734a = this.f733a.getSharedPreferences("config", 0); /* renamed from: a reason: collision with other field name */ private List f735a = new ArrayList(); private bl(Context context) { this.f733a = context; } public static bl a() { return f731a; } public static synchronized void a(Context context) { synchronized (bl.class) { if (f731a == null) { f731a = new bl(context); } } } /* renamed from: a reason: collision with other method in class */ public static boolean m3107a() { return false; } /* renamed from: a reason: collision with other method in class */ public long m3108a() { return this.f734a.getLong("d_m_i", Long.MAX_VALUE); } /* renamed from: a reason: collision with other method in class */ public String m3109a() { return this.f734a.getString("m_s_u", "https://metok.sys.miui.com"); } /* renamed from: a reason: collision with other method in class */ public void m3110a() { synchronized (this.f735a) { for (cr crVar : this.f735a) { crVar.a(); } } } public void a(cr crVar) { if (crVar != null) { synchronized (this.f735a) { this.f735a.add(crVar); } } } public void a(String str) { SharedPreferences.Editor edit = this.f734a.edit(); edit.putString("config_update_time", str); edit.commit(); } public long b() { return this.f734a.getLong("d_s_t", Long.MAX_VALUE); } /* renamed from: b reason: collision with other method in class */ public String m3111b() { return this.f734a.getString("config_update_time", PushConstants.PUSH_TYPE_NOTIFY); } /* renamed from: b reason: collision with other method in class */ public void m3112b() { int i; int i2; String a2; String b = m3111b(); String f = bq.f(); if (!b.equals(f)) { String d = bq.d(); String a3 = bs.a("collect", "t_" + d); if (a3 == null || a3.isEmpty()) { int i3 = 0; do { a2 = bs.a("collect", "t_" + d); if (a2 != null && !a2.isEmpty()) { break; } i3++; } while (i3 != 5); if (i3 != 5) { a3 = a2; } else { return; } } try { JSONObject jSONObject = new JSONObject(new JSONObject(a3).getString("data")); String string = this.f734a.getString("s_f", ""); String optString = jSONObject.optString("s_f", ""); boolean a4 = bq.a(jSONObject.optInt("f_d_d", 0)); SharedPreferences.Editor edit = this.f734a.edit(); edit.putString("s_f", optString); edit.putBoolean("f_d_d", a4); edit.putString("m_s_u", jSONObject.optString("m_s_u", "https://metok.sys.miui.com")); edit.commit(); new Date(); new Date(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmm"); if (string != null && !string.isEmpty() && optString != null && !optString.isEmpty()) { Date parse = simpleDateFormat.parse(string); Date parse2 = simpleDateFormat.parse(optString); if (parse2.before(parse) || parse2.equals(parse)) { a(f); m3110a(); return; } } String a5 = bs.a("collect", "f_" + d); if (a5 == null || a5.isEmpty()) { int i4 = 0; while (true) { a5 = bs.a("collect", "f_" + d); if (a5 != null && !a5.isEmpty()) { i2 = i4; i = 5; break; } i2 = i4 + 1; i = 5; if (i2 == 5) { break; } i4 = i2; } if (i2 == i) { return; } } try { JSONObject jSONObject2 = new JSONObject(new JSONObject(a5).getString("data")); SharedPreferences.Editor edit2 = this.f734a.edit(); edit2.putLong("d_m_i", jSONObject2.optLong("d_m_i", Long.MAX_VALUE)); edit2.putBoolean("d_n_s", bq.a(jSONObject2.optInt("d_n_s", f6619a))); edit2.putLong("d_s_t", jSONObject2.optLong("d_s_t", Long.MAX_VALUE)); edit2.putLong("d_s_c_t", jSONObject2.optLong("d_s_c_t", Long.MAX_VALUE)); edit2.commit(); a(f); m3110a(); } catch (Exception unused) { } } catch (Exception unused2) { } } } /* renamed from: b reason: collision with other method in class */ public boolean m3113b() { return this.f734a.getBoolean("f_d_d", true); } public long c() { return this.f734a.getLong("d_s_c_t", Long.MAX_VALUE); } /* renamed from: c reason: collision with other method in class */ public boolean m3114c() { return this.f734a.getBoolean("d_n_s", f732a); } }