297 lines
11 KiB
Java
297 lines
11 KiB
Java
|
package com.facetec.sdk;
|
||
|
|
||
|
import com.facetec.sdk.lq;
|
||
|
import com.google.common.primitives.UnsignedBytes;
|
||
|
import java.io.Closeable;
|
||
|
import java.io.IOException;
|
||
|
import java.util.List;
|
||
|
import java.util.logging.Level;
|
||
|
import java.util.logging.Logger;
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
final class lv implements Closeable {
|
||
|
static final Logger d = Logger.getLogger(lt.class.getName());
|
||
|
private lq.a a;
|
||
|
final mr b;
|
||
|
final boolean c;
|
||
|
private final a e;
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
interface d {
|
||
|
void a(int i, lo loVar);
|
||
|
|
||
|
void a(boolean z, int i, List<ln> list);
|
||
|
|
||
|
void b(int i, long j);
|
||
|
|
||
|
void b(mb mbVar);
|
||
|
|
||
|
void c(int i, mt mtVar);
|
||
|
|
||
|
void c(boolean z, int i, int i2);
|
||
|
|
||
|
void d(int i, List<ln> list) throws IOException;
|
||
|
|
||
|
void d(boolean z, int i, mr mrVar, int i2) throws IOException;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public lv(mr mrVar, boolean z) {
|
||
|
this.b = mrVar;
|
||
|
this.c = z;
|
||
|
a aVar = new a(mrVar);
|
||
|
this.e = aVar;
|
||
|
this.a = new lq.a(aVar, (byte) 0);
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
public final boolean c(boolean z, d dVar) throws IOException {
|
||
|
try {
|
||
|
this.b.e(9L);
|
||
|
int a2 = a(this.b);
|
||
|
if (a2 < 0 || a2 > 16384) {
|
||
|
throw lt.b("FRAME_SIZE_ERROR: %s", Integer.valueOf(a2));
|
||
|
}
|
||
|
byte g = this.b.g();
|
||
|
if (z && g != 4) {
|
||
|
throw lt.b("Expected a SETTINGS frame but was %s", Byte.valueOf(g));
|
||
|
}
|
||
|
byte g2 = this.b.g();
|
||
|
int h = this.b.h() & Integer.MAX_VALUE;
|
||
|
Logger logger = d;
|
||
|
if (logger.isLoggable(Level.FINE)) {
|
||
|
logger.fine(lt.e(true, h, a2, g, g2));
|
||
|
}
|
||
|
switch (g) {
|
||
|
case 0:
|
||
|
if (h == 0) {
|
||
|
throw lt.b("PROTOCOL_ERROR: TYPE_DATA streamId == 0", new Object[0]);
|
||
|
}
|
||
|
boolean z2 = (g2 & 1) != 0;
|
||
|
if ((g2 & 32) != 0) {
|
||
|
throw lt.b("PROTOCOL_ERROR: FLAG_COMPRESSED without SETTINGS_COMPRESS_DATA", new Object[0]);
|
||
|
}
|
||
|
short g3 = (g2 & 8) != 0 ? (short) (this.b.g() & UnsignedBytes.MAX_VALUE) : (short) 0;
|
||
|
dVar.d(z2, h, this.b, b(a2, g2, g3));
|
||
|
this.b.f(g3);
|
||
|
return true;
|
||
|
case 1:
|
||
|
if (h == 0) {
|
||
|
throw lt.b("PROTOCOL_ERROR: TYPE_HEADERS streamId == 0", new Object[0]);
|
||
|
}
|
||
|
boolean z3 = (g2 & 1) != 0;
|
||
|
short g4 = (g2 & 8) != 0 ? (short) (this.b.g() & UnsignedBytes.MAX_VALUE) : (short) 0;
|
||
|
if ((g2 & 32) != 0) {
|
||
|
c();
|
||
|
a2 -= 5;
|
||
|
}
|
||
|
dVar.a(z3, h, d(b(a2, g2, g4), g4, g2, h));
|
||
|
return true;
|
||
|
case 2:
|
||
|
if (a2 != 5) {
|
||
|
throw lt.b("TYPE_PRIORITY length: %d != 5", Integer.valueOf(a2));
|
||
|
}
|
||
|
if (h == 0) {
|
||
|
throw lt.b("TYPE_PRIORITY streamId == 0", new Object[0]);
|
||
|
}
|
||
|
c();
|
||
|
return true;
|
||
|
case 3:
|
||
|
if (a2 != 4) {
|
||
|
throw lt.b("TYPE_RST_STREAM length: %d != 4", Integer.valueOf(a2));
|
||
|
}
|
||
|
if (h == 0) {
|
||
|
throw lt.b("TYPE_RST_STREAM streamId == 0", new Object[0]);
|
||
|
}
|
||
|
int h2 = this.b.h();
|
||
|
lo e = lo.e(h2);
|
||
|
if (e == null) {
|
||
|
throw lt.b("TYPE_RST_STREAM unexpected error code: %d", Integer.valueOf(h2));
|
||
|
}
|
||
|
dVar.a(h, e);
|
||
|
return true;
|
||
|
case 4:
|
||
|
if (h != 0) {
|
||
|
throw lt.b("TYPE_SETTINGS streamId != 0", new Object[0]);
|
||
|
}
|
||
|
if ((g2 & 1) == 0) {
|
||
|
if (a2 % 6 != 0) {
|
||
|
throw lt.b("TYPE_SETTINGS length %% 6 != 0: %s", Integer.valueOf(a2));
|
||
|
}
|
||
|
mb mbVar = new mb();
|
||
|
for (int i = 0; i < a2; i += 6) {
|
||
|
int i2 = this.b.i() & 65535;
|
||
|
int h3 = this.b.h();
|
||
|
if (i2 != 2) {
|
||
|
if (i2 == 3) {
|
||
|
i2 = 4;
|
||
|
} else if (i2 == 4) {
|
||
|
if (h3 < 0) {
|
||
|
throw lt.b("PROTOCOL_ERROR SETTINGS_INITIAL_WINDOW_SIZE > 2^31 - 1", new Object[0]);
|
||
|
}
|
||
|
i2 = 7;
|
||
|
} else if (i2 == 5 && (h3 < 16384 || h3 > 16777215)) {
|
||
|
throw lt.b("PROTOCOL_ERROR SETTINGS_MAX_FRAME_SIZE: %s", Integer.valueOf(h3));
|
||
|
}
|
||
|
} else if (h3 != 0 && h3 != 1) {
|
||
|
throw lt.b("PROTOCOL_ERROR SETTINGS_ENABLE_PUSH != 0 or 1", new Object[0]);
|
||
|
}
|
||
|
mbVar.c(i2, h3);
|
||
|
}
|
||
|
dVar.b(mbVar);
|
||
|
} else if (a2 != 0) {
|
||
|
throw lt.b("FRAME_SIZE_ERROR ack frame should be empty!", new Object[0]);
|
||
|
}
|
||
|
return true;
|
||
|
case 5:
|
||
|
if (h == 0) {
|
||
|
throw lt.b("PROTOCOL_ERROR: TYPE_PUSH_PROMISE streamId == 0", new Object[0]);
|
||
|
}
|
||
|
short g5 = (g2 & 8) != 0 ? (short) (this.b.g() & UnsignedBytes.MAX_VALUE) : (short) 0;
|
||
|
dVar.d(this.b.h() & Integer.MAX_VALUE, d(b(a2 - 4, g2, g5), g5, g2, h));
|
||
|
return true;
|
||
|
case 6:
|
||
|
if (a2 != 8) {
|
||
|
throw lt.b("TYPE_PING length != 8: %s", Integer.valueOf(a2));
|
||
|
}
|
||
|
if (h != 0) {
|
||
|
throw lt.b("TYPE_PING streamId != 0", new Object[0]);
|
||
|
}
|
||
|
dVar.c((g2 & 1) != 0, this.b.h(), this.b.h());
|
||
|
return true;
|
||
|
case 7:
|
||
|
if (a2 < 8) {
|
||
|
throw lt.b("TYPE_GOAWAY length < 8: %s", Integer.valueOf(a2));
|
||
|
}
|
||
|
if (h != 0) {
|
||
|
throw lt.b("TYPE_GOAWAY streamId != 0", new Object[0]);
|
||
|
}
|
||
|
int h4 = this.b.h();
|
||
|
int h5 = this.b.h();
|
||
|
int i3 = a2 - 8;
|
||
|
if (lo.e(h5) == null) {
|
||
|
throw lt.b("TYPE_GOAWAY unexpected error code: %d", Integer.valueOf(h5));
|
||
|
}
|
||
|
mt mtVar = mt.a;
|
||
|
if (i3 > 0) {
|
||
|
mtVar = this.b.b(i3);
|
||
|
}
|
||
|
dVar.c(h4, mtVar);
|
||
|
return true;
|
||
|
case 8:
|
||
|
if (a2 != 4) {
|
||
|
throw lt.b("TYPE_WINDOW_UPDATE length !=4: %s", Integer.valueOf(a2));
|
||
|
}
|
||
|
long h6 = this.b.h() & 2147483647L;
|
||
|
if (h6 == 0) {
|
||
|
throw lt.b("windowSizeIncrement was 0", Long.valueOf(h6));
|
||
|
}
|
||
|
dVar.b(h, h6);
|
||
|
return true;
|
||
|
default:
|
||
|
this.b.f(a2);
|
||
|
return true;
|
||
|
}
|
||
|
} catch (IOException unused) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private List<ln> d(int i, short s, byte b, int i2) throws IOException {
|
||
|
a aVar = this.e;
|
||
|
aVar.c = i;
|
||
|
aVar.b = i;
|
||
|
this.e.e = s;
|
||
|
this.e.d = b;
|
||
|
this.e.a = i2;
|
||
|
this.a.a();
|
||
|
return this.a.c();
|
||
|
}
|
||
|
|
||
|
private void c() throws IOException {
|
||
|
this.b.h();
|
||
|
this.b.g();
|
||
|
}
|
||
|
|
||
|
@Override // java.io.Closeable, java.lang.AutoCloseable
|
||
|
public final void close() throws IOException {
|
||
|
this.b.close();
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* loaded from: classes.dex */
|
||
|
public static final class a implements nk {
|
||
|
int a;
|
||
|
int b;
|
||
|
int c;
|
||
|
byte d;
|
||
|
short e;
|
||
|
private final mr g;
|
||
|
|
||
|
@Override // com.facetec.sdk.nk, java.io.Closeable, java.lang.AutoCloseable
|
||
|
public final void close() throws IOException {
|
||
|
}
|
||
|
|
||
|
a(mr mrVar) {
|
||
|
this.g = mrVar;
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.nk
|
||
|
public final long b(ms msVar, long j) throws IOException {
|
||
|
int i;
|
||
|
int h;
|
||
|
do {
|
||
|
int i2 = this.c;
|
||
|
if (i2 == 0) {
|
||
|
this.g.f(this.e);
|
||
|
this.e = (short) 0;
|
||
|
if ((this.d & 4) != 0) {
|
||
|
return -1L;
|
||
|
}
|
||
|
i = this.a;
|
||
|
int a = lv.a(this.g);
|
||
|
this.c = a;
|
||
|
this.b = a;
|
||
|
byte g = this.g.g();
|
||
|
this.d = this.g.g();
|
||
|
if (lv.d.isLoggable(Level.FINE)) {
|
||
|
lv.d.fine(lt.e(true, this.a, this.b, g, this.d));
|
||
|
}
|
||
|
h = this.g.h() & Integer.MAX_VALUE;
|
||
|
this.a = h;
|
||
|
if (g != 9) {
|
||
|
throw lt.b("%s != TYPE_CONTINUATION", Byte.valueOf(g));
|
||
|
}
|
||
|
} else {
|
||
|
long b = this.g.b(msVar, Math.min(j, i2));
|
||
|
if (b == -1) {
|
||
|
return -1L;
|
||
|
}
|
||
|
this.c = (int) (this.c - b);
|
||
|
return b;
|
||
|
}
|
||
|
} while (h == i);
|
||
|
throw lt.b("TYPE_CONTINUATION streamId changed", new Object[0]);
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.nk
|
||
|
public final nh b() {
|
||
|
return this.g.b();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
static int a(mr mrVar) throws IOException {
|
||
|
return (mrVar.g() & UnsignedBytes.MAX_VALUE) | ((mrVar.g() & UnsignedBytes.MAX_VALUE) << 16) | ((mrVar.g() & UnsignedBytes.MAX_VALUE) << 8);
|
||
|
}
|
||
|
|
||
|
private static int b(int i, byte b, short s) throws IOException {
|
||
|
if ((b & 8) != 0) {
|
||
|
i--;
|
||
|
}
|
||
|
if (s <= i) {
|
||
|
return (short) (i - s);
|
||
|
}
|
||
|
throw lt.b("PROTOCOL_ERROR padding %s > remaining length %s", Short.valueOf(s), Integer.valueOf(i));
|
||
|
}
|
||
|
}
|