353 lines
11 KiB
Java
353 lines
11 KiB
Java
package com.facetec.sdk;
|
|
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.OutputStream;
|
|
import java.net.Socket;
|
|
import java.net.SocketTimeoutException;
|
|
import java.util.logging.Level;
|
|
import java.util.logging.Logger;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class nb {
|
|
static final Logger b = Logger.getLogger(nb.class.getName());
|
|
|
|
private nb() {
|
|
}
|
|
|
|
public static mr c(nk nkVar) {
|
|
return new nd(nkVar);
|
|
}
|
|
|
|
public static mv e(nj njVar) {
|
|
return new ne(njVar);
|
|
}
|
|
|
|
public static nj a(Socket socket) throws IOException {
|
|
if (socket == null) {
|
|
throw new IllegalArgumentException("socket == null");
|
|
}
|
|
if (socket.getOutputStream() == null) {
|
|
throw new IOException("socket's output stream == null");
|
|
}
|
|
mo b2 = b(socket);
|
|
OutputStream outputStream = socket.getOutputStream();
|
|
if (outputStream == null) {
|
|
throw new IllegalArgumentException("out == null");
|
|
}
|
|
return new nj(b2, new nj(b2, outputStream) { // from class: com.facetec.sdk.nb.4
|
|
private OutputStream b;
|
|
private nh c;
|
|
|
|
{
|
|
this.c = b2;
|
|
this.b = outputStream;
|
|
}
|
|
|
|
@Override // com.facetec.sdk.nj
|
|
public final void c(ms msVar, long j) throws IOException {
|
|
ng.d(msVar.e, 0L, j);
|
|
while (j > 0) {
|
|
this.c.f();
|
|
nc ncVar = msVar.b;
|
|
int min = (int) Math.min(j, ncVar.a - ncVar.e);
|
|
this.b.write(ncVar.b, ncVar.e, min);
|
|
ncVar.e += min;
|
|
long j2 = min;
|
|
j -= j2;
|
|
msVar.e -= j2;
|
|
if (ncVar.e == ncVar.a) {
|
|
msVar.b = ncVar.b();
|
|
nf.a(ncVar);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // com.facetec.sdk.nj, java.io.Flushable
|
|
public final void flush() throws IOException {
|
|
this.b.flush();
|
|
}
|
|
|
|
@Override // com.facetec.sdk.nj, java.io.Closeable, java.lang.AutoCloseable
|
|
public final void close() throws IOException {
|
|
this.b.close();
|
|
}
|
|
|
|
public final String toString() {
|
|
StringBuilder sb = new StringBuilder("sink(");
|
|
sb.append(this.b);
|
|
sb.append(")");
|
|
return sb.toString();
|
|
}
|
|
|
|
@Override // com.facetec.sdk.nj
|
|
public final nh b() {
|
|
return this.c;
|
|
}
|
|
}) { // from class: com.facetec.sdk.mo.2
|
|
private mo b;
|
|
private nj c;
|
|
|
|
public AnonymousClass2(nh b22, nj njVar) {
|
|
this.b = b22;
|
|
this.c = njVar;
|
|
}
|
|
|
|
@Override // com.facetec.sdk.nj
|
|
public final void c(ms msVar, long j) throws IOException {
|
|
ng.d(msVar.e, 0L, j);
|
|
while (true) {
|
|
long j2 = 0;
|
|
if (j <= 0) {
|
|
return;
|
|
}
|
|
nc ncVar = msVar.b;
|
|
while (true) {
|
|
if (j2 >= 65536) {
|
|
break;
|
|
}
|
|
j2 += ncVar.a - ncVar.e;
|
|
if (j2 >= j) {
|
|
j2 = j;
|
|
break;
|
|
}
|
|
ncVar = ncVar.i;
|
|
}
|
|
this.b.e();
|
|
try {
|
|
try {
|
|
this.c.c(msVar, j2);
|
|
j -= j2;
|
|
this.b.d(true);
|
|
} catch (IOException e) {
|
|
throw this.b.d(e);
|
|
}
|
|
} catch (Throwable th) {
|
|
this.b.d(false);
|
|
throw th;
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // com.facetec.sdk.nj, java.io.Flushable
|
|
public final void flush() throws IOException {
|
|
this.b.e();
|
|
try {
|
|
try {
|
|
this.c.flush();
|
|
this.b.d(true);
|
|
} catch (IOException e) {
|
|
throw this.b.d(e);
|
|
}
|
|
} catch (Throwable th) {
|
|
this.b.d(false);
|
|
throw th;
|
|
}
|
|
}
|
|
|
|
@Override // com.facetec.sdk.nj, java.io.Closeable, java.lang.AutoCloseable
|
|
public final void close() throws IOException {
|
|
this.b.e();
|
|
try {
|
|
try {
|
|
this.c.close();
|
|
this.b.d(true);
|
|
} catch (IOException e) {
|
|
throw this.b.d(e);
|
|
}
|
|
} catch (Throwable th) {
|
|
this.b.d(false);
|
|
throw th;
|
|
}
|
|
}
|
|
|
|
public final String toString() {
|
|
StringBuilder sb = new StringBuilder("AsyncTimeout.sink(");
|
|
sb.append(this.c);
|
|
sb.append(")");
|
|
return sb.toString();
|
|
}
|
|
|
|
@Override // com.facetec.sdk.nj
|
|
public final nh b() {
|
|
return this.b;
|
|
}
|
|
};
|
|
}
|
|
|
|
public static nk e(InputStream inputStream) {
|
|
return d(inputStream, new nh());
|
|
}
|
|
|
|
private static nk d(InputStream inputStream, nh nhVar) {
|
|
if (inputStream == null) {
|
|
throw new IllegalArgumentException("in == null");
|
|
}
|
|
if (nhVar == null) {
|
|
throw new IllegalArgumentException("timeout == null");
|
|
}
|
|
return new nk(nhVar, inputStream) { // from class: com.facetec.sdk.nb.1
|
|
private nh a;
|
|
private InputStream e;
|
|
|
|
{
|
|
this.a = nhVar;
|
|
this.e = inputStream;
|
|
}
|
|
|
|
@Override // com.facetec.sdk.nk
|
|
public final long b(ms msVar, long j) throws IOException {
|
|
if (j < 0) {
|
|
throw new IllegalArgumentException("byteCount < 0: ".concat(String.valueOf(j)));
|
|
}
|
|
if (j == 0) {
|
|
return 0L;
|
|
}
|
|
try {
|
|
this.a.f();
|
|
nc a = msVar.a(1);
|
|
int read = this.e.read(a.b, a.a, (int) Math.min(j, 8192 - a.a));
|
|
if (read == -1) {
|
|
return -1L;
|
|
}
|
|
a.a += read;
|
|
long j2 = read;
|
|
msVar.e += j2;
|
|
return j2;
|
|
} catch (AssertionError e) {
|
|
if (nb.b(e)) {
|
|
throw new IOException(e);
|
|
}
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
@Override // com.facetec.sdk.nk, java.io.Closeable, java.lang.AutoCloseable
|
|
public final void close() throws IOException {
|
|
this.e.close();
|
|
}
|
|
|
|
public final String toString() {
|
|
StringBuilder sb = new StringBuilder("source(");
|
|
sb.append(this.e);
|
|
sb.append(")");
|
|
return sb.toString();
|
|
}
|
|
|
|
@Override // com.facetec.sdk.nk
|
|
public final nh b() {
|
|
return this.a;
|
|
}
|
|
};
|
|
}
|
|
|
|
public static nk e(Socket socket) throws IOException {
|
|
if (socket == null) {
|
|
throw new IllegalArgumentException("socket == null");
|
|
}
|
|
if (socket.getInputStream() == null) {
|
|
throw new IOException("socket's input stream == null");
|
|
}
|
|
mo b2 = b(socket);
|
|
return new nk(b2, d(socket.getInputStream(), b2)) { // from class: com.facetec.sdk.mo.3
|
|
private mo b;
|
|
private nk c;
|
|
|
|
public AnonymousClass3(mo b22, nk nkVar) {
|
|
this.b = b22;
|
|
this.c = nkVar;
|
|
}
|
|
|
|
@Override // com.facetec.sdk.nk
|
|
public final long b(ms msVar, long j) throws IOException {
|
|
this.b.e();
|
|
try {
|
|
try {
|
|
long b3 = this.c.b(msVar, j);
|
|
this.b.d(true);
|
|
return b3;
|
|
} catch (IOException e) {
|
|
throw this.b.d(e);
|
|
}
|
|
} catch (Throwable th) {
|
|
this.b.d(false);
|
|
throw th;
|
|
}
|
|
}
|
|
|
|
@Override // com.facetec.sdk.nk, java.io.Closeable, java.lang.AutoCloseable
|
|
public final void close() throws IOException {
|
|
try {
|
|
try {
|
|
this.c.close();
|
|
this.b.d(true);
|
|
} catch (IOException e) {
|
|
throw this.b.d(e);
|
|
}
|
|
} catch (Throwable th) {
|
|
this.b.d(false);
|
|
throw th;
|
|
}
|
|
}
|
|
|
|
public final String toString() {
|
|
StringBuilder sb = new StringBuilder("AsyncTimeout.source(");
|
|
sb.append(this.c);
|
|
sb.append(")");
|
|
return sb.toString();
|
|
}
|
|
|
|
@Override // com.facetec.sdk.nk
|
|
public final nh b() {
|
|
return this.b;
|
|
}
|
|
};
|
|
}
|
|
|
|
private static mo b(Socket socket) {
|
|
return new mo(socket) { // from class: com.facetec.sdk.nb.3
|
|
private Socket d;
|
|
|
|
{
|
|
this.d = socket;
|
|
}
|
|
|
|
@Override // com.facetec.sdk.mo
|
|
protected final IOException a(IOException iOException) {
|
|
SocketTimeoutException socketTimeoutException = new SocketTimeoutException("timeout");
|
|
if (iOException != null) {
|
|
socketTimeoutException.initCause(iOException);
|
|
}
|
|
return socketTimeoutException;
|
|
}
|
|
|
|
@Override // com.facetec.sdk.mo
|
|
protected final void d() {
|
|
try {
|
|
this.d.close();
|
|
} catch (AssertionError e) {
|
|
if (nb.b(e)) {
|
|
Logger logger = nb.b;
|
|
Level level = Level.WARNING;
|
|
StringBuilder sb = new StringBuilder("Failed to close timed out socket ");
|
|
sb.append(this.d);
|
|
logger.log(level, sb.toString(), (Throwable) e);
|
|
return;
|
|
}
|
|
throw e;
|
|
} catch (Exception e2) {
|
|
Logger logger2 = nb.b;
|
|
Level level2 = Level.WARNING;
|
|
StringBuilder sb2 = new StringBuilder("Failed to close timed out socket ");
|
|
sb2.append(this.d);
|
|
logger2.log(level2, sb2.toString(), (Throwable) e2);
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
static boolean b(AssertionError assertionError) {
|
|
return (assertionError.getCause() == null || assertionError.getMessage() == null || !assertionError.getMessage().contains("getsockname failed")) ? false : true;
|
|
}
|
|
}
|