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 gl { /* renamed from: a reason: collision with root package name */ private static long f36669a = 0; /* renamed from: a reason: collision with other field name */ public static final String f609a = Locale.getDefault().getLanguage().toLowerCase(); /* renamed from: a reason: collision with other field name */ public static final DateFormat f610a; /* renamed from: b reason: collision with root package name */ private static String f36670b = null; /* renamed from: c reason: collision with root package name */ private static String f36671c = (gw.a(5) + Constants.ACCEPT_TIME_SEPARATOR_SERVER); /* renamed from: a reason: collision with other field name */ private gp f611a = null; /* renamed from: a reason: collision with other field name */ private List<gi> f612a = new CopyOnWriteArrayList(); /* renamed from: a reason: collision with other field name */ private final Map<String, Object> f613a = new HashMap(); /* renamed from: d reason: collision with root package name */ private String f36672d = f36670b; /* renamed from: e reason: collision with root package name */ private String f36673e = null; /* renamed from: f reason: collision with root package name */ private String f36674f = null; /* renamed from: g reason: collision with root package name */ private String f36675g = null; /* renamed from: h reason: collision with root package name */ private String f36676h = null; /* renamed from: i reason: collision with root package name */ private String f36677i = null; static { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); f610a = simpleDateFormat; simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); } public gl() { } public gl(Bundle bundle) { this.f36674f = bundle.getString("ext_to"); this.f36675g = bundle.getString("ext_from"); this.f36676h = bundle.getString("ext_chid"); this.f36673e = bundle.getString("ext_pkt_id"); Parcelable[] parcelableArray = bundle.getParcelableArray("ext_exts"); if (parcelableArray != null) { this.f612a = new ArrayList(parcelableArray.length); for (Parcelable parcelable : parcelableArray) { gi a14 = gi.a((Bundle) parcelable); if (a14 != null) { this.f612a.add(a14); } } } Bundle bundle2 = bundle.getBundle("ext_ERROR"); if (bundle2 != null) { this.f611a = new gp(bundle2); } } public static synchronized String i() { String sb3; synchronized (gl.class) { StringBuilder sb4 = new StringBuilder(); sb4.append(f36671c); long j14 = f36669a; f36669a = 1 + j14; sb4.append(Long.toString(j14)); sb3 = sb4.toString(); } return sb3; } public static String q() { return f609a; } public Bundle a() { Bundle bundle = new Bundle(); if (!TextUtils.isEmpty(this.f36672d)) { bundle.putString("ext_ns", this.f36672d); } if (!TextUtils.isEmpty(this.f36675g)) { bundle.putString("ext_from", this.f36675g); } if (!TextUtils.isEmpty(this.f36674f)) { bundle.putString("ext_to", this.f36674f); } if (!TextUtils.isEmpty(this.f36673e)) { bundle.putString("ext_pkt_id", this.f36673e); } if (!TextUtils.isEmpty(this.f36676h)) { bundle.putString("ext_chid", this.f36676h); } gp gpVar = this.f611a; if (gpVar != null) { bundle.putBundle("ext_ERROR", gpVar.a()); } List<gi> list = this.f612a; if (list != null) { Bundle[] bundleArr = new Bundle[list.size()]; int i10 = 0; for (gi giVar : this.f612a) { Bundle a14 = giVar.a(); if (a14 != null) { bundleArr[i10] = a14; i10++; } } bundle.putParcelableArray("ext_exts", bundleArr); } return bundle; } public gi a(String str) { return a(str, null); } public gi a(String str, String str2) { for (gi giVar : this.f612a) { if ((str2 == null || str2.equals(giVar.b())) && str.equals(giVar.m457a())) { return giVar; } } return null; } /* renamed from: a reason: collision with other method in class */ public gp m462a() { return this.f611a; } /* renamed from: a reason: collision with other method in class */ public synchronized Object m463a(String str) { Map<String, Object> map = this.f613a; if (map == null) { return null; } return map.get(str); } /* renamed from: a reason: collision with other method in class */ public abstract String m464a(); /* renamed from: a reason: collision with other method in class */ public synchronized Collection<gi> m465a() { if (this.f612a == null) { return Collections.emptyList(); } return Collections.unmodifiableList(new ArrayList(this.f612a)); } public void a(gi giVar) { this.f612a.add(giVar); } public void a(gp gpVar) { this.f611a = gpVar; } public synchronized Collection<String> b() { if (this.f613a == null) { return Collections.emptySet(); } return Collections.unmodifiableSet(new HashSet(this.f613a.keySet())); } public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } gl glVar = (gl) obj; gp gpVar = this.f611a; if (gpVar == null ? glVar.f611a != null : !gpVar.equals(glVar.f611a)) { return false; } String str = this.f36675g; if (str == null ? glVar.f36675g != null : !str.equals(glVar.f36675g)) { return false; } if (!this.f612a.equals(glVar.f612a)) { return false; } String str2 = this.f36673e; if (str2 == null ? glVar.f36673e != null : !str2.equals(glVar.f36673e)) { return false; } String str3 = this.f36676h; if (str3 == null ? glVar.f36676h != null : !str3.equals(glVar.f36676h)) { return false; } Map<String, Object> map = this.f613a; if (map == null ? glVar.f613a != null : !map.equals(glVar.f613a)) { return false; } String str4 = this.f36674f; if (str4 == null ? glVar.f36674f != null : !str4.equals(glVar.f36674f)) { return false; } String str5 = this.f36672d; String str6 = glVar.f36672d; if (str5 != null) { return str5.equals(str6); } if (str6 == null) { return true; } } public int hashCode() { String str = this.f36672d; int i10 = 0; int hashCode = (str != null ? str.hashCode() : 0) * 31; String str2 = this.f36673e; int hashCode2 = (hashCode + (str2 != null ? str2.hashCode() : 0)) * 31; String str3 = this.f36674f; int hashCode3 = (hashCode2 + (str3 != null ? str3.hashCode() : 0)) * 31; String str4 = this.f36675g; int hashCode4 = (hashCode3 + (str4 != null ? str4.hashCode() : 0)) * 31; String str5 = this.f36676h; int hashCode5 = (((((hashCode4 + (str5 != null ? str5.hashCode() : 0)) * 31) + this.f612a.hashCode()) * 31) + this.f613a.hashCode()) * 31; gp gpVar = this.f611a; if (gpVar != null) { i10 = gpVar.hashCode(); } return hashCode5 + i10; } public String j() { if ("ID_NOT_AVAILABLE".equals(this.f36673e)) { return null; } if (this.f36673e == null) { this.f36673e = i(); } return this.f36673e; } public String k() { return this.f36676h; } public void k(String str) { this.f36673e = str; } public String l() { return this.f36674f; } public void l(String str) { this.f36676h = str; } public String m() { return this.f36675g; } public void m(String str) { this.f36674f = str; } public String n() { return this.f36677i; } public void n(String str) { this.f36675g = 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 sb3; ByteArrayOutputStream byteArrayOutputStream; Throwable th3; ObjectOutputStream objectOutputStream; Exception e14; Exception e15; String str; sb3 = new StringBuilder(); for (gi giVar : m465a()) { sb3.append(giVar.d()); } Map<String, Object> map = this.f613a; if (map != null && !map.isEmpty()) { sb3.append("<properties xmlns=\"http://www.jivesoftware.com/xmlns/xmpp/properties\">"); for (String str2 : b()) { Object a14 = m463a(str2); sb3.append("<property>"); sb3.append("<name>"); sb3.append(gw.a(str2)); sb3.append("</name>"); sb3.append("<value type=\""); if (a14 instanceof Integer) { sb3.append("integer\">"); sb3.append(a14); str = "</value>"; } else if (a14 instanceof Long) { sb3.append("long\">"); sb3.append(a14); str = "</value>"; } else if (a14 instanceof Float) { sb3.append("float\">"); sb3.append(a14); str = "</value>"; } else if (a14 instanceof Double) { sb3.append("double\">"); sb3.append(a14); str = "</value>"; } else if (a14 instanceof Boolean) { sb3.append("boolean\">"); sb3.append(a14); str = "</value>"; } else if (a14 instanceof String) { sb3.append("string\">"); sb3.append(gw.a((String) a14)); str = "</value>"; } else { ObjectOutputStream objectOutputStream2 = null; try { byteArrayOutputStream = new ByteArrayOutputStream(); try { objectOutputStream = new ObjectOutputStream(byteArrayOutputStream); } catch (Exception e16) { e15 = e16; objectOutputStream = null; e14 = e15; try { e14.printStackTrace(); if (objectOutputStream != null) { } if (byteArrayOutputStream == null) { } byteArrayOutputStream.close(); sb3.append("</property>"); } catch (Throwable th4) { th3 = th4; objectOutputStream2 = objectOutputStream; if (objectOutputStream2 != null) { try { objectOutputStream2.close(); } catch (Exception unused) { } } if (byteArrayOutputStream != null) { try { byteArrayOutputStream.close(); } catch (Exception unused2) { } } throw th3; } } catch (Throwable th5) { th3 = th5; if (objectOutputStream2 != null) { } if (byteArrayOutputStream != null) { } throw th3; } try { objectOutputStream.writeObject(a14); sb3.append("java-object\">"); sb3.append(gw.a(byteArrayOutputStream.toByteArray())); sb3.append("</value>"); objectOutputStream.close(); } catch (Exception e17) { e14 = e17; e14.printStackTrace(); if (objectOutputStream != null) { try { objectOutputStream.close(); } catch (Exception unused3) { } } if (byteArrayOutputStream == null) { sb3.append("</property>"); } byteArrayOutputStream.close(); sb3.append("</property>"); } } catch (Exception e18) { e15 = e18; byteArrayOutputStream = null; objectOutputStream = null; e14 = e15; e14.printStackTrace(); if (objectOutputStream != null) { } if (byteArrayOutputStream == null) { } byteArrayOutputStream.close(); sb3.append("</property>"); } catch (Throwable th6) { th3 = th6; byteArrayOutputStream = null; if (objectOutputStream2 != null) { } if (byteArrayOutputStream != null) { } throw th3; } try { byteArrayOutputStream.close(); } catch (Exception unused4) { } sb3.append("</property>"); } sb3.append(str); sb3.append("</property>"); } sb3.append("</properties>"); } return sb3.toString(); } public void o(String str) { this.f36677i = str; } public String p() { return this.f36672d; } }