package com.facetec.sdk; import com.facetec.sdk.ln; import com.google.common.base.Ascii; import java.io.IOException; import java.io.InterruptedIOException; import java.net.SocketTimeoutException; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Deque; import net.sf.scuba.smartcards.ISO7816; import okhttp3.internal.http2.Http2Stream; import org.bouncycastle.crypto.tls.CipherSuite; /* loaded from: classes.dex */ public final class ls { static final boolean k; private static final byte[] m = null; private static final int n = 0; long a; long b = 0; final int c; final Deque d; final lw e; final a f; final c g; boolean h; final a i; final b j; lo l; /* renamed from: o, reason: collision with root package name */ private ln.d f6455o; /* JADX WARN: Removed duplicated region for block: B:10:0x0029 */ /* JADX WARN: Removed duplicated region for block: B:7:0x0021 */ /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:10:0x0029 -> B:4:0x002f). Please report as a decompilation issue!!! */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ private static void p(byte r6, int r7, short r8, java.lang.Object[] r9) { /* int r6 = r6 * 3 int r7 = r7 * 12 int r7 = 16 - r7 byte[] r0 = com.facetec.sdk.ls.m int r8 = r8 * 7 int r8 = 106 - r8 int r1 = r6 + 13 byte[] r1 = new byte[r1] int r6 = r6 + 12 r2 = 0 if (r0 != 0) goto L19 r3 = r6 r8 = r7 r4 = r2 goto L2f L19: r3 = r2 L1a: byte r4 = (byte) r8 r1[r3] = r4 int r4 = r3 + 1 if (r3 != r6) goto L29 java.lang.String r6 = new java.lang.String r6.(r1, r2) r9[r2] = r6 return L29: r3 = r0[r7] r5 = r8 r8 = r7 r7 = r3 r3 = r5 L2f: int r3 = r3 + r7 int r7 = r3 + 2 int r8 = r8 + 1 r3 = r4 r5 = r8 r8 = r7 r7 = r5 goto L1a */ throw new UnsupportedOperationException("Method not decompiled: com.facetec.sdk.ls.p(byte, int, short, java.lang.Object[]):void"); } /* JADX INFO: Access modifiers changed from: package-private */ public ls(int i, lw lwVar, boolean z, boolean z2, jv jvVar) { ArrayDeque arrayDeque = new ArrayDeque(); this.d = arrayDeque; this.f = new a(this); this.i = new a(this); this.l = null; if (lwVar == null) { throw new NullPointerException("connection == null"); } this.c = i; this.e = lwVar; this.a = lwVar.k.c(); b bVar = new b(this, lwVar.m.c()); this.j = bVar; c cVar = new c(this); this.g = cVar; bVar.b = z2; cVar.a = z; if (jvVar != null) { arrayDeque.add(jvVar); } if (b() && jvVar != null) { throw new IllegalStateException("locally-initiated streams shouldn't have headers yet"); } if (!b() && jvVar == null) { throw new IllegalStateException("remotely-initiated streams should have headers"); } } public final boolean a() { synchronized (this) { if (this.l != null) { return false; } if ((this.j.b || this.j.a) && (this.g.a || this.g.e)) { if (this.h) { return false; } } return true; } } public final boolean b() { return this.e.a == ((this.c & 1) == 1); } public final jv c() throws IOException { jv removeFirst; synchronized (this) { this.f.e(); while (this.d.isEmpty() && this.l == null) { try { h(); } catch (Throwable th) { this.f.c(); throw th; } } this.f.c(); if (!this.d.isEmpty()) { removeFirst = this.d.removeFirst(); } else { throw new lx(this.l); } } return removeFirst; } public final nj d() { synchronized (this) { if (!this.h && !b()) { throw new IllegalStateException("reply before requesting the sink"); } } return this.g; } public final void e(lo loVar) throws IOException { if (b(loVar)) { this.e.c(this.c, loVar); } } public final void d(lo loVar) { if (b(loVar)) { this.e.d(this.c, loVar); } } private boolean b(lo loVar) { if (!k && Thread.holdsLock(this)) { throw new AssertionError(); } synchronized (this) { if (this.l != null) { return false; } if (this.j.b && this.g.a) { return false; } this.l = loVar; notifyAll(); this.e.d(this.c); return true; } } /* JADX INFO: Access modifiers changed from: package-private */ public final void j() { boolean a2; if (!k && Thread.holdsLock(this)) { throw new AssertionError(); } synchronized (this) { this.j.b = true; a2 = a(); notifyAll(); } if (a2) { return; } this.e.d(this.c); } /* JADX INFO: Access modifiers changed from: package-private */ public final void a(lo loVar) { synchronized (this) { if (this.l == null) { this.l = loVar; notifyAll(); } } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public final class b implements nk { static boolean f = true; boolean a; boolean b; final ms c = new ms(); final ms d = new ms(); final long e; ls h; b(ls lsVar, long j) { this.h = lsVar; this.e = j; } /* JADX WARN: Code restructure failed: missing block: B:25:0x00c7, code lost: if (r11 == (-1)) goto L42; */ /* JADX WARN: Code restructure failed: missing block: B:26:0x00c9, code lost: e(r11); */ /* JADX WARN: Code restructure failed: missing block: B:27:0x00cc, code lost: return r11; */ /* JADX WARN: Code restructure failed: missing block: B:29:0x00cd, code lost: if (r0 != null) goto L44; */ /* JADX WARN: Code restructure failed: missing block: B:30:0x00cf, code lost: return -1; */ /* JADX WARN: Code restructure failed: missing block: B:32:0x00d5, code lost: throw new com.facetec.sdk.lx(r0); */ /* JADX WARN: Code restructure failed: missing block: B:59:0x00dd, code lost: throw new java.io.IOException("stream closed"); */ @Override // com.facetec.sdk.nk /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public final long b(com.facetec.sdk.ms r18, long r19) throws java.io.IOException { /* Method dump skipped, instructions count: 250 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: com.facetec.sdk.ls.b.b(com.facetec.sdk.ms, long):long"); } private void e(long j) { if (!f && Thread.holdsLock(this.h)) { throw new AssertionError(); } this.h.e.e(j); } @Override // com.facetec.sdk.nk public final nh b() { return this.h.f; } @Override // com.facetec.sdk.nk, java.io.Closeable, java.lang.AutoCloseable public final void close() throws IOException { long c; ArrayList arrayList; ln.d dVar; synchronized (this.h) { this.a = true; c = this.d.c(); this.d.t(); if (this.h.d.isEmpty() || this.h.f6455o == null) { arrayList = null; dVar = null; } else { arrayList = new ArrayList(this.h.d); this.h.d.clear(); dVar = this.h.f6455o; } this.h.notifyAll(); } if (c > 0) { e(c); } this.h.i(); if (dVar != null) { for (jv jvVar : arrayList) { } } } } final void i() throws IOException { boolean z; boolean a2; if (!k && Thread.holdsLock(this)) { throw new AssertionError(); } synchronized (this) { z = !this.j.b && this.j.a && (this.g.a || this.g.e); a2 = a(); } if (z) { e(lo.CANCEL); } else { if (a2) { return; } this.e.d(this.c); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public final class c implements nj { private static boolean b = true; boolean a; private final ms c = new ms(); private ls d; boolean e; c(ls lsVar) { this.d = lsVar; } @Override // com.facetec.sdk.nj public final void c(ms msVar, long j) throws IOException { if (!b && Thread.holdsLock(this.d)) { throw new AssertionError(); } this.c.c(msVar, j); while (this.c.c() >= Http2Stream.EMIT_BUFFER_SIZE) { a(false); } } private void a(boolean z) throws IOException { long min; synchronized (this.d) { this.d.i.e(); while (this.d.a <= 0 && !this.a && !this.e && this.d.l == null) { try { this.d.h(); } finally { } } this.d.i.c(); this.d.g(); min = Math.min(this.d.a, this.c.c()); this.d.a -= min; } this.d.i.e(); try { this.d.e.e(this.d.c, z && min == this.c.c(), this.c, min); } finally { } } @Override // com.facetec.sdk.nj, java.io.Flushable public final void flush() throws IOException { if (!b && Thread.holdsLock(this.d)) { throw new AssertionError(); } synchronized (this.d) { this.d.g(); } while (this.c.c() > 0) { a(false); this.d.e.e(); } } @Override // com.facetec.sdk.nj public final nh b() { return this.d.i; } @Override // com.facetec.sdk.nj, java.io.Closeable, java.lang.AutoCloseable public final void close() throws IOException { if (!b && Thread.holdsLock(this.d)) { throw new AssertionError(); } synchronized (this.d) { if (this.e) { return; } if (!this.d.g.a) { if (this.c.c() > 0) { while (this.c.c() > 0) { a(true); } } else { this.d.e.e(this.d.c, true, null, 0L); } } synchronized (this.d) { this.e = true; } this.d.e.e(); this.d.i(); } } } /* JADX INFO: Access modifiers changed from: package-private */ public final void c(long j) { this.a += j; if (j > 0) { notifyAll(); } } final void g() throws IOException { if (this.g.e) { throw new IOException("stream closed"); } if (this.g.a) { throw new IOException("stream finished"); } if (this.l != null) { throw new lx(this.l); } } final void h() throws InterruptedIOException { try { try { wait(); } catch (InterruptedException unused) { byte b2 = m[15]; byte b3 = (byte) (b2 - 1); Object[] objArr = new Object[1]; p(b2, b3, b3, objArr); Class cls = Class.forName((String) objArr[0]); byte b4 = (byte) (m[15] - 1); byte b5 = m[15]; Object[] objArr2 = new Object[1]; p(b4, b5, b5, objArr2); ((Thread) cls.getMethod((String) objArr2[0], null).invoke(null, null)).interrupt(); throw new InterruptedIOException(); } } catch (Throwable th) { Throwable cause = th.getCause(); if (cause == null) { throw th; } throw cause; } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public final class a extends mo { private ls e; a(ls lsVar) { this.e = lsVar; } @Override // com.facetec.sdk.mo public final void d() { this.e.d(lo.CANCEL); } @Override // com.facetec.sdk.mo public final IOException a(IOException iOException) { SocketTimeoutException socketTimeoutException = new SocketTimeoutException("timeout"); if (iOException != null) { socketTimeoutException.initCause(iOException); } return socketTimeoutException; } public final void c() throws IOException { if (a()) { throw a((IOException) null); } } } public final int e() { return this.c; } static void f() { m = new byte[]{15, 82, -61, -51, 16, -5, -2, -15, 7, 4, -34, Ascii.DC2, 8, -15, -6, 1, -11, 19, -23, -53, 60, -13, 11, -9, -59, ISO7816.INS_CHANGE_CHV, Ascii.DC2, 8, -15, -6, 1}; n = CipherSuite.TLS_DHE_PSK_WITH_NULL_SHA256; } static { f(); k = true; } }