GzipSource.smali
.class public final Lokio/GzipSource;
.super Ljava/lang/Object;
.source "GzipSource.java"
# interfaces
.implements Lokio/Source;
# static fields
.field private static final FCOMMENT:B = 0x4t
.field private static final FEXTRA:B = 0x2t
.field private static final FHCRC:B = 0x1t
.field private static final FNAME:B = 0x3t
.field private static final SECTION_BODY:B = 0x1t
.field private static final SECTION_DONE:B = 0x3t
.field private static final SECTION_HEADER:B = 0x0t
.field private static final SECTION_TRAILER:B = 0x2t
# instance fields
.field private final crc:Ljava/util/zip/CRC32;
.field private final inflater:Ljava/util/zip/Inflater;
.field private final inflaterSource:Lokio/InflaterSource;
.field private section:I
.field private final source:Lokio/BufferedSource;
# direct methods
.method static constructor <clinit>()V
.registers 1
return-void
.end method
.method public constructor <init>(Lokio/Source;)V
.registers 5
.param p1, "source" # Lokio/Source;
.line 60
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
.line 39
const/4 v0, 0x0
iput v0, p0, Lokio/GzipSource;->section:I
.line 58
new-instance v0, Ljava/util/zip/CRC32;
invoke-direct {v0}, Ljava/util/zip/CRC32;-><init>()V
iput-object v0, p0, Lokio/GzipSource;->crc:Ljava/util/zip/CRC32;
.line 61
if-eqz p1, :cond_27
.line 62
new-instance v0, Ljava/util/zip/Inflater;
const/4 v1, 0x1
invoke-direct {v0, v1}, Ljava/util/zip/Inflater;-><init>(Z)V
iput-object v0, p0, Lokio/GzipSource;->inflater:Ljava/util/zip/Inflater;
.line 63
invoke-static {p1}, Lokio/Okio;->buffer(Lokio/Source;)Lokio/BufferedSource;
move-result-object v0
iput-object v0, p0, Lokio/GzipSource;->source:Lokio/BufferedSource;
.line 64
new-instance v1, Lokio/InflaterSource;
iget-object v2, p0, Lokio/GzipSource;->inflater:Ljava/util/zip/Inflater;
invoke-direct {v1, v0, v2}, Lokio/InflaterSource;-><init>(Lokio/BufferedSource;Ljava/util/zip/Inflater;)V
iput-object v1, p0, Lokio/GzipSource;->inflaterSource:Lokio/InflaterSource;
.line 65
return-void
.line 61
:cond_27
new-instance v0, Ljava/lang/IllegalArgumentException;
const-string v1, "source == null"
invoke-direct {v0, v1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
throw v0
.end method
.method private checkEqual(Ljava/lang/String;II)V
.registers 8
.param p1, "name" # Ljava/lang/String;
.param p2, "expected" # I
.param p3, "actual" # I
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 204
if-ne p3, p2, :cond_3
.line 208
return-void
.line 205
:cond_3
new-instance v0, Ljava/io/IOException;
const/4 v1, 0x3
new-array v1, v1, [Ljava/lang/Object;
const/4 v2, 0x0
aput-object p1, v1, v2
const/4 v2, 0x1
.line 206
invoke-static {p3}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v3
aput-object v3, v1, v2
const/4 v2, 0x2
invoke-static {p2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v3
aput-object v3, v1, v2
.line 205
const-string v2, "%s: actual 0x%08x != expected 0x%08x"
invoke-static {v2, v1}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object v1
invoke-direct {v0, v1}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V
throw v0
.end method
.method private consumeHeader()V
.registers 19
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 114
move-object/from16 v6, p0
iget-object v0, v6, Lokio/GzipSource;->source:Lokio/BufferedSource;
const-wide/16 v1, 0xa
invoke-interface {v0, v1, v2}, Lokio/BufferedSource;->require(J)V
.line 115
iget-object v0, v6, Lokio/GzipSource;->source:Lokio/BufferedSource;
invoke-interface {v0}, Lokio/BufferedSource;->buffer()Lokio/Buffer;
move-result-object v0
const-wide/16 v1, 0x3
invoke-virtual {v0, v1, v2}, Lokio/Buffer;->getByte(J)B
move-result v7
.line 116
.local v7, "flags":B
shr-int/lit8 v0, v7, 0x1
const/4 v8, 0x1
and-int/2addr v0, v8
const/4 v9, 0x0
if-ne v0, v8, :cond_1e
const/4 v0, 0x1
goto :goto_1f
:cond_1e
const/4 v0, 0x0
:goto_1f
move v10, v0
.line 117
.local v10, "fhcrc":Z
if-eqz v10, :cond_31
iget-object v0, v6, Lokio/GzipSource;->source:Lokio/BufferedSource;
invoke-interface {v0}, Lokio/BufferedSource;->buffer()Lokio/Buffer;
move-result-object v1
const-wide/16 v2, 0x0
const-wide/16 v4, 0xa
move-object/from16 v0, p0
invoke-direct/range {v0 .. v5}, Lokio/GzipSource;->updateCrc(Lokio/Buffer;JJ)V
.line 119
:cond_31
iget-object v0, v6, Lokio/GzipSource;->source:Lokio/BufferedSource;
invoke-interface {v0}, Lokio/BufferedSource;->readShort()S
move-result v11
.line 120
.local v11, "id1id2":S
const/16 v0, 0x1f8b
const-string v1, "ID1ID2"
invoke-direct {v6, v1, v0, v11}, Lokio/GzipSource;->checkEqual(Ljava/lang/String;II)V
.line 121
iget-object v0, v6, Lokio/GzipSource;->source:Lokio/BufferedSource;
const-wide/16 v1, 0x8
invoke-interface {v0, v1, v2}, Lokio/BufferedSource;->skip(J)V
.line 127
shr-int/lit8 v0, v7, 0x2
and-int/2addr v0, v8
if-ne v0, v8, :cond_88
.line 128
iget-object v0, v6, Lokio/GzipSource;->source:Lokio/BufferedSource;
const-wide/16 v1, 0x2
invoke-interface {v0, v1, v2}, Lokio/BufferedSource;->require(J)V
.line 129
if-eqz v10, :cond_62
iget-object v0, v6, Lokio/GzipSource;->source:Lokio/BufferedSource;
invoke-interface {v0}, Lokio/BufferedSource;->buffer()Lokio/Buffer;
move-result-object v1
const-wide/16 v2, 0x0
const-wide/16 v4, 0x2
move-object/from16 v0, p0
invoke-direct/range {v0 .. v5}, Lokio/GzipSource;->updateCrc(Lokio/Buffer;JJ)V
.line 130
:cond_62
iget-object v0, v6, Lokio/GzipSource;->source:Lokio/BufferedSource;
invoke-interface {v0}, Lokio/BufferedSource;->buffer()Lokio/Buffer;
move-result-object v0
invoke-virtual {v0}, Lokio/Buffer;->readShortLe()S
move-result v12
.line 131
.local v12, "xlen":I
iget-object v0, v6, Lokio/GzipSource;->source:Lokio/BufferedSource;
int-to-long v1, v12
invoke-interface {v0, v1, v2}, Lokio/BufferedSource;->require(J)V
.line 132
if-eqz v10, :cond_82
iget-object v0, v6, Lokio/GzipSource;->source:Lokio/BufferedSource;
invoke-interface {v0}, Lokio/BufferedSource;->buffer()Lokio/Buffer;
move-result-object v1
const-wide/16 v2, 0x0
int-to-long v4, v12
move-object/from16 v0, p0
invoke-direct/range {v0 .. v5}, Lokio/GzipSource;->updateCrc(Lokio/Buffer;JJ)V
.line 133
:cond_82
iget-object v0, v6, Lokio/GzipSource;->source:Lokio/BufferedSource;
int-to-long v1, v12
invoke-interface {v0, v1, v2}, Lokio/BufferedSource;->skip(J)V
.line 140
.end local v12 # "xlen":I
:cond_88
shr-int/lit8 v0, v7, 0x3
and-int/2addr v0, v8
const-wide/16 v12, -0x1
const-wide/16 v14, 0x1
if-ne v0, v8, :cond_ba
.line 141
iget-object v0, v6, Lokio/GzipSource;->source:Lokio/BufferedSource;
invoke-interface {v0, v9}, Lokio/BufferedSource;->indexOf(B)J
move-result-wide v16
.line 142
.local v16, "index":J
cmp-long v0, v16, v12
if-eqz v0, :cond_b4
.line 143
if-eqz v10, :cond_ac
iget-object v0, v6, Lokio/GzipSource;->source:Lokio/BufferedSource;
invoke-interface {v0}, Lokio/BufferedSource;->buffer()Lokio/Buffer;
move-result-object v1
const-wide/16 v2, 0x0
add-long v4, v16, v14
move-object/from16 v0, p0
invoke-direct/range {v0 .. v5}, Lokio/GzipSource;->updateCrc(Lokio/Buffer;JJ)V
.line 144
:cond_ac
iget-object v0, v6, Lokio/GzipSource;->source:Lokio/BufferedSource;
add-long v1, v16, v14
invoke-interface {v0, v1, v2}, Lokio/BufferedSource;->skip(J)V
goto :goto_ba
.line 142
:cond_b4
new-instance v0, Ljava/io/EOFException;
invoke-direct {v0}, Ljava/io/EOFException;-><init>()V
throw v0
.line 151
.end local v16 # "index":J
:cond_ba
:goto_ba
shr-int/lit8 v0, v7, 0x4
and-int/2addr v0, v8
if-ne v0, v8, :cond_e7
.line 152
iget-object v0, v6, Lokio/GzipSource;->source:Lokio/BufferedSource;
invoke-interface {v0, v9}, Lokio/BufferedSource;->indexOf(B)J
move-result-wide v8
.line 153
.local v8, "index":J
cmp-long v0, v8, v12
if-eqz v0, :cond_e1
.line 154
if-eqz v10, :cond_da
iget-object v0, v6, Lokio/GzipSource;->source:Lokio/BufferedSource;
invoke-interface {v0}, Lokio/BufferedSource;->buffer()Lokio/Buffer;
move-result-object v1
const-wide/16 v2, 0x0
add-long v4, v8, v14
move-object/from16 v0, p0
invoke-direct/range {v0 .. v5}, Lokio/GzipSource;->updateCrc(Lokio/Buffer;JJ)V
.line 155
:cond_da
iget-object v0, v6, Lokio/GzipSource;->source:Lokio/BufferedSource;
add-long/2addr v14, v8
invoke-interface {v0, v14, v15}, Lokio/BufferedSource;->skip(J)V
goto :goto_e7
.line 153
:cond_e1
new-instance v0, Ljava/io/EOFException;
invoke-direct {v0}, Ljava/io/EOFException;-><init>()V
throw v0
.line 162
.end local v8 # "index":J
:cond_e7
:goto_e7
if-eqz v10, :cond_101
.line 163
iget-object v0, v6, Lokio/GzipSource;->source:Lokio/BufferedSource;
invoke-interface {v0}, Lokio/BufferedSource;->readShortLe()S
move-result v0
iget-object v1, v6, Lokio/GzipSource;->crc:Ljava/util/zip/CRC32;
invoke-virtual {v1}, Ljava/util/zip/CRC32;->getValue()J
move-result-wide v1
long-to-int v2, v1
int-to-short v1, v2
const-string v2, "FHCRC"
invoke-direct {v6, v2, v0, v1}, Lokio/GzipSource;->checkEqual(Ljava/lang/String;II)V
.line 164
iget-object v0, v6, Lokio/GzipSource;->crc:Ljava/util/zip/CRC32;
invoke-virtual {v0}, Ljava/util/zip/CRC32;->reset()V
.line 166
:cond_101
return-void
.end method
.method private consumeTrailer()V
.registers 4
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 173
iget-object v0, p0, Lokio/GzipSource;->source:Lokio/BufferedSource;
invoke-interface {v0}, Lokio/BufferedSource;->readIntLe()I
move-result v0
iget-object v1, p0, Lokio/GzipSource;->crc:Ljava/util/zip/CRC32;
invoke-virtual {v1}, Ljava/util/zip/CRC32;->getValue()J
move-result-wide v1
long-to-int v2, v1
const-string v1, "CRC"
invoke-direct {p0, v1, v0, v2}, Lokio/GzipSource;->checkEqual(Ljava/lang/String;II)V
.line 174
iget-object v0, p0, Lokio/GzipSource;->source:Lokio/BufferedSource;
invoke-interface {v0}, Lokio/BufferedSource;->readIntLe()I
move-result v0
iget-object v1, p0, Lokio/GzipSource;->inflater:Ljava/util/zip/Inflater;
invoke-virtual {v1}, Ljava/util/zip/Inflater;->getBytesWritten()J
move-result-wide v1
long-to-int v2, v1
const-string v1, "ISIZE"
invoke-direct {p0, v1, v0, v2}, Lokio/GzipSource;->checkEqual(Ljava/lang/String;II)V
.line 175
return-void
.end method
.method private updateCrc(Lokio/Buffer;JJ)V
.registers 11
.param p1, "buffer" # Lokio/Buffer;
.param p2, "offset" # J
.param p4, "byteCount" # J
.line 188
iget-object v0, p1, Lokio/Buffer;->head:Lokio/Segment;
.line 189
.local v0, "s":Lokio/Segment;
:goto_2
iget v1, v0, Lokio/Segment;->limit:I
iget v2, v0, Lokio/Segment;->pos:I
sub-int/2addr v1, v2
int-to-long v1, v1
cmp-long v3, p2, v1
if-ltz v3, :cond_16
.line 190
iget v1, v0, Lokio/Segment;->limit:I
iget v2, v0, Lokio/Segment;->pos:I
sub-int/2addr v1, v2
int-to-long v1, v1
sub-long/2addr p2, v1
.line 189
iget-object v0, v0, Lokio/Segment;->next:Lokio/Segment;
goto :goto_2
.line 194
:cond_16
:goto_16
const-wide/16 v1, 0x0
cmp-long v3, p4, v1
if-lez v3, :cond_38
.line 195
iget v1, v0, Lokio/Segment;->pos:I
int-to-long v1, v1
add-long/2addr v1, p2
long-to-int v2, v1
.line 196
.local v2, "pos":I
iget v1, v0, Lokio/Segment;->limit:I
sub-int/2addr v1, v2
int-to-long v3, v1
invoke-static {v3, v4, p4, p5}, Ljava/lang/Math;->min(JJ)J
move-result-wide v3
long-to-int v1, v3
.line 197
.local v1, "toUpdate":I
iget-object v3, p0, Lokio/GzipSource;->crc:Ljava/util/zip/CRC32;
iget-object v4, v0, Lokio/Segment;->data:[B
invoke-virtual {v3, v4, v2, v1}, Ljava/util/zip/CRC32;->update([BII)V
.line 198
int-to-long v3, v1
sub-long/2addr p4, v3
.line 199
const-wide/16 p2, 0x0
.line 194
.end local v1 # "toUpdate":I
.end local v2 # "pos":I
iget-object v0, v0, Lokio/Segment;->next:Lokio/Segment;
goto :goto_16
.line 201
:cond_38
return-void
.end method
# virtual methods
.method public close()V
.registers 2
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 182
iget-object v0, p0, Lokio/GzipSource;->inflaterSource:Lokio/InflaterSource;
invoke-virtual {v0}, Lokio/InflaterSource;->close()V
.line 183
return-void
.end method
.method public read(Lokio/Buffer;J)J
.registers 18
.param p1, "sink" # Lokio/Buffer;
.param p2, "byteCount" # J
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 68
move-object v6, p0
move-object v7, p1
move-wide/from16 v8, p2
const-wide/16 v0, 0x0
cmp-long v2, v8, v0
if-ltz v2, :cond_52
.line 69
cmp-long v2, v8, v0
if-nez v2, :cond_f
return-wide v0
.line 72
:cond_f
iget v0, v6, Lokio/GzipSource;->section:I
const/4 v1, 0x1
if-nez v0, :cond_19
.line 73
invoke-direct {p0}, Lokio/GzipSource;->consumeHeader()V
.line 74
iput v1, v6, Lokio/GzipSource;->section:I
.line 78
:cond_19
iget v0, v6, Lokio/GzipSource;->section:I
const-wide/16 v2, -0x1
const/4 v4, 0x2
if-ne v0, v1, :cond_36
.line 79
iget-wide v10, v7, Lokio/Buffer;->size:J
.line 80
.local v10, "offset":J
iget-object v0, v6, Lokio/GzipSource;->inflaterSource:Lokio/InflaterSource;
invoke-virtual {v0, p1, v8, v9}, Lokio/InflaterSource;->read(Lokio/Buffer;J)J
move-result-wide v12
.line 81
.local v12, "result":J
cmp-long v0, v12, v2
if-eqz v0, :cond_34
.line 82
move-object v0, p0
move-object v1, p1
move-wide v2, v10
move-wide v4, v12
invoke-direct/range {v0 .. v5}, Lokio/GzipSource;->updateCrc(Lokio/Buffer;JJ)V
.line 83
return-wide v12
.line 85
:cond_34
iput v4, v6, Lokio/GzipSource;->section:I
.line 91
.end local v10 # "offset":J
.end local v12 # "result":J
:cond_36
iget v0, v6, Lokio/GzipSource;->section:I
if-ne v0, v4, :cond_51
.line 92
invoke-direct {p0}, Lokio/GzipSource;->consumeTrailer()V
.line 93
const/4 v0, 0x3
iput v0, v6, Lokio/GzipSource;->section:I
.line 99
iget-object v0, v6, Lokio/GzipSource;->source:Lokio/BufferedSource;
invoke-interface {v0}, Lokio/BufferedSource;->exhausted()Z
move-result v0
if-eqz v0, :cond_49
goto :goto_51
.line 100
:cond_49
new-instance v0, Ljava/io/IOException;
const-string v1, "gzip finished without exhausting source"
invoke-direct {v0, v1}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V
throw v0
.line 104
:cond_51
:goto_51
return-wide v2
.line 68
:cond_52
new-instance v0, Ljava/lang/IllegalArgumentException;
new-instance v1, Ljava/lang/StringBuilder;
invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
const-string v2, "byteCount < 0: "
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v1, v8, v9}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v1
invoke-direct {v0, v1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
throw v0
.end method
.method public timeout()Lokio/Timeout;
.registers 2
.line 178
iget-object v0, p0, Lokio/GzipSource;->source:Lokio/BufferedSource;
invoke-interface {v0}, Lokio/BufferedSource;->timeout()Lokio/Timeout;
move-result-object v0
return-object v0
.end method