alexandroid/decompiled/jadx/sources/okio/DeflaterSink.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

146 lines
6.3 KiB
Java

package okio;
import com.amazon.alexa.presence.service.PresenceJobService;
import java.io.IOException;
import java.util.zip.Deflater;
import kotlin.Metadata;
import kotlin.jvm.internal.SourceDebugExtension;
import org.jetbrains.annotations.NotNull;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
@Metadata(d1 = {"\u0000B\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\t\n\u0000\u0018\u00002\u00020\u0001B\u0017\b\u0016\u0012\u0006\u0010\u0002\u001a\u00020\u0001\u0012\u0006\u0010\u0003\u001a\u00020\u0004¢\u0006\u0002\u0010\u0005B\u0017\b\u0000\u0012\u0006\u0010\u0002\u001a\u00020\u0006\u0012\u0006\u0010\u0003\u001a\u00020\u0004¢\u0006\u0002\u0010\u0007J\b\u0010\n\u001a\u00020\u000bH\u0016J\u0010\u0010\f\u001a\u00020\u000b2\u0006\u0010\r\u001a\u00020\tH\u0002J\r\u0010\u000e\u001a\u00020\u000bH\u0000¢\u0006\u0002\b\u000fJ\b\u0010\u0010\u001a\u00020\u000bH\u0016J\b\u0010\u0011\u001a\u00020\u0012H\u0016J\b\u0010\u0013\u001a\u00020\u0014H\u0016J\u0018\u0010\u0015\u001a\u00020\u000b2\u0006\u0010\u0016\u001a\u00020\u00172\u0006\u0010\u0018\u001a\u00020\u0019H\u0016R\u000e\u0010\b\u001a\u00020\tX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0003\u001a\u00020\u0004X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0002\u001a\u00020\u0006X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\u001a"}, d2 = {"Lokio/DeflaterSink;", "Lokio/Sink;", "sink", "deflater", "Ljava/util/zip/Deflater;", "(Lokio/Sink;Ljava/util/zip/Deflater;)V", "Lokio/BufferedSink;", "(Lokio/BufferedSink;Ljava/util/zip/Deflater;)V", "closed", "", "close", "", "deflate", "syncFlush", "finishDeflate", "finishDeflate$okio", PresenceJobService.ACTION_REFRESH_FLUSH_KEY, "timeout", "Lokio/Timeout;", "toString", "", "write", "source", "Lokio/Buffer;", "byteCount", "", "okio"}, k = 1, mv = {1, 9, 0}, xi = 48)
@SourceDebugExtension({"SMAP\nDeflaterSink.kt\nKotlin\n*S Kotlin\n*F\n+ 1 DeflaterSink.kt\nokio/DeflaterSink\n+ 2 Util.kt\nokio/-SegmentedByteString\n*L\n1#1,163:1\n86#2:164\n*S KotlinDebug\n*F\n+ 1 DeflaterSink.kt\nokio/DeflaterSink\n*L\n58#1:164\n*E\n"})
/* loaded from: classes10.dex */
public final class DeflaterSink implements Sink {
private boolean closed;
@NotNull
private final Deflater deflater;
@NotNull
private final BufferedSink sink;
public DeflaterSink(@NotNull BufferedSink bufferedSink, @NotNull Deflater deflater) {
bufferedSink.getClass();
deflater.getClass();
this.sink = bufferedSink;
this.deflater = deflater;
}
private final void deflate(boolean syncFlush) {
Segment writableSegment$okio;
int deflate;
Buffer buffer = this.sink.getBuffer();
while (true) {
writableSegment$okio = buffer.writableSegment$okio(1);
Deflater deflater = this.deflater;
if (syncFlush) {
try {
byte[] bArr = writableSegment$okio.data;
int i = writableSegment$okio.limit;
deflate = deflater.deflate(bArr, i, 8192 - i, 2);
} catch (NullPointerException e) {
Buffer$$ExternalSyntheticBUOutline0.m("Deflater already closed", e);
return;
}
} else {
byte[] bArr2 = writableSegment$okio.data;
int i2 = writableSegment$okio.limit;
deflate = deflater.deflate(bArr2, i2, 8192 - i2);
}
if (deflate > 0) {
writableSegment$okio.limit += deflate;
buffer.setSize$okio(buffer.size() + deflate);
this.sink.emitCompleteSegments();
} else if (this.deflater.needsInput()) {
break;
}
}
if (writableSegment$okio.pos == writableSegment$okio.limit) {
buffer.head = writableSegment$okio.pop();
SegmentPool.recycle(writableSegment$okio);
}
}
@Override // okio.Sink, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
if (this.closed) {
return;
}
try {
finishDeflate$okio();
th = null;
} catch (Throwable th) {
th = th;
}
try {
this.deflater.end();
} catch (Throwable th2) {
if (th == null) {
th = th2;
}
}
try {
this.sink.close();
} catch (Throwable th3) {
if (th == null) {
th = th3;
}
}
this.closed = true;
if (th != null) {
throw th;
}
}
public final void finishDeflate$okio() {
this.deflater.finish();
deflate(false);
}
@Override // okio.Sink, java.io.Flushable
public void flush() throws IOException {
deflate(true);
this.sink.flush();
}
@Override // okio.Sink
@NotNull
public Timeout timeout() {
return this.sink.timeout();
}
@NotNull
public String toString() {
return "DeflaterSink(" + this.sink + ')';
}
@Override // okio.Sink
public void write(@NotNull Buffer source, long byteCount) throws IOException {
source.getClass();
SegmentedByteString.checkOffsetAndCount(source.size(), 0L, byteCount);
while (byteCount > 0) {
Segment segment = source.head;
segment.getClass();
int min = (int) Math.min(byteCount, segment.limit - segment.pos);
this.deflater.setInput(segment.data, segment.pos, min);
deflate(false);
long j = min;
source.setSize$okio(source.size() - j);
int i = segment.pos + min;
segment.pos = i;
if (i == segment.limit) {
source.head = segment.pop();
SegmentPool.recycle(segment);
}
byteCount -= j;
}
}
/* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
public DeflaterSink(@NotNull Sink sink, @NotNull Deflater deflater) {
this(Okio.buffer(sink), deflater);
sink.getClass();
deflater.getClass();
}
}