package com.facetec.sdk; import com.facetec.sdk.kc; import java.io.IOException; import java.io.InterruptedIOException; import java.util.ArrayList; import java.util.concurrent.TimeUnit; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public final class kg implements jo { final ll a; final mo b; final ka c; jx d; final ke e; final boolean f; private boolean h; private kg(ka kaVar, ke keVar, boolean z) { this.c = kaVar; this.e = keVar; this.f = z; this.a = new ll(kaVar, z); mo moVar = new mo(this) { // from class: com.facetec.sdk.kg.3 private kg b; { this.b = this; } @Override // com.facetec.sdk.mo public final void d() { lh lhVar; kt ktVar; ll llVar = this.b.a; llVar.b = true; ky kyVar = llVar.c; if (kyVar != null) { synchronized (kyVar.b) { kyVar.i = true; lhVar = kyVar.h; ktVar = kyVar.c; } if (lhVar != null) { lhVar.b(); } else if (ktVar != null) { ktVar.a(); } } } }; this.b = moVar; moVar.a(kaVar.g, TimeUnit.MILLISECONDS); } /* JADX INFO: Access modifiers changed from: package-private */ public static kg d(ka kaVar, ke keVar, boolean z) { kg kgVar = new kg(kaVar, keVar, z); kgVar.d = kaVar.c.b(); return kgVar; } /* JADX INFO: Access modifiers changed from: package-private */ public final IOException e(IOException iOException) { if (!this.b.a()) { return iOException; } InterruptedIOException interruptedIOException = new InterruptedIOException("timeout"); if (iOException != null) { interruptedIOException.initCause(iOException); } return interruptedIOException; } @Override // com.facetec.sdk.jo public final void a(jm jmVar) { synchronized (this) { if (this.h) { throw new IllegalStateException("Already Executed"); } this.h = true; } this.a.d = mi.c().a("response.body().close()"); jr l = this.c.l(); a aVar = new a(this, jmVar); synchronized (l) { l.a.add(aVar); } l.b(); } public final boolean b() { return this.a.a(); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public final class a extends kl { static final boolean c = true; final jm a; final kg e; /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ a(kg kgVar, jm jmVar) { super("OkHttp %s", kgVar.c()); this.e = kgVar; this.a = jmVar; } /* JADX INFO: Access modifiers changed from: package-private */ public final String b() { return this.e.e.a().i(); } @Override // com.facetec.sdk.kl public final void a() { boolean z; this.e.b.e(); try { try { kg kgVar = this.e; ArrayList arrayList = new ArrayList(); arrayList.addAll(kgVar.c.d); arrayList.add(kgVar.a); arrayList.add(new lc(kgVar.c.a())); ka kaVar = kgVar.c; arrayList.add(new ko(kaVar.j != null ? kaVar.j.c : kaVar.i)); arrayList.add(new kx(kgVar.c)); if (!kgVar.f) { arrayList.addAll(kgVar.c.b); } arrayList.add(new la(kgVar.f)); kh c2 = new lf(arrayList, null, null, null, 0, kgVar.e, kgVar, kgVar.d, kgVar.c.f, kgVar.c.m, kgVar.c.k).c(kgVar.e); try { if (this.e.a.a()) { jm jmVar = this.a; new IOException("Canceled"); jmVar.e(); } else { this.a.e(c2); } } catch (IOException e) { e = e; z = true; IOException e2 = this.e.e(e); if (!z) { jx unused = this.e.d; this.a.e(); } else { mi c3 = mi.c(); StringBuilder sb = new StringBuilder("Callback failure for "); kg kgVar2 = this.e; StringBuilder sb2 = new StringBuilder(); sb2.append(kgVar2.b() ? "canceled " : ""); sb2.append(kgVar2.f ? "web socket" : "call"); sb2.append(" to "); sb2.append(kgVar2.c()); sb.append(sb2.toString()); c3.d(4, sb.toString(), e2); } } } catch (IOException e3) { e = e3; z = false; } } finally { this.e.c.l().b(this); } } } final String c() { kc.c a2 = this.e.a().a("/..."); a2.c = kc.c("", " \"':;<=>@[]^`{}|/\\?#", false, false, false, true); a2.d = kc.c("", " \"':;<=>@[]^`{}|/\\?#", false, false, false, true); return a2.b().toString(); } public final /* synthetic */ Object clone() throws CloneNotSupportedException { return d(this.c, this.e, this.f); } }