package com.xiaomi.push; import android.os.Bundle; import android.os.Parcelable; import android.text.TextUtils; import com.xiaomi.mipush.sdk.Constants; import java.io.ByteArrayOutputStream; import java.io.ObjectOutputStream; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.TimeZone; import java.util.concurrent.CopyOnWriteArrayList; public abstract class gg { private static long a = 0; /* renamed from: a reason: collision with other field name */ protected static final String f7056a = Locale.getDefault().getLanguage().toLowerCase(); /* renamed from: a reason: collision with other field name */ public static final DateFormat f7057a; private static String b = null; private static String c = (gr.a(5) + Constants.ACCEPT_TIME_SEPARATOR_SERVER); /* renamed from: a reason: collision with other field name */ private gk f7058a = null; /* renamed from: a reason: collision with other field name */ private List<gd> f7059a = new CopyOnWriteArrayList(); /* renamed from: a reason: collision with other field name */ private final Map<String, Object> f7060a = new HashMap(); private String d = b; private String e = null; private String f = null; private String g = null; private String h = null; private String i = null; static { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); f7057a = simpleDateFormat; simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); } public gg() { } public gg(Bundle bundle) { this.f = bundle.getString("ext_to"); this.g = bundle.getString("ext_from"); this.h = bundle.getString("ext_chid"); this.e = bundle.getString("ext_pkt_id"); Parcelable[] parcelableArray = bundle.getParcelableArray("ext_exts"); if (parcelableArray != null) { this.f7059a = new ArrayList(parcelableArray.length); for (Parcelable parcelable : parcelableArray) { gd a2 = gd.a((Bundle) parcelable); if (a2 != null) { this.f7059a.add(a2); } } } Bundle bundle2 = bundle.getBundle("ext_ERROR"); if (bundle2 != null) { this.f7058a = new gk(bundle2); } } public static synchronized String i() { String sb; synchronized (gg.class) { StringBuilder sb2 = new StringBuilder(); sb2.append(c); long j = a; a = 1 + j; sb2.append(Long.toString(j)); sb = sb2.toString(); } return sb; } public static String q() { return f7056a; } public Bundle a() { Bundle bundle = new Bundle(); if (!TextUtils.isEmpty(this.d)) { bundle.putString("ext_ns", this.d); } if (!TextUtils.isEmpty(this.g)) { bundle.putString("ext_from", this.g); } if (!TextUtils.isEmpty(this.f)) { bundle.putString("ext_to", this.f); } if (!TextUtils.isEmpty(this.e)) { bundle.putString("ext_pkt_id", this.e); } if (!TextUtils.isEmpty(this.h)) { bundle.putString("ext_chid", this.h); } gk gkVar = this.f7058a; if (gkVar != null) { bundle.putBundle("ext_ERROR", gkVar.a()); } List<gd> list = this.f7059a; if (list != null) { Bundle[] bundleArr = new Bundle[list.size()]; int i2 = 0; for (gd gdVar : this.f7059a) { Bundle a2 = gdVar.a(); if (a2 != null) { bundleArr[i2] = a2; i2++; } } bundle.putParcelableArray("ext_exts", bundleArr); } return bundle; } public gd a(String str) { return a(str, null); } public gd a(String str, String str2) { for (gd gdVar : this.f7059a) { if ((str2 == null || str2.equals(gdVar.b())) && str.equals(gdVar.m9387a())) { return gdVar; } } return null; } /* renamed from: a reason: collision with other method in class */ public gk m9392a() { return this.f7058a; } /* renamed from: a reason: collision with other method in class */ public synchronized Object m9393a(String str) { if (this.f7060a == null) { return null; } return this.f7060a.get(str); } /* renamed from: a reason: collision with other method in class */ public abstract String m9394a(); /* renamed from: a reason: collision with other method in class */ public synchronized Collection<gd> m9395a() { if (this.f7059a == null) { return Collections.emptyList(); } return Collections.unmodifiableList(new ArrayList(this.f7059a)); } public void a(gd gdVar) { this.f7059a.add(gdVar); } public void a(gk gkVar) { this.f7058a = gkVar; } public synchronized Collection<String> b() { if (this.f7060a == null) { return Collections.emptySet(); } return Collections.unmodifiableSet(new HashSet(this.f7060a.keySet())); } public boolean equals(Object obj) { if (this == obj) { return true; } if (obj != null && getClass() == obj.getClass()) { gg ggVar = (gg) obj; gk gkVar = this.f7058a; if (gkVar == null ? ggVar.f7058a != null : !gkVar.equals(ggVar.f7058a)) { return false; } String str = this.g; if (str == null ? ggVar.g != null : !str.equals(ggVar.g)) { return false; } if (!this.f7059a.equals(ggVar.f7059a)) { return false; } String str2 = this.e; if (str2 == null ? ggVar.e != null : !str2.equals(ggVar.e)) { return false; } String str3 = this.h; if (str3 == null ? ggVar.h != null : !str3.equals(ggVar.h)) { return false; } Map<String, Object> map = this.f7060a; if (map == null ? ggVar.f7060a != null : !map.equals(ggVar.f7060a)) { return false; } String str4 = this.f; if (str4 == null ? ggVar.f != null : !str4.equals(ggVar.f)) { return false; } String str5 = this.d; String str6 = ggVar.d; return str5 == null ? str6 == null : str5.equals(str6); } } public int hashCode() { String str = this.d; int i2 = 0; int hashCode = (str != null ? str.hashCode() : 0) * 31; String str2 = this.e; int hashCode2 = (hashCode + (str2 != null ? str2.hashCode() : 0)) * 31; String str3 = this.f; int hashCode3 = (hashCode2 + (str3 != null ? str3.hashCode() : 0)) * 31; String str4 = this.g; int hashCode4 = (hashCode3 + (str4 != null ? str4.hashCode() : 0)) * 31; String str5 = this.h; int hashCode5 = (((((hashCode4 + (str5 != null ? str5.hashCode() : 0)) * 31) + this.f7059a.hashCode()) * 31) + this.f7060a.hashCode()) * 31; gk gkVar = this.f7058a; if (gkVar != null) { i2 = gkVar.hashCode(); } return hashCode5 + i2; } public String j() { if ("ID_NOT_AVAILABLE".equals(this.e)) { return null; } if (this.e == null) { this.e = i(); } return this.e; } public String k() { return this.h; } public void k(String str) { this.e = str; } public String l() { return this.f; } public void l(String str) { this.h = str; } public String m() { return this.g; } public void m(String str) { this.f = str; } public String n() { return this.i; } public void n(String str) { this.g = str; } /* access modifiers changed from: protected */ /* JADX WARNING: Failed to process nested try/catch */ /* JADX WARNING: Missing exception handler attribute for start block: B:41:0x00f0 */ /* JADX WARNING: Removed duplicated region for block: B:55:0x0107 A[SYNTHETIC, Splitter:B:55:0x0107] */ /* JADX WARNING: Removed duplicated region for block: B:64:0x011a A[SYNTHETIC, Splitter:B:64:0x011a] */ /* JADX WARNING: Removed duplicated region for block: B:68:0x0121 A[SYNTHETIC, Splitter:B:68:0x0121] */ /* JADX WARNING: Removed duplicated region for block: B:82:0x010f A[SYNTHETIC] */ public synchronized String o() { StringBuilder sb; ByteArrayOutputStream byteArrayOutputStream; Throwable th; ObjectOutputStream objectOutputStream; Exception e2; Exception e3; String str; sb = new StringBuilder(); for (gd gdVar : m9395a()) { sb.append(gdVar.d()); } if (this.f7060a != null && !this.f7060a.isEmpty()) { sb.append("<properties xmlns=\"http://www.jivesoftware.com/xmlns/xmpp/properties\">"); for (String str2 : b()) { Object a2 = m9393a(str2); sb.append("<property>"); sb.append("<name>"); sb.append(gr.a(str2)); sb.append("</name>"); sb.append("<value type=\""); if (a2 instanceof Integer) { sb.append("integer\">"); sb.append(a2); str = "</value>"; } else if (a2 instanceof Long) { sb.append("long\">"); sb.append(a2); str = "</value>"; } else if (a2 instanceof Float) { sb.append("float\">"); sb.append(a2); str = "</value>"; } else if (a2 instanceof Double) { sb.append("double\">"); sb.append(a2); str = "</value>"; } else if (a2 instanceof Boolean) { sb.append("boolean\">"); sb.append(a2); str = "</value>"; } else if (a2 instanceof String) { sb.append("string\">"); sb.append(gr.a((String) a2)); str = "</value>"; } else { ObjectOutputStream objectOutputStream2 = null; try { byteArrayOutputStream = new ByteArrayOutputStream(); try { objectOutputStream = new ObjectOutputStream(byteArrayOutputStream); try { objectOutputStream.writeObject(a2); sb.append("java-object\">"); sb.append(gr.a(byteArrayOutputStream.toByteArray())); sb.append("</value>"); objectOutputStream.close(); } catch (Exception e4) { e2 = e4; try { e2.printStackTrace(); if (objectOutputStream != null) { } if (byteArrayOutputStream == null) { } byteArrayOutputStream.close(); sb.append("</property>"); } catch (Throwable th2) { th = th2; objectOutputStream2 = objectOutputStream; if (objectOutputStream2 != null) { try { objectOutputStream2.close(); } catch (Exception unused) { } } if (byteArrayOutputStream != null) { try { byteArrayOutputStream.close(); } catch (Exception unused2) { } } throw th; } } } catch (Exception e5) { e3 = e5; objectOutputStream = null; e2 = e3; e2.printStackTrace(); if (objectOutputStream != null) { } if (byteArrayOutputStream == null) { } byteArrayOutputStream.close(); sb.append("</property>"); } catch (Throwable th3) { th = th3; if (objectOutputStream2 != null) { } if (byteArrayOutputStream != null) { } throw th; } } catch (Exception e6) { e3 = e6; byteArrayOutputStream = null; objectOutputStream = null; e2 = e3; e2.printStackTrace(); if (objectOutputStream != null) { try { objectOutputStream.close(); } catch (Exception unused3) { } } if (byteArrayOutputStream == null) { sb.append("</property>"); } byteArrayOutputStream.close(); sb.append("</property>"); } catch (Throwable th4) { th = th4; byteArrayOutputStream = null; if (objectOutputStream2 != null) { } if (byteArrayOutputStream != null) { } throw th; } try { byteArrayOutputStream.close(); } catch (Exception unused4) { } sb.append("</property>"); } sb.append(str); sb.append("</property>"); } sb.append("</properties>"); } return sb.toString(); } public void o(String str) { this.i = str; } public String p() { return this.d; } }