941 lines
39 KiB
Java
941 lines
39 KiB
Java
package com.kofax.mobile.sdk.extract.id;
|
|
|
|
import android.content.Context;
|
|
import android.net.ConnectivityManager;
|
|
import android.net.NetworkInfo;
|
|
import bolts.Capture;
|
|
import bolts.Continuation;
|
|
import bolts.Task;
|
|
import com.google.common.net.HttpHeaders;
|
|
import com.google.firebase.crashlytics.internal.common.AbstractSpiCall;
|
|
import com.google.gson.Gson;
|
|
import com.kofax.R;
|
|
import com.kofax.kmc.kut.utilities.CertificateValidatorListener;
|
|
import com.kofax.kmc.kut.utilities.SdkVersion;
|
|
import com.kofax.kmc.kut.utilities.error.ErrorInfo;
|
|
import com.kofax.kmc.kut.utilities.error.KmcRuntimeException;
|
|
import com.kofax.mobile.sdk._internal.dagger.Injector;
|
|
import com.kofax.mobile.sdk.extract.id.bundle.IBundleCacheProvider;
|
|
import com.kofax.mobile.sdk.extract.id.bundle.ZipInputStreamBundle;
|
|
import java.io.File;
|
|
import java.io.FileInputStream;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.net.MalformedURLException;
|
|
import java.net.URL;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.concurrent.Callable;
|
|
import java.util.concurrent.CopyOnWriteArrayList;
|
|
import java.util.concurrent.TimeUnit;
|
|
import o.C15195gjp;
|
|
import o.InterfaceC13391fZD;
|
|
import o.gjJ;
|
|
import okhttp3.Call;
|
|
import okhttp3.Callback;
|
|
import okhttp3.HttpUrl;
|
|
import okhttp3.OkHttpClient;
|
|
import okhttp3.Request;
|
|
|
|
/* loaded from: classes3.dex */
|
|
public class ServerProjectProvider implements IProjectProvider {
|
|
private static final String aeW = "GetHighestVersion";
|
|
private static final String aeX = "getProject";
|
|
private static final String aeY = "getVariant";
|
|
private static final String aeZ = "sdkVersion";
|
|
private static final String afa = "version";
|
|
private static final String afb = "project";
|
|
private static final String afc = "variant";
|
|
private static final Object afd = new Object();
|
|
private static final String yX = "VariantsList.json";
|
|
|
|
@InterfaceC13391fZD
|
|
IBundleCacheProvider aec;
|
|
private final List<a> afe;
|
|
private final Map<String, Map<String, String>> aff;
|
|
private final String afg;
|
|
private final String afh;
|
|
private final String afi;
|
|
|
|
@InterfaceC13391fZD
|
|
ConnectivityManager afj;
|
|
|
|
/* loaded from: classes3.dex */
|
|
public static class Error {
|
|
public String Message;
|
|
public String message;
|
|
}
|
|
|
|
public ServerProjectProvider(Context context, String str) throws MalformedURLException {
|
|
this(context, null, str, null);
|
|
Injector.getInjector(context).inject(this);
|
|
}
|
|
|
|
public ServerProjectProvider(Context context, IBundleCacheProvider iBundleCacheProvider, String str, ConnectivityManager connectivityManager) throws MalformedURLException {
|
|
this.afe = new CopyOnWriteArrayList();
|
|
this.aff = new HashMap();
|
|
if (context == null) {
|
|
throw new KmcRuntimeException(ErrorInfo.KMC_GN_ILLEGAL_ARGUMENT_EXCEPTION);
|
|
}
|
|
if (!str.endsWith("/")) {
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append(str);
|
|
sb.append("/");
|
|
str = sb.toString();
|
|
}
|
|
this.afg = str;
|
|
if (HttpUrl.parse(str) == null) {
|
|
throw new MalformedURLException();
|
|
}
|
|
this.afh = context.getString(R.string.ProjectProvider_NoNetworkConnection);
|
|
this.afi = context.getString(R.string.ProjectProvider_UnparsableError);
|
|
this.aec = iBundleCacheProvider;
|
|
this.afj = connectivityManager;
|
|
}
|
|
|
|
public void setCertificateValidatorListener(CertificateValidatorListener certificateValidatorListener) {
|
|
synchronized (afd) {
|
|
HttpClientHolder.uc().b(this.afg, certificateValidatorListener);
|
|
}
|
|
}
|
|
|
|
public void setRequestTimeout(long j, TimeUnit timeUnit) {
|
|
synchronized (afd) {
|
|
HttpClientHolder.uc().a(j, timeUnit);
|
|
}
|
|
}
|
|
|
|
@Override // com.kofax.mobile.sdk.extract.id.IProjectProvider
|
|
public void getHighestVersion(String str, String str2, ICompletionListener<String> iCompletionListener) {
|
|
if (iCompletionListener != null) {
|
|
getHighestVersionAsync(str, str2, false).continueWith(new Continuation<String, Void>(this, iCompletionListener) { // from class: com.kofax.mobile.sdk.extract.id.ServerProjectProvider.1
|
|
final ICompletionListener afk;
|
|
final ServerProjectProvider afl;
|
|
|
|
{
|
|
this.afl = this;
|
|
this.afk = iCompletionListener;
|
|
}
|
|
|
|
public /* bridge */ /* synthetic */ Object then(Task task) throws Exception {
|
|
return m294then((Task<String>) task);
|
|
}
|
|
|
|
/* renamed from: then, reason: collision with other method in class */
|
|
public Void m294then(Task<String> task) throws Exception {
|
|
this.afk.onComplete(task.getResult(), task.getError());
|
|
return null;
|
|
}
|
|
}, 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;
|
|
}
|
|
|
|
protected Task<String> getHighestVersionAsync(String str, String str2, boolean z) {
|
|
return P(str, str2).continueWithTask(new Continuation<String, Task<String>>(this, str, str2, z) { // from class: com.kofax.mobile.sdk.extract.id.ServerProjectProvider.10
|
|
final String aeg;
|
|
final ServerProjectProvider afl;
|
|
final boolean afm;
|
|
final String afo;
|
|
|
|
{
|
|
this.afl = this;
|
|
this.aeg = str;
|
|
this.afo = str2;
|
|
this.afm = z;
|
|
}
|
|
|
|
/* renamed from: then, reason: collision with other method in class */
|
|
public /* bridge */ /* synthetic */ Object m295then(Task task) throws Exception {
|
|
return then((Task<String>) task);
|
|
}
|
|
|
|
public Task<String> then(Task<String> task) throws Exception {
|
|
return task.isFaulted() ? this.afl.a(this.aeg, this.afo, this.afm) : task;
|
|
}
|
|
}).continueWithTask(new Continuation<String, Task<String>>(this, str, str2) { // from class: com.kofax.mobile.sdk.extract.id.ServerProjectProvider.9
|
|
final String aeg;
|
|
final ServerProjectProvider afl;
|
|
final String afo;
|
|
|
|
{
|
|
this.afl = this;
|
|
this.aeg = str;
|
|
this.afo = str2;
|
|
}
|
|
|
|
/* renamed from: then, reason: collision with other method in class */
|
|
public /* bridge */ /* synthetic */ Object m306then(Task task) throws Exception {
|
|
return then((Task<String>) task);
|
|
}
|
|
|
|
public Task<String> then(Task<String> task) throws Exception {
|
|
return task.isFaulted() ? this.afl.a(this.aeg, this.afo, task) : task;
|
|
}
|
|
}).onSuccess(new Continuation<String, String>(this, str, str2) { // from class: com.kofax.mobile.sdk.extract.id.ServerProjectProvider.8
|
|
final String aeg;
|
|
final ServerProjectProvider afl;
|
|
final String afo;
|
|
|
|
{
|
|
this.afl = this;
|
|
this.aeg = str;
|
|
this.afo = str2;
|
|
}
|
|
|
|
/* renamed from: b, reason: merged with bridge method [inline-methods] */
|
|
public String then(Task<String> task) throws Exception {
|
|
String str3 = (String) task.getResult();
|
|
this.afl.g(this.aeg, this.afo, str3);
|
|
return str3;
|
|
}
|
|
});
|
|
}
|
|
|
|
private Task<String> P(String str, String str2) {
|
|
return Task.callInBackground(new Callable<String>(this, str, str2) { // from class: com.kofax.mobile.sdk.extract.id.ServerProjectProvider.11
|
|
final String aeg;
|
|
final ServerProjectProvider afl;
|
|
final String afo;
|
|
|
|
{
|
|
this.afl = this;
|
|
this.aeg = str;
|
|
this.afo = str2;
|
|
}
|
|
|
|
@Override // java.util.concurrent.Callable
|
|
/* renamed from: mB, reason: merged with bridge method [inline-methods] */
|
|
public String call() throws Exception {
|
|
Map map = (Map) this.afl.aff.get(this.aeg);
|
|
String str3 = map != null ? (String) map.get(this.afo) : null;
|
|
if (str3 != null) {
|
|
return str3;
|
|
}
|
|
throw new Exception();
|
|
}
|
|
});
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public Task<String> a(String str, String str2, boolean z) {
|
|
return Task.callInBackground(new c()).onSuccessTask(new Continuation<String, Task<String>>(this, str, str2, z) { // from class: com.kofax.mobile.sdk.extract.id.ServerProjectProvider.12
|
|
final String aeg;
|
|
final ServerProjectProvider afl;
|
|
final boolean afm;
|
|
final String afo;
|
|
|
|
{
|
|
this.afl = this;
|
|
this.aeg = str;
|
|
this.afo = str2;
|
|
this.afm = z;
|
|
}
|
|
|
|
/* renamed from: then, reason: collision with other method in class */
|
|
public /* bridge */ /* synthetic */ Object m296then(Task task) throws Exception {
|
|
return then((Task<String>) task);
|
|
}
|
|
|
|
public Task<String> then(Task<String> task) throws Exception {
|
|
return new f(this.afl, this.aeg, this.afo).x(this.afm);
|
|
}
|
|
});
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public Task<String> a(String str, String str2, Task<String> task) {
|
|
String latestVersionForProject = this.aec.getLatestVersionForProject(str);
|
|
return gjJ.b((CharSequence) latestVersionForProject) ? task : Task.forResult(latestVersionForProject);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void g(String str, String str2, String str3) {
|
|
if (gjJ.b((CharSequence) str3) || this.aff.containsKey(str)) {
|
|
return;
|
|
}
|
|
HashMap hashMap = new HashMap(1);
|
|
hashMap.put(str2, str3);
|
|
this.aff.put(str, hashMap);
|
|
}
|
|
|
|
@Override // com.kofax.mobile.sdk.extract.id.IProjectProvider
|
|
public void getProject(String str, String str2, ICompletionListener<File> iCompletionListener) {
|
|
if (iCompletionListener != null) {
|
|
b(str, str2, false).continueWith(new Continuation<File, Void>(this, iCompletionListener) { // from class: com.kofax.mobile.sdk.extract.id.ServerProjectProvider.13
|
|
final ICompletionListener afk;
|
|
final ServerProjectProvider afl;
|
|
|
|
{
|
|
this.afl = this;
|
|
this.afk = iCompletionListener;
|
|
}
|
|
|
|
public /* bridge */ /* synthetic */ Object then(Task task) throws Exception {
|
|
return m297then((Task<File>) task);
|
|
}
|
|
|
|
/* renamed from: then, reason: collision with other method in class */
|
|
public Void m297then(Task<File> task) throws Exception {
|
|
this.afk.onComplete(task.getResult(), task.getError());
|
|
return null;
|
|
}
|
|
}, Task.UI_THREAD_EXECUTOR);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public Task<File> b(String str, String str2, boolean z) {
|
|
return Q(str, str2).continueWithTask(new Continuation<File, Task<File>>(this, str, str2, z) { // from class: com.kofax.mobile.sdk.extract.id.ServerProjectProvider.14
|
|
final String aeg;
|
|
final String aei;
|
|
final ServerProjectProvider afl;
|
|
final boolean afm;
|
|
|
|
{
|
|
this.afl = this;
|
|
this.aeg = str;
|
|
this.aei = str2;
|
|
this.afm = z;
|
|
}
|
|
|
|
/* renamed from: then, reason: collision with other method in class */
|
|
public /* bridge */ /* synthetic */ Object m298then(Task task) throws Exception {
|
|
return then((Task<File>) task);
|
|
}
|
|
|
|
public Task<File> then(Task<File> task) throws Exception {
|
|
return task.isFaulted() ? this.afl.c(this.aeg, this.aei, this.afm) : task;
|
|
}
|
|
});
|
|
}
|
|
|
|
private Task<File> Q(String str, String str2) {
|
|
File project = this.aec.getProject(str, str2);
|
|
if (project == null) {
|
|
return Task.forError(new Exception());
|
|
}
|
|
return Task.forResult(project);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public Task<File> c(String str, String str2, boolean z) {
|
|
return Task.callInBackground(new c()).onSuccessTask(new Continuation<File, Task<File>>(this, str, str2, z) { // from class: com.kofax.mobile.sdk.extract.id.ServerProjectProvider.15
|
|
final String aeg;
|
|
final String aei;
|
|
final ServerProjectProvider afl;
|
|
final boolean afm;
|
|
|
|
{
|
|
this.afl = this;
|
|
this.aeg = str;
|
|
this.aei = str2;
|
|
this.afm = z;
|
|
}
|
|
|
|
/* renamed from: then, reason: collision with other method in class */
|
|
public /* bridge */ /* synthetic */ Object m299then(Task task) throws Exception {
|
|
return then((Task<File>) task);
|
|
}
|
|
|
|
public Task<File> then(Task<File> task) throws Exception {
|
|
return new b(this.afl, this.aeg, this.aei).x(this.afm);
|
|
}
|
|
});
|
|
}
|
|
|
|
@Override // com.kofax.mobile.sdk.extract.id.IProjectProvider
|
|
public void getVariant(String str, String str2, String str3, ICompletionListener<File> iCompletionListener) {
|
|
if (iCompletionListener != null) {
|
|
a(str, str2, str3, false).continueWith(new Continuation<File, Void>(this, iCompletionListener) { // from class: com.kofax.mobile.sdk.extract.id.ServerProjectProvider.2
|
|
final ICompletionListener afk;
|
|
final ServerProjectProvider afl;
|
|
|
|
{
|
|
this.afl = this;
|
|
this.afk = iCompletionListener;
|
|
}
|
|
|
|
public /* bridge */ /* synthetic */ Object then(Task task) throws Exception {
|
|
return m300then((Task<File>) task);
|
|
}
|
|
|
|
/* renamed from: then, reason: collision with other method in class */
|
|
public Void m300then(Task<File> task) throws Exception {
|
|
this.afk.onComplete(task.getResult(), task.getError());
|
|
return null;
|
|
}
|
|
}, Task.UI_THREAD_EXECUTOR);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public Task<File> a(String str, String str2, String str3, boolean z) {
|
|
return h(str, str2, str3).continueWithTask(new Continuation<File, Task<File>>(this, str, str2, str3, z) { // from class: com.kofax.mobile.sdk.extract.id.ServerProjectProvider.3
|
|
final String aeg;
|
|
final String aei;
|
|
final String aek;
|
|
final ServerProjectProvider afl;
|
|
final boolean afm;
|
|
|
|
{
|
|
this.afl = this;
|
|
this.aeg = str;
|
|
this.aek = str2;
|
|
this.aei = str3;
|
|
this.afm = z;
|
|
}
|
|
|
|
/* renamed from: then, reason: collision with other method in class */
|
|
public /* bridge */ /* synthetic */ Object m301then(Task task) throws Exception {
|
|
return then((Task<File>) task);
|
|
}
|
|
|
|
public Task<File> then(Task<File> task) throws Exception {
|
|
return task.isFaulted() ? this.afl.b(this.aeg, this.aek, this.aei, this.afm) : task;
|
|
}
|
|
});
|
|
}
|
|
|
|
private Task<File> h(String str, String str2, String str3) {
|
|
File variant = this.aec.getVariant(str, str2, str3);
|
|
if (variant == null) {
|
|
return Task.forError(new Exception());
|
|
}
|
|
return Task.forResult(variant);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public Task<File> b(String str, String str2, String str3, boolean z) {
|
|
return Task.callInBackground(new c()).onSuccessTask(new Continuation<File, Task<File>>(this, str, str2, str3, z) { // from class: com.kofax.mobile.sdk.extract.id.ServerProjectProvider.4
|
|
final String aeg;
|
|
final String aei;
|
|
final String aek;
|
|
final ServerProjectProvider afl;
|
|
final boolean afm;
|
|
|
|
{
|
|
this.afl = this;
|
|
this.aeg = str;
|
|
this.aek = str2;
|
|
this.aei = str3;
|
|
this.afm = z;
|
|
}
|
|
|
|
/* renamed from: then, reason: collision with other method in class */
|
|
public /* bridge */ /* synthetic */ Object m302then(Task task) throws Exception {
|
|
return then((Task<File>) task);
|
|
}
|
|
|
|
public Task<File> then(Task<File> task) throws Exception {
|
|
return new e(this.afl, this.aeg, this.aek, this.aei).x(this.afm);
|
|
}
|
|
});
|
|
}
|
|
|
|
public void loadAllVariantsForProject(String str, ICompletionListener<Void> iCompletionListener) {
|
|
if (iCompletionListener != null) {
|
|
String sdkVersion = sdkVersion();
|
|
Capture capture = new Capture();
|
|
getHighestVersionAsync(str, sdkVersion, true).onSuccessTask(new Continuation<String, Task<File>>(this, capture, str) { // from class: com.kofax.mobile.sdk.extract.id.ServerProjectProvider.7
|
|
final String aeg;
|
|
final ServerProjectProvider afl;
|
|
final Capture afn;
|
|
|
|
{
|
|
this.afl = this;
|
|
this.afn = capture;
|
|
this.aeg = str;
|
|
}
|
|
|
|
/* renamed from: then, reason: collision with other method in class */
|
|
public /* bridge */ /* synthetic */ Object m305then(Task task) throws Exception {
|
|
return then((Task<String>) task);
|
|
}
|
|
|
|
public Task<File> then(Task<String> task) throws Exception {
|
|
this.afn.set(task.getResult());
|
|
return this.afl.b(this.aeg, (String) task.getResult(), true);
|
|
}
|
|
}).onSuccessTask(new Continuation<File, Task<Void>>(this, capture, str) { // from class: com.kofax.mobile.sdk.extract.id.ServerProjectProvider.6
|
|
final String aeg;
|
|
final ServerProjectProvider afl;
|
|
final Capture afn;
|
|
|
|
{
|
|
this.afl = this;
|
|
this.afn = capture;
|
|
this.aeg = str;
|
|
}
|
|
|
|
/* renamed from: then, reason: collision with other method in class */
|
|
public /* bridge */ /* synthetic */ Object m304then(Task task) throws Exception {
|
|
return then((Task<File>) task);
|
|
}
|
|
|
|
public Task<Void> then(Task<File> task) throws Exception {
|
|
String str2 = (String) this.afn.get();
|
|
String[] f2 = this.afl.f((File) task.getResult());
|
|
ArrayList arrayList = new ArrayList();
|
|
for (String str3 : f2) {
|
|
arrayList.add(this.afl.a(this.aeg, str3, str2, true));
|
|
}
|
|
return Task.whenAll(arrayList);
|
|
}
|
|
}).continueWithTask(new d()).continueWith(new Continuation<Void, Void>(this, iCompletionListener) { // from class: com.kofax.mobile.sdk.extract.id.ServerProjectProvider.5
|
|
final ICompletionListener afk;
|
|
final ServerProjectProvider afl;
|
|
|
|
{
|
|
this.afl = this;
|
|
this.afk = iCompletionListener;
|
|
}
|
|
|
|
public /* bridge */ /* synthetic */ Object then(Task task) throws Exception {
|
|
return m303then((Task<Void>) task);
|
|
}
|
|
|
|
/* renamed from: then, reason: collision with other method in class */
|
|
public Void m303then(Task<Void> task) throws Exception {
|
|
if (task.isCancelled()) {
|
|
this.afk.onComplete(null, new KmcRuntimeException(ErrorInfo.KMC_EV_CANCEL_OPERATION_SUCCESS));
|
|
} else {
|
|
this.afk.onComplete(null, task.getError());
|
|
}
|
|
return null;
|
|
}
|
|
}, Task.UI_THREAD_EXECUTOR);
|
|
}
|
|
}
|
|
|
|
public void cancelLoadAllVariants() {
|
|
Iterator<a> it = this.afe.iterator();
|
|
while (it.hasNext()) {
|
|
it.next().cancel();
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public HttpUrl R(String str, String str2) {
|
|
return aN(aeW).addQueryParameter(afb, str).addQueryParameter(aeZ, str2).build();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public HttpUrl S(String str, String str2) {
|
|
return aN(aeX).addQueryParameter(afb, str).addQueryParameter("version", str2).build();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public HttpUrl i(String str, String str2, String str3) {
|
|
return aN(aeY).addQueryParameter(afb, str).addQueryParameter(afc, str2).addQueryParameter("version", str3).build();
|
|
}
|
|
|
|
private HttpUrl.Builder aN(String str) {
|
|
return HttpUrl.parse(this.afg).newBuilder().addPathSegment(str);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public Request a(HttpUrl httpUrl) {
|
|
return new Request.Builder().url(httpUrl).addHeader("Accept", AbstractSpiCall.ACCEPT_JSON_VALUE).addHeader(HttpHeaders.ACCEPT_ENCODING, "identity").build();
|
|
}
|
|
|
|
protected String sdkVersion() {
|
|
return SdkVersion.getSdkVersion();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public String[] f(File file) throws IOException {
|
|
FileInputStream fileInputStream = new FileInputStream(new File(file, yX));
|
|
String b2 = C15195gjp.b(fileInputStream);
|
|
C15195gjp.d((InputStream) fileInputStream);
|
|
return (String[]) new Gson().getAdapter(String[].class).fromJson(b2);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes3.dex */
|
|
public static class HttpClientHolder {
|
|
private static final long aft = 10;
|
|
private static final TimeUnit afu = TimeUnit.SECONDS;
|
|
private static HttpClientHolder afz;
|
|
long afv;
|
|
TimeUnit afw;
|
|
String afx;
|
|
CertificateValidatorListener afy;
|
|
OkHttpClient client;
|
|
|
|
static HttpClientHolder uc() {
|
|
if (afz == null) {
|
|
afz = new HttpClientHolder(aft, afu, null, null);
|
|
}
|
|
return afz;
|
|
}
|
|
|
|
private HttpClientHolder(long j, TimeUnit timeUnit, String str, CertificateValidatorListener certificateValidatorListener) {
|
|
b(j, timeUnit, str, certificateValidatorListener);
|
|
}
|
|
|
|
private void b(long j, TimeUnit timeUnit, String str, CertificateValidatorListener certificateValidatorListener) {
|
|
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
|
builder.connectTimeout(j, timeUnit);
|
|
builder.writeTimeout(j, timeUnit);
|
|
builder.readTimeout(j, timeUnit);
|
|
if (certificateValidatorListener != null && str != null) {
|
|
try {
|
|
URL url = new URL(str);
|
|
if (url.getProtocol().equalsIgnoreCase("https")) {
|
|
builder.sslSocketFactory(certificateValidatorListener.getSSLSocketFactory(url.getHost()));
|
|
}
|
|
} catch (Exception e) {
|
|
throw new ProjectProviderException(e);
|
|
}
|
|
}
|
|
this.client = builder.build();
|
|
this.afv = j;
|
|
this.afw = timeUnit;
|
|
this.afx = str;
|
|
this.afy = certificateValidatorListener;
|
|
}
|
|
|
|
void a(long j, TimeUnit timeUnit) {
|
|
b(j, timeUnit, this.afx, this.afy);
|
|
}
|
|
|
|
void b(String str, CertificateValidatorListener certificateValidatorListener) {
|
|
b(this.afv, this.afw, str, certificateValidatorListener);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes3.dex */
|
|
public class d<T> implements Continuation<T, Task<T>> {
|
|
final ServerProjectProvider afl;
|
|
|
|
private d(ServerProjectProvider serverProjectProvider) {
|
|
this.afl = serverProjectProvider;
|
|
}
|
|
|
|
/* renamed from: then, reason: merged with bridge method [inline-methods] */
|
|
public Task<T> m308then(Task<T> task) throws Exception {
|
|
if (!task.isFaulted()) {
|
|
return task;
|
|
}
|
|
return Task.callInBackground(new c()).onSuccessTask(new Continuation<T, Task<Void>>(this) { // from class: com.kofax.mobile.sdk.extract.id.ServerProjectProvider.d.3
|
|
final d afD;
|
|
|
|
{
|
|
this.afD = this;
|
|
}
|
|
|
|
/* renamed from: then, reason: merged with bridge method [inline-methods] */
|
|
public Task<Void> m311then(Task<T> task2) throws Exception {
|
|
return Task.delay(20L);
|
|
}
|
|
}).onSuccessTask(new Continuation<Void, Task<Void>>(this) { // from class: com.kofax.mobile.sdk.extract.id.ServerProjectProvider.d.2
|
|
final d afD;
|
|
|
|
{
|
|
this.afD = this;
|
|
}
|
|
|
|
/* renamed from: then, reason: collision with other method in class */
|
|
public /* bridge */ /* synthetic */ Object m310then(Task task2) throws Exception {
|
|
return then((Task<Void>) task2);
|
|
}
|
|
|
|
public Task<Void> then(Task<Void> task2) throws Exception {
|
|
return Task.callInBackground(new c());
|
|
}
|
|
}).onSuccessTask(new Continuation<Void, Task<T>>(this, task.getError()) { // from class: com.kofax.mobile.sdk.extract.id.ServerProjectProvider.d.1
|
|
final Exception afC;
|
|
final d afD;
|
|
|
|
{
|
|
this.afD = this;
|
|
this.afC = r2;
|
|
}
|
|
|
|
/* renamed from: then, reason: collision with other method in class */
|
|
public /* bridge */ /* synthetic */ Object m309then(Task task2) throws Exception {
|
|
return then((Task<Void>) task2);
|
|
}
|
|
|
|
public Task<T> then(Task<Void> task2) throws Exception {
|
|
return Task.forError(this.afC);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes3.dex */
|
|
public class c<T> implements Callable<T> {
|
|
final ServerProjectProvider afl;
|
|
|
|
private c(ServerProjectProvider serverProjectProvider) {
|
|
this.afl = serverProjectProvider;
|
|
}
|
|
|
|
@Override // java.util.concurrent.Callable
|
|
public T call() throws Exception {
|
|
NetworkInfo activeNetworkInfo = this.afl.afj.getActiveNetworkInfo();
|
|
if (activeNetworkInfo == null || !activeNetworkInfo.isConnectedOrConnecting()) {
|
|
throw new ProjectProviderException(this.afl.afh);
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes3.dex */
|
|
public abstract class a<T> implements Callback {
|
|
final ServerProjectProvider afl;
|
|
private final Request afp;
|
|
private final Task<T>.TaskCompletionSource afq = Task.create();
|
|
private Call afr;
|
|
|
|
protected abstract T b(InputStream inputStream) throws Exception;
|
|
|
|
public a(ServerProjectProvider serverProjectProvider, Request request) {
|
|
this.afl = serverProjectProvider;
|
|
this.afp = request;
|
|
}
|
|
|
|
public Task<T> x(boolean z) {
|
|
Call newCall = HttpClientHolder.uc().client.newCall(this.afp);
|
|
this.afr = newCall;
|
|
newCall.enqueue(this);
|
|
if (z) {
|
|
this.afl.afe.add(this);
|
|
}
|
|
return this.afq.getTask().continueWithTask(new Continuation<T, Task<T>>(this) { // from class: com.kofax.mobile.sdk.extract.id.ServerProjectProvider.a.1
|
|
final a afs;
|
|
|
|
{
|
|
this.afs = this;
|
|
}
|
|
|
|
/* renamed from: then, reason: merged with bridge method [inline-methods] */
|
|
public Task<T> m307then(Task<T> task) throws Exception {
|
|
this.afs.afl.afe.remove(this.afs);
|
|
return task;
|
|
}
|
|
}).continueWithTask(new d());
|
|
}
|
|
|
|
public void cancel() {
|
|
this.afq.trySetCancelled();
|
|
this.afr.cancel();
|
|
}
|
|
|
|
@Override // okhttp3.Callback
|
|
public void onFailure(Call call, IOException iOException) {
|
|
a(new ProjectProviderException((Exception) iOException));
|
|
}
|
|
|
|
private void a(ProjectProviderException projectProviderException) {
|
|
this.afq.trySetError(projectProviderException);
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
/* JADX WARN: Removed duplicated region for block: B:24:0x00a2 */
|
|
/* JADX WARN: Removed duplicated region for block: B:25:? A[RETURN, SYNTHETIC] */
|
|
/* JADX WARN: Removed duplicated region for block: B:31:0x00b5 */
|
|
@Override // okhttp3.Callback
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public void onResponse(okhttp3.Call r6, okhttp3.Response r7) throws java.io.IOException {
|
|
/*
|
|
r5 = this;
|
|
r6 = 0
|
|
okhttp3.ResponseBody r0 = r7.body() // Catch: java.lang.Throwable -> L89 java.lang.Exception -> L8d
|
|
int r7 = r7.code() // Catch: java.lang.Throwable -> L85 java.lang.Exception -> L87
|
|
r1 = 200(0xc8, float:2.8E-43)
|
|
if (r7 != r1) goto L42
|
|
java.util.UUID r7 = java.util.UUID.randomUUID() // Catch: java.lang.Throwable -> L85 java.lang.Exception -> L87
|
|
java.lang.String r7 = r7.toString() // Catch: java.lang.Throwable -> L85 java.lang.Exception -> L87
|
|
android.os.MemoryFile r1 = new android.os.MemoryFile // Catch: java.lang.Throwable -> L85 java.lang.Exception -> L87
|
|
long r2 = r0.contentLength() // Catch: java.lang.Throwable -> L85 java.lang.Exception -> L87
|
|
int r2 = (int) r2 // Catch: java.lang.Throwable -> L85 java.lang.Exception -> L87
|
|
r1.<init>(r7, r2) // Catch: java.lang.Throwable -> L85 java.lang.Exception -> L87
|
|
java.io.OutputStream r6 = r1.getOutputStream() // Catch: java.lang.Throwable -> L38 java.lang.Exception -> L3b
|
|
java.io.InputStream r7 = r0.byteStream() // Catch: java.lang.Throwable -> L38 java.lang.Exception -> L3b
|
|
o.C15195gjp.c(r7, r6) // Catch: java.lang.Throwable -> L38 java.lang.Exception -> L3b
|
|
java.io.InputStream r7 = r1.getInputStream() // Catch: java.lang.Throwable -> L38 java.lang.Exception -> L3b
|
|
java.lang.Object r7 = r5.b(r7) // Catch: java.lang.Throwable -> L38 java.lang.Exception -> L3b
|
|
bolts.Task<T>$TaskCompletionSource r2 = r5.afq // Catch: java.lang.Throwable -> L38 java.lang.Exception -> L3b
|
|
r2.trySetResult(r7) // Catch: java.lang.Throwable -> L38 java.lang.Exception -> L3b
|
|
goto L7c
|
|
L38:
|
|
r7 = move-exception
|
|
goto Lad
|
|
L3b:
|
|
r7 = move-exception
|
|
r4 = r7
|
|
r7 = r6
|
|
r6 = r1
|
|
r1 = r0
|
|
r0 = r4
|
|
goto L92
|
|
L42:
|
|
com.google.gson.Gson r7 = new com.google.gson.Gson // Catch: java.lang.Throwable -> L85 java.lang.Exception -> L87
|
|
r7.<init>() // Catch: java.lang.Throwable -> L85 java.lang.Exception -> L87
|
|
java.lang.Class<com.kofax.mobile.sdk.extract.id.ServerProjectProvider$Error> r1 = com.kofax.mobile.sdk.extract.id.ServerProjectProvider.Error.class
|
|
com.google.gson.TypeAdapter r7 = r7.getAdapter(r1) // Catch: java.lang.Throwable -> L85 java.lang.Exception -> L87
|
|
java.lang.String r1 = r0.string() // Catch: java.lang.Throwable -> L85 java.lang.Exception -> L87
|
|
java.lang.Object r7 = r7.fromJson(r1) // Catch: java.lang.Throwable -> L85 java.lang.Exception -> L87
|
|
com.kofax.mobile.sdk.extract.id.ServerProjectProvider$Error r7 = (com.kofax.mobile.sdk.extract.id.ServerProjectProvider.Error) r7 // Catch: java.lang.Throwable -> L85 java.lang.Exception -> L87
|
|
java.lang.String r1 = r7.message // Catch: java.lang.Throwable -> L85 java.lang.Exception -> L87
|
|
boolean r1 = o.gjJ.b(r1) // Catch: java.lang.Throwable -> L85 java.lang.Exception -> L87
|
|
if (r1 != 0) goto L62
|
|
java.lang.String r7 = r7.message // Catch: java.lang.Throwable -> L85 java.lang.Exception -> L87
|
|
goto L73
|
|
L62:
|
|
java.lang.String r1 = r7.Message // Catch: java.lang.Throwable -> L85 java.lang.Exception -> L87
|
|
boolean r1 = o.gjJ.b(r1) // Catch: java.lang.Throwable -> L85 java.lang.Exception -> L87
|
|
if (r1 != 0) goto L6d
|
|
java.lang.String r7 = r7.Message // Catch: java.lang.Throwable -> L85 java.lang.Exception -> L87
|
|
goto L73
|
|
L6d:
|
|
com.kofax.mobile.sdk.extract.id.ServerProjectProvider r7 = r5.afl // Catch: java.lang.Throwable -> L85 java.lang.Exception -> L87
|
|
java.lang.String r7 = com.kofax.mobile.sdk.extract.id.ServerProjectProvider.e(r7) // Catch: java.lang.Throwable -> L85 java.lang.Exception -> L87
|
|
L73:
|
|
com.kofax.mobile.sdk.extract.id.ProjectProviderException r1 = new com.kofax.mobile.sdk.extract.id.ProjectProviderException // Catch: java.lang.Throwable -> L85 java.lang.Exception -> L87
|
|
r1.<init>(r7) // Catch: java.lang.Throwable -> L85 java.lang.Exception -> L87
|
|
r5.a(r1) // Catch: java.lang.Throwable -> L85 java.lang.Exception -> L87
|
|
r1 = r6
|
|
L7c:
|
|
o.C15195gjp.d(r0)
|
|
o.C15195gjp.e(r6)
|
|
if (r1 == 0) goto La6
|
|
goto La3
|
|
L85:
|
|
r7 = move-exception
|
|
goto L8b
|
|
L87:
|
|
r7 = move-exception
|
|
goto L8f
|
|
L89:
|
|
r7 = move-exception
|
|
r0 = r6
|
|
L8b:
|
|
r1 = r6
|
|
goto Lad
|
|
L8d:
|
|
r7 = move-exception
|
|
r0 = r6
|
|
L8f:
|
|
r1 = r0
|
|
r0 = r7
|
|
r7 = r6
|
|
L92:
|
|
com.kofax.mobile.sdk.extract.id.ProjectProviderException r2 = new com.kofax.mobile.sdk.extract.id.ProjectProviderException // Catch: java.lang.Throwable -> La7
|
|
r2.<init>(r0) // Catch: java.lang.Throwable -> La7
|
|
r5.a(r2) // Catch: java.lang.Throwable -> La7
|
|
o.C15195gjp.d(r1)
|
|
o.C15195gjp.e(r7)
|
|
if (r6 == 0) goto La6
|
|
r1 = r6
|
|
La3:
|
|
r1.close()
|
|
La6:
|
|
return
|
|
La7:
|
|
r0 = move-exception
|
|
r4 = r1
|
|
r1 = r6
|
|
r6 = r7
|
|
r7 = r0
|
|
r0 = r4
|
|
Lad:
|
|
o.C15195gjp.d(r0)
|
|
o.C15195gjp.e(r6)
|
|
if (r1 == 0) goto Lb8
|
|
r1.close()
|
|
Lb8:
|
|
throw r7
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.kofax.mobile.sdk.extract.id.ServerProjectProvider.a.onResponse(okhttp3.Call, okhttp3.Response):void");
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes3.dex */
|
|
public class f extends a<String> {
|
|
final ServerProjectProvider afl;
|
|
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
public f(ServerProjectProvider serverProjectProvider, String str, String str2) {
|
|
super(serverProjectProvider, serverProjectProvider.a(serverProjectProvider.R(str, str2)));
|
|
this.afl = serverProjectProvider;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
@Override // com.kofax.mobile.sdk.extract.id.ServerProjectProvider.a
|
|
/* renamed from: d, reason: merged with bridge method [inline-methods] */
|
|
public String b(InputStream inputStream) throws Exception {
|
|
return C15195gjp.b(inputStream).replace("\"", "");
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes3.dex */
|
|
public class b extends a<File> {
|
|
private final String afA;
|
|
private final String afB;
|
|
final ServerProjectProvider afl;
|
|
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
public b(ServerProjectProvider serverProjectProvider, String str, String str2) {
|
|
super(serverProjectProvider, serverProjectProvider.a(serverProjectProvider.S(str, str2)));
|
|
this.afl = serverProjectProvider;
|
|
this.afA = str;
|
|
this.afB = str2;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
@Override // com.kofax.mobile.sdk.extract.id.ServerProjectProvider.a
|
|
/* renamed from: c, reason: merged with bridge method [inline-methods] */
|
|
public File b(InputStream inputStream) throws Exception {
|
|
return this.afl.aec.cacheProject(this.afA, new ZipInputStreamBundle(inputStream), this.afB);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes3.dex */
|
|
public class e extends a<File> {
|
|
private final String afA;
|
|
private final String afB;
|
|
private final String afE;
|
|
final ServerProjectProvider afl;
|
|
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
public e(ServerProjectProvider serverProjectProvider, String str, String str2, String str3) {
|
|
super(serverProjectProvider, serverProjectProvider.a(serverProjectProvider.i(str, str2, str3)));
|
|
this.afl = serverProjectProvider;
|
|
this.afA = str;
|
|
this.afE = str2;
|
|
this.afB = str3;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
@Override // com.kofax.mobile.sdk.extract.id.ServerProjectProvider.a
|
|
/* renamed from: c, reason: merged with bridge method [inline-methods] */
|
|
public File b(InputStream inputStream) throws Exception {
|
|
return this.afl.aec.cacheVariant(this.afA, this.afE, new ZipInputStreamBundle(inputStream), this.afB);
|
|
}
|
|
}
|
|
}
|