Files
rr3-apk/smali_classes3/com/google/protobuf/ByteBufferWriter.smali
Daniel Elliott f3960ee359 Add Discord APKTool decompilation (Smali source for modding)
- Imported from https://github.com/supermegamestre/Project-Real-Resurrection-3
- APKTool decompilation (Smali bytecode) for modding and rebuilding APK
- Supports both 32-bit (armeabi-v7a) and 64-bit (arm64-v8a) architectures
- Includes full Smali source, resources, and native libraries
- Ready to rebuild APK after modifications with apktool b command
- Added comprehensive README-apktool.md with modding guide

This branch complements the JADX branches:
- Use JADX (main/discord-community) to UNDERSTAND code (readable Java)
- Use APKTool (this branch) to MODIFY and REBUILD APK (editable Smali)

Total: 44,417 files, 538.51 MB Smali source code
2026-02-18 16:13:44 -08:00

446 lines
9.3 KiB
Smali

.class public final Lcom/google/protobuf/ByteBufferWriter;
.super Ljava/lang/Object;
.source "SourceFile"
# static fields
.field private static final BUFFER:Ljava/lang/ThreadLocal;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/lang/ThreadLocal<",
"Ljava/lang/ref/SoftReference<",
"[B>;>;"
}
.end annotation
.end field
.field private static final BUFFER_REALLOCATION_THRESHOLD:F = 0.5f
.field private static final CHANNEL_FIELD_OFFSET:J
.field private static final FILE_OUTPUT_STREAM_CLASS:Ljava/lang/Class;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/lang/Class<",
"*>;"
}
.end annotation
.end field
.field private static final MAX_CACHED_BUFFER_SIZE:I = 0x4000
.field private static final MIN_CACHED_BUFFER_SIZE:I = 0x400
# direct methods
.method static constructor <clinit>()V
.locals 2
.line 71
new-instance v0, Ljava/lang/ThreadLocal;
invoke-direct {v0}, Ljava/lang/ThreadLocal;-><init>()V
sput-object v0, Lcom/google/protobuf/ByteBufferWriter;->BUFFER:Ljava/lang/ThreadLocal;
const-string v0, "java.io.FileOutputStream"
.line 75
invoke-static {v0}, Lcom/google/protobuf/ByteBufferWriter;->safeGetClass(Ljava/lang/String;)Ljava/lang/Class;
move-result-object v0
sput-object v0, Lcom/google/protobuf/ByteBufferWriter;->FILE_OUTPUT_STREAM_CLASS:Ljava/lang/Class;
.line 77
invoke-static {v0}, Lcom/google/protobuf/ByteBufferWriter;->getChannelFieldOffset(Ljava/lang/Class;)J
move-result-wide v0
sput-wide v0, Lcom/google/protobuf/ByteBufferWriter;->CHANNEL_FIELD_OFFSET:J
return-void
.end method
.method private constructor <init>()V
.locals 0
.line 45
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
.method public static clearCachedBuffer()V
.locals 2
sget-object v0, Lcom/google/protobuf/ByteBufferWriter;->BUFFER:Ljava/lang/ThreadLocal;
const/4 v1, 0x0
.line 84
invoke-virtual {v0, v1}, Ljava/lang/ThreadLocal;->set(Ljava/lang/Object;)V
return-void
.end method
.method private static getBuffer()[B
.locals 1
sget-object v0, Lcom/google/protobuf/ByteBufferWriter;->BUFFER:Ljava/lang/ThreadLocal;
.line 137
invoke-virtual {v0}, Ljava/lang/ThreadLocal;->get()Ljava/lang/Object;
move-result-object v0
check-cast v0, Ljava/lang/ref/SoftReference;
if-nez v0, :cond_0
const/4 v0, 0x0
goto :goto_0
.line 138
:cond_0
invoke-virtual {v0}, Ljava/lang/ref/SoftReference;->get()Ljava/lang/Object;
move-result-object v0
check-cast v0, [B
:goto_0
return-object v0
.end method
.method private static getChannelFieldOffset(Ljava/lang/Class;)J
.locals 2
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Ljava/lang/Class<",
"*>;)J"
}
.end annotation
if-eqz p0, :cond_0
.line 172
:try_start_0
invoke-static {}, Lcom/google/protobuf/UnsafeUtil;->hasUnsafeArrayOperations()Z
move-result v0
if-eqz v0, :cond_0
const-string v0, "channel"
.line 173
invoke-virtual {p0, v0}, Ljava/lang/Class;->getDeclaredField(Ljava/lang/String;)Ljava/lang/reflect/Field;
move-result-object p0
.line 174
invoke-static {p0}, Lcom/google/protobuf/UnsafeUtil;->objectFieldOffset(Ljava/lang/reflect/Field;)J
move-result-wide v0
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
return-wide v0
:catchall_0
:cond_0
const-wide/16 v0, -0x1
return-wide v0
.end method
.method private static getOrCreateBuffer(I)[B
.locals 2
const/16 v0, 0x400
.line 115
invoke-static {p0, v0}, Ljava/lang/Math;->max(II)I
move-result p0
.line 117
invoke-static {}, Lcom/google/protobuf/ByteBufferWriter;->getBuffer()[B
move-result-object v0
if-eqz v0, :cond_0
.line 119
array-length v1, v0
invoke-static {p0, v1}, Lcom/google/protobuf/ByteBufferWriter;->needToReallocate(II)Z
move-result v1
if-eqz v1, :cond_1
.line 120
:cond_0
new-array v0, p0, [B
const/16 v1, 0x4000
if-gt p0, v1, :cond_1
.line 124
invoke-static {v0}, Lcom/google/protobuf/ByteBufferWriter;->setBuffer([B)V
:cond_1
return-object v0
.end method
.method private static needToReallocate(II)Z
.locals 1
if-ge p1, p0, :cond_0
int-to-float p1, p1
int-to-float p0, p0
const/high16 v0, 0x3f000000 # 0.5f
mul-float/2addr p0, v0
cmpg-float p0, p1, p0
if-gez p0, :cond_0
const/4 p0, 0x1
goto :goto_0
:cond_0
const/4 p0, 0x0
:goto_0
return p0
.end method
.method private static safeGetClass(Ljava/lang/String;)Ljava/lang/Class;
.locals 0
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Ljava/lang/String;",
")",
"Ljava/lang/Class<",
"*>;"
}
.end annotation
.line 164
:try_start_0
invoke-static {p0}, Ljava/lang/Class;->forName(Ljava/lang/String;)Ljava/lang/Class;
move-result-object p0
:try_end_0
.catch Ljava/lang/ClassNotFoundException; {:try_start_0 .. :try_end_0} :catch_0
return-object p0
:catch_0
const/4 p0, 0x0
return-object p0
.end method
.method private static setBuffer([B)V
.locals 2
sget-object v0, Lcom/google/protobuf/ByteBufferWriter;->BUFFER:Ljava/lang/ThreadLocal;
.line 142
new-instance v1, Ljava/lang/ref/SoftReference;
invoke-direct {v1, p0}, Ljava/lang/ref/SoftReference;-><init>(Ljava/lang/Object;)V
invoke-virtual {v0, v1}, Ljava/lang/ThreadLocal;->set(Ljava/lang/Object;)V
return-void
.end method
.method public static write(Ljava/nio/ByteBuffer;Ljava/io/OutputStream;)V
.locals 4
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 92
invoke-virtual {p0}, Ljava/nio/Buffer;->position()I
move-result v0
.line 94
:try_start_0
invoke-virtual {p0}, Ljava/nio/ByteBuffer;->hasArray()Z
move-result v1
if-eqz v1, :cond_0
.line 97
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/Buffer;->position()I
move-result v3
add-int/2addr v2, v3
invoke-virtual {p0}, Ljava/nio/Buffer;->remaining()I
move-result v3
invoke-virtual {p1, v1, v2, v3}, Ljava/io/OutputStream;->write([BII)V
goto :goto_1
:catchall_0
move-exception p1
goto :goto_2
.line 98
:cond_0
invoke-static {p0, p1}, Lcom/google/protobuf/ByteBufferWriter;->writeToChannel(Ljava/nio/ByteBuffer;Ljava/io/OutputStream;)Z
move-result v1
if-nez v1, :cond_1
.line 101
invoke-virtual {p0}, Ljava/nio/Buffer;->remaining()I
move-result v1
invoke-static {v1}, Lcom/google/protobuf/ByteBufferWriter;->getOrCreateBuffer(I)[B
move-result-object v1
.line 102
:goto_0
invoke-virtual {p0}, Ljava/nio/Buffer;->hasRemaining()Z
move-result v2
if-eqz v2, :cond_1
.line 103
invoke-virtual {p0}, Ljava/nio/Buffer;->remaining()I
move-result v2
array-length v3, v1
invoke-static {v2, v3}, Ljava/lang/Math;->min(II)I
move-result v2
const/4 v3, 0x0
.line 104
invoke-virtual {p0, v1, v3, v2}, Ljava/nio/ByteBuffer;->get([BII)Ljava/nio/ByteBuffer;
.line 105
invoke-virtual {p1, v1, v3, v2}, Ljava/io/OutputStream;->write([BII)V
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
goto :goto_0
.line 110
:cond_1
:goto_1
invoke-virtual {p0, v0}, Ljava/nio/ByteBuffer;->position(I)Ljava/nio/Buffer;
move-result-object p0
check-cast p0, Ljava/nio/ByteBuffer;
return-void
:goto_2
invoke-virtual {p0, v0}, Ljava/nio/ByteBuffer;->position(I)Ljava/nio/Buffer;
move-result-object p0
check-cast p0, Ljava/nio/ByteBuffer;
.line 111
throw p1
.end method
.method private static writeToChannel(Ljava/nio/ByteBuffer;Ljava/io/OutputStream;)Z
.locals 4
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
sget-wide v0, Lcom/google/protobuf/ByteBufferWriter;->CHANNEL_FIELD_OFFSET:J
const-wide/16 v2, 0x0
cmp-long v2, v0, v2
if-ltz v2, :cond_0
sget-object v2, Lcom/google/protobuf/ByteBufferWriter;->FILE_OUTPUT_STREAM_CLASS:Ljava/lang/Class;
.line 146
invoke-virtual {v2, p1}, Ljava/lang/Class;->isInstance(Ljava/lang/Object;)Z
move-result v2
if-eqz v2, :cond_0
.line 150
:try_start_0
invoke-static {p1, v0, v1}, Lcom/google/protobuf/UnsafeUtil;->getObject(Ljava/lang/Object;J)Ljava/lang/Object;
move-result-object p1
check-cast p1, Ljava/nio/channels/WritableByteChannel;
:try_end_0
.catch Ljava/lang/ClassCastException; {:try_start_0 .. :try_end_0} :catch_0
goto :goto_0
:catch_0
const/4 p1, 0x0
:goto_0
if-eqz p1, :cond_0
.line 155
invoke-interface {p1, p0}, Ljava/nio/channels/WritableByteChannel;->write(Ljava/nio/ByteBuffer;)I
const/4 p0, 0x1
return p0
:cond_0
const/4 p0, 0x0
return p0
.end method