discord-jadx/app/src/main/java/g0/l.java

165 lines
5.1 KiB
Java
Raw Normal View History

2021-11-08 18:25:28 +00:00
package g0;
import androidx.recyclerview.widget.RecyclerView;
2021-12-21 23:37:30 +00:00
import b.d.b.a.a;
2021-11-08 18:25:28 +00:00
import d0.z.d.m;
import java.io.EOFException;
import java.io.IOException;
import java.util.Arrays;
import java.util.zip.CRC32;
import java.util.zip.Inflater;
/* compiled from: GzipSource.kt */
2022-03-02 20:59:20 +00:00
/* loaded from: classes3.dex */
2021-11-08 18:25:28 +00:00
public final class l implements x {
2021-12-17 22:03:14 +00:00
public byte j;
public final r k;
public final Inflater l;
public final m m;
public final CRC32 n = new CRC32();
2021-11-08 18:25:28 +00:00
public l(x xVar) {
m.checkParameterIsNotNull(xVar, "source");
r rVar = new r(xVar);
2021-12-17 22:03:14 +00:00
this.k = rVar;
2021-11-08 18:25:28 +00:00
Inflater inflater = new Inflater(true);
2021-12-17 22:03:14 +00:00
this.l = inflater;
this.m = new m((g) rVar, inflater);
2021-11-08 18:25:28 +00:00
}
public final void a(String str, int i, int i2) {
if (i2 != i) {
String format = String.format("%s: actual 0x%08x != expected 0x%08x", Arrays.copyOf(new Object[]{str, Integer.valueOf(i2), Integer.valueOf(i)}, 3));
m.checkExpressionValueIsNotNull(format, "java.lang.String.format(this, *args)");
throw new IOException(format);
}
}
public final void b(e eVar, long j, long j2) {
2022-03-02 20:59:20 +00:00
int i;
2021-12-17 22:03:14 +00:00
s sVar = eVar.j;
2021-11-08 18:25:28 +00:00
if (sVar == null) {
m.throwNpe();
}
while (true) {
2022-03-02 20:59:20 +00:00
int i2 = sVar.c;
2022-03-30 16:43:10 +00:00
int i3 = sVar.f3675b;
2022-03-02 20:59:20 +00:00
if (j >= i2 - i3) {
j -= i2 - i3;
sVar = sVar.f;
if (sVar == null) {
m.throwNpe();
}
2021-11-08 18:25:28 +00:00
}
}
while (j2 > 0) {
2022-03-02 20:59:20 +00:00
int min = (int) Math.min(sVar.c - i, j2);
2022-03-30 16:43:10 +00:00
this.n.update(sVar.a, (int) (sVar.f3675b + j), min);
2022-03-02 20:59:20 +00:00
j2 -= min;
2021-11-08 18:25:28 +00:00
sVar = sVar.f;
if (sVar == null) {
m.throwNpe();
}
j = 0;
}
}
@Override // g0.x, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
2021-12-17 22:03:14 +00:00
this.m.close();
2021-11-08 18:25:28 +00:00
}
@Override // g0.x
public long i0(e eVar, long j) throws IOException {
long j2;
m.checkParameterIsNotNull(eVar, "sink");
boolean z2 = false;
2022-03-02 20:59:20 +00:00
int i = (j > 0L ? 1 : (j == 0L ? 0 : -1));
2021-11-08 18:25:28 +00:00
if (!(i >= 0)) {
throw new IllegalArgumentException(a.s("byteCount < 0: ", j).toString());
} else if (i == 0) {
2022-03-02 20:59:20 +00:00
return 0L;
2021-11-08 18:25:28 +00:00
} else {
2021-12-17 22:03:14 +00:00
if (this.j == 0) {
2022-03-02 20:59:20 +00:00
this.k.p0(10L);
byte q = this.k.j.q(3L);
2021-11-08 18:25:28 +00:00
boolean z3 = ((q >> 1) & 1) == 1;
if (z3) {
2022-03-02 20:59:20 +00:00
b(this.k.j, 0L, 10L);
2021-11-08 18:25:28 +00:00
}
2021-12-17 22:03:14 +00:00
a("ID1ID2", 8075, this.k.readShort());
2022-03-02 20:59:20 +00:00
this.k.skip(8L);
2021-11-08 18:25:28 +00:00
if (((q >> 2) & 1) == 1) {
2022-03-02 20:59:20 +00:00
this.k.p0(2L);
2021-11-08 18:25:28 +00:00
if (z3) {
2022-03-02 20:59:20 +00:00
b(this.k.j, 0L, 2L);
2021-11-08 18:25:28 +00:00
}
2022-03-02 20:59:20 +00:00
long y2 = this.k.j.y();
2021-12-17 22:03:14 +00:00
this.k.p0(y2);
2021-11-08 18:25:28 +00:00
if (z3) {
j2 = y2;
2022-03-02 20:59:20 +00:00
b(this.k.j, 0L, y2);
2021-11-08 18:25:28 +00:00
} else {
j2 = y2;
}
2021-12-17 22:03:14 +00:00
this.k.skip(j2);
2021-11-08 18:25:28 +00:00
}
if (((q >> 3) & 1) == 1) {
2022-03-02 20:59:20 +00:00
long a = this.k.a((byte) 0, 0L, RecyclerView.FOREVER_NS);
2021-11-08 18:25:28 +00:00
if (a != -1) {
if (z3) {
2022-03-02 20:59:20 +00:00
b(this.k.j, 0L, a + 1);
2021-11-08 18:25:28 +00:00
}
2021-12-17 22:03:14 +00:00
this.k.skip(a + 1);
2021-11-08 18:25:28 +00:00
} else {
throw new EOFException();
}
}
if (((q >> 4) & 1) == 1) {
z2 = true;
}
if (z2) {
2022-03-02 20:59:20 +00:00
long a2 = this.k.a((byte) 0, 0L, RecyclerView.FOREVER_NS);
2021-11-08 18:25:28 +00:00
if (a2 != -1) {
if (z3) {
2022-03-02 20:59:20 +00:00
b(this.k.j, 0L, a2 + 1);
2021-11-08 18:25:28 +00:00
}
2021-12-17 22:03:14 +00:00
this.k.skip(a2 + 1);
2021-11-08 18:25:28 +00:00
} else {
throw new EOFException();
}
}
if (z3) {
2021-12-17 22:03:14 +00:00
r rVar = this.k;
2022-03-02 20:59:20 +00:00
rVar.p0(2L);
a("FHCRC", rVar.j.y(), (short) this.n.getValue());
2021-12-17 22:03:14 +00:00
this.n.reset();
2021-11-08 18:25:28 +00:00
}
2022-03-02 20:59:20 +00:00
this.j = (byte) 1;
2021-11-08 18:25:28 +00:00
}
2021-12-17 22:03:14 +00:00
if (this.j == 1) {
long j3 = eVar.k;
long i02 = this.m.i0(eVar, j);
2021-11-08 18:25:28 +00:00
if (i02 != -1) {
b(eVar, j3, i02);
return i02;
}
2022-03-02 20:59:20 +00:00
this.j = (byte) 2;
2021-11-08 18:25:28 +00:00
}
2021-12-17 22:03:14 +00:00
if (this.j == 2) {
a("CRC", this.k.b(), (int) this.n.getValue());
a("ISIZE", this.k.b(), (int) this.l.getBytesWritten());
2022-03-02 20:59:20 +00:00
this.j = (byte) 3;
2021-12-17 22:03:14 +00:00
if (!this.k.w()) {
2021-11-08 18:25:28 +00:00
throw new IOException("gzip finished without exhausting source");
}
}
2022-03-02 20:59:20 +00:00
return -1L;
2021-11-08 18:25:28 +00:00
}
}
@Override // g0.x
public y timeout() {
2021-12-17 22:03:14 +00:00
return this.k.timeout();
2021-11-08 18:25:28 +00:00
}
}