199 lines
4.9 KiB
Smali
199 lines
4.9 KiB
Smali
.class Lcom/google/firebase/installations/CrossProcessLock;
|
|
.super Ljava/lang/Object;
|
|
.source "CrossProcessLock.java"
|
|
|
|
|
|
# static fields
|
|
.field private static final TAG:Ljava/lang/String; = "CrossProcessLock"
|
|
|
|
|
|
# instance fields
|
|
.field private final channel:Ljava/nio/channels/FileChannel;
|
|
|
|
.field private final lock:Ljava/nio/channels/FileLock;
|
|
|
|
|
|
# direct methods
|
|
.method private constructor <init>(Ljava/nio/channels/FileChannel;Ljava/nio/channels/FileLock;)V
|
|
.locals 0
|
|
|
|
.line 1
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
.line 2
|
|
iput-object p1, p0, Lcom/google/firebase/installations/CrossProcessLock;->channel:Ljava/nio/channels/FileChannel;
|
|
|
|
.line 3
|
|
iput-object p2, p0, Lcom/google/firebase/installations/CrossProcessLock;->lock:Ljava/nio/channels/FileLock;
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public static acquire(Landroid/content/Context;Ljava/lang/String;)Lcom/google/firebase/installations/CrossProcessLock;
|
|
.locals 4
|
|
|
|
const/4 v0, 0x0
|
|
|
|
.line 1
|
|
:try_start_0
|
|
new-instance v1, Ljava/io/File;
|
|
|
|
invoke-virtual {p0}, Landroid/content/Context;->getFilesDir()Ljava/io/File;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-direct {v1, p0, p1}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V
|
|
|
|
.line 2
|
|
new-instance p0, Ljava/io/RandomAccessFile;
|
|
|
|
const-string p1, "rw"
|
|
|
|
invoke-direct {p0, v1, p1}, Ljava/io/RandomAccessFile;-><init>(Ljava/io/File;Ljava/lang/String;)V
|
|
|
|
invoke-virtual {p0}, Ljava/io/RandomAccessFile;->getChannel()Ljava/nio/channels/FileChannel;
|
|
|
|
move-result-object p0
|
|
:try_end_0
|
|
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_8
|
|
.catch Ljava/lang/Error; {:try_start_0 .. :try_end_0} :catch_7
|
|
.catch Ljava/nio/channels/OverlappingFileLockException; {:try_start_0 .. :try_end_0} :catch_6
|
|
|
|
.line 3
|
|
:try_start_1
|
|
invoke-virtual {p0}, Ljava/nio/channels/FileChannel;->lock()Ljava/nio/channels/FileLock;
|
|
|
|
move-result-object p1
|
|
:try_end_1
|
|
.catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_5
|
|
.catch Ljava/lang/Error; {:try_start_1 .. :try_end_1} :catch_4
|
|
.catch Ljava/nio/channels/OverlappingFileLockException; {:try_start_1 .. :try_end_1} :catch_3
|
|
|
|
.line 4
|
|
:try_start_2
|
|
new-instance v1, Lcom/google/firebase/installations/CrossProcessLock;
|
|
|
|
invoke-direct {v1, p0, p1}, Lcom/google/firebase/installations/CrossProcessLock;-><init>(Ljava/nio/channels/FileChannel;Ljava/nio/channels/FileLock;)V
|
|
:try_end_2
|
|
.catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_2
|
|
.catch Ljava/lang/Error; {:try_start_2 .. :try_end_2} :catch_1
|
|
.catch Ljava/nio/channels/OverlappingFileLockException; {:try_start_2 .. :try_end_2} :catch_0
|
|
|
|
return-object v1
|
|
|
|
:catch_0
|
|
move-exception v1
|
|
|
|
goto :goto_2
|
|
|
|
:catch_1
|
|
move-exception v1
|
|
|
|
goto :goto_2
|
|
|
|
:catch_2
|
|
move-exception v1
|
|
|
|
goto :goto_2
|
|
|
|
:catch_3
|
|
move-exception v1
|
|
|
|
goto :goto_0
|
|
|
|
:catch_4
|
|
move-exception v1
|
|
|
|
goto :goto_0
|
|
|
|
:catch_5
|
|
move-exception v1
|
|
|
|
:goto_0
|
|
move-object p1, v0
|
|
|
|
goto :goto_2
|
|
|
|
:catch_6
|
|
move-exception v1
|
|
|
|
goto :goto_1
|
|
|
|
:catch_7
|
|
move-exception v1
|
|
|
|
goto :goto_1
|
|
|
|
:catch_8
|
|
move-exception v1
|
|
|
|
:goto_1
|
|
move-object p0, v0
|
|
|
|
move-object p1, p0
|
|
|
|
:goto_2
|
|
const-string v2, "CrossProcessLock"
|
|
|
|
const-string v3, "encountered error while creating and acquiring the lock, ignoring"
|
|
|
|
.line 5
|
|
invoke-static {v2, v3, v1}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
|
|
|
|
if-eqz p1, :cond_0
|
|
|
|
.line 6
|
|
:try_start_3
|
|
invoke-virtual {p1}, Ljava/nio/channels/FileLock;->release()V
|
|
:try_end_3
|
|
.catch Ljava/io/IOException; {:try_start_3 .. :try_end_3} :catch_9
|
|
|
|
:catch_9
|
|
:cond_0
|
|
if-eqz p0, :cond_1
|
|
|
|
.line 7
|
|
:try_start_4
|
|
invoke-virtual {p0}, Ljava/nio/channels/FileChannel;->close()V
|
|
:try_end_4
|
|
.catch Ljava/io/IOException; {:try_start_4 .. :try_end_4} :catch_a
|
|
|
|
:catch_a
|
|
:cond_1
|
|
return-object v0
|
|
.end method
|
|
|
|
|
|
# virtual methods
|
|
.method public releaseAndClose()V
|
|
.locals 3
|
|
|
|
.line 1
|
|
:try_start_0
|
|
iget-object v0, p0, Lcom/google/firebase/installations/CrossProcessLock;->lock:Ljava/nio/channels/FileLock;
|
|
|
|
invoke-virtual {v0}, Ljava/nio/channels/FileLock;->release()V
|
|
|
|
.line 2
|
|
iget-object v0, p0, Lcom/google/firebase/installations/CrossProcessLock;->channel:Ljava/nio/channels/FileChannel;
|
|
|
|
invoke-virtual {v0}, Ljava/nio/channels/FileChannel;->close()V
|
|
:try_end_0
|
|
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
|
|
|
|
goto :goto_0
|
|
|
|
:catch_0
|
|
move-exception v0
|
|
|
|
const-string v1, "CrossProcessLock"
|
|
|
|
const-string v2, "encountered error while releasing, ignoring"
|
|
|
|
.line 3
|
|
invoke-static {v1, v2, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
|
|
|
|
:goto_0
|
|
return-void
|
|
.end method
|