364 lines
9.1 KiB
Smali
364 lines
9.1 KiB
Smali
.class public final Lco/discord/media_engine/internal/AssetManagement;
|
|
.super Ljava/lang/Object;
|
|
.source "AssetManagement.kt"
|
|
|
|
|
|
# instance fields
|
|
.field public final ctx:Landroid/content/Context;
|
|
|
|
|
|
# direct methods
|
|
.method public constructor <init>(Landroid/content/Context;)V
|
|
.locals 0
|
|
|
|
if-eqz p1, :cond_0
|
|
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
iput-object p1, p0, Lco/discord/media_engine/internal/AssetManagement;->ctx:Landroid/content/Context;
|
|
|
|
return-void
|
|
|
|
:cond_0
|
|
const-string p1, "ctx"
|
|
|
|
invoke-static {p1}, Lj0/n/c/h;->c(Ljava/lang/String;)V
|
|
|
|
const/4 p1, 0x0
|
|
|
|
throw p1
|
|
.end method
|
|
|
|
.method private final cleanup()V
|
|
.locals 4
|
|
|
|
:try_start_0
|
|
new-instance v0, Ljava/io/File;
|
|
|
|
iget-object v1, p0, Lco/discord/media_engine/internal/AssetManagement;->ctx:Landroid/content/Context;
|
|
|
|
invoke-virtual {v1}, Landroid/content/Context;->getFilesDir()Ljava/io/File;
|
|
|
|
move-result-object v1
|
|
|
|
const-string v2, "thz"
|
|
|
|
invoke-direct {v0, v1, v2}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V
|
|
|
|
invoke-virtual {v0}, Ljava/io/File;->exists()Z
|
|
|
|
move-result v1
|
|
|
|
if-eqz v1, :cond_2
|
|
|
|
sget-object v1, Lj0/m/b;->e:Lj0/m/b;
|
|
|
|
new-instance v2, Lj0/m/a;
|
|
|
|
invoke-direct {v2, v0, v1}, Lj0/m/a;-><init>(Ljava/io/File;Lj0/m/b;)V
|
|
|
|
invoke-virtual {v2}, Lj0/m/a;->iterator()Ljava/util/Iterator;
|
|
|
|
move-result-object v0
|
|
|
|
:goto_0
|
|
const/4 v1, 0x1
|
|
|
|
:goto_1
|
|
invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z
|
|
|
|
move-result v2
|
|
|
|
if-eqz v2, :cond_2
|
|
|
|
invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;
|
|
|
|
move-result-object v2
|
|
|
|
check-cast v2, Ljava/io/File;
|
|
|
|
invoke-virtual {v2}, Ljava/io/File;->delete()Z
|
|
|
|
move-result v3
|
|
|
|
if-nez v3, :cond_0
|
|
|
|
invoke-virtual {v2}, Ljava/io/File;->exists()Z
|
|
|
|
move-result v2
|
|
:try_end_0
|
|
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
|
|
|
|
if-nez v2, :cond_1
|
|
|
|
:cond_0
|
|
if-eqz v1, :cond_1
|
|
|
|
goto :goto_0
|
|
|
|
:cond_1
|
|
const/4 v1, 0x0
|
|
|
|
goto :goto_1
|
|
|
|
:catch_0
|
|
move-exception v0
|
|
|
|
const-string v1, "Failed removing krisp model files: "
|
|
|
|
invoke-static {v1}, Lf/e/b/a/a;->D(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
move-result-object v1
|
|
|
|
invoke-virtual {v0}, Ljava/lang/Exception;->getMessage()Ljava/lang/String;
|
|
|
|
move-result-object v2
|
|
|
|
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
const-string v2, ": "
|
|
|
|
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v0}, Ljava/lang/Exception;->toString()Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-virtual {v1, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
const-string v1, "DiscordKrisp"
|
|
|
|
invoke-static {v1, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I
|
|
|
|
:cond_2
|
|
return-void
|
|
.end method
|
|
|
|
.method private final copy(Ljava/io/File;Ljava/lang/String;)V
|
|
.locals 3
|
|
|
|
iget-object v0, p0, Lco/discord/media_engine/internal/AssetManagement;->ctx:Landroid/content/Context;
|
|
|
|
invoke-virtual {v0}, Landroid/content/Context;->getAssets()Landroid/content/res/AssetManager;
|
|
|
|
move-result-object v0
|
|
|
|
new-instance v1, Ljava/lang/StringBuilder;
|
|
|
|
invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
|
|
|
|
const-string v2, "thz/"
|
|
|
|
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v1, p2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
move-result-object v1
|
|
|
|
invoke-virtual {v0, v1}, Landroid/content/res/AssetManager;->open(Ljava/lang/String;)Ljava/io/InputStream;
|
|
|
|
move-result-object v0
|
|
|
|
const-string v1, "ctx.assets.open(\"thz/\" + name)"
|
|
|
|
invoke-static {v0, v1}, Lj0/n/c/h;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
new-instance v1, Ljava/io/FileOutputStream;
|
|
|
|
new-instance v2, Ljava/io/File;
|
|
|
|
invoke-direct {v2, p1, p2}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V
|
|
|
|
invoke-direct {v1, v2}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;)V
|
|
|
|
const/16 p1, 0x400
|
|
|
|
new-array p1, p1, [B
|
|
|
|
invoke-virtual {v0, p1}, Ljava/io/InputStream;->read([B)I
|
|
|
|
move-result p2
|
|
|
|
:goto_0
|
|
if-ltz p2, :cond_0
|
|
|
|
const/4 v2, 0x0
|
|
|
|
invoke-virtual {v1, p1, v2, p2}, Ljava/io/OutputStream;->write([BII)V
|
|
|
|
invoke-virtual {v0, p1}, Ljava/io/InputStream;->read([B)I
|
|
|
|
move-result p2
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
invoke-virtual {v0}, Ljava/io/InputStream;->close()V
|
|
|
|
invoke-virtual {v1}, Ljava/io/FileOutputStream;->close()V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
|
|
# virtual methods
|
|
.method public final ensureKrispModelsCopied(Z)V
|
|
.locals 5
|
|
|
|
const-string v0, "thz"
|
|
|
|
if-eqz p1, :cond_2
|
|
|
|
:try_start_0
|
|
new-instance p1, Ljava/io/File;
|
|
|
|
iget-object v1, p0, Lco/discord/media_engine/internal/AssetManagement;->ctx:Landroid/content/Context;
|
|
|
|
invoke-virtual {v1}, Landroid/content/Context;->getFilesDir()Ljava/io/File;
|
|
|
|
move-result-object v1
|
|
|
|
invoke-direct {p1, v1, v0}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V
|
|
|
|
iget-object v1, p0, Lco/discord/media_engine/internal/AssetManagement;->ctx:Landroid/content/Context;
|
|
|
|
sget v2, Lcom/hammerandchisel/libdiscord/R$string;->krisp_model_version:I
|
|
|
|
invoke-virtual {v1, v2}, Landroid/content/Context;->getString(I)Ljava/lang/String;
|
|
|
|
move-result-object v1
|
|
|
|
const-string v2, "ctx.getString(R.string.krisp_model_version)"
|
|
|
|
invoke-static {v1, v2}, Lj0/n/c/h;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
new-instance v2, Ljava/io/File;
|
|
|
|
invoke-direct {v2, p1, v1}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V
|
|
|
|
invoke-virtual {v2}, Ljava/io/File;->exists()Z
|
|
|
|
move-result p1
|
|
|
|
if-eqz p1, :cond_0
|
|
|
|
return-void
|
|
|
|
:cond_0
|
|
invoke-direct {p0}, Lco/discord/media_engine/internal/AssetManagement;->cleanup()V
|
|
|
|
new-instance p1, Ljava/io/File;
|
|
|
|
iget-object v2, p0, Lco/discord/media_engine/internal/AssetManagement;->ctx:Landroid/content/Context;
|
|
|
|
invoke-virtual {v2}, Landroid/content/Context;->getFilesDir()Ljava/io/File;
|
|
|
|
move-result-object v2
|
|
|
|
invoke-direct {p1, v2, v0}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V
|
|
|
|
invoke-virtual {p1}, Ljava/io/File;->mkdir()Z
|
|
|
|
new-instance v2, Ljava/io/File;
|
|
|
|
invoke-direct {v2, p1, v1}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V
|
|
|
|
invoke-virtual {v2}, Ljava/io/File;->mkdir()Z
|
|
|
|
iget-object p1, p0, Lco/discord/media_engine/internal/AssetManagement;->ctx:Landroid/content/Context;
|
|
|
|
invoke-virtual {p1}, Landroid/content/Context;->getAssets()Landroid/content/res/AssetManager;
|
|
|
|
move-result-object p1
|
|
|
|
invoke-virtual {p1, v0}, Landroid/content/res/AssetManager;->list(Ljava/lang/String;)[Ljava/lang/String;
|
|
|
|
move-result-object p1
|
|
|
|
const/4 v0, 0x0
|
|
|
|
if-eqz p1, :cond_1
|
|
|
|
goto :goto_0
|
|
|
|
:cond_1
|
|
new-array p1, v0, [Ljava/lang/String;
|
|
|
|
:goto_0
|
|
array-length v1, p1
|
|
|
|
:goto_1
|
|
if-ge v0, v1, :cond_3
|
|
|
|
aget-object v3, p1, v0
|
|
|
|
const-string v4, "file"
|
|
|
|
invoke-static {v3, v4}, Lj0/n/c/h;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
invoke-direct {p0, v2, v3}, Lco/discord/media_engine/internal/AssetManagement;->copy(Ljava/io/File;Ljava/lang/String;)V
|
|
:try_end_0
|
|
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
|
|
|
|
add-int/lit8 v0, v0, 0x1
|
|
|
|
goto :goto_1
|
|
|
|
:catch_0
|
|
move-exception p1
|
|
|
|
const-string v0, "Failed copying krisp model files: "
|
|
|
|
invoke-static {v0}, Lf/e/b/a/a;->D(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-virtual {p1}, Ljava/lang/Exception;->getMessage()Ljava/lang/String;
|
|
|
|
move-result-object v1
|
|
|
|
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
const-string v1, ": "
|
|
|
|
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {p1}, Ljava/lang/Exception;->toString()Ljava/lang/String;
|
|
|
|
move-result-object p1
|
|
|
|
invoke-virtual {v0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
move-result-object p1
|
|
|
|
const-string v0, "DiscordKrisp"
|
|
|
|
invoke-static {v0, p1}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I
|
|
|
|
invoke-direct {p0}, Lco/discord/media_engine/internal/AssetManagement;->cleanup()V
|
|
|
|
goto :goto_2
|
|
|
|
:cond_2
|
|
invoke-direct {p0}, Lco/discord/media_engine/internal/AssetManagement;->cleanup()V
|
|
|
|
:cond_3
|
|
:goto_2
|
|
return-void
|
|
.end method
|
|
|
|
.method public final getCtx()Landroid/content/Context;
|
|
.locals 1
|
|
|
|
iget-object v0, p0, Lco/discord/media_engine/internal/AssetManagement;->ctx:Landroid/content/Context;
|
|
|
|
return-object v0
|
|
.end method
|