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

515 lines
13 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_PREFIX:Landroidx/annotation/RestrictTo$Scope;
}
.end annotation
# static fields
.field public static final CACHE_FILE_PREFIX:Ljava/lang/String; = ".font"
.field public static final TAG:Ljava/lang/String; = "TypefaceCompatUtil"
# direct methods
.method public 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
const/4 p0, 0x1
invoke-static {v3}, Landroidx/core/graphics/TypefaceCompatUtil;->closeQuietly(Ljava/io/Closeable;)V
invoke-static {v0}, Landroid/os/StrictMode;->setThreadPolicy(Landroid/os/StrictMode$ThreadPolicy;)V
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;
invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V
const-string v4, "Error copying resource contents to temp file: "
invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
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
throw p0
.end method
.method public static getTempFile(Landroid/content/Context;)Ljava/io/File;
.locals 5
.annotation build Landroidx/annotation/Nullable;
.end annotation
invoke-virtual {p0}, Landroid/content/Context;->getCacheDir()Ljava/io/File;
move-result-object p0
const/4 v0, 0x0
if-nez p0, :cond_0
return-object v0
:cond_0
const-string v1, ".font"
invoke-static {v1}, Lf/e/c/a/a;->F(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v1
invoke-static {}, Landroid/os/Process;->myPid()I
move-result v2
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
const-string v2, "-"
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-static {}, Landroid/os/Process;->myTid()I
move-result v3
invoke-virtual {v1, v3}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v1
const/4 v2, 0x0
:goto_0
const/16 v3, 0x64
if-ge v2, v3, :cond_2
new-instance v3, Ljava/io/File;
invoke-static {v1, v2}, Lf/e/c/a/a;->i(Ljava/lang/String;I)Ljava/lang/String;
move-result-object v4
invoke-direct {v3, p0, v4}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V
:try_start_0
invoke-virtual {v3}, Ljava/io/File;->createNewFile()Z
move-result v4
:try_end_0
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
if-eqz v4, :cond_1
return-object v3
:catch_0
:cond_1
add-int/lit8 v2, v2, 0x1
goto :goto_0
:cond_2
return-object v0
.end method
.method public static mmap(Landroid/content/Context;Landroid/os/CancellationSignal;Landroid/net/Uri;)Ljava/nio/ByteBuffer;
.locals 7
.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_0
: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
.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
.catchall {:try_start_2 .. :try_end_2} :catchall_0
:try_start_3
invoke-virtual {p1}, Ljava/io/FileInputStream;->close()V
:try_end_3
.catchall {:try_start_3 .. :try_end_3} :catchall_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_0
return-object p2
:catchall_0
move-exception p2
:try_start_5
invoke-virtual {p1}, Ljava/io/FileInputStream;->close()V
:try_end_5
.catchall {:try_start_5 .. :try_end_5} :catchall_1
goto :goto_0
:catchall_1
move-exception p1
:try_start_6
invoke-virtual {p2, p1}, Ljava/lang/Throwable;->addSuppressed(Ljava/lang/Throwable;)V
:goto_0
throw p2
:try_end_6
.catchall {:try_start_6 .. :try_end_6} :catchall_2
:catchall_2
move-exception p1
:try_start_7
invoke-virtual {p0}, Landroid/os/ParcelFileDescriptor;->close()V
:try_end_7
.catchall {:try_start_7 .. :try_end_7} :catchall_3
goto :goto_1
:catchall_3
move-exception p0
:try_start_8
invoke-virtual {p1, p0}, Ljava/lang/Throwable;->addSuppressed(Ljava/lang/Throwable;)V
:goto_1
throw p1
:try_end_8
.catch Ljava/io/IOException; {:try_start_8 .. :try_end_8} :catch_0
:catch_0
return-object v0
.end method
.method public static mmap(Ljava/io/File;)Ljava/nio/ByteBuffer;
.locals 7
.annotation build Landroidx/annotation/Nullable;
.end annotation
.annotation build Landroidx/annotation/RequiresApi;
value = 0x13
.end annotation
:try_start_0
new-instance v0, Ljava/io/FileInputStream;
invoke-direct {v0, p0}, Ljava/io/FileInputStream;-><init>(Ljava/io/File;)V
:try_end_0
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
:try_start_1
invoke-virtual {v0}, 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 p0
:try_end_1
.catchall {:try_start_1 .. :try_end_1} :catchall_0
:try_start_2
invoke-virtual {v0}, Ljava/io/FileInputStream;->close()V
:try_end_2
.catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_0
return-object p0
:catchall_0
move-exception p0
:try_start_3
invoke-virtual {v0}, Ljava/io/FileInputStream;->close()V
:try_end_3
.catchall {:try_start_3 .. :try_end_3} :catchall_1
goto :goto_0
:catchall_1
move-exception v0
:try_start_4
invoke-virtual {p0, v0}, Ljava/lang/Throwable;->addSuppressed(Ljava/lang/Throwable;)V
:goto_0
throw p0
:try_end_4
.catch Ljava/io/IOException; {:try_start_4 .. :try_end_4} :catch_0
:catch_0
const/4 p0, 0x0
return-object p0
.end method