package com.facetec.sdk; import com.facetec.sdk.kb; import com.facetec.sdk.lb; import java.io.IOException; import java.lang.ref.WeakReference; import java.net.Proxy; import java.net.Socket; import java.util.concurrent.TimeUnit; /* loaded from: classes.dex */ public final class ky { public static final boolean j = true; public final jx a; public final jp b; public kt c; public final jo d; public kj e; private lb.b f; private jj g; public lh h; public boolean i; private final lb k; private int l; private boolean m; private boolean n; /* renamed from: o, reason: collision with root package name */ private final Object f6452o; public ky(jp jpVar, jj jjVar, jo joVar, jx jxVar, Object obj) { this.b = jpVar; this.g = jjVar; this.d = joVar; this.a = jxVar; this.k = new lb(jjVar, h(), joVar, jxVar); this.f6452o = obj; } public final lh a(ka kaVar, kb.c cVar, boolean z) { lh lpVar; try { kt d = d(cVar.c(), cVar.a(), cVar.e(), kaVar.l, kaVar.k(), z); if (d.f != null) { lpVar = new lu(kaVar, cVar, this, d.f); } else { d.a.setSoTimeout(cVar.a()); d.g.b().a(cVar.a(), TimeUnit.MILLISECONDS); d.j.b().a(cVar.e(), TimeUnit.MILLISECONDS); lpVar = new lp(kaVar, this, d.g, d.j); } synchronized (this.b) { this.h = lpVar; } return lpVar; } catch (IOException e2) { throw new kz(e2); } } private kt d(int i, int i2, int i3, int i4, boolean z, boolean z2) throws IOException { while (true) { kt c = c(i, i2, i3, i4, z); synchronized (this.b) { if (c.m == 0) { return c; } if (c.e(z2)) { return c; } b(); } } } /* JADX WARN: Multi-variable type inference failed */ /* JADX WARN: Removed duplicated region for block: B:182:0x0599 */ /* JADX WARN: Removed duplicated region for block: B:192:0x05b7 */ /* JADX WARN: Removed duplicated region for block: B:218:0x0684 A[Catch: all -> 0x068b, TryCatch #5 {all -> 0x068b, blocks: (B:212:0x05e3, B:213:0x062c, B:216:0x067e, B:218:0x0684, B:219:0x0689, B:220:0x068a, B:244:0x0633, B:245:0x0664), top: B:136:0x0487 }] */ /* JADX WARN: Removed duplicated region for block: B:220:0x068a A[Catch: all -> 0x068b, TRY_LEAVE, TryCatch #5 {all -> 0x068b, blocks: (B:212:0x05e3, B:213:0x062c, B:216:0x067e, B:218:0x0684, B:219:0x0689, B:220:0x068a, B:244:0x0633, B:245:0x0664), top: B:136:0x0487 }] */ /* JADX WARN: Removed duplicated region for block: B:230:0x06c8 */ /* JADX WARN: Removed duplicated region for block: B:232:0x06d7 */ /* JADX WARN: Removed duplicated region for block: B:237:0x06df A[SYNTHETIC] */ /* JADX WARN: Removed duplicated region for block: B:239:0x06ce */ /* JADX WARN: Removed duplicated region for block: B:241:0x068e A[EXC_TOP_SPLITTER, SYNTHETIC] */ /* JADX WARN: Type inference failed for: r0v97, types: [com.facetec.sdk.mi] */ /* JADX WARN: Type inference failed for: r0v99, types: [com.facetec.sdk.mi] */ /* JADX WARN: Type inference failed for: r10v5, types: [com.facetec.sdk.mi] */ /* JADX WARN: Type inference failed for: r11v15, types: [com.facetec.sdk.jt] */ /* JADX WARN: Type inference failed for: r12v16, types: [com.facetec.sdk.kn] */ /* JADX WARN: Type inference failed for: r5v2, types: [com.facetec.sdk.kw] */ /* JADX WARN: Type inference failed for: r7v16, types: [com.facetec.sdk.kn] */ /* JADX WARN: Type inference failed for: r7v29, types: [com.facetec.sdk.mi] */ /* JADX WARN: Type inference failed for: r8v0 */ /* JADX WARN: Type inference failed for: r8v1 */ /* JADX WARN: Type inference failed for: r8v11 */ /* JADX WARN: Type inference failed for: r8v12, types: [java.net.Socket, javax.net.ssl.SSLSocket] */ /* JADX WARN: Type inference failed for: r8v13 */ /* JADX WARN: Type inference failed for: r8v17, types: [java.net.Socket, javax.net.ssl.SSLSocket] */ /* JADX WARN: Type inference failed for: r8v2 */ /* JADX WARN: Type inference failed for: r8v3 */ /* JADX WARN: Type inference failed for: r8v30 */ /* JADX WARN: Type inference failed for: r8v33 */ /* JADX WARN: Type inference failed for: r8v34, types: [int] */ /* JADX WARN: Type inference failed for: r8v35 */ /* JADX WARN: Type inference failed for: r8v37, types: [com.facetec.sdk.kj] */ /* JADX WARN: Type inference failed for: r8v4 */ /* JADX WARN: Type inference failed for: r8v51 */ /* JADX WARN: Type inference failed for: r8v52 */ /* JADX WARN: Type inference failed for: r8v53 */ /* JADX WARN: Type inference failed for: r8v54 */ /* JADX WARN: Type inference failed for: r8v7 */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ private com.facetec.sdk.kt c(int r19, int r20, int r21, int r22, boolean r23) throws java.io.IOException { /* Method dump skipped, instructions count: 1819 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: com.facetec.sdk.ky.c(int, int, int, int, boolean):com.facetec.sdk.kt"); } public final void e(boolean z, lh lhVar, IOException iOException) { Socket b; boolean z2; synchronized (this.b) { if (lhVar != null) { if (lhVar == this.h) { if (!z) { this.c.m++; } b = b(z, false, true); z2 = this.n; } } StringBuilder sb = new StringBuilder("expected "); sb.append(this.h); sb.append(" but was "); sb.append(lhVar); throw new IllegalStateException(sb.toString()); } km.b(b); if (iOException != null) { kn.a.a(this.d, iOException); } else if (z2) { kn.a.a(this.d, (IOException) null); } } public final lh d() { lh lhVar; synchronized (this.b) { lhVar = this.h; } return lhVar; } private kv h() { return kn.a.b(this.b); } public final kt e() { kt ktVar; synchronized (this) { ktVar = this.c; } return ktVar; } public final void c() { kt ktVar; Socket b; synchronized (this.b) { ktVar = this.c; b = b(false, true, false); if (this.c != null) { ktVar = null; } } km.b(b); if (ktVar != null) { kn.a.a(this.d, (IOException) null); } } public final void b() { Socket b; synchronized (this.b) { b = b(true, false, false); } km.b(b); } public final Socket b(boolean z, boolean z2, boolean z3) { Socket socket; if (!j && !Thread.holdsLock(this.b)) { throw new AssertionError(); } if (z3) { this.h = null; } if (z2) { this.n = true; } kt ktVar = this.c; if (ktVar == null) { return null; } if (z) { ktVar.i = true; } if (this.h != null) { return null; } if (!this.n && !this.c.i) { return null; } a(this.c); if (this.c.f6451o.isEmpty()) { this.c.k = System.nanoTime(); if (kn.a.e(this.b, this.c)) { socket = this.c.d(); this.c = null; return socket; } } socket = null; this.c = null; return socket; } public final void b(IOException iOException) { boolean z; Socket b; synchronized (this.b) { if (iOException instanceof lx) { lo loVar = ((lx) iOException).e; if (loVar == lo.REFUSED_STREAM) { int i = this.l + 1; this.l = i; if (i > 1) { this.e = null; z = true; } } else if (loVar != lo.CANCEL) { this.e = null; z = true; } z = false; } else { kt ktVar = this.c; if (ktVar != null && (!ktVar.b() || (iOException instanceof lr))) { if (this.c.m == 0) { kj kjVar = this.e; if (kjVar != null && iOException != null) { lb lbVar = this.k; if (kjVar.b().type() != Proxy.Type.DIRECT && lbVar.e.c() != null) { lbVar.e.c().connectFailed(lbVar.e.b().e(), kjVar.b().address(), iOException); } lbVar.d.c(kjVar); } this.e = null; } z = true; } z = false; } b = b(z, false, true); } km.b(b); } public final void b(kt ktVar, boolean z) { if (!j && !Thread.holdsLock(this.b)) { throw new AssertionError(); } if (this.c != null) { throw new IllegalStateException(); } this.c = ktVar; this.m = z; ktVar.f6451o.add(new e(this, this.f6452o)); } private void a(kt ktVar) { int size = ktVar.f6451o.size(); for (int i = 0; i < size; i++) { if (ktVar.f6451o.get(i).get() == this) { ktVar.f6451o.remove(i); return; } } throw new IllegalStateException(); } public final boolean a() { if (this.e != null) { return true; } lb.b bVar = this.f; return (bVar != null && bVar.b()) || this.k.b(); } public final String toString() { kt e2 = e(); return e2 != null ? e2.toString() : this.g.toString(); } /* loaded from: classes.dex */ public static final class e extends WeakReference { public final Object c; e(ky kyVar, Object obj) { super(kyVar); this.c = obj; } } }