apkfuckery/com.discord/smali/androidx/room/util/CopyLock.smali

199 lines
5.2 KiB
Smali
Raw Normal View History

2020-07-08 16:44:49 +00:00
.class public Landroidx/room/util/CopyLock;
.super Ljava/lang/Object;
.source "CopyLock.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 sThreadLocks:Ljava/util/Map;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/util/Map<",
"Ljava/lang/String;",
"Ljava/util/concurrent/locks/Lock;",
">;"
}
.end annotation
.end field
# instance fields
.field public final mCopyLockFile:Ljava/io/File;
.field public final mFileLevelLock:Z
.field public mLockChannel:Ljava/nio/channels/FileChannel;
.field public final mThreadLock:Ljava/util/concurrent/locks/Lock;
# direct methods
.method public static constructor <clinit>()V
.locals 1
new-instance v0, Ljava/util/HashMap;
invoke-direct {v0}, Ljava/util/HashMap;-><init>()V
sput-object v0, Landroidx/room/util/CopyLock;->sThreadLocks:Ljava/util/Map;
return-void
.end method
.method public constructor <init>(Ljava/lang/String;Ljava/io/File;Z)V
.locals 2
.param p1 # Ljava/lang/String;
.annotation build Landroidx/annotation/NonNull;
.end annotation
.end param
.param p2 # Ljava/io/File;
.annotation build Landroidx/annotation/NonNull;
.end annotation
.end param
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
new-instance v0, Ljava/io/File;
const-string v1, ".lck"
invoke-static {p1, v1}, Lf/e/b/a/a;->p(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
move-result-object p1
invoke-direct {v0, p2, p1}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V
iput-object v0, p0, Landroidx/room/util/CopyLock;->mCopyLockFile:Ljava/io/File;
invoke-virtual {v0}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;
move-result-object p1
invoke-static {p1}, Landroidx/room/util/CopyLock;->getThreadLock(Ljava/lang/String;)Ljava/util/concurrent/locks/Lock;
move-result-object p1
iput-object p1, p0, Landroidx/room/util/CopyLock;->mThreadLock:Ljava/util/concurrent/locks/Lock;
iput-boolean p3, p0, Landroidx/room/util/CopyLock;->mFileLevelLock:Z
return-void
.end method
.method public static getThreadLock(Ljava/lang/String;)Ljava/util/concurrent/locks/Lock;
.locals 3
sget-object v0, Landroidx/room/util/CopyLock;->sThreadLocks:Ljava/util/Map;
monitor-enter v0
:try_start_0
sget-object v1, Landroidx/room/util/CopyLock;->sThreadLocks:Ljava/util/Map;
invoke-interface {v1, p0}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object;
move-result-object v1
check-cast v1, Ljava/util/concurrent/locks/Lock;
if-nez v1, :cond_0
new-instance v1, Ljava/util/concurrent/locks/ReentrantLock;
invoke-direct {v1}, Ljava/util/concurrent/locks/ReentrantLock;-><init>()V
sget-object v2, Landroidx/room/util/CopyLock;->sThreadLocks:Ljava/util/Map;
invoke-interface {v2, p0, v1}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
:cond_0
monitor-exit v0
return-object v1
:catchall_0
move-exception p0
monitor-exit v0
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
throw p0
.end method
# virtual methods
.method public lock()V
.locals 3
iget-object v0, p0, Landroidx/room/util/CopyLock;->mThreadLock:Ljava/util/concurrent/locks/Lock;
invoke-interface {v0}, Ljava/util/concurrent/locks/Lock;->lock()V
iget-boolean v0, p0, Landroidx/room/util/CopyLock;->mFileLevelLock:Z
if-eqz v0, :cond_0
:try_start_0
new-instance v0, Ljava/io/FileOutputStream;
iget-object v1, p0, Landroidx/room/util/CopyLock;->mCopyLockFile:Ljava/io/File;
invoke-direct {v0, v1}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;)V
invoke-virtual {v0}, Ljava/io/FileOutputStream;->getChannel()Ljava/nio/channels/FileChannel;
move-result-object v0
iput-object v0, p0, Landroidx/room/util/CopyLock;->mLockChannel:Ljava/nio/channels/FileChannel;
invoke-virtual {v0}, Ljava/nio/channels/FileChannel;->lock()Ljava/nio/channels/FileLock;
:try_end_0
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
goto :goto_0
:catch_0
move-exception v0
new-instance v1, Ljava/lang/IllegalStateException;
const-string v2, "Unable to grab copy lock."
invoke-direct {v1, v2, v0}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V
throw v1
:cond_0
:goto_0
return-void
.end method
.method public unlock()V
.locals 1
iget-object v0, p0, Landroidx/room/util/CopyLock;->mLockChannel:Ljava/nio/channels/FileChannel;
if-eqz v0, :cond_0
:try_start_0
invoke-virtual {v0}, Ljava/nio/channels/FileChannel;->close()V
:try_end_0
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
:catch_0
:cond_0
iget-object v0, p0, Landroidx/room/util/CopyLock;->mThreadLock:Ljava/util/concurrent/locks/Lock;
invoke-interface {v0}, Ljava/util/concurrent/locks/Lock;->unlock()V
return-void
.end method