package com.xiaomi.push.service; import android.content.SharedPreferences; import com.xiaomi.push.ab; import com.xiaomi.push.ao; import com.xiaomi.push.b; import com.xiaomi.push.c; import com.xiaomi.push.dx; import com.xiaomi.push.dy; import com.xiaomi.push.gs; import com.xiaomi.push.i; import com.xiaomi.push.v; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.util.ArrayList; import java.util.List; public class bs { private static bs a = new bs(); /* renamed from: a reason: collision with other field name */ private static String f7578a; /* renamed from: a reason: collision with other field name */ private ao.b f7579a; /* renamed from: a reason: collision with other field name */ private dx.a f7580a; /* renamed from: a reason: collision with other field name */ private List<a> f7581a = new ArrayList(); public static abstract class a { public void a(dx.a aVar) { } public void a(dy.b bVar) { } } private bs() { } public static bs a() { return a; } /* renamed from: a reason: collision with other method in class */ public static synchronized String m9706a() { String str; synchronized (bs.class) { if (f7578a == null) { SharedPreferences sharedPreferences = v.m9749a().getSharedPreferences("XMPushServiceConfig", 0); String string = sharedPreferences.getString("DeviceUUID", null); f7578a = string; if (string == null) { String a2 = i.a(v.m9749a(), false); f7578a = a2; if (a2 != null) { sharedPreferences.edit().putString("DeviceUUID", f7578a).commit(); } } } str = f7578a; } return str; } private void b() { if (this.f7580a == null) { d(); } } private void c() { if (this.f7579a == null) { bt btVar = new bt(this); this.f7579a = btVar; gs.a(btVar); } } /* JADX WARNING: Removed duplicated region for block: B:14:0x0043 */ /* JADX WARNING: Removed duplicated region for block: B:19:? A[RETURN, SYNTHETIC] */ private void d() { BufferedInputStream bufferedInputStream; Throwable th; Exception e; try { bufferedInputStream = new BufferedInputStream(v.m9749a().openFileInput("XMCloudCfg")); try { this.f7580a = dx.a.b(b.a(bufferedInputStream)); bufferedInputStream.close(); } catch (Exception e2) { e = e2; } } catch (Exception e3) { bufferedInputStream = null; e = e3; try { com.xiaomi.channel.commonutils.logger.b.m9051a("load config failure: " + e.getMessage()); ab.a(bufferedInputStream); if (this.f7580a != null) { } } catch (Throwable th2) { th = th2; ab.a(bufferedInputStream); throw th; } } catch (Throwable th3) { bufferedInputStream = null; th = th3; ab.a(bufferedInputStream); throw th; } ab.a(bufferedInputStream); if (this.f7580a != null) { this.f7580a = new dx.a(); } } private void e() { try { if (this.f7580a != null) { BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(v.m9749a().openFileOutput("XMCloudCfg", 0)); c a2 = c.a(bufferedOutputStream); this.f7580a.a(a2); a2.m9174a(); bufferedOutputStream.close(); } } catch (Exception e) { com.xiaomi.channel.commonutils.logger.b.m9051a("save config failure: " + e.getMessage()); } } /* access modifiers changed from: package-private */ /* renamed from: a reason: collision with other method in class */ public int m9707a() { b(); dx.a aVar = this.f7580a; if (aVar != null) { return aVar.c(); } return 0; } /* renamed from: a reason: collision with other method in class */ public dx.a m9708a() { b(); return this.f7580a; } /* access modifiers changed from: package-private */ /* renamed from: a reason: collision with other method in class */ public synchronized void m9709a() { this.f7581a.clear(); } /* access modifiers changed from: package-private */ public void a(dy.b bVar) { a[] aVarArr; if (bVar.m9256d() && bVar.d() > m9707a()) { c(); } synchronized (this) { aVarArr = (a[]) this.f7581a.toArray(new a[this.f7581a.size()]); } for (a aVar : aVarArr) { aVar.a(bVar); } } public synchronized void a(a aVar) { this.f7581a.add(aVar); } }