what-the-bank/sources/com/google/firebase/installations/CrossProcessLock.java

64 lines
2.1 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.google.firebase.installations;
import android.content.Context;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
import java.nio.channels.OverlappingFileLockException;
/* loaded from: classes2.dex */
class CrossProcessLock {
private final FileChannel channel;
private final FileLock lock;
private CrossProcessLock(FileChannel fileChannel, FileLock fileLock) {
this.channel = fileChannel;
this.lock = fileLock;
}
/* JADX INFO: Access modifiers changed from: package-private */
public static CrossProcessLock acquire(Context context, String str) {
FileChannel fileChannel;
FileLock fileLock;
try {
fileChannel = new RandomAccessFile(new File(context.getFilesDir(), str), "rw").getChannel();
try {
fileLock = fileChannel.lock();
try {
return new CrossProcessLock(fileChannel, fileLock);
} catch (IOException | Error | OverlappingFileLockException unused) {
if (fileLock != null) {
try {
fileLock.release();
} catch (IOException unused2) {
}
}
if (fileChannel != null) {
try {
fileChannel.close();
} catch (IOException unused3) {
}
}
return null;
}
} catch (IOException | Error | OverlappingFileLockException unused4) {
fileLock = null;
}
} catch (IOException | Error | OverlappingFileLockException unused5) {
fileChannel = null;
fileLock = null;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public void releaseAndClose() {
try {
this.lock.release();
this.channel.close();
} catch (IOException unused) {
}
}
}