package com.facetec.sdk; import android.content.Context; import android.os.Process; import com.facetec.sdk.bi; import com.facetec.sdk.ka; import com.facetec.sdk.ke; import com.facetec.sdk.t; import com.google.common.net.HttpHeaders; import com.google.firebase.crashlytics.internal.common.AbstractSpiCall; import java.util.ArrayList; import java.util.Iterator; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public final class o { private static ka d; private final Semaphore a = new Semaphore(1); private static ka b() { ka.e eVar = new ka.e(); eVar.x = km.e("timeout", TimeUnit.SECONDS); eVar.z = km.e("timeout", TimeUnit.SECONDS); eVar.D = km.e("timeout", TimeUnit.SECONDS); return eVar.b(); } private static ka c() { ka kaVar; synchronized (o.class) { if (d == null) { d = b(); } kaVar = d; } return kaVar; } private void a(final Context context) { final aj c; if (bf.e()) { try { if (ah.c(context).booleanValue()) { c = ah.a; } else { c = ah.c(); } this.a.acquire(); cy.c(new Runnable(this, context, c) { // from class: com.facetec.sdk.o$$ExternalSyntheticLambda2 public final o f$0; public final Context f$1; public final aj f$2; @Override // java.lang.Runnable public final void run() { this.f$0.d(this.f$1, this.f$2); } { this.f$0 = this; this.f$1 = context; this.f$2 = c; } }); } catch (ae unused) { } catch (InterruptedException e) { k.a(e); } } } /* JADX INFO: Access modifiers changed from: private */ public /* synthetic */ void d(Context context, aj ajVar) { Process.setThreadPriority(19); t.e((bg) context, ajVar, true, bi.d.FRONT, cd.d); this.a.release(); } /* JADX INFO: Access modifiers changed from: package-private */ public final void e(Context context, FaceTecSessionResult faceTecSessionResult, String str) { synchronized (this) { ec ecVar = new ec(); ecVar.e("faceScan", faceTecSessionResult.getFaceScanBase64()); ecVar.e("auditTrailImage", faceTecSessionResult.getAuditTrailCompressedBase64()[0]); ecVar.e("lowQualityAuditTrailImage", faceTecSessionResult.getLowQualityAuditTrailCompressedBase64()[0]); if (t.c()) { c().c(new ke.d().d("https://api.facetec.com/api/v3.1/biometrics/liveness-3d").a(HttpHeaders.CONTENT_TYPE, AbstractSpiCall.ACCEPT_JSON_VALUE).a("X-Device-Key", str).a("User-Agent", FaceTecSDK.createFaceTecAPIUserAgentString(faceTecSessionResult.getSessionId())).a("X-User-Agent", FaceTecSDK.createFaceTecAPIUserAgentString(faceTecSessionResult.getSessionId())).d(ki.e(jz.a("application/json; charset=utf-8"), ecVar.toString())).b()).a(new jm(this) { // from class: com.facetec.sdk.o.5 private o b; @Override // com.facetec.sdk.jm public final void e() { } @Override // com.facetec.sdk.jm public final void e(kh khVar) { } { this.b = this; } }); } a(context); } } private static ArrayList d(t.d dVar, boolean z) { boolean n = cg.n(); ArrayList arrayList = new ArrayList<>(); arrayList.add(ak.d); ci ciVar = ci.ZOOM_FAR; if (z) { ciVar = cg.g(); } if (ciVar == ci.PROCESSING_COMPLETE_SUCCESS) { arrayList.add(ak.a); } else if (ciVar == ci.PROCESSING_COMPLETE_RETRY) { arrayList.add(ak.b); } else if (dVar == t.d.USER_CANCELLED) { arrayList.add(ak.c); arrayList.add(t.e); } else if (dVar == t.d.SESSION_CONTEXT_SWITCH) { arrayList.add(ak.h); arrayList.add(t.e); } else if (dVar == t.d.PRE_SESSION_PHASE_1_TIMEOUT) { arrayList.add(ak.t); arrayList.add(t.e); } else if (dVar == t.d.PRE_SESSION_PHASE_2_TIMEOUT) { arrayList.add(ak.s); arrayList.add(t.e); } else if (dVar == t.d.SESSION_TIMEOUT) { arrayList.add(ak.i); arrayList.add(t.e); } else if (dVar == t.d.USER_WAS_SUCCESSFUL) { arrayList.add(ak.a); } else { arrayList.add(ak.b); } if (n) { arrayList.add(ak.f); } else { arrayList.add(ak.j); } return arrayList; } /* JADX INFO: Access modifiers changed from: package-private */ public final void a(final Context context, final t.d dVar) { synchronized (this) { t.b(context, dVar); final ArrayList d2 = d(dVar, true); if (dVar != t.d.USER_WAS_SUCCESSFUL) { Iterator it = d2.iterator(); while (it.hasNext()) { cg.z(it.next()); } } if (t.c()) { try { this.a.acquire(); final String str = null; cy.c(new Runnable(this, dVar, context, str, d2) { // from class: com.facetec.sdk.o$$ExternalSyntheticLambda1 public final o f$0; public final t.d f$1; public final Context f$2; public final String f$3; public final ArrayList f$4; @Override // java.lang.Runnable public final void run() { this.f$0.c(this.f$1, this.f$2, this.f$3, this.f$4); } { this.f$0 = this; this.f$1 = dVar; this.f$2 = context; this.f$3 = str; this.f$4 = d2; } }); } catch (InterruptedException e) { k.a(e); } } a(context); } } /* JADX INFO: Access modifiers changed from: private */ public /* synthetic */ void c(t.d dVar, Context context, String str, ArrayList arrayList) { if (dVar != t.d.USER_CANCELLED) { Process.setThreadPriority(19); } t.c(context, str, arrayList, "", q.FACE_SCAN, ""); this.a.release(); } /* JADX INFO: Access modifiers changed from: package-private */ public final void e(final Context context, final t.d dVar, final String str, final boolean z) { synchronized (this) { t.b(context, dVar); final ArrayList d2 = d(dVar, false); if (dVar != t.d.USER_WAS_SUCCESSFUL) { Iterator it = d2.iterator(); while (it.hasNext()) { cg.z(it.next()); } } if (t.c()) { try { this.a.acquire(); final String str2 = null; cy.c(new Runnable(this, dVar, z, context, str2, d2, str) { // from class: com.facetec.sdk.o$$ExternalSyntheticLambda0 public final o f$0; public final t.d f$1; public final boolean f$2; public final Context f$3; public final String f$4; public final ArrayList f$5; public final String f$6; @Override // java.lang.Runnable public final void run() { this.f$0.c(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, this.f$6); } { this.f$0 = this; this.f$1 = dVar; this.f$2 = z; this.f$3 = context; this.f$4 = str2; this.f$5 = d2; this.f$6 = str; } }); } catch (InterruptedException e) { k.a(e); } } } } /* JADX INFO: Access modifiers changed from: private */ public /* synthetic */ void c(t.d dVar, boolean z, Context context, String str, ArrayList arrayList, String str2) { if (dVar != t.d.USER_CANCELLED) { Process.setThreadPriority(19); } t.c(context, str, arrayList, "", z ? q.ID_SCAN_ONLY : q.ID_SCAN_MATCH, str2); this.a.release(); } /* JADX INFO: Access modifiers changed from: package-private */ public final void a() { Semaphore semaphore = this.a; if (semaphore != null) { try { if (semaphore.tryAcquire(5L, TimeUnit.SECONDS)) { this.a.release(); } } catch (InterruptedException unused) { } } } }