apkfuckery/com.discord/smali/androidx/browser/browseractions/BrowserServiceFileProvider$FileCleanupTask.smali
2020-07-08 16:44:49 +00:00

345 lines
8.8 KiB
Smali

.class public Landroidx/browser/browseractions/BrowserServiceFileProvider$FileCleanupTask;
.super Landroid/os/AsyncTask;
.source "BrowserServiceFileProvider.java"
# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
value = Landroidx/browser/browseractions/BrowserServiceFileProvider;
.end annotation
.annotation system Ldalvik/annotation/InnerClass;
accessFlags = 0x9
name = "FileCleanupTask"
.end annotation
.annotation system Ldalvik/annotation/Signature;
value = {
"Landroid/os/AsyncTask<",
"Ljava/lang/Void;",
"Ljava/lang/Void;",
"Ljava/lang/Void;",
">;"
}
.end annotation
# static fields
.field public static final CLEANUP_REQUIRED_TIME_SPAN:J
.field public static final DELETION_FAILED_REATTEMPT_DURATION:J
.field public static final IMAGE_RETENTION_DURATION:J
# instance fields
.field public final mAppContext:Landroid/content/Context;
# direct methods
.method public static constructor <clinit>()V
.locals 5
sget-object v0, Ljava/util/concurrent/TimeUnit;->DAYS:Ljava/util/concurrent/TimeUnit;
const-wide/16 v1, 0x7
invoke-virtual {v0, v1, v2}, Ljava/util/concurrent/TimeUnit;->toMillis(J)J
move-result-wide v3
sput-wide v3, Landroidx/browser/browseractions/BrowserServiceFileProvider$FileCleanupTask;->IMAGE_RETENTION_DURATION:J
sget-object v0, Ljava/util/concurrent/TimeUnit;->DAYS:Ljava/util/concurrent/TimeUnit;
invoke-virtual {v0, v1, v2}, Ljava/util/concurrent/TimeUnit;->toMillis(J)J
move-result-wide v0
sput-wide v0, Landroidx/browser/browseractions/BrowserServiceFileProvider$FileCleanupTask;->CLEANUP_REQUIRED_TIME_SPAN:J
sget-object v0, Ljava/util/concurrent/TimeUnit;->DAYS:Ljava/util/concurrent/TimeUnit;
const-wide/16 v1, 0x1
invoke-virtual {v0, v1, v2}, Ljava/util/concurrent/TimeUnit;->toMillis(J)J
move-result-wide v0
sput-wide v0, Landroidx/browser/browseractions/BrowserServiceFileProvider$FileCleanupTask;->DELETION_FAILED_REATTEMPT_DURATION:J
return-void
.end method
.method public constructor <init>(Landroid/content/Context;)V
.locals 0
invoke-direct {p0}, Landroid/os/AsyncTask;-><init>()V
invoke-virtual {p1}, Landroid/content/Context;->getApplicationContext()Landroid/content/Context;
move-result-object p1
iput-object p1, p0, Landroidx/browser/browseractions/BrowserServiceFileProvider$FileCleanupTask;->mAppContext:Landroid/content/Context;
return-void
.end method
.method public static isImageFile(Ljava/io/File;)Z
.locals 1
invoke-virtual {p0}, Ljava/io/File;->getName()Ljava/lang/String;
move-result-object p0
const-string v0, "..png"
invoke-virtual {p0, v0}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z
move-result p0
return p0
.end method
.method public static shouldCleanUp(Landroid/content/SharedPreferences;)Z
.locals 6
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v0
const-string v2, "last_cleanup_time"
invoke-interface {p0, v2, v0, v1}, Landroid/content/SharedPreferences;->getLong(Ljava/lang/String;J)J
move-result-wide v0
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v2
sget-wide v4, Landroidx/browser/browseractions/BrowserServiceFileProvider$FileCleanupTask;->CLEANUP_REQUIRED_TIME_SPAN:J
add-long/2addr v0, v4
cmp-long p0, v2, v0
if-lez p0, :cond_0
const/4 p0, 0x1
goto :goto_0
:cond_0
const/4 p0, 0x0
:goto_0
return p0
.end method
# virtual methods
.method public bridge synthetic doInBackground([Ljava/lang/Object;)Ljava/lang/Object;
.locals 0
check-cast p1, [Ljava/lang/Void;
invoke-virtual {p0, p1}, Landroidx/browser/browseractions/BrowserServiceFileProvider$FileCleanupTask;->doInBackground([Ljava/lang/Void;)Ljava/lang/Void;
move-result-object p1
return-object p1
.end method
.method public varargs doInBackground([Ljava/lang/Void;)Ljava/lang/Void;
.locals 13
iget-object p1, p0, Landroidx/browser/browseractions/BrowserServiceFileProvider$FileCleanupTask;->mAppContext:Landroid/content/Context;
new-instance v0, Ljava/lang/StringBuilder;
invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
iget-object v1, p0, Landroidx/browser/browseractions/BrowserServiceFileProvider$FileCleanupTask;->mAppContext:Landroid/content/Context;
invoke-virtual {v1}, Landroid/content/Context;->getPackageName()Ljava/lang/String;
move-result-object v1
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
const-string v1, ".image_provider"
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
invoke-virtual {p1, v0, v1}, Landroid/content/Context;->getSharedPreferences(Ljava/lang/String;I)Landroid/content/SharedPreferences;
move-result-object p1
invoke-static {p1}, Landroidx/browser/browseractions/BrowserServiceFileProvider$FileCleanupTask;->shouldCleanUp(Landroid/content/SharedPreferences;)Z
move-result v0
const/4 v2, 0x0
if-nez v0, :cond_0
return-object v2
:cond_0
sget-object v0, Landroidx/browser/browseractions/BrowserServiceFileProvider;->sFileCleanupLock:Ljava/lang/Object;
monitor-enter v0
:try_start_0
new-instance v3, Ljava/io/File;
iget-object v4, p0, Landroidx/browser/browseractions/BrowserServiceFileProvider$FileCleanupTask;->mAppContext:Landroid/content/Context;
invoke-virtual {v4}, Landroid/content/Context;->getFilesDir()Ljava/io/File;
move-result-object v4
const-string v5, "image_provider"
invoke-direct {v3, v4, v5}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V
invoke-virtual {v3}, Ljava/io/File;->exists()Z
move-result v4
if-nez v4, :cond_1
monitor-exit v0
return-object v2
:cond_1
invoke-virtual {v3}, Ljava/io/File;->listFiles()[Ljava/io/File;
move-result-object v3
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v4
sget-wide v6, Landroidx/browser/browseractions/BrowserServiceFileProvider$FileCleanupTask;->IMAGE_RETENTION_DURATION:J
sub-long/2addr v4, v6
array-length v6, v3
const/4 v7, 0x1
const/4 v8, 0x0
:goto_0
if-ge v8, v6, :cond_4
aget-object v9, v3, v8
invoke-static {v9}, Landroidx/browser/browseractions/BrowserServiceFileProvider$FileCleanupTask;->isImageFile(Ljava/io/File;)Z
move-result v10
if-nez v10, :cond_2
goto :goto_1
:cond_2
invoke-virtual {v9}, Ljava/io/File;->lastModified()J
move-result-wide v10
cmp-long v12, v10, v4
if-gez v12, :cond_3
invoke-virtual {v9}, Ljava/io/File;->delete()Z
move-result v10
if-nez v10, :cond_3
const-string v7, "BrowserServiceFP"
new-instance v10, Ljava/lang/StringBuilder;
invoke-direct {v10}, Ljava/lang/StringBuilder;-><init>()V
const-string v11, "Fail to delete image: "
invoke-virtual {v10, v11}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v9}, Ljava/io/File;->getAbsoluteFile()Ljava/io/File;
move-result-object v9
invoke-virtual {v10, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
invoke-virtual {v10}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v9
invoke-static {v7, v9}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I
const/4 v7, 0x0
:cond_3
:goto_1
add-int/lit8 v8, v8, 0x1
goto :goto_0
:cond_4
if-eqz v7, :cond_5
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v3
goto :goto_2
:cond_5
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v3
sget-wide v5, Landroidx/browser/browseractions/BrowserServiceFileProvider$FileCleanupTask;->CLEANUP_REQUIRED_TIME_SPAN:J
sub-long/2addr v3, v5
sget-wide v5, Landroidx/browser/browseractions/BrowserServiceFileProvider$FileCleanupTask;->DELETION_FAILED_REATTEMPT_DURATION:J
add-long/2addr v3, v5
:goto_2
invoke-interface {p1}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor;
move-result-object p1
const-string v1, "last_cleanup_time"
invoke-interface {p1, v1, v3, v4}, Landroid/content/SharedPreferences$Editor;->putLong(Ljava/lang/String;J)Landroid/content/SharedPreferences$Editor;
invoke-interface {p1}, Landroid/content/SharedPreferences$Editor;->apply()V
monitor-exit v0
return-object v2
:catchall_0
move-exception p1
monitor-exit v0
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
throw p1
.end method