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 */
|
|
|
|
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) {
|
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) {
|
2021-12-21 23:37:30 +00:00
|
|
|
int i = sVar.c;
|
2022-02-14 21:43:51 +00:00
|
|
|
int i2 = sVar.f3671b;
|
2021-11-08 18:25:28 +00:00
|
|
|
if (j < ((long) (i - i2))) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
j -= (long) (i - i2);
|
|
|
|
sVar = sVar.f;
|
|
|
|
if (sVar == null) {
|
|
|
|
m.throwNpe();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (j2 > 0) {
|
2022-02-14 21:43:51 +00:00
|
|
|
int i3 = (int) (((long) sVar.f3671b) + j);
|
2021-12-21 23:37:30 +00:00
|
|
|
int min = (int) Math.min((long) (sVar.c - i3), j2);
|
2021-12-17 22:03:14 +00:00
|
|
|
this.n.update(sVar.a, i3, min);
|
2021-11-08 18:25:28 +00:00
|
|
|
j2 -= (long) min;
|
|
|
|
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;
|
|
|
|
int i = (j > 0 ? 1 : (j == 0 ? 0 : -1));
|
|
|
|
if (!(i >= 0)) {
|
|
|
|
throw new IllegalArgumentException(a.s("byteCount < 0: ", j).toString());
|
|
|
|
} else if (i == 0) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
2021-12-17 22:03:14 +00:00
|
|
|
if (this.j == 0) {
|
|
|
|
this.k.p0(10);
|
|
|
|
byte q = this.k.j.q(3);
|
2021-11-08 18:25:28 +00:00
|
|
|
boolean z3 = ((q >> 1) & 1) == 1;
|
|
|
|
if (z3) {
|
2021-12-17 22:03:14 +00:00
|
|
|
b(this.k.j, 0, 10);
|
2021-11-08 18:25:28 +00:00
|
|
|
}
|
2021-12-17 22:03:14 +00:00
|
|
|
a("ID1ID2", 8075, this.k.readShort());
|
|
|
|
this.k.skip(8);
|
2021-11-08 18:25:28 +00:00
|
|
|
if (((q >> 2) & 1) == 1) {
|
2021-12-17 22:03:14 +00:00
|
|
|
this.k.p0(2);
|
2021-11-08 18:25:28 +00:00
|
|
|
if (z3) {
|
2021-12-17 22:03:14 +00:00
|
|
|
b(this.k.j, 0, 2);
|
2021-11-08 18:25:28 +00:00
|
|
|
}
|
2021-12-17 22:03:14 +00:00
|
|
|
long y2 = (long) this.k.j.y();
|
|
|
|
this.k.p0(y2);
|
2021-11-08 18:25:28 +00:00
|
|
|
if (z3) {
|
|
|
|
j2 = y2;
|
2021-12-17 22:03:14 +00:00
|
|
|
b(this.k.j, 0, 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) {
|
2021-12-17 22:03:14 +00:00
|
|
|
long a = this.k.a((byte) 0, 0, RecyclerView.FOREVER_NS);
|
2021-11-08 18:25:28 +00:00
|
|
|
if (a != -1) {
|
|
|
|
if (z3) {
|
2021-12-17 22:03:14 +00:00
|
|
|
b(this.k.j, 0, 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) {
|
2021-12-17 22:03:14 +00:00
|
|
|
long a2 = this.k.a((byte) 0, 0, RecyclerView.FOREVER_NS);
|
2021-11-08 18:25:28 +00:00
|
|
|
if (a2 != -1) {
|
|
|
|
if (z3) {
|
2021-12-17 22:03:14 +00:00
|
|
|
b(this.k.j, 0, 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;
|
2021-11-08 18:25:28 +00:00
|
|
|
rVar.p0(2);
|
2021-12-17 22:03:14 +00:00
|
|
|
a("FHCRC", rVar.j.y(), (short) ((int) this.n.getValue()));
|
|
|
|
this.n.reset();
|
2021-11-08 18:25:28 +00:00
|
|
|
}
|
2021-12-17 22:03:14 +00:00
|
|
|
this.j = 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;
|
|
|
|
}
|
2021-12-17 22:03:14 +00:00
|
|
|
this.j = 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());
|
|
|
|
this.j = 3;
|
|
|
|
if (!this.k.w()) {
|
2021-11-08 18:25:28 +00:00
|
|
|
throw new IOException("gzip finished without exhausting source");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@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
|
|
|
}
|
|
|
|
}
|