apkfuckery/com.discord/smali/androidx/core/graphics/TypefaceCompatUtil.smali

605 lines
14 KiB
Smali

.class public Landroidx/core/graphics/TypefaceCompatUtil;
.super Ljava/lang/Object;
.source "TypefaceCompatUtil.java"
# annotations
.annotation build Landroidx/annotation/RestrictTo;
value = {
.enum Landroidx/annotation/RestrictTo$Scope;->LIBRARY_GROUP:Landroidx/annotation/RestrictTo$Scope;
}
.end annotation
# static fields
.field private static final CACHE_FILE_PREFIX:Ljava/lang/String; = ".font"
.field private static final TAG:Ljava/lang/String; = "TypefaceCompatUtil"
# direct methods
.method private constructor <init>()V
.locals 0
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
.method public static closeQuietly(Ljava/io/Closeable;)V
.locals 0
if-eqz p0, :cond_0
:try_start_0
invoke-interface {p0}, Ljava/io/Closeable;->close()V
:try_end_0
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
:catch_0
:cond_0
return-void
.end method
.method public static copyToDirectBuffer(Landroid/content/Context;Landroid/content/res/Resources;I)Ljava/nio/ByteBuffer;
.locals 1
.annotation build Landroidx/annotation/Nullable;
.end annotation
.annotation build Landroidx/annotation/RequiresApi;
value = 0x13
.end annotation
invoke-static {p0}, Landroidx/core/graphics/TypefaceCompatUtil;->getTempFile(Landroid/content/Context;)Ljava/io/File;
move-result-object p0
const/4 v0, 0x0
if-nez p0, :cond_0
return-object v0
:cond_0
:try_start_0
invoke-static {p0, p1, p2}, Landroidx/core/graphics/TypefaceCompatUtil;->copyToFile(Ljava/io/File;Landroid/content/res/Resources;I)Z
move-result p1
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
if-nez p1, :cond_1
invoke-virtual {p0}, Ljava/io/File;->delete()Z
return-object v0
:cond_1
:try_start_1
invoke-static {p0}, Landroidx/core/graphics/TypefaceCompatUtil;->mmap(Ljava/io/File;)Ljava/nio/ByteBuffer;
move-result-object p1
:try_end_1
.catchall {:try_start_1 .. :try_end_1} :catchall_0
invoke-virtual {p0}, Ljava/io/File;->delete()Z
return-object p1
:catchall_0
move-exception p1
invoke-virtual {p0}, Ljava/io/File;->delete()Z
throw p1
.end method
.method public static copyToFile(Ljava/io/File;Landroid/content/res/Resources;I)Z
.locals 0
:try_start_0
invoke-virtual {p1, p2}, Landroid/content/res/Resources;->openRawResource(I)Ljava/io/InputStream;
move-result-object p1
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_1
:try_start_1
invoke-static {p0, p1}, Landroidx/core/graphics/TypefaceCompatUtil;->copyToFile(Ljava/io/File;Ljava/io/InputStream;)Z
move-result p0
:try_end_1
.catchall {:try_start_1 .. :try_end_1} :catchall_0
invoke-static {p1}, Landroidx/core/graphics/TypefaceCompatUtil;->closeQuietly(Ljava/io/Closeable;)V
return p0
:catchall_0
move-exception p0
goto :goto_0
:catchall_1
move-exception p0
const/4 p1, 0x0
:goto_0
invoke-static {p1}, Landroidx/core/graphics/TypefaceCompatUtil;->closeQuietly(Ljava/io/Closeable;)V
throw p0
.end method
.method public static copyToFile(Ljava/io/File;Ljava/io/InputStream;)Z
.locals 5
invoke-static {}, Landroid/os/StrictMode;->allowThreadDiskWrites()Landroid/os/StrictMode$ThreadPolicy;
move-result-object v0
const/4 v1, 0x0
const/4 v2, 0x0
:try_start_0
new-instance v3, Ljava/io/FileOutputStream;
invoke-direct {v3, p0, v1}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;Z)V
:try_end_0
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_1
.catchall {:try_start_0 .. :try_end_0} :catchall_1
const/16 p0, 0x400
:try_start_1
new-array p0, p0, [B
:goto_0
invoke-virtual {p1, p0}, Ljava/io/InputStream;->read([B)I
move-result v2
const/4 v4, -0x1
if-eq v2, v4, :cond_0
invoke-virtual {v3, p0, v1, v2}, Ljava/io/FileOutputStream;->write([BII)V
:try_end_1
.catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_0
.catchall {:try_start_1 .. :try_end_1} :catchall_0
goto :goto_0
:cond_0
invoke-static {v3}, Landroidx/core/graphics/TypefaceCompatUtil;->closeQuietly(Ljava/io/Closeable;)V
invoke-static {v0}, Landroid/os/StrictMode;->setThreadPolicy(Landroid/os/StrictMode$ThreadPolicy;)V
const/4 p0, 0x1
return p0
:catchall_0
move-exception p0
move-object v2, v3
goto :goto_2
:catch_0
move-exception p0
move-object v2, v3
goto :goto_1
:catchall_1
move-exception p0
goto :goto_2
:catch_1
move-exception p0
:goto_1
:try_start_2
const-string p1, "TypefaceCompatUtil"
new-instance v3, Ljava/lang/StringBuilder;
const-string v4, "Error copying resource contents to temp file: "
invoke-direct {v3, v4}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
invoke-virtual {p0}, Ljava/io/IOException;->getMessage()Ljava/lang/String;
move-result-object p0
invoke-virtual {v3, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p0
invoke-static {p1, p0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I
:try_end_2
.catchall {:try_start_2 .. :try_end_2} :catchall_1
invoke-static {v2}, Landroidx/core/graphics/TypefaceCompatUtil;->closeQuietly(Ljava/io/Closeable;)V
invoke-static {v0}, Landroid/os/StrictMode;->setThreadPolicy(Landroid/os/StrictMode$ThreadPolicy;)V
return v1
:goto_2
invoke-static {v2}, Landroidx/core/graphics/TypefaceCompatUtil;->closeQuietly(Ljava/io/Closeable;)V
invoke-static {v0}, Landroid/os/StrictMode;->setThreadPolicy(Landroid/os/StrictMode$ThreadPolicy;)V
goto :goto_4
:goto_3
throw p0
:goto_4
goto :goto_3
.end method
.method public static getTempFile(Landroid/content/Context;)Ljava/io/File;
.locals 5
.annotation build Landroidx/annotation/Nullable;
.end annotation
new-instance v0, Ljava/lang/StringBuilder;
const-string v1, ".font"
invoke-direct {v0, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
invoke-static {}, Landroid/os/Process;->myPid()I
move-result v1
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
const-string v1, "-"
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-static {}, Landroid/os/Process;->myTid()I
move-result v2
invoke-virtual {v0, v2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v0
const/4 v1, 0x0
:goto_0
const/16 v2, 0x64
if-ge v1, v2, :cond_1
new-instance v2, Ljava/io/File;
invoke-virtual {p0}, Landroid/content/Context;->getCacheDir()Ljava/io/File;
move-result-object v3
new-instance v4, Ljava/lang/StringBuilder;
invoke-direct {v4}, Ljava/lang/StringBuilder;-><init>()V
invoke-virtual {v4, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v4, v1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v4
invoke-direct {v2, v3, v4}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V
:try_start_0
invoke-virtual {v2}, Ljava/io/File;->createNewFile()Z
move-result v3
:try_end_0
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
if-eqz v3, :cond_0
return-object v2
:catch_0
:cond_0
add-int/lit8 v1, v1, 0x1
goto :goto_0
:cond_1
const/4 p0, 0x0
return-object p0
.end method
.method public static mmap(Landroid/content/Context;Landroid/os/CancellationSignal;Landroid/net/Uri;)Ljava/nio/ByteBuffer;
.locals 8
.annotation build Landroidx/annotation/Nullable;
.end annotation
.annotation build Landroidx/annotation/RequiresApi;
value = 0x13
.end annotation
invoke-virtual {p0}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;
move-result-object p0
const/4 v0, 0x0
:try_start_0
const-string v1, "r"
invoke-virtual {p0, p2, v1, p1}, Landroid/content/ContentResolver;->openFileDescriptor(Landroid/net/Uri;Ljava/lang/String;Landroid/os/CancellationSignal;)Landroid/os/ParcelFileDescriptor;
move-result-object p0
if-nez p0, :cond_1
if-eqz p0, :cond_0
invoke-virtual {p0}, Landroid/os/ParcelFileDescriptor;->close()V
:try_end_0
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_4
:cond_0
return-object v0
:cond_1
:try_start_1
new-instance p1, Ljava/io/FileInputStream;
invoke-virtual {p0}, Landroid/os/ParcelFileDescriptor;->getFileDescriptor()Ljava/io/FileDescriptor;
move-result-object p2
invoke-direct {p1, p2}, Ljava/io/FileInputStream;-><init>(Ljava/io/FileDescriptor;)V
:try_end_1
.catch Ljava/lang/Throwable; {:try_start_1 .. :try_end_1} :catch_2
.catchall {:try_start_1 .. :try_end_1} :catchall_2
:try_start_2
invoke-virtual {p1}, Ljava/io/FileInputStream;->getChannel()Ljava/nio/channels/FileChannel;
move-result-object v1
invoke-virtual {v1}, Ljava/nio/channels/FileChannel;->size()J
move-result-wide v5
sget-object v2, Ljava/nio/channels/FileChannel$MapMode;->READ_ONLY:Ljava/nio/channels/FileChannel$MapMode;
const-wide/16 v3, 0x0
invoke-virtual/range {v1 .. v6}, Ljava/nio/channels/FileChannel;->map(Ljava/nio/channels/FileChannel$MapMode;JJ)Ljava/nio/MappedByteBuffer;
move-result-object p2
:try_end_2
.catch Ljava/lang/Throwable; {:try_start_2 .. :try_end_2} :catch_0
.catchall {:try_start_2 .. :try_end_2} :catchall_0
:try_start_3
invoke-virtual {p1}, Ljava/io/FileInputStream;->close()V
:try_end_3
.catch Ljava/lang/Throwable; {:try_start_3 .. :try_end_3} :catch_2
.catchall {:try_start_3 .. :try_end_3} :catchall_2
if-eqz p0, :cond_2
:try_start_4
invoke-virtual {p0}, Landroid/os/ParcelFileDescriptor;->close()V
:try_end_4
.catch Ljava/io/IOException; {:try_start_4 .. :try_end_4} :catch_4
:cond_2
return-object p2
:catchall_0
move-exception p2
move-object v1, v0
goto :goto_0
:catch_0
move-exception p2
:try_start_5
throw p2
:try_end_5
.catchall {:try_start_5 .. :try_end_5} :catchall_1
:catchall_1
move-exception v1
move-object v7, v1
move-object v1, p2
move-object p2, v7
:goto_0
if-eqz v1, :cond_3
:try_start_6
invoke-virtual {p1}, Ljava/io/FileInputStream;->close()V
:try_end_6
.catch Ljava/lang/Throwable; {:try_start_6 .. :try_end_6} :catch_1
.catchall {:try_start_6 .. :try_end_6} :catchall_2
goto :goto_1
:cond_3
:try_start_7
invoke-virtual {p1}, Ljava/io/FileInputStream;->close()V
:catch_1
:goto_1
throw p2
:try_end_7
.catch Ljava/lang/Throwable; {:try_start_7 .. :try_end_7} :catch_2
.catchall {:try_start_7 .. :try_end_7} :catchall_2
:catchall_2
move-exception p1
move-object p2, v0
goto :goto_2
:catch_2
move-exception p1
:try_start_8
throw p1
:try_end_8
.catchall {:try_start_8 .. :try_end_8} :catchall_3
:catchall_3
move-exception p2
move-object v7, p2
move-object p2, p1
move-object p1, v7
:goto_2
if-eqz p0, :cond_5
if-eqz p2, :cond_4
:try_start_9
invoke-virtual {p0}, Landroid/os/ParcelFileDescriptor;->close()V
:try_end_9
.catch Ljava/lang/Throwable; {:try_start_9 .. :try_end_9} :catch_3
.catch Ljava/io/IOException; {:try_start_9 .. :try_end_9} :catch_4
goto :goto_3
:cond_4
:try_start_a
invoke-virtual {p0}, Landroid/os/ParcelFileDescriptor;->close()V
:catch_3
:cond_5
:goto_3
throw p1
:try_end_a
.catch Ljava/io/IOException; {:try_start_a .. :try_end_a} :catch_4
:catch_4
return-object v0
.end method
.method private static mmap(Ljava/io/File;)Ljava/nio/ByteBuffer;
.locals 9
.annotation build Landroidx/annotation/Nullable;
.end annotation
.annotation build Landroidx/annotation/RequiresApi;
value = 0x13
.end annotation
const/4 v0, 0x0
:try_start_0
new-instance v1, Ljava/io/FileInputStream;
invoke-direct {v1, p0}, Ljava/io/FileInputStream;-><init>(Ljava/io/File;)V
:try_end_0
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_2
:try_start_1
invoke-virtual {v1}, Ljava/io/FileInputStream;->getChannel()Ljava/nio/channels/FileChannel;
move-result-object v2
invoke-virtual {v2}, Ljava/nio/channels/FileChannel;->size()J
move-result-wide v6
sget-object v3, Ljava/nio/channels/FileChannel$MapMode;->READ_ONLY:Ljava/nio/channels/FileChannel$MapMode;
const-wide/16 v4, 0x0
invoke-virtual/range {v2 .. v7}, Ljava/nio/channels/FileChannel;->map(Ljava/nio/channels/FileChannel$MapMode;JJ)Ljava/nio/MappedByteBuffer;
move-result-object p0
:try_end_1
.catch Ljava/lang/Throwable; {:try_start_1 .. :try_end_1} :catch_0
.catchall {:try_start_1 .. :try_end_1} :catchall_0
:try_start_2
invoke-virtual {v1}, Ljava/io/FileInputStream;->close()V
:try_end_2
.catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_2
return-object p0
:catchall_0
move-exception p0
move-object v2, v0
goto :goto_0
:catch_0
move-exception p0
:try_start_3
throw p0
:try_end_3
.catchall {:try_start_3 .. :try_end_3} :catchall_1
:catchall_1
move-exception v2
move-object v8, v2
move-object v2, p0
move-object p0, v8
:goto_0
if-eqz v2, :cond_0
:try_start_4
invoke-virtual {v1}, Ljava/io/FileInputStream;->close()V
:try_end_4
.catch Ljava/lang/Throwable; {:try_start_4 .. :try_end_4} :catch_1
.catch Ljava/io/IOException; {:try_start_4 .. :try_end_4} :catch_2
goto :goto_1
:cond_0
:try_start_5
invoke-virtual {v1}, Ljava/io/FileInputStream;->close()V
:catch_1
:goto_1
throw p0
:try_end_5
.catch Ljava/io/IOException; {:try_start_5 .. :try_end_5} :catch_2
:catch_2
return-object v0
.end method