276 lines
6 KiB
Smali
276 lines
6 KiB
Smali
.class final Landroidx/multidex/ZipUtil;
|
|
.super Ljava/lang/Object;
|
|
|
|
|
|
# annotations
|
|
.annotation system Ldalvik/annotation/MemberClasses;
|
|
value = {
|
|
Landroidx/multidex/ZipUtil$CentralDirectory;
|
|
}
|
|
.end annotation
|
|
|
|
|
|
# static fields
|
|
.field private static final BUFFER_SIZE:I = 0x4000
|
|
|
|
.field private static final ENDHDR:I = 0x16
|
|
|
|
.field private static final ENDSIG:I = 0x6054b50
|
|
|
|
|
|
# direct methods
|
|
.method constructor <init>()V
|
|
.locals 0
|
|
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method static computeCrcOfCentralDir(Ljava/io/RandomAccessFile;Landroidx/multidex/ZipUtil$CentralDirectory;)J
|
|
.locals 9
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
value = {
|
|
Ljava/io/IOException;
|
|
}
|
|
.end annotation
|
|
|
|
new-instance v0, Ljava/util/zip/CRC32;
|
|
|
|
invoke-direct {v0}, Ljava/util/zip/CRC32;-><init>()V
|
|
|
|
iget-wide v1, p1, Landroidx/multidex/ZipUtil$CentralDirectory;->size:J
|
|
|
|
iget-wide v3, p1, Landroidx/multidex/ZipUtil$CentralDirectory;->offset:J
|
|
|
|
invoke-virtual {p0, v3, v4}, Ljava/io/RandomAccessFile;->seek(J)V
|
|
|
|
const-wide/16 v3, 0x4000
|
|
|
|
invoke-static {v3, v4, v1, v2}, Ljava/lang/Math;->min(JJ)J
|
|
|
|
move-result-wide v5
|
|
|
|
long-to-int p1, v5
|
|
|
|
const/16 v5, 0x4000
|
|
|
|
new-array v5, v5, [B
|
|
|
|
const/4 v6, 0x0
|
|
|
|
:goto_0
|
|
invoke-virtual {p0, v5, v6, p1}, Ljava/io/RandomAccessFile;->read([BII)I
|
|
|
|
move-result p1
|
|
|
|
const/4 v7, -0x1
|
|
|
|
if-eq p1, v7, :cond_0
|
|
|
|
invoke-virtual {v0, v5, v6, p1}, Ljava/util/zip/CRC32;->update([BII)V
|
|
|
|
int-to-long v7, p1
|
|
|
|
sub-long/2addr v1, v7
|
|
|
|
const-wide/16 v7, 0x0
|
|
|
|
cmp-long p1, v1, v7
|
|
|
|
if-eqz p1, :cond_0
|
|
|
|
invoke-static {v3, v4, v1, v2}, Ljava/lang/Math;->min(JJ)J
|
|
|
|
move-result-wide v7
|
|
|
|
long-to-int p1, v7
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
invoke-virtual {v0}, Ljava/util/zip/CRC32;->getValue()J
|
|
|
|
move-result-wide p0
|
|
|
|
return-wide p0
|
|
.end method
|
|
|
|
.method static findCentralDirectory(Ljava/io/RandomAccessFile;)Landroidx/multidex/ZipUtil$CentralDirectory;
|
|
.locals 7
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
value = {
|
|
Ljava/io/IOException;,
|
|
Ljava/util/zip/ZipException;
|
|
}
|
|
.end annotation
|
|
|
|
invoke-virtual {p0}, Ljava/io/RandomAccessFile;->length()J
|
|
|
|
move-result-wide v0
|
|
|
|
const-wide/16 v2, 0x16
|
|
|
|
sub-long/2addr v0, v2
|
|
|
|
const-wide/16 v2, 0x0
|
|
|
|
cmp-long v4, v0, v2
|
|
|
|
if-ltz v4, :cond_3
|
|
|
|
const-wide/32 v4, 0x10000
|
|
|
|
sub-long v4, v0, v4
|
|
|
|
cmp-long v6, v4, v2
|
|
|
|
if-gez v6, :cond_0
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
move-wide v2, v4
|
|
|
|
:goto_0
|
|
const v4, 0x6054b50
|
|
|
|
invoke-static {v4}, Ljava/lang/Integer;->reverseBytes(I)I
|
|
|
|
move-result v4
|
|
|
|
:goto_1
|
|
invoke-virtual {p0, v0, v1}, Ljava/io/RandomAccessFile;->seek(J)V
|
|
|
|
invoke-virtual {p0}, Ljava/io/RandomAccessFile;->readInt()I
|
|
|
|
move-result v5
|
|
|
|
if-eq v5, v4, :cond_2
|
|
|
|
const-wide/16 v5, 0x1
|
|
|
|
sub-long/2addr v0, v5
|
|
|
|
cmp-long v5, v0, v2
|
|
|
|
if-ltz v5, :cond_1
|
|
|
|
goto :goto_1
|
|
|
|
:cond_1
|
|
new-instance p0, Ljava/util/zip/ZipException;
|
|
|
|
const-string v0, "End Of Central Directory signature not found"
|
|
|
|
invoke-direct {p0, v0}, Ljava/util/zip/ZipException;-><init>(Ljava/lang/String;)V
|
|
|
|
throw p0
|
|
|
|
:cond_2
|
|
const/4 v0, 0x2
|
|
|
|
invoke-virtual {p0, v0}, Ljava/io/RandomAccessFile;->skipBytes(I)I
|
|
|
|
invoke-virtual {p0, v0}, Ljava/io/RandomAccessFile;->skipBytes(I)I
|
|
|
|
invoke-virtual {p0, v0}, Ljava/io/RandomAccessFile;->skipBytes(I)I
|
|
|
|
invoke-virtual {p0, v0}, Ljava/io/RandomAccessFile;->skipBytes(I)I
|
|
|
|
new-instance v0, Landroidx/multidex/ZipUtil$CentralDirectory;
|
|
|
|
invoke-direct {v0}, Landroidx/multidex/ZipUtil$CentralDirectory;-><init>()V
|
|
|
|
invoke-virtual {p0}, Ljava/io/RandomAccessFile;->readInt()I
|
|
|
|
move-result v1
|
|
|
|
invoke-static {v1}, Ljava/lang/Integer;->reverseBytes(I)I
|
|
|
|
move-result v1
|
|
|
|
int-to-long v1, v1
|
|
|
|
const-wide v3, 0xffffffffL
|
|
|
|
and-long/2addr v1, v3
|
|
|
|
iput-wide v1, v0, Landroidx/multidex/ZipUtil$CentralDirectory;->size:J
|
|
|
|
invoke-virtual {p0}, Ljava/io/RandomAccessFile;->readInt()I
|
|
|
|
move-result p0
|
|
|
|
invoke-static {p0}, Ljava/lang/Integer;->reverseBytes(I)I
|
|
|
|
move-result p0
|
|
|
|
int-to-long v1, p0
|
|
|
|
and-long/2addr v1, v3
|
|
|
|
iput-wide v1, v0, Landroidx/multidex/ZipUtil$CentralDirectory;->offset:J
|
|
|
|
return-object v0
|
|
|
|
:cond_3
|
|
new-instance v0, Ljava/util/zip/ZipException;
|
|
|
|
new-instance v1, Ljava/lang/StringBuilder;
|
|
|
|
const-string v2, "File too short to be a zip file: "
|
|
|
|
invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
|
|
|
|
invoke-virtual {p0}, Ljava/io/RandomAccessFile;->length()J
|
|
|
|
move-result-wide v2
|
|
|
|
invoke-virtual {v1, v2, v3}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-direct {v0, p0}, Ljava/util/zip/ZipException;-><init>(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
.end method
|
|
|
|
.method static getZipCrc(Ljava/io/File;)J
|
|
.locals 3
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
value = {
|
|
Ljava/io/IOException;
|
|
}
|
|
.end annotation
|
|
|
|
new-instance v0, Ljava/io/RandomAccessFile;
|
|
|
|
const-string v1, "r"
|
|
|
|
invoke-direct {v0, p0, v1}, Ljava/io/RandomAccessFile;-><init>(Ljava/io/File;Ljava/lang/String;)V
|
|
|
|
:try_start_0
|
|
invoke-static {v0}, Landroidx/multidex/ZipUtil;->findCentralDirectory(Ljava/io/RandomAccessFile;)Landroidx/multidex/ZipUtil$CentralDirectory;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-static {v0, p0}, Landroidx/multidex/ZipUtil;->computeCrcOfCentralDir(Ljava/io/RandomAccessFile;Landroidx/multidex/ZipUtil$CentralDirectory;)J
|
|
|
|
move-result-wide v1
|
|
:try_end_0
|
|
.catchall {:try_start_0 .. :try_end_0} :catchall_0
|
|
|
|
invoke-virtual {v0}, Ljava/io/RandomAccessFile;->close()V
|
|
|
|
return-wide v1
|
|
|
|
:catchall_0
|
|
move-exception p0
|
|
|
|
invoke-virtual {v0}, Ljava/io/RandomAccessFile;->close()V
|
|
|
|
throw p0
|
|
.end method
|