package jh; import java.io.ByteArrayInputStream; import java.util.HashMap; import java.util.Map; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.DOMException; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; public class h { /* renamed from: a reason: collision with root package name */ public String f240042a; /* renamed from: b reason: collision with root package name */ public Map<String, a> f240043b = new HashMap(); /* renamed from: c reason: collision with root package name */ public int f240044c; public static class a { /* renamed from: a reason: collision with root package name */ public String f240045a; /* renamed from: b reason: collision with root package name */ public String f240046b; /* renamed from: c reason: collision with root package name */ public String f240047c; /* renamed from: d reason: collision with root package name */ public String f240048d; /* renamed from: e reason: collision with root package name */ public int f240049e; public a(String str, String str2, String str3, String str4, int i15) { this.f240045a = str; this.f240046b = str2; this.f240047c = str3; this.f240049e = i15; this.f240048d = str4; } public int a() { return this.f240049e; } } public h(String str, int i15) { if (str == null) { this.f240042a = "http://dldir1.qq.com/weixin/android/"; } else { this.f240042a = str; } this.f240044c = i15; } /* JADX WARNING: Code restructure failed: missing block: B:23:0x0070, code lost: r0 = null; */ /* JADX WARNING: Failed to process nested try/catch */ /* JADX WARNING: Removed duplicated region for block: B:42:0x00c2 A[RETURN] */ /* JADX WARNING: Removed duplicated region for block: B:43:0x00c3 */ /* JADX WARNING: Removed duplicated region for block: B:8:? A[ExcHandler: ParserConfigurationException (unused javax.xml.parsers.ParserConfigurationException), SYNTHETIC, Splitter:B:15:0x004c] */ public static h b(String str) { int i15; HashMap hashMap; Integer num; String str2 = str; if (str2 == null) { i15 = -1; } else { i15 = str2.indexOf(60); } if (i15 < 0) { System.err.println("text not in xml format"); } else { if (i15 > 0) { System.err.println("fix xml header from " + i15); str2 = str2.substring(i15); } if (str2 != null && str2.length() > 0) { hashMap = new HashMap(); try { DocumentBuilder newDocumentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); if (newDocumentBuilder == null) { System.err.println("new Document Builder failed"); } else { Document document = newDocumentBuilder.parse(new InputSource(new ByteArrayInputStream(str2.getBytes()))); document.normalize(); if (document == null) { System.err.println("new Document failed"); } else { Element documentElement = document.getDocumentElement(); if (documentElement == null) { System.err.println("getDocumentElement failed"); } else { if ("patchupdate".equals(documentElement.getNodeName())) { f.a(hashMap, "", "", documentElement, 0); } else { NodeList elementsByTagName = documentElement.getElementsByTagName("patchupdate"); if (elementsByTagName.getLength() <= 0) { System.err.println("parse item null"); } else { if (elementsByTagName.getLength() > 1) { System.err.println("parse items more than one"); } f.a(hashMap, "", "", elementsByTagName.item(0), 0); } } if (hashMap != null) { return null; } h hVar = new h((String) hashMap.get(".patchupdate.$base"), i.a((String) hashMap.get(".patchupdate.$versioncode"), 0)); int a15 = i.a((String) hashMap.get(".patchupdate.$count"), 0); for (int i16 = 0; i16 < a15; i16++) { StringBuilder sb5 = new StringBuilder(); sb5.append(".patchupdate.item"); if (i16 > 0) { num = Integer.valueOf(i16); } else { num = ""; } sb5.append(num); String sb6 = sb5.toString(); String str3 = (String) hashMap.get(sb6 + ".$old"); String str4 = (String) hashMap.get(sb6 + ".$new"); String str5 = (String) hashMap.get(sb6 + ".$patch"); String str6 = (String) hashMap.get(sb6 + ".$url"); a aVar = new a(str3, str4, str5, str6, i.a((String) hashMap.get(sb6 + ".$size"), 0)); if ((str3 == null || str4 == null || str5 == null || str6 == null) ? false : true) { ((HashMap) hVar.f240043b).put(str3, aVar); } } return hVar; } } } } catch (DOMException unused) { } catch (ParserConfigurationException unused2) { } } } hashMap = null; if (hashMap != null) { } } public a a(String str) { return (a) ((HashMap) this.f240043b).get(str); } public String c() { StringBuilder sb5 = new StringBuilder(); sb5.append(String.format("<patchupdate base=\"%s\" count=\"%d\" versioncode=\"%d\">", this.f240042a, Integer.valueOf(((HashMap) this.f240043b).size()), Integer.valueOf(this.f240044c))); for (Map.Entry entry : ((HashMap) this.f240043b).entrySet()) { a aVar = (a) entry.getValue(); sb5.append(String.format("<item old=\"%s\" new=\"%s\" patch=\"%s\" url=\"%s\" size=\"%s\"></item>", aVar.f240045a, aVar.f240046b, aVar.f240047c, aVar.f240048d, Integer.valueOf(aVar.f240049e))); } sb5.append("</patchupdate>"); return sb5.toString(); } }