package b.f.m; import android.content.Context; import android.util.Log; import b.c.a.a0.d; import b.f.m.a; import b.f.m.m; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.Arrays; import java.util.Enumeration; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.Objects; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; /* compiled from: ExtractFromZipSoSource */ public class f extends m { public final File f; public final String g; /* compiled from: ExtractFromZipSoSource */ public static final class b extends m.b implements Comparable { public final ZipEntry l; public final int m; public b(String str, ZipEntry zipEntry, int i) { super(str, String.format("pseudo-zip-hash-1-%s-%s-%s-%s", zipEntry.getName(), Long.valueOf(zipEntry.getSize()), Long.valueOf(zipEntry.getCompressedSize()), Long.valueOf(zipEntry.getCrc()))); this.l = zipEntry; this.m = i; } @Override // java.lang.Comparable public int compareTo(Object obj) { return this.j.compareTo(((b) obj).j); } } /* compiled from: ExtractFromZipSoSource */ public class c extends m.f { public b[] j; public final ZipFile k; public final m l; /* compiled from: ExtractFromZipSoSource */ public final class a extends m.e { public int j; public a(a aVar) { } @Override // b.f.m.m.e public boolean a() { c.this.c(); return this.j < c.this.j.length; } @Override // b.f.m.m.e public m.d b() throws IOException { c.this.c(); c cVar = c.this; b[] bVarArr = cVar.j; int i = this.j; this.j = i + 1; b bVar = bVarArr[i]; InputStream inputStream = cVar.k.getInputStream(bVar.l); try { return new m.d(bVar, inputStream); } catch (Throwable th) { if (inputStream != null) { inputStream.close(); } throw th; } } } public c(m mVar) throws IOException { this.k = new ZipFile(f.this.f); this.l = mVar; } @Override // b.f.m.m.f public final m.c a() throws IOException { return new m.c(c()); } @Override // b.f.m.m.f public final m.e b() throws IOException { return new a(null); } /* JADX WARNING: Removed duplicated region for block: B:41:0x0120 */ /* JADX WARNING: Removed duplicated region for block: B:42:0x0123 */ public final b[] c() { int i; boolean z2; String str; if (this.j == null) { LinkedHashSet linkedHashSet = new LinkedHashSet(); HashMap hashMap = new HashMap(); Pattern compile = Pattern.compile(f.this.g); String[] C0 = d.C0(); Enumeration entries = this.k.entries(); while (true) { i = 0; if (!entries.hasMoreElements()) { break; } ZipEntry zipEntry = (ZipEntry) entries.nextElement(); Matcher matcher = compile.matcher(zipEntry.getName()); if (matcher.matches()) { String group = matcher.group(1); String group2 = matcher.group(2); while (true) { if (i >= C0.length) { i = -1; break; } if (C0[i] != null && group.equals(C0[i])) { break; } i++; } if (i >= 0) { linkedHashSet.add(group); b bVar = (b) hashMap.get(group2); if (bVar == null || i < bVar.m) { hashMap.put(group2, new b(group2, zipEntry, i)); } } } } m mVar = this.l; String[] strArr = (String[]) linkedHashSet.toArray(new String[linkedHashSet.size()]); Objects.requireNonNull(mVar); b[] bVarArr = (b[]) hashMap.values().toArray(new b[hashMap.size()]); Arrays.sort(bVarArr); int i2 = 0; for (int i3 = 0; i3 < bVarArr.length; i3++) { b bVar2 = bVarArr[i3]; ZipEntry zipEntry2 = bVar2.l; String str2 = bVar2.j; a.C0070a aVar = (a.C0070a) this; String name = zipEntry2.getName(); if (str2.equals(a.this.d)) { a.this.d = null; str = String.format("allowing consideration of corrupted lib %s", str2); } else if ((aVar.o & 1) == 0) { str = b.d.b.a.a.w("allowing consideration of ", name, ": self-extraction preferred"); } else { File file = new File(aVar.n, str2); if (!file.isFile()) { str = String.format("allowing considering of %s: %s not in system lib dir", name, str2); } else { long length = file.length(); long size = zipEntry2.getSize(); if (length != size) { str = String.format("allowing consideration of %s: sysdir file length is %s, but the file is %s bytes long in the APK", file, Long.valueOf(length), Long.valueOf(size)); } else { str = b.d.b.a.a.w("not allowing consideration of ", name, ": deferring to libdir"); z2 = false; Log.d("ApkSoSource", str); if (!z2) { i2++; } else { bVarArr[i3] = null; } } } } z2 = true; Log.d("ApkSoSource", str); if (!z2) { } } b[] bVarArr2 = new b[i2]; int i4 = 0; while (i < bVarArr.length) { b bVar3 = bVarArr[i]; if (bVar3 != null) { bVarArr2[i4] = bVar3; i4++; } i++; } this.j = bVarArr2; } return this.j; } @Override // b.f.m.m.f, java.io.Closeable, java.lang.AutoCloseable public void close() throws IOException { this.k.close(); } } public f(Context context, String str, File file, String str2) { super(context, str); this.f = file; this.g = str2; } }