InflaterSource.smali
.class public final Lokio/InflaterSource;
.super Ljava/lang/Object;
.source "InflaterSource.java"
# interfaces
.implements Lokio/Source;
# instance fields
.field private bufferBytesHeldByInflater:I
.field private closed:Z
.field private final inflater:Ljava/util/zip/Inflater;
.field private final source:Lokio/BufferedSource;
# direct methods
.method constructor <init>(Lokio/BufferedSource;Ljava/util/zip/Inflater;)V
.registers 3
.line 48
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
if-eqz p1, :cond_14
if-eqz p2, :cond_c
.line 51
iput-object p1, p0, Lokio/InflaterSource;->source:Lokio/BufferedSource;
.line 52
iput-object p2, p0, Lokio/InflaterSource;->inflater:Ljava/util/zip/Inflater;
return-void
.line 50
:cond_c
new-instance p1, Ljava/lang/IllegalArgumentException;
const-string p2, "inflater == null"
invoke-direct {p1, p2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
throw p1
.line 49
:cond_14
new-instance p1, Ljava/lang/IllegalArgumentException;
const-string p2, "source == null"
invoke-direct {p1, p2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
throw p1
.end method
.method public constructor <init>(Lokio/Source;Ljava/util/zip/Inflater;)V
.registers 3
.line 40
invoke-static {p1}, Lokio/Okio;->buffer(Lokio/Source;)Lokio/BufferedSource;
move-result-object p1
invoke-direct {p0, p1, p2}, Lokio/InflaterSource;-><init>(Lokio/BufferedSource;Ljava/util/zip/Inflater;)V
return-void
.end method
.method private releaseInflatedBytes()V
.registers 5
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 113
iget v0, p0, Lokio/InflaterSource;->bufferBytesHeldByInflater:I
if-nez v0, :cond_5
return-void
.line 114
:cond_5
iget-object v1, p0, Lokio/InflaterSource;->inflater:Ljava/util/zip/Inflater;
invoke-virtual {v1}, Ljava/util/zip/Inflater;->getRemaining()I
move-result v1
sub-int/2addr v0, v1
.line 115
iget v1, p0, Lokio/InflaterSource;->bufferBytesHeldByInflater:I
sub-int/2addr v1, v0
iput v1, p0, Lokio/InflaterSource;->bufferBytesHeldByInflater:I
.line 116
iget-object v1, p0, Lokio/InflaterSource;->source:Lokio/BufferedSource;
int-to-long v2, v0
invoke-interface {v1, v2, v3}, Lokio/BufferedSource;->skip(J)V
return-void
.end method
# virtual methods
.method public close()V
.registers 2
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 124
iget-boolean v0, p0, Lokio/InflaterSource;->closed:Z
if-eqz v0, :cond_5
return-void
.line 125
:cond_5
iget-object v0, p0, Lokio/InflaterSource;->inflater:Ljava/util/zip/Inflater;
invoke-virtual {v0}, Ljava/util/zip/Inflater;->end()V
const/4 v0, 0x1
.line 126
iput-boolean v0, p0, Lokio/InflaterSource;->closed:Z
.line 127
iget-object v0, p0, Lokio/InflaterSource;->source:Lokio/BufferedSource;
invoke-interface {v0}, Lokio/BufferedSource;->close()V
return-void
.end method
.method public read(Lokio/Buffer;J)J
.registers 10
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
const-wide/16 v0, 0x0
cmp-long v2, p2, v0
if-ltz v2, :cond_78
.line 58
iget-boolean v3, p0, Lokio/InflaterSource;->closed:Z
if-nez v3, :cond_70
if-nez v2, :cond_d
return-wide v0
.line 62
:cond_d
:goto_d
invoke-virtual {p0}, Lokio/InflaterSource;->refill()Z
move-result v0
const/4 v1, 0x1
.line 66
:try_start_12
invoke-virtual {p1, v1}, Lokio/Buffer;->writableSegment(I)Lokio/Segment;
move-result-object v1
.line 67
iget v2, v1, Lokio/Segment;->limit:I
rsub-int v2, v2, 0x2000
int-to-long v2, v2
invoke-static {p2, p3, v2, v3}, Ljava/lang/Math;->min(JJ)J
move-result-wide v2
long-to-int v2, v2
.line 68
iget-object v3, p0, Lokio/InflaterSource;->inflater:Ljava/util/zip/Inflater;
iget-object v4, v1, Lokio/Segment;->data:[B
iget v5, v1, Lokio/Segment;->limit:I
invoke-virtual {v3, v4, v5, v2}, Ljava/util/zip/Inflater;->inflate([BII)I
move-result v2
if-lez v2, :cond_38
.line 70
iget p2, v1, Lokio/Segment;->limit:I
add-int/2addr p2, v2
iput p2, v1, Lokio/Segment;->limit:I
.line 71
iget-wide p2, p1, Lokio/Buffer;->size:J
int-to-long v0, v2
add-long/2addr p2, v0
iput-wide p2, p1, Lokio/Buffer;->size:J
return-wide v0
.line 74
:cond_38
iget-object v2, p0, Lokio/InflaterSource;->inflater:Ljava/util/zip/Inflater;
invoke-virtual {v2}, Ljava/util/zip/Inflater;->finished()Z
move-result v2
if-nez v2, :cond_54
iget-object v2, p0, Lokio/InflaterSource;->inflater:Ljava/util/zip/Inflater;
invoke-virtual {v2}, Ljava/util/zip/Inflater;->needsDictionary()Z
move-result v2
if-eqz v2, :cond_49
goto :goto_54
:cond_49
if-nez v0, :cond_4c
goto :goto_d
.line 83
:cond_4c
new-instance p1, Ljava/io/EOFException;
const-string p2, "source exhausted prematurely"
invoke-direct {p1, p2}, Ljava/io/EOFException;-><init>(Ljava/lang/String;)V
throw p1
.line 75
:cond_54
:goto_54
invoke-direct {p0}, Lokio/InflaterSource;->releaseInflatedBytes()V
.line 76
iget p2, v1, Lokio/Segment;->pos:I
iget p3, v1, Lokio/Segment;->limit:I
if-ne p2, p3, :cond_66
.line 78
invoke-virtual {v1}, Lokio/Segment;->pop()Lokio/Segment;
move-result-object p2
iput-object p2, p1, Lokio/Buffer;->head:Lokio/Segment;
.line 79
invoke-static {v1}, Lokio/SegmentPool;->recycle(Lokio/Segment;)V
:try_end_66
.catch Ljava/util/zip/DataFormatException; {:try_start_12 .. :try_end_66} :catch_69
:cond_66
const-wide/16 p1, -0x1
return-wide p1
:catch_69
move-exception p1
.line 85
new-instance p2, Ljava/io/IOException;
invoke-direct {p2, p1}, Ljava/io/IOException;-><init>(Ljava/lang/Throwable;)V
throw p2
.line 58
:cond_70
new-instance p1, Ljava/lang/IllegalStateException;
const-string p2, "closed"
invoke-direct {p1, p2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw p1
.line 57
:cond_78
new-instance p1, Ljava/lang/IllegalArgumentException;
new-instance v0, Ljava/lang/StringBuilder;
invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
const-string v1, "byteCount < 0: "
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v0
invoke-virtual {v0, p2, p3}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;
move-result-object p2
invoke-virtual {p2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p2
invoke-direct {p1, p2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
throw p1
.end method
.method public refill()Z
.registers 6
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 96
iget-object v0, p0, Lokio/InflaterSource;->inflater:Ljava/util/zip/Inflater;
invoke-virtual {v0}, Ljava/util/zip/Inflater;->needsInput()Z
move-result v0
const/4 v1, 0x0
if-nez v0, :cond_a
return v1
.line 98
:cond_a
invoke-direct {p0}, Lokio/InflaterSource;->releaseInflatedBytes()V
.line 99
iget-object v0, p0, Lokio/InflaterSource;->inflater:Ljava/util/zip/Inflater;
invoke-virtual {v0}, Ljava/util/zip/Inflater;->getRemaining()I
move-result v0
if-nez v0, :cond_3a
.line 102
iget-object v0, p0, Lokio/InflaterSource;->source:Lokio/BufferedSource;
invoke-interface {v0}, Lokio/BufferedSource;->exhausted()Z
move-result v0
if-eqz v0, :cond_1f
const/4 v0, 0x1
return v0
.line 105
:cond_1f
iget-object v0, p0, Lokio/InflaterSource;->source:Lokio/BufferedSource;
invoke-interface {v0}, Lokio/BufferedSource;->buffer()Lokio/Buffer;
move-result-object v0
iget-object v0, v0, Lokio/Buffer;->head:Lokio/Segment;
.line 106
iget v2, v0, Lokio/Segment;->limit:I
iget v3, v0, Lokio/Segment;->pos:I
sub-int/2addr v2, v3
iput v2, p0, Lokio/InflaterSource;->bufferBytesHeldByInflater:I
.line 107
iget-object v2, p0, Lokio/InflaterSource;->inflater:Ljava/util/zip/Inflater;
iget-object v3, v0, Lokio/Segment;->data:[B
iget v0, v0, Lokio/Segment;->pos:I
iget v4, p0, Lokio/InflaterSource;->bufferBytesHeldByInflater:I
invoke-virtual {v2, v3, v0, v4}, Ljava/util/zip/Inflater;->setInput([BII)V
return v1
.line 99
:cond_3a
new-instance v0, Ljava/lang/IllegalStateException;
const-string v1, "?"
invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw v0
.end method
.method public timeout()Lokio/Timeout;
.registers 2
.line 120
iget-object v0, p0, Lokio/InflaterSource;->source:Lokio/BufferedSource;
invoke-interface {v0}, Lokio/BufferedSource;->timeout()Lokio/Timeout;
move-result-object v0
return-object v0
.end method