package com.xiaomi.push; import android.os.Bundle; import android.os.Parcelable; import android.text.TextUtils; import com.google.android.material.datepicker.UtcDates; 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 ha { /* renamed from: a reason: collision with root package name */ public static long f25156a = 0; /* renamed from: a reason: collision with other field name */ public static final String f496a = Locale.getDefault().getLanguage().toLowerCase(); /* renamed from: a reason: collision with other field name */ public static final DateFormat f497a; /* renamed from: b reason: collision with root package name */ public static String f25157b = null; public static String c = (hl.a(5) + "-"); /* renamed from: a reason: collision with other field name */ public he f498a = null; /* renamed from: a reason: collision with other field name */ public List<gx> f499a = new CopyOnWriteArrayList(); /* renamed from: a reason: collision with other field name */ public final Map<String, Object> f500a = new HashMap(); public String d = f25157b; public String e = null; public String f = null; public String g = null; public String h = null; public String i = null; static { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); f497a = simpleDateFormat; simpleDateFormat.setTimeZone(TimeZone.getTimeZone(UtcDates.UTC)); } public ha() { } public ha(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.f499a = new ArrayList(parcelableArray.length); for (Parcelable parcelable : parcelableArray) { gx a2 = gx.a((Bundle) parcelable); if (a2 != null) { this.f499a.add(a2); } } } Bundle bundle2 = bundle.getBundle("ext_ERROR"); if (bundle2 != null) { this.f498a = new he(bundle2); } } public static synchronized String i() { String sb; synchronized (ha.class) { StringBuilder sb2 = new StringBuilder(); sb2.append(c); long j = f25156a; f25156a = 1 + j; sb2.append(Long.toString(j)); sb = sb2.toString(); } return sb; } public static String q() { return f496a; } 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); } he heVar = this.f498a; if (heVar != null) { bundle.putBundle("ext_ERROR", heVar.a()); } List<gx> list = this.f499a; if (list != null) { Bundle[] bundleArr = new Bundle[list.size()]; int i2 = 0; for (gx gxVar : this.f499a) { Bundle a2 = gxVar.a(); if (a2 != null) { bundleArr[i2] = a2; i2++; } } bundle.putParcelableArray("ext_exts", bundleArr); } return bundle; } public gx a(String str) { return a(str, null); } public gx a(String str, String str2) { for (gx gxVar : this.f499a) { if ((str2 == null || str2.equals(gxVar.b())) && str.equals(gxVar.m394a())) { return gxVar; } } return null; } /* renamed from: a reason: collision with other method in class */ public he m399a() { return this.f498a; } /* renamed from: a reason: collision with other method in class */ public synchronized Object m400a(String str) { Map<String, Object> map = this.f500a; if (map == null) { return null; } return map.get(str); } /* renamed from: a reason: collision with other method in class */ public abstract String m401a(); /* renamed from: a reason: collision with other method in class */ public synchronized Collection<gx> m402a() { if (this.f499a == null) { return Collections.emptyList(); } return Collections.unmodifiableList(new ArrayList(this.f499a)); } public void a(gx gxVar) { this.f499a.add(gxVar); } public void a(he heVar) { this.f498a = heVar; } public synchronized Collection<String> b() { if (this.f500a == null) { return Collections.emptySet(); } return Collections.unmodifiableSet(new HashSet(this.f500a.keySet())); } public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } ha haVar = (ha) obj; he heVar = this.f498a; if (heVar == null ? haVar.f498a != null : !heVar.equals(haVar.f498a)) { return false; } String str = this.g; if (str == null ? haVar.g != null : !str.equals(haVar.g)) { return false; } if (!this.f499a.equals(haVar.f499a)) { return false; } String str2 = this.e; if (str2 == null ? haVar.e != null : !str2.equals(haVar.e)) { return false; } String str3 = this.h; if (str3 == null ? haVar.h != null : !str3.equals(haVar.h)) { return false; } Map<String, Object> map = this.f500a; if (map == null ? haVar.f500a != null : !map.equals(haVar.f500a)) { return false; } String str4 = this.f; if (str4 == null ? haVar.f != null : !str4.equals(haVar.f)) { return false; } String str5 = this.d; String str6 = haVar.d; if (str5 != null) { return str5.equals(str6); } if (str6 == null) { return true; } } 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.f499a.hashCode()) * 31) + this.f500a.hashCode()) * 31; he heVar = this.f498a; if (heVar != null) { i2 = heVar.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; } /* JADX WARNING: Failed to process nested try/catch */ /* JADX WARNING: Missing exception handler attribute for start block: B:41:0x00ee */ /* JADX WARNING: Removed duplicated region for block: B:55:0x0105 A[SYNTHETIC, Splitter:B:55:0x0105] */ /* JADX WARNING: Removed duplicated region for block: B:64:0x0118 A[SYNTHETIC, Splitter:B:64:0x0118] */ /* JADX WARNING: Removed duplicated region for block: B:68:0x011f A[SYNTHETIC, Splitter:B:68:0x011f] */ /* JADX WARNING: Removed duplicated region for block: B:82:0x010d A[SYNTHETIC] */ public synchronized String o() { StringBuilder sb; ByteArrayOutputStream byteArrayOutputStream; Throwable th; ObjectOutputStream objectOutputStream; Exception e2; Exception e3; String str; sb = new StringBuilder(); for (gx gxVar : m402a()) { sb.append(gxVar.d()); } Map<String, Object> map = this.f500a; if (map != null && !map.isEmpty()) { sb.append("<properties xmlns=\"http://www.jivesoftware.com/xmlns/xmpp/properties\">"); for (String str2 : b()) { Object a2 = m400a(str2); sb.append("<property>"); sb.append("<name>"); sb.append(hl.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(hl.a((String) a2)); str = "</value>"; } else { ObjectOutputStream objectOutputStream2 = null; try { byteArrayOutputStream = new ByteArrayOutputStream(); try { objectOutputStream = new ObjectOutputStream(byteArrayOutputStream); } catch (Exception e4) { e3 = e4; objectOutputStream = null; e2 = e3; 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 (Throwable th3) { th = th3; if (objectOutputStream2 != null) { } if (byteArrayOutputStream != null) { } throw th; } try { objectOutputStream.writeObject(a2); sb.append("java-object\">"); sb.append(hl.a(byteArrayOutputStream.toByteArray())); sb.append("</value>"); objectOutputStream.close(); } catch (Exception e5) { e2 = e5; e2.printStackTrace(); if (objectOutputStream != null) { try { objectOutputStream.close(); } catch (Exception unused3) { } } if (byteArrayOutputStream == null) { sb.append("</property>"); } byteArrayOutputStream.close(); sb.append("</property>"); } } catch (Exception e6) { e3 = e6; byteArrayOutputStream = null; objectOutputStream = null; e2 = e3; e2.printStackTrace(); if (objectOutputStream != null) { } if (byteArrayOutputStream == null) { } 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; } }