package vf; import ab.m; import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.Signature; import android.content.res.AssetManager; import android.os.Build; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import java.lang.reflect.Constructor; import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.Iterator; import java.util.Objects; import org.xmlpull.v1.XmlPullParserException; import xf.b; import xf.e; public final class n { /* renamed from: a reason: collision with root package name */ public final e f171336a; /* renamed from: b reason: collision with root package name */ public final Context f171337b; /* renamed from: c reason: collision with root package name */ public final m f171338c; /* renamed from: d reason: collision with root package name */ public PackageInfo f171339d; public n(Context context, e eVar, m mVar) { m mVar2 = new m(new b(eVar)); this.f171336a = eVar; this.f171337b = context; this.f171338c = mVar2; } /* JADX WARNING: Code restructure failed: missing block: B:19:0x0063, code lost: if (r6.f171335a.getName().equals("manifest") == false) goto L_0x00c8; */ /* JADX WARNING: Code restructure failed: missing block: B:20:0x0065, code lost: r7 = r6.f171335a.getAttributeValue("http://schemas.android.com/apk/res/android", "versionCode"); r6 = r6.f171335a.getAttributeValue("http://schemas.android.com/apk/res/android", "versionCodeMajor"); */ /* JADX WARNING: Code restructure failed: missing block: B:21:0x0077, code lost: if (r7 == null) goto L_0x00c0; */ /* JADX WARNING: Code restructure failed: missing block: B:23:?, code lost: r7 = java.lang.Integer.parseInt(r7); */ /* JADX WARNING: Code restructure failed: missing block: B:24:0x007d, code lost: if (r6 != null) goto L_0x0081; */ /* JADX WARNING: Code restructure failed: missing block: B:25:0x007f, code lost: r6 = (long) r7; */ /* JADX WARNING: Code restructure failed: missing block: B:28:0x0085, code lost: r6 = (((long) r7) & 4294967295L) | (((long) java.lang.Integer.parseInt(r6)) << 32); */ /* JADX WARNING: Code restructure failed: missing block: B:32:0x0096, code lost: r13 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:34:0x00aa, code lost: throw new org.xmlpull.v1.XmlPullParserException(java.lang.String.format("Couldn't parse versionCodeMajor to int: %s", r13.getMessage())); */ /* JADX WARNING: Code restructure failed: missing block: B:35:0x00ab, code lost: r13 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:37:0x00bf, code lost: throw new org.xmlpull.v1.XmlPullParserException(java.lang.String.format("Couldn't parse versionCode to int: %s", r13.getMessage())); */ /* JADX WARNING: Code restructure failed: missing block: B:39:0x00c7, code lost: throw new org.xmlpull.v1.XmlPullParserException("Manifest entry doesn't contain 'versionCode' attribute."); */ public final boolean a(File[] fileArr) throws IOException, XmlPullParserException { long j14; long j15; PackageInfo c14 = c(); if (Build.VERSION.SDK_INT >= 28) { j14 = c14.getLongVersionCode(); } else { j14 = (long) c14.versionCode; } try { Constructor declaredConstructor = AssetManager.class.getDeclaredConstructor(new Class[0]); if (!declaredConstructor.isAccessible()) { declaredConstructor.setAccessible(true); } AssetManager assetManager = (AssetManager) declaredConstructor.newInstance(new Object[0]); int length = fileArr.length; loop0: do { length--; if (length < 0) { return true; } m mVar = this.f171338c; File file = fileArr[length]; Objects.requireNonNull(mVar); mVar.f171335a = assetManager.openXmlResourceParser(b.b(assetManager, file), "AndroidManifest.xml"); m mVar2 = this.f171338c; if (mVar2.f171335a != null) { while (true) { int next = mVar2.f171335a.next(); if (next != 2) { if (next == 1) { break loop0; } } else { break; } } throw new XmlPullParserException("Couldn't find manifest entry at top-level."); } throw new XmlPullParserException("Manifest file needs to be loaded before parsing."); } while (j14 == j15); return false; } catch (Exception e14) { throw new w(String.format("Failed to invoke default constructor on class %s", AssetManager.class.getName()), e14); } } public final boolean b(File[] fileArr) { String absolutePath; X509Certificate x509Certificate; PackageInfo c14 = c(); ArrayList arrayList = null; if (!(c14 == null || c14.signatures == null)) { ArrayList arrayList2 = new ArrayList(); for (Signature signature : c14.signatures) { try { x509Certificate = (X509Certificate) CertificateFactory.getInstance("X509").generateCertificate(new ByteArrayInputStream(signature.toByteArray())); } catch (CertificateException unused) { x509Certificate = null; } if (x509Certificate != null) { arrayList2.add(x509Certificate); } } arrayList = arrayList2; } if (arrayList == null || arrayList.isEmpty()) { return false; } int length = fileArr.length; loop1: while (true) { length--; if (length < 0) { return true; } try { absolutePath = fileArr[length].getAbsolutePath(); try { X509Certificate[][] a14 = m0.a(absolutePath); if (a14 == null || a14.length == 0 || a14[0].length == 0) { new StringBuilder(String.valueOf(absolutePath).length() + 32); } else if (arrayList.isEmpty()) { break; } else { Iterator it3 = arrayList.iterator(); while (true) { if (it3.hasNext()) { X509Certificate x509Certificate2 = (X509Certificate) it3.next(); int length2 = a14.length; int i14 = 0; while (true) { if (i14 >= length2) { break loop1; } else if (!a14[i14][0].equals(x509Certificate2)) { i14++; } } } } } } catch (Exception unused2) { new StringBuilder(String.valueOf(absolutePath).length() + 32); } } catch (Exception unused3) { } } new StringBuilder(String.valueOf(absolutePath).length() + 32); return false; } public final PackageInfo c() { if (this.f171339d == null) { try { this.f171339d = this.f171337b.getPackageManager().getPackageInfo(this.f171337b.getPackageName(), 64); } catch (PackageManager.NameNotFoundException unused) { return null; } } return this.f171339d; } }