what-the-bank/sources/com/kofax/mobile/sdk/logistics/CaptureServer.java

959 lines
46 KiB
Java

package com.kofax.mobile.sdk.logistics;
import bolts.Continuation;
import bolts.Task;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.kofax.BuildConfig;
import com.kofax.kmc.ken.engines.data.BasicSettingsProfile;
import com.kofax.kmc.ken.engines.data.Image;
import com.kofax.kmc.ken.engines.data.ImagePerfectionProfile;
import com.kofax.kmc.ken.engines.processing.ColorDepth;
import com.kofax.kmc.ken.engines.processing.CropType;
import com.kofax.kmc.ken.engines.processing.DeskewType;
import com.kofax.kmc.ken.engines.processing.DocumentDimensions;
import com.kofax.kmc.ken.engines.processing.ImageProcessorConfiguration;
import com.kofax.kmc.ken.engines.processing.RotateType;
import com.kofax.kmc.klo.logistics.data.Document;
import com.kofax.kmc.klo.logistics.data.DocumentType;
import com.kofax.kmc.klo.logistics.data.Field;
import com.kofax.kmc.klo.logistics.data.FieldType;
import com.kofax.kmc.klo.logistics.data.Page;
import com.kofax.kmc.klo.logistics.data.UserProfile;
import com.kofax.kmc.klo.logistics.webservice.DeviceProfileResponse;
import com.kofax.kmc.klo.logistics.webservice.DeviceServiceResponse;
import com.kofax.kmc.klo.logistics.webservice.GetIndexFieldsResponse;
import com.kofax.kmc.klo.logistics.webservice.RetrieveScanSettingsResponse;
import com.kofax.kmc.klo.logistics.webservice.StartJobResponse;
import com.kofax.kmc.klo.logistics.webservice.UserLoginResponse;
import com.kofax.kmc.klo.logistics.webservice.WebServiceCallResult;
import com.kofax.kmc.klo.logistics.webservice.WscDestination;
import com.kofax.kmc.klo.logistics.webservice.WscIndexField;
import com.kofax.kmc.klo.logistics.webservice.WscScanSetting;
import com.kofax.kmc.klo.logistics.webservice.calls.DeviceService;
import com.kofax.kmc.klo.logistics.webservice.calls.GetIndexFields;
import com.kofax.kmc.klo.logistics.webservice.calls.ProfileService;
import com.kofax.kmc.klo.logistics.webservice.calls.RetrieveScanSettings;
import com.kofax.kmc.klo.logistics.webservice.calls.SendImage;
import com.kofax.kmc.klo.logistics.webservice.calls.StartJob;
import com.kofax.kmc.klo.logistics.webservice.calls.UserLogin;
import com.kofax.kmc.klo.logistics.webservice.calls.UserLogout;
import com.kofax.kmc.kut.utilities.CertificateValidatorListener;
import com.kofax.kmc.kut.utilities.Licensing;
import com.kofax.kmc.kut.utilities.error.ErrorInfo;
import com.kofax.kmc.kut.utilities.error.IllegalArgumentException;
import com.kofax.kmc.kut.utilities.error.KmcException;
import com.kofax.kmc.kut.utilities.error.KmcRuntimeException;
import com.kofax.mobile.sdk._internal.k;
import com.kofax.mobile.sdk.extract.id.ICompletionListener;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.Callable;
import o.gjJ;
/* loaded from: classes3.dex */
public class CaptureServer implements ICaptureServer {
private CertificateValidatorListener JI;
private URL agd;
private DocumentType.SourceServer agf;
private final String TAG = "CaptureServer";
private final String agc = "EVRSOperationsString";
private Map<String, WscDestination> age = null;
private boolean agg = false;
private int agh = 20000;
private UserProfile agi = null;
private HashMap<String, Boolean> agj = null;
public CaptureServer(String str, DocumentType.SourceServer sourceServer) {
this.agf = DocumentType.SourceServer.SERVER_NONE;
try {
if (!Licensing.isSdkLicensed(Licensing.LicenseType.LOGISTICS)) {
throw new KmcRuntimeException(ErrorInfo.KMC_UT_LICENSE_LOGISTICS);
}
if (str == null) {
throw new IllegalArgumentException("server url is null");
}
if (sourceServer == null) {
throw new IllegalArgumentException("SourceServer is null");
}
this.agd = new URL(str);
this.agf = sourceServer;
} catch (MalformedURLException e) {
ErrorInfo errorInfo = ErrorInfo.KMC_LO_INVALID_SERVER_URL;
errorInfo.setErrCause(e.getMessage());
throw new KmcRuntimeException(errorInfo, e);
}
}
public int getServerTimeout() {
return this.agh / 1000;
}
@Override // com.kofax.mobile.sdk.logistics.ICaptureServer
public void registerDevice(ICompletionListener<Void> iCompletionListener) {
if (iCompletionListener == null) {
throw new IllegalArgumentException("CompletionListener cannot be null");
}
ud().continueWith(new Continuation<Void, Void>(this, iCompletionListener) { // from class: com.kofax.mobile.sdk.logistics.CaptureServer.1
final ICompletionListener JC;
final CaptureServer agk;
{
this.agk = this;
this.JC = iCompletionListener;
}
public /* bridge */ /* synthetic */ Object then(Task task) throws Exception {
return m313then((Task<Void>) task);
}
/* renamed from: then, reason: collision with other method in class */
public Void m313then(Task<Void> task) throws Exception {
this.JC.onComplete(task.getResult(), task.getError());
return null;
}
}, Task.UI_THREAD_EXECUTOR);
}
@Override // com.kofax.mobile.sdk.logistics.ICaptureServer
public void login(UserProfile userProfile, ICompletionListener<List<String>> iCompletionListener) {
if (iCompletionListener == null) {
throw new IllegalArgumentException("CompletionListener cannot be null");
}
this.agi = userProfile.m277clone();
a(userProfile).continueWith(new Continuation<List<String>, Void>(this, iCompletionListener) { // from class: com.kofax.mobile.sdk.logistics.CaptureServer.10
final ICompletionListener JC;
final CaptureServer agk;
{
this.agk = this;
this.JC = iCompletionListener;
}
public /* bridge */ /* synthetic */ Object then(Task task) throws Exception {
return m314then((Task<List<String>>) task);
}
/* renamed from: then, reason: collision with other method in class */
public Void m314then(Task<List<String>> task) throws Exception {
this.JC.onComplete(task.getResult(), task.getError());
return null;
}
}, Task.UI_THREAD_EXECUTOR);
}
@Override // com.kofax.mobile.sdk.logistics.ICaptureServer
public void loginAnonymously(ICompletionListener<List<String>> iCompletionListener) {
if (iCompletionListener == null) {
throw new IllegalArgumentException("CompletionListener cannot be null");
}
this.agi = new UserProfile();
ue().continueWith(new Continuation<List<String>, Void>(this, iCompletionListener) { // from class: com.kofax.mobile.sdk.logistics.CaptureServer.11
final ICompletionListener JC;
final CaptureServer agk;
{
this.agk = this;
this.JC = iCompletionListener;
}
public /* bridge */ /* synthetic */ Object then(Task task) throws Exception {
return m315then((Task<List<String>>) task);
}
/* renamed from: then, reason: collision with other method in class */
public Void m315then(Task<List<String>> task) throws Exception {
this.JC.onComplete(task.getResult(), task.getError());
return null;
}
}, Task.UI_THREAD_EXECUTOR);
}
@Override // com.kofax.mobile.sdk.logistics.ICaptureServer
public void logout(ICompletionListener<Void> iCompletionListener) {
if (iCompletionListener == null) {
throw new IllegalArgumentException("CompletionListener cannot be null");
}
uf().continueWith(new Continuation<Void, Void>(this, iCompletionListener) { // from class: com.kofax.mobile.sdk.logistics.CaptureServer.12
final ICompletionListener JC;
final CaptureServer agk;
{
this.agk = this;
this.JC = iCompletionListener;
}
public /* bridge */ /* synthetic */ Object then(Task task) throws Exception {
return m316then((Task<Void>) task);
}
/* renamed from: then, reason: collision with other method in class */
public Void m316then(Task<Void> task) throws Exception {
this.JC.onComplete(task.getResult(), task.getError());
return null;
}
}, Task.UI_THREAD_EXECUTOR);
}
@Override // com.kofax.mobile.sdk.logistics.ICaptureServer
public void getDocumentType(String str, ICompletionListener<DocumentType> iCompletionListener) {
if (iCompletionListener == null) {
throw new IllegalArgumentException("CompletionListener cannot be null");
}
aO(str).continueWith(new Continuation<DocumentType, Void>(this, iCompletionListener) { // from class: com.kofax.mobile.sdk.logistics.CaptureServer.13
final ICompletionListener JC;
final CaptureServer agk;
{
this.agk = this;
this.JC = iCompletionListener;
}
public /* bridge */ /* synthetic */ Object then(Task task) throws Exception {
return m317then((Task<DocumentType>) task);
}
/* renamed from: then, reason: collision with other method in class */
public Void m317then(Task<DocumentType> task) throws Exception {
DocumentType documentType = (DocumentType) task.getResult();
if (documentType != null) {
documentType.setSourceServer(this.agk.agf);
}
this.JC.onComplete(documentType, task.getError());
return null;
}
}, Task.UI_THREAD_EXECUTOR);
}
@Override // com.kofax.mobile.sdk.logistics.ICaptureServer
public void startJobService(ICompletionListener<String> iCompletionListener) {
if (iCompletionListener == null) {
throw new IllegalArgumentException("CompletionListener cannot be null");
}
ug().continueWith(new Continuation<String, Void>(this, iCompletionListener) { // from class: com.kofax.mobile.sdk.logistics.CaptureServer.14
final ICompletionListener JC;
final CaptureServer agk;
{
this.agk = this;
this.JC = iCompletionListener;
}
public /* bridge */ /* synthetic */ Object then(Task task) throws Exception {
return m318then((Task<String>) task);
}
/* renamed from: then, reason: collision with other method in class */
public Void m318then(Task<String> task) throws Exception {
this.JC.onComplete(task.getResult(), task.getError());
return null;
}
}, Task.UI_THREAD_EXECUTOR);
}
@Override // com.kofax.mobile.sdk.logistics.ICaptureServer
public void sendImageService(Document document, String str, Image image, int i, boolean z, ICompletionListener<Void> iCompletionListener) {
if (iCompletionListener == null) {
throw new IllegalArgumentException("CompletionListener cannot be null");
}
a(document, image, str, i, z).continueWith(new Continuation<Void, Void>(this, iCompletionListener) { // from class: com.kofax.mobile.sdk.logistics.CaptureServer.15
final ICompletionListener JC;
final CaptureServer agk;
{
this.agk = this;
this.JC = iCompletionListener;
}
public /* bridge */ /* synthetic */ Object then(Task task) throws Exception {
return m319then((Task<Void>) task);
}
/* renamed from: then, reason: collision with other method in class */
public Void m319then(Task<Void> task) throws Exception {
this.JC.onComplete(task.getResult(), task.getError());
return null;
}
}, Task.UI_THREAD_EXECUTOR);
}
@Override // com.kofax.mobile.sdk.logistics.ICaptureServer
public void submitDocument(Document document, IProgressListener iProgressListener, ICompletionListener iCompletionListener) {
if (iCompletionListener == null) {
throw new IllegalArgumentException("CompletionListener cannot be null");
}
if (iProgressListener == null) {
throw new IllegalArgumentException("ProgressListener cannot be null");
}
a(this.agi, document, iProgressListener).continueWith(new Continuation<Integer, Void>(this, iCompletionListener) { // from class: com.kofax.mobile.sdk.logistics.CaptureServer.16
final CaptureServer agk;
final ICompletionListener agv;
{
this.agk = this;
this.agv = iCompletionListener;
}
public /* bridge */ /* synthetic */ Object then(Task task) throws Exception {
return m320then((Task<Integer>) task);
}
/* renamed from: then, reason: collision with other method in class */
public Void m320then(Task<Integer> task) throws Exception {
this.agv.onComplete(task.getResult(), task.getError());
return null;
}
}, Task.UI_THREAD_EXECUTOR);
}
@Override // com.kofax.mobile.sdk.logistics.ICaptureServer
public ErrorInfo cancelSubmission(String str) {
ErrorInfo errorInfo = ErrorInfo.KMC_SUCCESS;
if (!this.agj.containsKey(str)) {
return ErrorInfo.KMC_LO_NO_OPERATION_TO_CANCEL;
}
this.agj.put(str, Boolean.TRUE);
return errorInfo;
}
private Task<Void> ud() {
return Task.callInBackground(new Callable<Void>(this) { // from class: com.kofax.mobile.sdk.logistics.CaptureServer.17
final CaptureServer agk;
{
this.agk = this;
}
@Override // java.util.concurrent.Callable
public Void call() throws Exception {
ErrorInfo errorInfo;
WebServiceCallResult updateDeviceInfo = DeviceService.updateDeviceInfo(this.agk.agd, this.agk.JI, this.agk.agh);
DeviceServiceResponse deviceServiceResponse = updateDeviceInfo.getExtraData() instanceof DeviceServiceResponse ? (DeviceServiceResponse) updateDeviceInfo.getExtraData() : null;
if (updateDeviceInfo.isSuccess()) {
return null;
}
if (deviceServiceResponse != null && deviceServiceResponse.getResultCode() == DeviceService.ERROR_LICENSE_REQUIRES_AUTH) {
throw new KmcRuntimeException(ErrorInfo.KMC_LO_REGISTER_REQUIRES_AUTH);
}
if (updateDeviceInfo.isCertificateError()) {
errorInfo = ErrorInfo.KMC_LO_INVALID_CERTIFICATE;
} else {
errorInfo = updateDeviceInfo.getErrorInfo() != null ? updateDeviceInfo.getErrorInfo() : ErrorInfo.KMC_LO_DEVICE_REG_LICENSING_ERROR;
}
StringBuilder sb = new StringBuilder();
if (deviceServiceResponse != null) {
StringBuilder sb2 = new StringBuilder(" (resultCode=");
sb2.append(deviceServiceResponse.getResultCode());
sb2.append(")");
sb.append(sb2.toString());
}
StringBuilder sb3 = new StringBuilder();
sb3.append(updateDeviceInfo.getErrorMsg());
sb3.append(sb.toString());
errorInfo.setErrCause(sb3.toString());
throw new KmcRuntimeException(errorInfo);
}
});
}
private Task<List<String>> a(UserProfile userProfile) {
return Task.callInBackground(new Callable<List<String>>(this, userProfile) { // from class: com.kofax.mobile.sdk.logistics.CaptureServer.2
final CaptureServer agk;
final UserProfile agl;
{
this.agk = this;
this.agl = userProfile;
}
@Override // java.util.concurrent.Callable
/* renamed from: mR, reason: merged with bridge method [inline-methods] */
public List<String> call() throws Exception {
ErrorInfo errorInfo;
UserProfile userProfile2 = this.agl;
if (userProfile2 == null) {
throw new KmcRuntimeException(ErrorInfo.KMC_GN_ILLEGAL_ARGUMENT_EXCEPTION, new IllegalArgumentException("login: userProfile parameter is null"));
}
if (userProfile2.getUsername().isEmpty()) {
throw new KmcRuntimeException(ErrorInfo.KMC_LO_USERNAME_NOT_SET);
}
WebServiceCallResult loginUser = UserLogin.loginUser(this.agk.agd, this.agl.getDomain(), this.agl.getUsername(), this.agl.getPassword(), this.agk.agh, this.agk.JI);
if (loginUser.isSuccess()) {
this.agk.age = new HashMap();
for (WscDestination wscDestination : ((UserLoginResponse) loginUser.getExtraData()).getPersonalShortCuts()) {
this.agk.age.put(wscDestination.getShortcutName(), wscDestination);
}
return this.agk.uh();
}
this.agk.ui();
if (loginUser.isCertificateError()) {
errorInfo = ErrorInfo.KMC_LO_INVALID_CERTIFICATE;
} else {
errorInfo = loginUser.getErrorInfo() != null ? loginUser.getErrorInfo() : ErrorInfo.KMC_LO_USER_LOGIN_ERROR;
}
errorInfo.setErrCause(loginUser.getErrorMsg());
throw new KmcRuntimeException(errorInfo);
}
});
}
private Task<List<String>> ue() {
return Task.callInBackground(new Callable<List<String>>(this) { // from class: com.kofax.mobile.sdk.logistics.CaptureServer.3
final CaptureServer agk;
{
this.agk = this;
}
@Override // java.util.concurrent.Callable
/* renamed from: mR, reason: merged with bridge method [inline-methods] */
public List<String> call() throws Exception {
ErrorInfo errorInfo;
WebServiceCallResult profile = ProfileService.getProfile(this.agk.agd, this.agk.agh, this.agk.JI);
if (profile.isSuccess()) {
this.agk.age = new HashMap();
for (WscDestination wscDestination : ((DeviceProfileResponse) profile.getExtraData()).getProfileShortCuts()) {
this.agk.age.put(wscDestination.getShortcutName(), wscDestination);
}
return this.agk.uh();
}
this.agk.ui();
if (profile.isCertificateError()) {
errorInfo = ErrorInfo.KMC_LO_INVALID_CERTIFICATE;
} else {
errorInfo = profile.getErrorInfo() != null ? profile.getErrorInfo() : ErrorInfo.KMC_LO_USER_LOGIN_ERROR;
}
errorInfo.setErrCause(profile.getErrorMsg());
throw new KmcRuntimeException(errorInfo);
}
});
}
private Task<Void> uf() {
return Task.callInBackground(new Callable<Void>(this) { // from class: com.kofax.mobile.sdk.logistics.CaptureServer.4
final CaptureServer agk;
{
this.agk = this;
}
@Override // java.util.concurrent.Callable
public Void call() throws Exception {
ErrorInfo errorInfo;
if (this.agk.age != null) {
if (this.agk.agi != null && this.agk.agi.getUsername().trim().equalsIgnoreCase("") && this.agk.agi.getPassword().trim().equalsIgnoreCase("")) {
this.agk.ui();
return null;
}
WebServiceCallResult logoutUser = UserLogout.logoutUser(this.agk.agd, this.agk.agi.getDomain(), this.agk.agi.getUsername(), this.agk.agi.getPassword(), this.agk.JI, this.agk.agh);
if (logoutUser.isSuccess()) {
this.agk.ui();
return null;
}
if (logoutUser.isCertificateError()) {
errorInfo = ErrorInfo.KMC_LO_INVALID_CERTIFICATE;
} else {
errorInfo = logoutUser.getErrorInfo() != null ? logoutUser.getErrorInfo() : ErrorInfo.KMC_LO_USER_LOGOUT_ERROR;
}
errorInfo.setErrCause(logoutUser.getErrorMsg());
throw new KmcRuntimeException(errorInfo);
}
throw new KmcRuntimeException(ErrorInfo.KMC_LO_NOT_LOGGED_IN);
}
});
}
private Task<DocumentType> aO(String str) {
return Task.callInBackground(new Callable<DocumentType>(this, str) { // from class: com.kofax.mobile.sdk.logistics.CaptureServer.5
final CaptureServer agk;
final String agm;
{
this.agk = this;
this.agm = str;
}
@Override // java.util.concurrent.Callable
/* renamed from: uj, reason: merged with bridge method [inline-methods] */
public DocumentType call() throws Exception {
if (this.agk.age != null) {
if (this.agk.age.containsKey(this.agm)) {
CaptureServer captureServer = this.agk;
GetIndexFieldsResponse a = captureServer.a(captureServer.agd, this.agk.agi, (WscDestination) this.agk.age.get(this.agm), this.agk.JI);
CaptureServer captureServer2 = this.agk;
RetrieveScanSettingsResponse b = captureServer2.b(captureServer2.agd, this.agk.agi, (WscDestination) this.agk.age.get(this.agm), this.agk.JI);
List<WscIndexField> indexFields = a.getIndexFields();
List<WscScanSetting> scanSettings = b.getScanSettings();
DocumentType documentType = new DocumentType(this.agk.w(indexFields));
BasicSettingsProfile basicSettingsProfile = null;
boolean z = false;
ImagePerfectionProfile imagePerfectionProfile = null;
ImageProcessorConfiguration imageProcessorConfiguration = null;
for (WscScanSetting wscScanSetting : scanSettings) {
if ("EVRSOperationsString".equals(wscScanSetting.getName()) && wscScanSetting.getValue() != null) {
imagePerfectionProfile = new ImagePerfectionProfile();
imagePerfectionProfile.setIpOperations(wscScanSetting.getValue());
imageProcessorConfiguration = new ImageProcessorConfiguration(wscScanSetting.getValue());
z = true;
}
String name = wscScanSetting.getName();
String value = wscScanSetting.getValue();
if (name != null && value != null) {
if (name.equalsIgnoreCase("ShortEdgeLength")) {
documentType.setDocWidth(this.agk.aQ(value));
} else if (name.equalsIgnoreCase("LongEdgeLength")) {
documentType.setDocHeight(this.agk.aQ(value));
}
}
}
if (!z) {
imageProcessorConfiguration = new ImageProcessorConfiguration();
basicSettingsProfile = this.agk.a(scanSettings, imageProcessorConfiguration);
}
documentType.setTypeName(this.agm);
documentType.setDisplayName(((WscDestination) this.agk.age.get(this.agm)).getDisplayValue());
documentType.setSourceServer(DocumentType.SourceServer.SERVER_NONE);
new DocumentType.FriendDT(documentType, BuildConfig.APPLICATION_ID).setWscIndexFields(indexFields);
if (basicSettingsProfile != null) {
documentType.setBasicSettingsProfile(basicSettingsProfile);
} else if (imagePerfectionProfile != null) {
documentType.setImagePerfectionProfile(imagePerfectionProfile);
}
documentType.setImageProcessorConfiguration(imageProcessorConfiguration);
return documentType;
}
throw new KmcRuntimeException(ErrorInfo.KMC_LO_INVALID_DOCUMENT_TYPE_NAME);
}
throw new KmcRuntimeException(ErrorInfo.KMC_LO_NOT_LOGGED_IN);
}
});
}
private Task<String> ug() {
return Task.callInBackground(new Callable<String>(this) { // from class: com.kofax.mobile.sdk.logistics.CaptureServer.6
final CaptureServer agk;
{
this.agk = this;
}
@Override // java.util.concurrent.Callable
/* renamed from: mB, reason: merged with bridge method [inline-methods] */
public String call() throws Exception {
if (this.agk.age != null) {
CaptureServer captureServer = this.agk;
return captureServer.b(captureServer.agi);
}
throw new KmcRuntimeException(ErrorInfo.KMC_LO_NOT_LOGGED_IN);
}
});
}
private Task<Void> a(Document document, Image image, String str, int i, boolean z) {
return Task.callInBackground(new Callable<Void>(this, document, image, str, i, z) { // from class: com.kofax.mobile.sdk.logistics.CaptureServer.7
final CaptureServer agk;
final Document agn;
final String ago;
final int agp;
final boolean agq;
final Image yB;
{
this.agk = this;
this.agn = document;
this.yB = image;
this.ago = str;
this.agp = i;
this.agq = z;
}
@Override // java.util.concurrent.Callable
public Void call() throws Exception {
if (this.agk.age == null) {
throw new KmcRuntimeException(ErrorInfo.KMC_LO_NOT_LOGGED_IN);
}
if (this.agn == null) {
throw new KmcRuntimeException(ErrorInfo.KMC_GN_ILLEGAL_ARGUMENT_EXCEPTION, new IllegalArgumentException("sendImage: document parameter is null"));
}
if (this.yB == null) {
throw new KmcRuntimeException(ErrorInfo.KMC_GN_ILLEGAL_ARGUMENT_EXCEPTION, new IllegalArgumentException("sendImage: Image parameter is null"));
}
if (this.ago != null) {
CaptureServer captureServer = this.agk;
ErrorInfo a = captureServer.a(captureServer.agd, this.agk.agi, this.yB, this.agn, this.agp, this.ago, this.agq, this.agk.JI);
if (a == ErrorInfo.KMC_SUCCESS) {
return null;
}
throw new KmcRuntimeException(a);
}
throw new KmcRuntimeException(ErrorInfo.KMC_GN_ILLEGAL_ARGUMENT_EXCEPTION, new IllegalArgumentException("sendImage: JobID parameter is null"));
}
});
}
private Task<Integer> a(UserProfile userProfile, Document document, IProgressListener iProgressListener) {
return Task.callInBackground(new Callable<Integer>(this, document, userProfile, iProgressListener) { // from class: com.kofax.mobile.sdk.logistics.CaptureServer.8
final CaptureServer agk;
final UserProfile agl;
final Document agn;
final IProgressListener agr;
{
this.agk = this;
this.agn = document;
this.agl = userProfile;
this.agr = iProgressListener;
}
@Override // java.util.concurrent.Callable
/* renamed from: uk, reason: merged with bridge method [inline-methods] */
public Integer call() throws Exception {
ErrorInfo a = this.agk.a(this.agn);
if (a == ErrorInfo.KMC_SUCCESS) {
this.agk.b(this.agn);
String b = this.agk.b(this.agl);
if (this.agk.agj == null) {
this.agk.agj = new HashMap();
}
this.agk.agj.put(b, Boolean.FALSE);
ErrorInfo a2 = this.agk.a(this.agl, this.agn.getPages(), this.agn, b, this.agr);
if (a2 != ErrorInfo.KMC_SUCCESS) {
throw new KmcRuntimeException(a2);
}
return Integer.valueOf(a2.ordinal());
}
throw new KmcRuntimeException(a);
}
});
}
/* JADX INFO: Access modifiers changed from: private */
/* JADX WARN: Code restructure failed: missing block: B:35:0x0148, code lost:
r19 = r14;
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public com.kofax.kmc.kut.utilities.error.ErrorInfo a(com.kofax.kmc.klo.logistics.data.UserProfile r22, java.util.List<com.kofax.kmc.klo.logistics.data.Page> r23, com.kofax.kmc.klo.logistics.data.Document r24, java.lang.String r25, com.kofax.mobile.sdk.logistics.IProgressListener r26) {
/*
Method dump skipped, instructions count: 349
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: com.kofax.mobile.sdk.logistics.CaptureServer.a(com.kofax.kmc.klo.logistics.data.UserProfile, java.util.List, com.kofax.kmc.klo.logistics.data.Document, java.lang.String, com.kofax.mobile.sdk.logistics.IProgressListener):com.kofax.kmc.kut.utilities.error.ErrorInfo");
}
private WebServiceCallResult a(UserProfile userProfile, WscDestination wscDestination, String str) {
return SendImage.cancelJob(this.agd, wscDestination, userProfile.getUsername(), userProfile.getPassword(), str, this.JI);
}
/* JADX INFO: Access modifiers changed from: private */
public ErrorInfo a(Document document) {
ErrorInfo errorInfo = ErrorInfo.KMC_SUCCESS;
List<Page> pages = document.getPages();
if (pages.isEmpty()) {
return ErrorInfo.KMC_LO_SUBMIT_DOCUMENT_NO_IMAGE_ERROR;
}
Iterator<Page> it = pages.iterator();
boolean z = false;
while (true) {
if (!it.hasNext()) {
break;
}
Page next = it.next();
List<Image> images = next.getImages();
if (!images.isEmpty()) {
Image image = images.get(next.getCurrentImageIndex());
boolean z2 = image.getImageFileRep() == Image.ImageFileRep.FILE_BUFFERED || image.getImageFileRep() == Image.ImageFileRep.FILE_STORED;
boolean z3 = image.getImageMimeType() == Image.ImageMimeType.MIMETYPE_JPEG || image.getImageMimeType() == Image.ImageMimeType.MIMETYPE_TIFF;
if (!z2) {
errorInfo = ErrorInfo.KMC_LO_SUBMIT_DOCUMENT_IMAGE_REP_ERROR;
break;
}
if (!z3) {
errorInfo = ErrorInfo.KMC_LO_SUBMIT_DOCUMENT_MIMETYPE_ERROR;
break;
}
if (image.getImageFileRep() == Image.ImageFileRep.FILE_STORED && !new File(image.getImageFilePath()).exists()) {
errorInfo = ErrorInfo.KMC_LO_SUBMIT_DOCUMENT_IMAGE_FILE_MISSING;
break;
}
z = true;
}
}
return (errorInfo != ErrorInfo.KMC_SUCCESS || z) ? errorInfo : ErrorInfo.KMC_LO_SUBMIT_DOCUMENT_NO_IMAGE_ERROR;
}
/* JADX INFO: Access modifiers changed from: private */
public String b(UserProfile userProfile) {
ErrorInfo errorInfo;
WebServiceCallResult startJob = StartJob.startJob(this.agd, userProfile.getUsername(), userProfile.getPassword(), this.JI, this.agh);
if (startJob.isSuccess()) {
StartJobResponse startJobResponse = (StartJobResponse) startJob.getExtraData();
if (gjJ.b((CharSequence) startJobResponse.getJobId())) {
ErrorInfo errorInfo2 = ErrorInfo.KMC_LO_START_SUBMIT_INVALID_JOB_ID;
errorInfo2.setErrCause("Null jobId returned from server");
throw new KmcRuntimeException(errorInfo2);
}
return startJobResponse.getJobId();
}
if (startJob.isCertificateError()) {
errorInfo = ErrorInfo.KMC_LO_INVALID_CERTIFICATE;
} else {
errorInfo = startJob.getErrorInfo() != null ? startJob.getErrorInfo() : ErrorInfo.KMC_LO_START_SUBMIT_JOB_ERROR;
}
errorInfo.setErrCause(startJob.getErrorMsg());
throw new KmcRuntimeException(errorInfo);
}
/* JADX INFO: Access modifiers changed from: private */
/* JADX WARN: Removed duplicated region for block: B:35:0x010a A[Catch: Exception -> 0x010e, TRY_ENTER, TRY_LEAVE, TryCatch #2 {Exception -> 0x010e, blocks: (B:27:0x00dc, B:35:0x010a), top: B:11:0x005e }] */
/* JADX WARN: Removed duplicated region for block: B:42:0x0121 A[EXC_TOP_SPLITTER, SYNTHETIC] */
/* JADX WARN: Removed duplicated region for block: B:49:? A[SYNTHETIC] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public com.kofax.kmc.kut.utilities.error.ErrorInfo a(java.net.URL r17, com.kofax.kmc.klo.logistics.data.UserProfile r18, com.kofax.kmc.ken.engines.data.Image r19, com.kofax.kmc.klo.logistics.data.Document r20, int r21, java.lang.String r22, boolean r23, com.kofax.kmc.kut.utilities.CertificateValidatorListener r24) {
/*
Method dump skipped, instructions count: 317
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: com.kofax.mobile.sdk.logistics.CaptureServer.a(java.net.URL, com.kofax.kmc.klo.logistics.data.UserProfile, com.kofax.kmc.ken.engines.data.Image, com.kofax.kmc.klo.logistics.data.Document, int, java.lang.String, boolean, com.kofax.kmc.kut.utilities.CertificateValidatorListener):com.kofax.kmc.kut.utilities.error.ErrorInfo");
}
/* JADX INFO: Access modifiers changed from: private */
public GetIndexFieldsResponse a(URL url, UserProfile userProfile, WscDestination wscDestination, CertificateValidatorListener certificateValidatorListener) {
ErrorInfo errorInfo;
WebServiceCallResult indexFields = GetIndexFields.getIndexFields(url, wscDestination, userProfile.getUsername(), userProfile.getPassword(), certificateValidatorListener, this.agh);
if (indexFields.isSuccess()) {
return (GetIndexFieldsResponse) indexFields.getExtraData();
}
if (indexFields.isCertificateError()) {
errorInfo = ErrorInfo.KMC_LO_INVALID_CERTIFICATE;
} else {
errorInfo = indexFields.getErrorInfo() != null ? indexFields.getErrorInfo() : ErrorInfo.KMC_LO_DOWNLOAD_DOCUMENT_FIELDS_ERROR;
}
errorInfo.setErrCause(indexFields.getErrorMsg());
throw new KmcRuntimeException(errorInfo);
}
/* JADX INFO: Access modifiers changed from: private */
public RetrieveScanSettingsResponse b(URL url, UserProfile userProfile, WscDestination wscDestination, CertificateValidatorListener certificateValidatorListener) {
ErrorInfo errorInfo;
WebServiceCallResult scanSettings = RetrieveScanSettings.getScanSettings(url, wscDestination, userProfile.getUsername(), userProfile.getPassword(), certificateValidatorListener, this.agh);
if (scanSettings.isSuccess()) {
return (RetrieveScanSettingsResponse) scanSettings.getExtraData();
}
if (scanSettings.isCertificateError()) {
errorInfo = ErrorInfo.KMC_LO_INVALID_CERTIFICATE;
} else {
errorInfo = scanSettings.getErrorInfo() != null ? scanSettings.getErrorInfo() : ErrorInfo.KMC_LO_DOWNLOAD_DOCUMENT_SCAN_SETTINGS_ERROR;
}
errorInfo.setErrCause(scanSettings.getErrorMsg());
throw new KmcRuntimeException(errorInfo);
}
/* JADX INFO: Access modifiers changed from: private */
public ArrayList<FieldType> w(List<WscIndexField> list) {
ArrayList<FieldType> arrayList = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
WscIndexField wscIndexField = list.get(i);
FieldType fieldType = new FieldType();
fieldType.setHidden(Boolean.valueOf(wscIndexField.isHidden()));
fieldType.setDisplayName(wscIndexField.getDisplayName());
fieldType.setName(wscIndexField.getName());
fieldType.setRequired(Boolean.valueOf(wscIndexField.isRequired()));
fieldType.setDefault(wscIndexField.getValue());
fieldType.setForceMatch(Boolean.valueOf(wscIndexField.isForceMatch()));
fieldType.setMin(wscIndexField.getMin());
fieldType.setMax(wscIndexField.getMax());
String str = this.TAG;
StringBuilder sb = new StringBuilder();
sb.append(wscIndexField.getDisplayName());
sb.append(" ");
sb.append(wscIndexField.getDataType());
sb.append(" ");
sb.append(wscIndexField.getMin());
sb.append(" ");
sb.append(wscIndexField.getMax());
k.c(str, sb.toString());
fieldType.setOptions((String[]) wscIndexField.getOptions().toArray(new String[wscIndexField.getOptions().size()]));
if (wscIndexField.getDataType().equalsIgnoreCase("string")) {
fieldType.setDataType(FieldType.DataType.STRING);
} else if (wscIndexField.getDataType().equalsIgnoreCase("date")) {
fieldType.setDataType(FieldType.DataType.DATE);
} else if (wscIndexField.getDataType().equalsIgnoreCase("float")) {
fieldType.setDataType(FieldType.DataType.FLOAT);
} else if (wscIndexField.getDataType().equalsIgnoreCase("int")) {
fieldType.setDataType(FieldType.DataType.INT);
} else if (wscIndexField.getDataType().equalsIgnoreCase("boolean")) {
fieldType.setDataType(FieldType.DataType.BOOL);
}
arrayList.add(fieldType);
}
return arrayList;
}
/* JADX INFO: Access modifiers changed from: private */
public BasicSettingsProfile a(Collection<WscScanSetting> collection, ImageProcessorConfiguration imageProcessorConfiguration) {
BasicSettingsProfile basicSettingsProfile = new BasicSettingsProfile();
Float valueOf = Float.valueOf(BitmapDescriptorFactory.HUE_RED);
Float f = valueOf;
for (WscScanSetting wscScanSetting : collection) {
String str = this.TAG;
StringBuilder sb = new StringBuilder("wscScanSetting.getName() = ");
sb.append(wscScanSetting.getName());
k.c(str, sb.toString());
String name = wscScanSetting.getName();
String str2 = this.TAG;
StringBuilder sb2 = new StringBuilder("wscScanSetting.getValue() = ");
sb2.append(wscScanSetting.getValue());
k.c(str2, sb2.toString());
String value = wscScanSetting.getValue();
if (value != null) {
if (name.equals("OutputColorMode")) {
if (Integer.parseInt(wscScanSetting.getValue()) == 3) {
basicSettingsProfile.setOutputBitDepth(BasicSettingsProfile.OutputBitDepth.BITONAL);
imageProcessorConfiguration.outputColorDepth = ColorDepth.BITONAL;
}
if (Integer.parseInt(wscScanSetting.getValue()) == 1) {
basicSettingsProfile.setOutputBitDepth(BasicSettingsProfile.OutputBitDepth.COLOR);
imageProcessorConfiguration.outputColorDepth = ColorDepth.COLOR;
}
if (Integer.parseInt(wscScanSetting.getValue()) == 2) {
basicSettingsProfile.setOutputBitDepth(BasicSettingsProfile.OutputBitDepth.GRAYSCALE);
imageProcessorConfiguration.outputColorDepth = ColorDepth.GRAYSCALE;
}
} else if (name.equalsIgnoreCase("DDPIV")) {
basicSettingsProfile.setOutputDPI(Integer.valueOf(value));
imageProcessorConfiguration.outputDPI = Integer.valueOf(value);
} else if (name.equalsIgnoreCase("AutoDeskew")) {
if (aP(wscScanSetting.getValue())) {
basicSettingsProfile.setDoDeskew(true);
imageProcessorConfiguration.deskewType = DeskewType.DESKEW_BY_DOCUMENT_EDGES;
} else {
basicSettingsProfile.setDoDeskew(false);
}
} else if (name.equalsIgnoreCase("AutoCrop")) {
if (aP(wscScanSetting.getValue())) {
basicSettingsProfile.setCropType(BasicSettingsProfile.CropType.CROP_AUTO);
imageProcessorConfiguration.cropType = CropType.CROP_AUTO;
} else {
basicSettingsProfile.setCropType(BasicSettingsProfile.CropType.CROP_NONE);
imageProcessorConfiguration.cropType = CropType.CROP_NONE;
}
} else if (name.equalsIgnoreCase("AutoOrientation")) {
if (aP(wscScanSetting.getValue())) {
basicSettingsProfile.setDoDeskew(true);
basicSettingsProfile.setRotateType(BasicSettingsProfile.RotateType.ROTATE_AUTO);
imageProcessorConfiguration.deskewType = DeskewType.DESKEW_BY_DOCUMENT_EDGES;
imageProcessorConfiguration.rotateType = RotateType.ROTATE_AUTO;
}
} else if (name.equalsIgnoreCase("ShortEdgeLength")) {
basicSettingsProfile.setInputDocShortEdge(Float.valueOf(aQ(value)));
valueOf = Float.valueOf(aQ(value));
} else if (name.equalsIgnoreCase("LongEdgeLength")) {
basicSettingsProfile.setInputDocLongEdge(Float.valueOf(aQ(value)));
f = Float.valueOf(aQ(value));
}
}
}
if (valueOf.floatValue() > BitmapDescriptorFactory.HUE_RED || f.floatValue() > BitmapDescriptorFactory.HUE_RED) {
imageProcessorConfiguration.documentDimensions = new DocumentDimensions(valueOf, f);
}
String str3 = this.TAG;
StringBuilder sb3 = new StringBuilder("bsp :: CROP = ");
sb3.append(basicSettingsProfile.getCropType());
sb3.append(" SKEW = ");
sb3.append(basicSettingsProfile.getDoDeskew());
sb3.append(" BITDEPTH = ");
sb3.append(basicSettingsProfile.getOutputBitDepth());
sb3.append(" ROTATE = ");
sb3.append(basicSettingsProfile.getRotateType());
k.c(str3, sb3.toString());
return basicSettingsProfile;
}
private boolean aP(String str) {
return gjJ.c((CharSequence) str) ? Integer.parseInt(str) == 1 : str.equalsIgnoreCase("True");
}
/* JADX INFO: Access modifiers changed from: private */
public float aQ(String str) {
float f = BitmapDescriptorFactory.HUE_RED;
if (str != null && !str.trim().equals("")) {
ArrayList arrayList = new ArrayList();
arrayList.add(new Locale("en"));
arrayList.add(new Locale("pt", "BR"));
arrayList.add(new Locale("de"));
arrayList.add(new Locale("es"));
arrayList.add(new Locale("fr"));
arrayList.add(new Locale("it"));
arrayList.add(new Locale("ja"));
for (int i = 0; i < arrayList.size(); i++) {
try {
f = NumberFormat.getNumberInstance((Locale) arrayList.get(i)).parse(str).floatValue();
break;
} catch (ParseException unused) {
}
}
}
return f;
}
/* JADX INFO: Access modifiers changed from: private */
public List<String> uh() {
ArrayList arrayList;
synchronized (this) {
arrayList = new ArrayList(this.age.keySet());
}
return arrayList;
}
/* JADX INFO: Access modifiers changed from: private */
public WscDestination b(Document document) {
try {
List<WscIndexField> wscIndexFields = new DocumentType.FriendDT(document.getDocumentType(), BuildConfig.APPLICATION_ID).getWscIndexFields();
List<Field> fields = document.getFields();
HashMap hashMap = new HashMap();
for (Field field : fields) {
hashMap.put(field.getFieldType().getName(), field);
}
for (WscIndexField wscIndexField : wscIndexFields) {
wscIndexField.setValue(((Field) hashMap.get(wscIndexField.getName())).getValue());
}
WscDestination wscDestination = this.age.get(document.getDocumentType().getTypeName());
wscDestination.setIndexFields(wscIndexFields);
return wscDestination;
} catch (KmcException e) {
throw new KmcRuntimeException(e.getErrorInfo(), e);
}
}
public void setServerTimeout(int i) {
this.agh = i <= 0 ? 20000 : i * 1000;
}
public void setCertificateValidatorListener(CertificateValidatorListener certificateValidatorListener) {
this.JI = certificateValidatorListener;
}
/* JADX INFO: Access modifiers changed from: private */
public void ui() {
this.age = null;
this.agi = null;
this.agj = null;
}
}