what-the-bank/sources/com/kofax/mobile/sdk/extract/id/LocalProjectProvider.java

616 lines
23 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.kofax.mobile.sdk.extract.id;
import android.content.Context;
import android.content.res.AssetManager;
import android.util.Base64;
import bolts.Continuation;
import bolts.Task;
import com.google.gson.Gson;
import com.kofax.R;
import com.kofax.kmc.kut.utilities.SdkVersion;
import com.kofax.mobile.sdk._internal.dagger.Injector;
import com.kofax.mobile.sdk.extract.id.bundle.IBundle;
import com.kofax.mobile.sdk.extract.id.bundle.IBundleCacheProvider;
import com.kofax.mobile.sdk.extract.id.bundle.IBundleFile;
import com.kofax.mobile.sdk.extract.id.bundle.ZipFileBundle;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.WeakReference;
import java.nio.charset.StandardCharsets;
import java.util.Enumeration;
import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.zip.ZipFile;
import o.C15195gjp;
import o.InterfaceC13391fZD;
import o.gjJ;
/* loaded from: classes.dex */
public class LocalProjectProvider implements IProjectProvider {
private static int a = 1;
private static final Executor adX = Executors.newSingleThreadExecutor();
private static final String adY = "Project.zip";
private static final String adZ = "VersionTable.json";
private static final String aea = "Variant.zip";
private static int e;
private final WeakReference<Context> KX;
private final WeakReference<AssetManager> aeb;
@InterfaceC13391fZD
IBundleCacheProvider aec;
private InputStream aed;
private String aee;
private File aef;
/* loaded from: classes.dex */
public static class VersionTable {
public VersionList[] VersionList;
/* loaded from: classes.dex */
public static class VersionList {
public String dataVersion;
public String sdkMajor;
public String sdkMinor;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public interface a<T> {
T b(IBundle iBundle) throws IOException;
}
@InterfaceC13391fZD
public LocalProjectProvider(Context context) {
this.KX = new WeakReference<>(context);
this.aeb = new WeakReference<>(context.getAssets());
this.aed = null;
Injector.getInjector(context).inject(this);
}
public LocalProjectProvider(Context context, InputStream inputStream, IBundleCacheProvider iBundleCacheProvider) {
this.KX = new WeakReference<>(context);
this.aeb = null;
this.aed = inputStream;
this.aec = iBundleCacheProvider;
}
@Override // com.kofax.mobile.sdk.extract.id.IProjectProvider
public void getHighestVersion(String str, String str2, ICompletionListener<String> iCompletionListener) {
if (iCompletionListener != null) {
aM(str).continueWith(new b(iCompletionListener), Task.UI_THREAD_EXECUTOR);
}
}
@Override // com.kofax.mobile.sdk.extract.id.IProjectProvider
public void getProject(String str, String str2, ICompletionListener<File> iCompletionListener) {
if (iCompletionListener != null) {
getProjectAsync(str, str2).continueWith(new b(iCompletionListener), Task.UI_THREAD_EXECUTOR);
}
}
@Override // com.kofax.mobile.sdk.extract.id.IProjectProvider
public void getVariant(String str, String str2, String str3, ICompletionListener<File> iCompletionListener) {
if (iCompletionListener != null) {
getVariantAsync(str, str2, str3).continueWith(new b(iCompletionListener), Task.UI_THREAD_EXECUTOR);
}
}
@Override // com.kofax.mobile.sdk.extract.id.IProjectProvider
public String getLatestCachedModelDataBuildInfo(String str) {
IBundleCacheProvider iBundleCacheProvider = this.aec;
if (iBundleCacheProvider != null) {
return iBundleCacheProvider.getLatestModelDataBuildInfo(str);
}
return null;
}
private Task<String> aM(String str) {
return Task.call(new Callable<String>(this, str) { // from class: com.kofax.mobile.sdk.extract.id.LocalProjectProvider.1
final String aeg;
final LocalProjectProvider aeh;
{
this.aeh = this;
this.aeg = str;
}
@Override // java.util.concurrent.Callable
/* renamed from: mB, reason: merged with bridge method [inline-methods] */
public String call() throws Exception {
return this.aeh.getBundleVersion(this.aeg);
}
}, adX);
}
protected String getBundleVersion(String str) {
if (this.aee == null) {
a(str, new a(this) { // from class: com.kofax.mobile.sdk.extract.id.LocalProjectProvider.2
private static int b = 1;
private static byte c = 6;
private static int e;
final LocalProjectProvider aeh;
private void d(String str2, Object[] objArr) {
byte[] decode = Base64.decode(str2, 0);
byte[] bArr = new byte[decode.length];
for (int i = 0; i < decode.length; i++) {
bArr[i] = (byte) (decode[(decode.length - i) - 1] ^ c);
}
objArr[0] = new String(bArr, StandardCharsets.UTF_8);
}
{
this.aeh = this;
}
@Override // com.kofax.mobile.sdk.extract.id.LocalProjectProvider.a
/* renamed from: a, reason: merged with bridge method [inline-methods] */
public Void b(IBundle iBundle) {
Throwable th;
int i = 2 % 2;
int i2 = b + 17;
e = i2 % 128;
File file = null;
try {
if (i2 % 2 != 0) {
this.aeh.a(LocalProjectProvider.adZ, iBundle);
throw null;
}
File a2 = this.aeh.a(LocalProjectProvider.adZ, iBundle);
try {
if (a2 == null) {
String string = ((Context) this.aeh.KX.get()).getString(R.string.ProjectProvider_CouldNotReadVersionTable);
if (string.startsWith(",*,)")) {
Object[] objArr = new Object[1];
d(string.substring(4), objArr);
string = ((String) objArr[0]).intern();
}
throw new ProjectProviderException(string);
}
int i3 = e + 37;
b = i3 % 128;
int i4 = i3 % 2;
LocalProjectProvider localProjectProvider = this.aeh;
localProjectProvider.aee = localProjectProvider.readVersion(a2);
if (gjJ.b((CharSequence) this.aeh.aee)) {
throw new ProjectProviderException(((Context) this.aeh.KX.get()).getString(R.string.ProjectProvider_CouldNotGetProjectZip));
}
int i5 = b + 119;
e = i5 % 128;
int i6 = i5 % 2;
if (a2 != null) {
a2.delete();
int i7 = e + 15;
b = i7 % 128;
int i8 = i7 % 2;
}
return null;
} catch (Throwable th2) {
th = th2;
file = a2;
if (file != null) {
file.delete();
}
throw th;
}
} catch (Throwable th3) {
th = th3;
}
}
});
}
return this.aee;
}
protected String readVersion(File file) {
try {
return readVersion(C15195gjp.b(new FileInputStream(file)));
} catch (IOException e2) {
throw new ProjectProviderException((Exception) e2);
}
}
protected String readVersion(String str) {
VersionTable versionTable = (VersionTable) new Gson().fromJson(str, VersionTable.class);
if (versionTable == null || versionTable.VersionList == null || versionTable.VersionList.length <= 0) {
throw new ProjectProviderException(this.KX.get().getString(R.string.ProjectProvider_CouldNotReadVersionTable));
}
String[] split = sdkVersion().split("\\.");
String str2 = split[0];
String str3 = split[1];
String str4 = null;
for (VersionTable.VersionList versionList : versionTable.VersionList) {
String str5 = versionList.sdkMajor;
String str6 = versionList.sdkMinor;
if (str5.equals(str2) && str6.equals(str3)) {
str4 = versionList.dataVersion;
}
}
if (str4 != null) {
return str4;
}
throw new ProjectProviderException(this.KX.get().getString(R.string.ProjectProvider_IncorrectBundleVersion));
}
protected String sdkVersion() {
return SdkVersion.getSdkVersion();
}
/* JADX INFO: Access modifiers changed from: private */
public File a(String str, IBundle iBundle) {
Enumeration<? extends IBundleFile> list = iBundle.list();
while (list.hasMoreElements()) {
IBundleFile nextElement = list.nextElement();
if (gjJ.e((CharSequence) nextElement.getAbsolutePath(), (CharSequence) str)) {
return nextElement.getFile();
}
}
return null;
}
protected Task<File> getProjectAsync(String str, String str2) {
return Task.call(new Callable<File>(this, str, str2) { // from class: com.kofax.mobile.sdk.extract.id.LocalProjectProvider.3
final String aeg;
final LocalProjectProvider aeh;
final String aei;
{
this.aeh = this;
this.aeg = str;
this.aei = str2;
}
@Override // java.util.concurrent.Callable
/* renamed from: tX, reason: merged with bridge method [inline-methods] */
public File call() throws Exception {
if (!this.aei.equals(this.aeh.getBundleVersion(this.aeg))) {
throw new ProjectProviderException(((Context) this.aeh.KX.get()).getString(R.string.ProjectProvider_IncorrectBundleVersion));
}
File project = this.aeh.aec.getProject(this.aeg, this.aei);
return project == null ? this.aeh.O(this.aeg, this.aei) : project;
}
}, adX);
}
/* JADX INFO: Access modifiers changed from: private */
public File O(String str, String str2) {
return (File) a(str, new a<File>(this, str, str2) { // from class: com.kofax.mobile.sdk.extract.id.LocalProjectProvider.4
final String aeg;
final LocalProjectProvider aeh;
final String aej;
{
this.aeh = this;
this.aeg = str;
this.aej = str2;
}
@Override // com.kofax.mobile.sdk.extract.id.LocalProjectProvider.a
/* renamed from: c, reason: merged with bridge method [inline-methods] */
public File b(IBundle iBundle) throws IOException {
File file = null;
try {
File a2 = this.aeh.a(LocalProjectProvider.adY, iBundle);
if (a2 == null) {
throw new ProjectProviderException(((Context) this.aeh.KX.get()).getString(R.string.ProjectProvider_CouldNotGetProjectZip));
}
File cacheProject = this.aeh.aec.cacheProject(this.aeg, new ZipFileBundle(new ZipFile(a2)), this.aej);
if (a2 != null) {
a2.delete();
}
return cacheProject;
} catch (Throwable th) {
if (0 != 0) {
file.delete();
}
throw th;
}
}
});
}
protected Task<File> getVariantAsync(String str, String str2, String str3) {
return Task.call(new Callable<File>(this, str, str3, str2) { // from class: com.kofax.mobile.sdk.extract.id.LocalProjectProvider.5
final String aeg;
final LocalProjectProvider aeh;
final String aei;
final String aek;
{
this.aeh = this;
this.aeg = str;
this.aei = str3;
this.aek = str2;
}
@Override // java.util.concurrent.Callable
/* renamed from: tX, reason: merged with bridge method [inline-methods] */
public File call() throws Exception {
if (!this.aei.equals(this.aeh.getBundleVersion(this.aeg))) {
throw new ProjectProviderException(((Context) this.aeh.KX.get()).getString(R.string.ProjectProvider_IncorrectBundleVersion));
}
File variant = this.aeh.aec.getVariant(this.aeg, this.aek, this.aei);
return variant == null ? this.aeh.f(this.aeg, this.aek, this.aei) : variant;
}
}, adX);
}
/* JADX INFO: Access modifiers changed from: private */
public File f(String str, String str2, String str3) {
return (File) a(str, new a<File>(this, str2, str, str3) { // from class: com.kofax.mobile.sdk.extract.id.LocalProjectProvider.6
final String aeg;
final LocalProjectProvider aeh;
final String aej;
final String aek;
{
this.aeh = this;
this.aek = str2;
this.aeg = str;
this.aej = str3;
}
@Override // com.kofax.mobile.sdk.extract.id.LocalProjectProvider.a
/* renamed from: c, reason: merged with bridge method [inline-methods] */
public File b(IBundle iBundle) {
File file = null;
try {
try {
LocalProjectProvider localProjectProvider = this.aeh;
StringBuilder sb = new StringBuilder("/");
sb.append(this.aek);
sb.append("/Variant.zip");
File a2 = localProjectProvider.a(sb.toString(), iBundle);
if (a2 == null) {
throw new ProjectProviderException(((Context) this.aeh.KX.get()).getString(R.string.ProjectProvider_CouldNotLocateVariantZip));
}
File cacheVariant = this.aeh.aec.cacheVariant(this.aeg, this.aek, new ZipFileBundle(new ZipFile(a2)), this.aej);
if (a2 != null) {
a2.delete();
}
return cacheVariant;
} catch (IOException e2) {
throw new ProjectProviderException((Exception) e2);
}
} catch (Throwable th) {
if (0 != 0) {
file.delete();
}
throw th;
}
}
});
}
/* JADX WARN: Code restructure failed: missing block: B:10:0x00f4, code lost:
r12 = e;
*/
/* JADX WARN: Code restructure failed: missing block: B:11:0x00f5, code lost:
r1 = null;
*/
/* JADX WARN: Code restructure failed: missing block: B:13:0x0101, code lost:
r2 = r10.aef;
*/
/* JADX WARN: Code restructure failed: missing block: B:14:0x0103, code lost:
if (r2 != null) goto L57;
*/
/* JADX WARN: Code restructure failed: missing block: B:15:0x0105, code lost:
r3 = com.kofax.mobile.sdk.extract.id.LocalProjectProvider.a + 121;
com.kofax.mobile.sdk.extract.id.LocalProjectProvider.e = r3 % 128;
*/
/* JADX WARN: Code restructure failed: missing block: B:16:0x010e, code lost:
if ((r3 % 2) != 0) goto L59;
*/
/* JADX WARN: Code restructure failed: missing block: B:17:0x0110, code lost:
r2.delete();
*/
/* JADX WARN: Code restructure failed: missing block: B:18:0x0113, code lost:
throw null;
*/
/* JADX WARN: Code restructure failed: missing block: B:20:0x0114, code lost:
r2.delete();
*/
/* JADX WARN: Code restructure failed: missing block: B:22:0x011c, code lost:
throw new com.kofax.mobile.sdk.extract.id.ProjectProviderException((java.lang.Exception) r12);
*/
/* JADX WARN: Code restructure failed: missing block: B:23:0x011d, code lost:
r12 = th;
*/
/* JADX WARN: Code restructure failed: missing block: B:24:0x011e, code lost:
r4 = r1;
*/
/* JADX WARN: Code restructure failed: missing block: B:29:0x00ef, code lost:
r12 = th;
*/
/* JADX WARN: Code restructure failed: missing block: B:30:0x00f0, code lost:
r1 = null;
*/
/* JADX WARN: Code restructure failed: missing block: B:31:0x00f1, code lost:
r11 = r11;
*/
/* JADX WARN: Code restructure failed: missing block: B:33:0x00c4, code lost:
r12 = r12.b(r1);
*/
/* JADX WARN: Code restructure failed: missing block: B:34:0x00c8, code lost:
if (r5 == true) goto L34;
*/
/* JADX WARN: Code restructure failed: missing block: B:35:0x00cb, code lost:
r2 = com.kofax.mobile.sdk.extract.id.LocalProjectProvider.a + 117;
com.kofax.mobile.sdk.extract.id.LocalProjectProvider.e = r2 % 128;
*/
/* JADX WARN: Code restructure failed: missing block: B:36:0x00d4, code lost:
if ((r2 % 2) != 0) goto L39;
*/
/* JADX WARN: Code restructure failed: missing block: B:37:0x00d6, code lost:
o.C15195gjp.d(r10.aed);
*/
/* JADX WARN: Code restructure failed: missing block: B:38:0x00e2, code lost:
o.C15195gjp.d(r10.aed);
r4.hashCode();
*/
/* JADX WARN: Code restructure failed: missing block: B:39:0x00ea, code lost:
throw null;
*/
/* JADX WARN: Code restructure failed: missing block: B:40:0x00db, code lost:
o.C15195gjp.d(r1);
o.C15195gjp.e(r11);
*/
/* JADX WARN: Code restructure failed: missing block: B:41:0x00e1, code lost:
return r12;
*/
/* JADX WARN: Code restructure failed: missing block: B:43:0x00ed, code lost:
r12 = e;
*/
/* JADX WARN: Code restructure failed: missing block: B:44:0x00eb, code lost:
r12 = th;
*/
/* JADX WARN: Code restructure failed: missing block: B:45:0x001d, code lost:
r2 = r2 + 17;
com.kofax.mobile.sdk.extract.id.LocalProjectProvider.e = r2 % 128;
r2 = r2 % 2;
*/
/* JADX WARN: Code restructure failed: missing block: B:48:0x0028, code lost:
if (r10.aed != null) goto L27;
*/
/* JADX WARN: Code restructure failed: missing block: B:49:0x002a, code lost:
r1 = r10.aeb.get();
r6 = new java.lang.StringBuilder();
r6.append(r11);
r6.append(".zip");
*/
/* JADX WARN: Code restructure failed: missing block: B:51:0x0041, code lost:
r11 = new java.lang.Object[]{r1, r6.toString()};
r1 = o.xzZ.y.get(-867414553);
*/
/* JADX WARN: Code restructure failed: missing block: B:52:0x0052, code lost:
if (r1 == null) goto L19;
*/
/* JADX WARN: Code restructure failed: missing block: B:55:0x0093, code lost:
r10.aed = (java.io.InputStream) ((java.lang.reflect.Method) r1).invoke(null, r11);
r5 = true;
*/
/* JADX WARN: Code restructure failed: missing block: B:57:0x0055, code lost:
r1 = ((java.lang.Class) o.xzZ.c(5 - android.text.TextUtils.getCapsMode("", 0, 0), (android.view.ViewConfiguration.getTouchSlop() >> 8) + 5, (char) (android.view.ViewConfiguration.getPressedStateDuration() >> 16))).getMethod("NN_", android.content.res.AssetManager.class, java.lang.String.class);
o.xzZ.y.put(-867414553, r1);
*/
/* JADX WARN: Code restructure failed: missing block: B:58:0x0097, code lost:
r11 = move-exception;
*/
/* JADX WARN: Code restructure failed: missing block: B:59:0x0098, code lost:
r12 = r11.getCause();
*/
/* JADX WARN: Code restructure failed: missing block: B:60:0x009c, code lost:
if (r12 != null) goto L25;
*/
/* JADX WARN: Code restructure failed: missing block: B:61:0x009e, code lost:
throw r12;
*/
/* JADX WARN: Code restructure failed: missing block: B:62:0x009f, code lost:
throw r11;
*/
/* JADX WARN: Code restructure failed: missing block: B:63:0x00a0, code lost:
r10.aef = java.io.File.createTempFile("ODE", ".zip");
r11 = new java.io.FileOutputStream(r10.aef);
*/
/* JADX WARN: Code restructure failed: missing block: B:65:0x00af, code lost:
o.C15195gjp.c(r10.aed, r11);
r10.aed = null;
*/
/* JADX WARN: Code restructure failed: missing block: B:6:0x0013, code lost:
if (r10.aef == null) goto L11;
*/
/* JADX WARN: Code restructure failed: missing block: B:71:0x001b, code lost:
if (r10.aef == null) goto L11;
*/
/* JADX WARN: Code restructure failed: missing block: B:7:0x00b7, code lost:
r11 = null;
*/
/* JADX WARN: Code restructure failed: missing block: B:8:0x00b8, code lost:
r1 = new com.kofax.mobile.sdk.extract.id.bundle.ZipFileBundle(new java.util.zip.ZipFile(r10.aef));
*/
/* JADX WARN: Removed duplicated region for block: B:15:0x0105 */
/* JADX WARN: Removed duplicated region for block: B:26:0x0121 */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
private <T> T a(java.lang.String r11, com.kofax.mobile.sdk.extract.id.LocalProjectProvider.a<T> r12) {
/*
Method dump skipped, instructions count: 301
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: com.kofax.mobile.sdk.extract.id.LocalProjectProvider.a(java.lang.String, com.kofax.mobile.sdk.extract.id.LocalProjectProvider$a):java.lang.Object");
}
protected void finalize() throws Throwable {
super.finalize();
File file = this.aef;
if (file != null) {
file.delete();
}
}
/* loaded from: classes3.dex */
static class b<T> implements Continuation<T, Void> {
private final ICompletionListener<T> ael;
private b(ICompletionListener<T> iCompletionListener) {
this.ael = iCompletionListener;
}
/* JADX WARN: Multi-variable type inference failed */
public Void then(Task<T> task) throws Exception {
this.ael.onComplete(task.getResult(), task.getError());
return null;
}
}
}