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

189 lines
7.6 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.kofax.mobile.sdk.extract.id;
import android.content.Context;
import bolts.Continuation;
import bolts.Task;
import bolts.TaskCompletionSource;
import com.kofax.kmc.kut.utilities.Licensing;
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._internal.extraction.id.k;
import com.kofax.mobile.sdk._internal.impl.extraction.onDevice.ae;
import com.kofax.mobile.sdk._internal.impl.extraction.onDevice.v;
import java.lang.ref.WeakReference;
import o.InterfaceC13391fZD;
/* loaded from: classes3.dex */
public class OnDeviceIdExtractor implements IIdExtractor {
private final WeakReference<Context> LU;
@InterfaceC13391fZD
k aen;
private IIdExtractor aeo;
public OnDeviceIdExtractor(Context context) {
this(context, Injector.getInjector(context.getApplicationContext()).getLocalProjectProvider());
}
@InterfaceC13391fZD
public OnDeviceIdExtractor(Context context, IProjectProvider iProjectProvider) {
this.LU = new WeakReference<>(context.getApplicationContext());
new com.kofax.mobile.sdk._internal.impl.extraction.onDevice.a(context).a(iProjectProvider);
}
private k tY() {
k kVar;
synchronized (this) {
if (this.aen == null) {
this.aen = Injector.getInjector(this.LU.get()).getIIdExtractorProvider();
}
kVar = this.aen;
}
return kVar;
}
private IIdExtractor tZ() {
IIdExtractor iIdExtractor;
synchronized (this) {
if (this.aeo == null) {
this.aeo = new ae(new a(new b(tY())));
}
iIdExtractor = this.aeo;
}
return iIdExtractor;
}
@Override // com.kofax.mobile.sdk.extract.id.IIdExtractor
public void extractFields(IdExtractionParameters idExtractionParameters) {
tZ().extractFields(idExtractionParameters);
}
@Override // com.kofax.mobile.sdk.extract.id.IIdExtractor
public void cancel() {
tZ().cancel();
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public static class b implements IIdExtractor {
private IIdExtractor Ly;
private b(k kVar) {
this.Ly = kVar.hp();
}
@Override // com.kofax.mobile.sdk.extract.id.IIdExtractor
public void extractFields(IdExtractionParameters idExtractionParameters) {
synchronized (this) {
this.Ly.extractFields(idExtractionParameters);
}
}
@Override // com.kofax.mobile.sdk.extract.id.IIdExtractor
public void cancel() {
synchronized (this) {
IIdExtractor iIdExtractor = this.Ly;
if (iIdExtractor == null) {
throw new KmcRuntimeException(ErrorInfo.KMC_EV_CANCEL_OPERATION_SUCCESS);
}
iIdExtractor.cancel();
}
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public static class a extends v {
a(IIdExtractor iIdExtractor) {
super(iIdExtractor);
}
@Override // com.kofax.mobile.sdk._internal.impl.extraction.onDevice.v, com.kofax.mobile.sdk.extract.id.IIdExtractor
public void extractFields(IdExtractionParameters idExtractionParameters) {
ua().onSuccess(new Continuation<Void, Void>(this, idExtractionParameters) { // from class: com.kofax.mobile.sdk.extract.id.OnDeviceIdExtractor.a.2
final IdExtractionParameters Lz;
final a aeq;
{
this.aeq = this;
this.Lz = idExtractionParameters;
}
public /* bridge */ /* synthetic */ Object then(Task task) throws Exception {
return m291then((Task<Void>) task);
}
/* renamed from: then, reason: collision with other method in class */
public Void m291then(Task<Void> task) throws Exception {
a.super.extractFields(this.Lz);
return null;
}
}).continueWith(new Continuation<Void, Void>(this, idExtractionParameters.getListener()) { // from class: com.kofax.mobile.sdk.extract.id.OnDeviceIdExtractor.a.1
final IIdExtractionListener aep;
final a aeq;
{
this.aeq = this;
this.aep = r2;
}
public /* bridge */ /* synthetic */ Object then(Task task) throws Exception {
return m290then((Task<Void>) task);
}
/* renamed from: then, reason: collision with other method in class */
public Void m290then(Task<Void> task) throws Exception {
if (task.isFaulted()) {
this.aep.onExtractionComplete(null, new AggregateException(task.getError(), null));
}
return null;
}
});
}
private static Task<Void> ua() {
if (!Licensing.isSdkLicensed(Licensing.LicenseType.ID_EXTRACTION)) {
return Task.forError(new KmcRuntimeException(ErrorInfo.KMC_UT_LICENSE_ID_EXTRACTION));
}
if (Licensing.getRemainingLicenseCount(Licensing.LicenseType.ID_EXTRACTION) <= 0) {
return c(Licensing.LicenseType.ID_EXTRACTION, 1);
}
return Task.forResult((Object) null);
}
private static Task<Void> c(Licensing.LicenseType licenseType, int i) {
TaskCompletionSource taskCompletionSource = new TaskCompletionSource();
Licensing.addVolumeLicenseEventListener(new Licensing.VolumeLicenseEventListener(taskCompletionSource) { // from class: com.kofax.mobile.sdk.extract.id.OnDeviceIdExtractor.a.3
final TaskCompletionSource val$tcs;
{
this.val$tcs = taskCompletionSource;
}
@Override // com.kofax.kmc.kut.utilities.Licensing.VolumeLicenseEventListener
public final void licenseOperationSucceeded(Licensing.VolumeLicenseResultData volumeLicenseResultData) {
Licensing.removeVolumeLicenseEventListener(this);
this.val$tcs.trySetResult((Object) null);
}
@Override // com.kofax.kmc.kut.utilities.Licensing.VolumeLicenseEventListener
public final void licenseOperationFailed(Licensing.VolumeLicenseFailureData volumeLicenseFailureData) {
Licensing.removeVolumeLicenseEventListener(this);
this.val$tcs.trySetError(new KmcRuntimeException(ErrorInfo.KMC_UT_OUT_OF_VOLUME_LICENSE, new KmcRuntimeException(volumeLicenseFailureData.resultCode)));
}
});
Licensing.acquireVolumeLicenses(licenseType, i);
return taskCompletionSource.getTask();
}
@Override // com.kofax.mobile.sdk._internal.impl.extraction.onDevice.v
public void a(IdExtractionParameters idExtractionParameters, IIdExtractionResult iIdExtractionResult, AggregateException aggregateException) {
if (iIdExtractionResult != null && iIdExtractionResult.getFields() != null && iIdExtractionResult.getFields().size() > 0) {
Licensing.decrementRemainingLicenseCount(Licensing.LicenseType.ID_EXTRACTION);
}
super.a(idExtractionParameters, iIdExtractionResult, aggregateException);
}
}
}