600 lines
13 KiB
Smali
600 lines
13 KiB
Smali
.class public final Lm5/a;
|
|
.super Ljava/lang/Object;
|
|
.source "ByteBufferUtil.java"
|
|
|
|
|
|
# annotations
|
|
.annotation system Ldalvik/annotation/MemberClasses;
|
|
value = {
|
|
Lm5/a$a;,
|
|
Lm5/a$b;
|
|
}
|
|
.end annotation
|
|
|
|
|
|
# static fields
|
|
.field public static final a:I = 0x4000
|
|
|
|
.field public static final b:Ljava/util/concurrent/atomic/AtomicReference;
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"Ljava/util/concurrent/atomic/AtomicReference<",
|
|
"[B>;"
|
|
}
|
|
.end annotation
|
|
.end field
|
|
|
|
|
|
# direct methods
|
|
.method public static constructor <clinit>()V
|
|
.locals 1
|
|
|
|
.line 1
|
|
new-instance v0, Ljava/util/concurrent/atomic/AtomicReference;
|
|
|
|
invoke-direct {v0}, Ljava/util/concurrent/atomic/AtomicReference;-><init>()V
|
|
|
|
sput-object v0, Lm5/a;->b:Ljava/util/concurrent/atomic/AtomicReference;
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public constructor <init>()V
|
|
.locals 0
|
|
|
|
.line 1
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public static a(Ljava/io/File;)Ljava/nio/ByteBuffer;
|
|
.locals 8
|
|
.param p0 # Ljava/io/File;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
value = {
|
|
Ljava/io/IOException;
|
|
}
|
|
.end annotation
|
|
|
|
const/4 v0, 0x0
|
|
|
|
.line 1
|
|
:try_start_0
|
|
invoke-virtual {p0}, Ljava/io/File;->length()J
|
|
|
|
move-result-wide v5
|
|
|
|
const-wide/32 v1, 0x7fffffff
|
|
|
|
cmp-long v1, v5, v1
|
|
|
|
if-gtz v1, :cond_1
|
|
|
|
const-wide/16 v1, 0x0
|
|
|
|
cmp-long v1, v5, v1
|
|
|
|
if-eqz v1, :cond_0
|
|
|
|
.line 2
|
|
new-instance v7, Ljava/io/RandomAccessFile;
|
|
|
|
const-string v1, "r"
|
|
|
|
invoke-direct {v7, p0, v1}, Ljava/io/RandomAccessFile;-><init>(Ljava/io/File;Ljava/lang/String;)V
|
|
:try_end_0
|
|
.catchall {:try_start_0 .. :try_end_0} :catchall_1
|
|
|
|
.line 3
|
|
:try_start_1
|
|
invoke-virtual {v7}, Ljava/io/RandomAccessFile;->getChannel()Ljava/nio/channels/FileChannel;
|
|
|
|
move-result-object v0
|
|
|
|
.line 4
|
|
sget-object v2, Ljava/nio/channels/FileChannel$MapMode;->READ_ONLY:Ljava/nio/channels/FileChannel$MapMode;
|
|
|
|
const-wide/16 v3, 0x0
|
|
|
|
move-object v1, v0
|
|
|
|
invoke-virtual/range {v1 .. v6}, Ljava/nio/channels/FileChannel;->map(Ljava/nio/channels/FileChannel$MapMode;JJ)Ljava/nio/MappedByteBuffer;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-virtual {p0}, Ljava/nio/MappedByteBuffer;->load()Ljava/nio/MappedByteBuffer;
|
|
|
|
move-result-object p0
|
|
:try_end_1
|
|
.catchall {:try_start_1 .. :try_end_1} :catchall_0
|
|
|
|
.line 5
|
|
:try_start_2
|
|
invoke-virtual {v0}, Ljava/nio/channels/FileChannel;->close()V
|
|
:try_end_2
|
|
.catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_0
|
|
|
|
.line 6
|
|
:catch_0
|
|
:try_start_3
|
|
invoke-virtual {v7}, Ljava/io/RandomAccessFile;->close()V
|
|
:try_end_3
|
|
.catch Ljava/io/IOException; {:try_start_3 .. :try_end_3} :catch_1
|
|
|
|
:catch_1
|
|
return-object p0
|
|
|
|
:catchall_0
|
|
move-exception p0
|
|
|
|
goto :goto_0
|
|
|
|
.line 7
|
|
:cond_0
|
|
:try_start_4
|
|
new-instance p0, Ljava/io/IOException;
|
|
|
|
const-string v1, "File unsuitable for memory mapping"
|
|
|
|
invoke-direct {p0, v1}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V
|
|
|
|
throw p0
|
|
|
|
.line 8
|
|
:cond_1
|
|
new-instance p0, Ljava/io/IOException;
|
|
|
|
const-string v1, "File too large to map into memory"
|
|
|
|
invoke-direct {p0, v1}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V
|
|
|
|
throw p0
|
|
:try_end_4
|
|
.catchall {:try_start_4 .. :try_end_4} :catchall_1
|
|
|
|
:catchall_1
|
|
move-exception p0
|
|
|
|
move-object v7, v0
|
|
|
|
:goto_0
|
|
if-eqz v0, :cond_2
|
|
|
|
.line 9
|
|
:try_start_5
|
|
invoke-virtual {v0}, Ljava/nio/channels/FileChannel;->close()V
|
|
:try_end_5
|
|
.catch Ljava/io/IOException; {:try_start_5 .. :try_end_5} :catch_2
|
|
|
|
:catch_2
|
|
:cond_2
|
|
if-eqz v7, :cond_3
|
|
|
|
.line 10
|
|
:try_start_6
|
|
invoke-virtual {v7}, Ljava/io/RandomAccessFile;->close()V
|
|
:try_end_6
|
|
.catch Ljava/io/IOException; {:try_start_6 .. :try_end_6} :catch_3
|
|
|
|
.line 11
|
|
:catch_3
|
|
:cond_3
|
|
throw p0
|
|
.end method
|
|
|
|
.method public static b(Ljava/io/InputStream;)Ljava/nio/ByteBuffer;
|
|
.locals 4
|
|
.param p0 # Ljava/io/InputStream;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
value = {
|
|
Ljava/io/IOException;
|
|
}
|
|
.end annotation
|
|
|
|
.line 1
|
|
new-instance v0, Ljava/io/ByteArrayOutputStream;
|
|
|
|
const/16 v1, 0x4000
|
|
|
|
invoke-direct {v0, v1}, Ljava/io/ByteArrayOutputStream;-><init>(I)V
|
|
|
|
.line 2
|
|
sget-object v2, Lm5/a;->b:Ljava/util/concurrent/atomic/AtomicReference;
|
|
|
|
const/4 v3, 0x0
|
|
|
|
invoke-virtual {v2, v3}, Ljava/util/concurrent/atomic/AtomicReference;->getAndSet(Ljava/lang/Object;)Ljava/lang/Object;
|
|
|
|
move-result-object v2
|
|
|
|
check-cast v2, [B
|
|
|
|
if-nez v2, :cond_0
|
|
|
|
new-array v2, v1, [B
|
|
|
|
.line 3
|
|
:cond_0
|
|
:goto_0
|
|
invoke-virtual {p0, v2}, Ljava/io/InputStream;->read([B)I
|
|
|
|
move-result v1
|
|
|
|
const/4 v3, 0x0
|
|
|
|
if-ltz v1, :cond_1
|
|
|
|
.line 4
|
|
invoke-virtual {v0, v2, v3, v1}, Ljava/io/ByteArrayOutputStream;->write([BII)V
|
|
|
|
goto :goto_0
|
|
|
|
.line 5
|
|
:cond_1
|
|
sget-object p0, Lm5/a;->b:Ljava/util/concurrent/atomic/AtomicReference;
|
|
|
|
invoke-virtual {p0, v2}, Ljava/util/concurrent/atomic/AtomicReference;->set(Ljava/lang/Object;)V
|
|
|
|
.line 6
|
|
invoke-virtual {v0}, Ljava/io/ByteArrayOutputStream;->toByteArray()[B
|
|
|
|
move-result-object p0
|
|
|
|
.line 7
|
|
array-length v0, p0
|
|
|
|
invoke-static {v0}, Ljava/nio/ByteBuffer;->allocateDirect(I)Ljava/nio/ByteBuffer;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-virtual {v0, p0}, Ljava/nio/ByteBuffer;->put([B)Ljava/nio/ByteBuffer;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-virtual {p0, v3}, Ljava/nio/ByteBuffer;->position(I)Ljava/nio/Buffer;
|
|
|
|
move-result-object p0
|
|
|
|
check-cast p0, Ljava/nio/ByteBuffer;
|
|
|
|
return-object p0
|
|
.end method
|
|
|
|
.method public static c(Ljava/nio/ByteBuffer;)Lm5/a$b;
|
|
.locals 3
|
|
.param p0 # Ljava/nio/ByteBuffer;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
.annotation build Landroidx/annotation/Nullable;
|
|
.end annotation
|
|
|
|
.line 1
|
|
invoke-virtual {p0}, Ljava/nio/ByteBuffer;->isReadOnly()Z
|
|
|
|
move-result v0
|
|
|
|
if-nez v0, :cond_0
|
|
|
|
invoke-virtual {p0}, Ljava/nio/ByteBuffer;->hasArray()Z
|
|
|
|
move-result v0
|
|
|
|
if-eqz v0, :cond_0
|
|
|
|
.line 2
|
|
new-instance v0, Lm5/a$b;
|
|
|
|
invoke-virtual {p0}, Ljava/nio/ByteBuffer;->array()[B
|
|
|
|
move-result-object v1
|
|
|
|
invoke-virtual {p0}, Ljava/nio/ByteBuffer;->arrayOffset()I
|
|
|
|
move-result v2
|
|
|
|
invoke-virtual {p0}, Ljava/nio/ByteBuffer;->limit()I
|
|
|
|
move-result p0
|
|
|
|
invoke-direct {v0, v1, v2, p0}, Lm5/a$b;-><init>([BII)V
|
|
|
|
return-object v0
|
|
|
|
:cond_0
|
|
const/4 p0, 0x0
|
|
|
|
return-object p0
|
|
.end method
|
|
|
|
.method public static d(Ljava/nio/ByteBuffer;)[B
|
|
.locals 2
|
|
.param p0 # Ljava/nio/ByteBuffer;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
|
|
.line 1
|
|
invoke-static {p0}, Lm5/a;->c(Ljava/nio/ByteBuffer;)Lm5/a$b;
|
|
|
|
move-result-object v0
|
|
|
|
if-eqz v0, :cond_0
|
|
|
|
.line 2
|
|
iget v1, v0, Lm5/a$b;->a:I
|
|
|
|
if-nez v1, :cond_0
|
|
|
|
iget v1, v0, Lm5/a$b;->b:I
|
|
|
|
iget-object v0, v0, Lm5/a$b;->c:[B
|
|
|
|
array-length v0, v0
|
|
|
|
if-ne v1, v0, :cond_0
|
|
|
|
.line 3
|
|
invoke-virtual {p0}, Ljava/nio/ByteBuffer;->array()[B
|
|
|
|
move-result-object p0
|
|
|
|
goto :goto_0
|
|
|
|
.line 4
|
|
:cond_0
|
|
invoke-virtual {p0}, Ljava/nio/ByteBuffer;->asReadOnlyBuffer()Ljava/nio/ByteBuffer;
|
|
|
|
move-result-object p0
|
|
|
|
.line 5
|
|
invoke-virtual {p0}, Ljava/nio/ByteBuffer;->limit()I
|
|
|
|
move-result v0
|
|
|
|
new-array v0, v0, [B
|
|
|
|
const/4 v1, 0x0
|
|
|
|
.line 6
|
|
invoke-virtual {p0, v1}, Ljava/nio/ByteBuffer;->position(I)Ljava/nio/Buffer;
|
|
|
|
.line 7
|
|
invoke-virtual {p0, v0}, Ljava/nio/ByteBuffer;->get([B)Ljava/nio/ByteBuffer;
|
|
|
|
move-object p0, v0
|
|
|
|
:goto_0
|
|
return-object p0
|
|
.end method
|
|
|
|
.method public static e(Ljava/nio/ByteBuffer;Ljava/io/File;)V
|
|
.locals 4
|
|
.param p0 # Ljava/nio/ByteBuffer;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
.param p1 # Ljava/io/File;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
value = {
|
|
Ljava/io/IOException;
|
|
}
|
|
.end annotation
|
|
|
|
const/4 v0, 0x0
|
|
|
|
.line 1
|
|
invoke-virtual {p0, v0}, Ljava/nio/ByteBuffer;->position(I)Ljava/nio/Buffer;
|
|
|
|
const/4 v1, 0x0
|
|
|
|
.line 2
|
|
:try_start_0
|
|
new-instance v2, Ljava/io/RandomAccessFile;
|
|
|
|
const-string v3, "rw"
|
|
|
|
invoke-direct {v2, p1, v3}, Ljava/io/RandomAccessFile;-><init>(Ljava/io/File;Ljava/lang/String;)V
|
|
:try_end_0
|
|
.catchall {:try_start_0 .. :try_end_0} :catchall_1
|
|
|
|
.line 3
|
|
:try_start_1
|
|
invoke-virtual {v2}, Ljava/io/RandomAccessFile;->getChannel()Ljava/nio/channels/FileChannel;
|
|
|
|
move-result-object v1
|
|
|
|
.line 4
|
|
invoke-virtual {v1, p0}, Ljava/nio/channels/FileChannel;->write(Ljava/nio/ByteBuffer;)I
|
|
|
|
.line 5
|
|
invoke-virtual {v1, v0}, Ljava/nio/channels/FileChannel;->force(Z)V
|
|
|
|
.line 6
|
|
invoke-virtual {v1}, Ljava/nio/channels/FileChannel;->close()V
|
|
|
|
.line 7
|
|
invoke-virtual {v2}, Ljava/io/RandomAccessFile;->close()V
|
|
:try_end_1
|
|
.catchall {:try_start_1 .. :try_end_1} :catchall_0
|
|
|
|
.line 8
|
|
:try_start_2
|
|
invoke-virtual {v1}, Ljava/nio/channels/FileChannel;->close()V
|
|
:try_end_2
|
|
.catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_0
|
|
|
|
.line 9
|
|
:catch_0
|
|
:try_start_3
|
|
invoke-virtual {v2}, Ljava/io/RandomAccessFile;->close()V
|
|
:try_end_3
|
|
.catch Ljava/io/IOException; {:try_start_3 .. :try_end_3} :catch_1
|
|
|
|
:catch_1
|
|
return-void
|
|
|
|
:catchall_0
|
|
move-exception p0
|
|
|
|
goto :goto_0
|
|
|
|
:catchall_1
|
|
move-exception p0
|
|
|
|
move-object v2, v1
|
|
|
|
:goto_0
|
|
if-eqz v1, :cond_0
|
|
|
|
.line 10
|
|
:try_start_4
|
|
invoke-virtual {v1}, Ljava/nio/channels/FileChannel;->close()V
|
|
:try_end_4
|
|
.catch Ljava/io/IOException; {:try_start_4 .. :try_end_4} :catch_2
|
|
|
|
:catch_2
|
|
:cond_0
|
|
if-eqz v2, :cond_1
|
|
|
|
.line 11
|
|
:try_start_5
|
|
invoke-virtual {v2}, Ljava/io/RandomAccessFile;->close()V
|
|
:try_end_5
|
|
.catch Ljava/io/IOException; {:try_start_5 .. :try_end_5} :catch_3
|
|
|
|
.line 12
|
|
:catch_3
|
|
:cond_1
|
|
throw p0
|
|
.end method
|
|
|
|
.method public static f(Ljava/nio/ByteBuffer;)Ljava/io/InputStream;
|
|
.locals 1
|
|
.param p0 # Ljava/nio/ByteBuffer;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
|
|
.line 1
|
|
new-instance v0, Lm5/a$a;
|
|
|
|
invoke-direct {v0, p0}, Lm5/a$a;-><init>(Ljava/nio/ByteBuffer;)V
|
|
|
|
return-object v0
|
|
.end method
|
|
|
|
.method public static g(Ljava/nio/ByteBuffer;Ljava/io/OutputStream;)V
|
|
.locals 3
|
|
.param p0 # Ljava/nio/ByteBuffer;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
.param p1 # Ljava/io/OutputStream;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
value = {
|
|
Ljava/io/IOException;
|
|
}
|
|
.end annotation
|
|
|
|
.line 1
|
|
invoke-static {p0}, Lm5/a;->c(Ljava/nio/ByteBuffer;)Lm5/a$b;
|
|
|
|
move-result-object v0
|
|
|
|
if-eqz v0, :cond_0
|
|
|
|
.line 2
|
|
iget-object p0, v0, Lm5/a$b;->c:[B
|
|
|
|
iget v1, v0, Lm5/a$b;->a:I
|
|
|
|
iget v0, v0, Lm5/a$b;->b:I
|
|
|
|
add-int/2addr v0, v1
|
|
|
|
invoke-virtual {p1, p0, v1, v0}, Ljava/io/OutputStream;->write([BII)V
|
|
|
|
goto :goto_1
|
|
|
|
.line 3
|
|
:cond_0
|
|
sget-object v0, Lm5/a;->b:Ljava/util/concurrent/atomic/AtomicReference;
|
|
|
|
const/4 v1, 0x0
|
|
|
|
invoke-virtual {v0, v1}, Ljava/util/concurrent/atomic/AtomicReference;->getAndSet(Ljava/lang/Object;)Ljava/lang/Object;
|
|
|
|
move-result-object v0
|
|
|
|
check-cast v0, [B
|
|
|
|
if-nez v0, :cond_1
|
|
|
|
const/16 v0, 0x4000
|
|
|
|
new-array v0, v0, [B
|
|
|
|
.line 4
|
|
:cond_1
|
|
:goto_0
|
|
invoke-virtual {p0}, Ljava/nio/ByteBuffer;->remaining()I
|
|
|
|
move-result v1
|
|
|
|
if-lez v1, :cond_2
|
|
|
|
.line 5
|
|
invoke-virtual {p0}, Ljava/nio/ByteBuffer;->remaining()I
|
|
|
|
move-result v1
|
|
|
|
array-length v2, v0
|
|
|
|
invoke-static {v1, v2}, Ljava/lang/Math;->min(II)I
|
|
|
|
move-result v1
|
|
|
|
const/4 v2, 0x0
|
|
|
|
.line 6
|
|
invoke-virtual {p0, v0, v2, v1}, Ljava/nio/ByteBuffer;->get([BII)Ljava/nio/ByteBuffer;
|
|
|
|
.line 7
|
|
invoke-virtual {p1, v0, v2, v1}, Ljava/io/OutputStream;->write([BII)V
|
|
|
|
goto :goto_0
|
|
|
|
.line 8
|
|
:cond_2
|
|
sget-object p0, Lm5/a;->b:Ljava/util/concurrent/atomic/AtomicReference;
|
|
|
|
invoke-virtual {p0, v0}, Ljava/util/concurrent/atomic/AtomicReference;->set(Ljava/lang/Object;)V
|
|
|
|
:goto_1
|
|
return-void
|
|
.end method
|