alexandroid/decompiled/jadx/sources/okio/GzipSource.java
KaKi87 a47fad5135 📦 Add decompiled Alexa 2.2.730155.0 (jadx, apktool, Hermes strings)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 00:04:16 +01:00

175 lines
8.2 KiB
Java

package okio;
import androidx.compose.animation.core.ArcMode$$ExternalSyntheticOutline0;
import java.io.IOException;
import java.util.Arrays;
import java.util.zip.CRC32;
import java.util.zip.Inflater;
import kotlin.Metadata;
import kotlin.UShort;
import kotlin.jvm.internal.SourceDebugExtension;
import org.jetbrains.annotations.NotNull;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
@Metadata(d1 = {"\u0000R\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0005\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\b\n\u0002\b\u0005\n\u0002\u0010\t\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\u0018\u00002\u00020\u0001B\r\u0012\u0006\u0010\u0002\u001a\u00020\u0001¢\u0006\u0002\u0010\u0003J \u0010\r\u001a\u00020\u000e2\u0006\u0010\u000f\u001a\u00020\u00102\u0006\u0010\u0011\u001a\u00020\u00122\u0006\u0010\u0013\u001a\u00020\u0012H\u0002J\b\u0010\u0014\u001a\u00020\u000eH\u0016J\b\u0010\u0015\u001a\u00020\u000eH\u0002J\b\u0010\u0016\u001a\u00020\u000eH\u0002J\u0018\u0010\u0017\u001a\u00020\u00182\u0006\u0010\u0019\u001a\u00020\u001a2\u0006\u0010\u001b\u001a\u00020\u0018H\u0016J\b\u0010\u001c\u001a\u00020\u001dH\u0016J \u0010\u001e\u001a\u00020\u000e2\u0006\u0010\u001f\u001a\u00020\u001a2\u0006\u0010 \u001a\u00020\u00182\u0006\u0010\u001b\u001a\u00020\u0018H\u0002R\u000e\u0010\u0004\u001a\u00020\u0005X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0007X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\b\u001a\u00020\tX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\u000bX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0002\u001a\u00020\fX\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006!"}, d2 = {"Lokio/GzipSource;", "Lokio/Source;", "source", "(Lokio/Source;)V", "crc", "Ljava/util/zip/CRC32;", "inflater", "Ljava/util/zip/Inflater;", "inflaterSource", "Lokio/InflaterSource;", "section", "", "Lokio/RealBufferedSource;", "checkEqual", "", "name", "", "expected", "", "actual", "close", "consumeHeader", "consumeTrailer", "read", "", "sink", "Lokio/Buffer;", "byteCount", "timeout", "Lokio/Timeout;", "updateCrc", "buffer", "offset", "okio"}, k = 1, mv = {1, 9, 0}, xi = 48)
@SourceDebugExtension({"SMAP\nGzipSource.kt\nKotlin\n*S Kotlin\n*F\n+ 1 GzipSource.kt\nokio/GzipSource\n+ 2 fake.kt\nkotlin/jvm/internal/FakeKt\n+ 3 RealBufferedSource.kt\nokio/RealBufferedSource\n+ 4 GzipSource.kt\nokio/-GzipSourceExtensions\n+ 5 Util.kt\nokio/-SegmentedByteString\n*L\n1#1,220:1\n1#2:221\n62#3:222\n62#3:224\n62#3:226\n62#3:227\n62#3:228\n62#3:230\n62#3:232\n202#4:223\n202#4:225\n202#4:229\n202#4:231\n89#5:233\n*S KotlinDebug\n*F\n+ 1 GzipSource.kt\nokio/GzipSource\n*L\n105#1:222\n107#1:224\n119#1:226\n120#1:227\n122#1:228\n133#1:230\n144#1:232\n106#1:223\n117#1:225\n130#1:229\n141#1:231\n187#1:233\n*E\n"})
/* loaded from: classes10.dex */
public final class GzipSource implements Source {
@NotNull
private final CRC32 crc;
@NotNull
private final Inflater inflater;
@NotNull
private final InflaterSource inflaterSource;
private byte section;
@NotNull
private final RealBufferedSource source;
public GzipSource(@NotNull Source source) {
source.getClass();
RealBufferedSource realBufferedSource = new RealBufferedSource(source);
this.source = realBufferedSource;
Inflater inflater = new Inflater(true);
this.inflater = inflater;
this.inflaterSource = new InflaterSource((BufferedSource) realBufferedSource, inflater);
this.crc = new CRC32();
}
private final void checkEqual(String name, int expected, int actual) {
if (actual != expected) {
throw new IOException(String.format("%s: actual 0x%08x != expected 0x%08x", Arrays.copyOf(new Object[]{name, Integer.valueOf(actual), Integer.valueOf(expected)}, 3)));
}
}
private final void consumeHeader() throws IOException {
this.source.require(10L);
byte b = this.source.bufferField.getByte(3L);
boolean z = ((b >> 1) & 1) == 1;
if (z) {
updateCrc(this.source.bufferField, 0L, 10L);
}
checkEqual("ID1ID2", 8075, this.source.readShort());
this.source.skip(8L);
if (((b >> 2) & 1) == 1) {
this.source.require(2L);
if (z) {
updateCrc(this.source.bufferField, 0L, 2L);
}
long readShortLe = this.source.bufferField.readShortLe() & UShort.MAX_VALUE;
this.source.require(readShortLe);
if (z) {
updateCrc(this.source.bufferField, 0L, readShortLe);
}
this.source.skip(readShortLe);
}
if (((b >> 3) & 1) == 1) {
long indexOf = this.source.indexOf((byte) 0);
if (indexOf == -1) {
Buffer$$ExternalSyntheticBUOutline0.m$3();
return;
} else {
if (z) {
updateCrc(this.source.bufferField, 0L, indexOf + 1);
}
this.source.skip(indexOf + 1);
}
}
if (((b >> 4) & 1) == 1) {
long indexOf2 = this.source.indexOf((byte) 0);
if (indexOf2 == -1) {
Buffer$$ExternalSyntheticBUOutline0.m$3();
return;
} else {
if (z) {
updateCrc(this.source.bufferField, 0L, indexOf2 + 1);
}
this.source.skip(indexOf2 + 1);
}
}
if (z) {
checkEqual("FHCRC", this.source.readShortLe(), (short) this.crc.getValue());
this.crc.reset();
}
}
private final void consumeTrailer() throws IOException {
checkEqual("CRC", this.source.readIntLe(), (int) this.crc.getValue());
checkEqual("ISIZE", this.source.readIntLe(), (int) this.inflater.getBytesWritten());
}
private final void updateCrc(Buffer buffer, long offset, long byteCount) {
Segment segment = buffer.head;
segment.getClass();
while (true) {
int i = segment.limit;
int i2 = segment.pos;
if (offset < i - i2) {
break;
}
offset -= i - i2;
segment = segment.next;
segment.getClass();
}
while (byteCount > 0) {
int min = (int) Math.min(segment.limit - r6, byteCount);
this.crc.update(segment.data, (int) (segment.pos + offset), min);
byteCount -= min;
segment = segment.next;
segment.getClass();
offset = 0;
}
}
@Override // okio.Source, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
this.inflaterSource.close();
}
@Override // okio.Source
public long read(@NotNull Buffer sink, long byteCount) throws IOException {
GzipSource gzipSource;
sink.getClass();
if (byteCount < 0) {
Path$$ExternalSyntheticBUOutline0.m((Object) ArcMode$$ExternalSyntheticOutline0.m(byteCount, "byteCount < 0: "));
return 0L;
}
if (byteCount == 0) {
return 0L;
}
if (this.section == 0) {
consumeHeader();
this.section = (byte) 1;
}
if (this.section == 1) {
long size = sink.size();
long read = this.inflaterSource.read(sink, byteCount);
if (read != -1) {
updateCrc(sink, size, read);
return read;
}
gzipSource = this;
gzipSource.section = (byte) 2;
} else {
gzipSource = this;
}
if (gzipSource.section == 2) {
gzipSource.consumeTrailer();
gzipSource.section = (byte) 3;
if (!gzipSource.source.exhausted()) {
Buffer$$ExternalSyntheticBUOutline0.m$2("gzip finished without exhausting source");
return 0L;
}
}
return -1L;
}
@Override // okio.Source
@NotNull
public Timeout timeout() {
return this.source.timeout();
}
}