package p138.p176.p291.p323;

import android.content.Context;
import android.util.Log;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;

/* JADX INFO: renamed from: ދ.ހ.ށ.ފ.ؠ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public class C5966 {

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final FileChannel f16796;

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final FileLock f16797;

    public C5966(FileChannel fileChannel, FileLock fileLock) {
        this.f16796 = fileChannel;
        this.f16797 = fileLock;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static C5966 m9293(Context context, String str) {
        FileChannel channel;
        FileLock fileLockLock;
        try {
            channel = new RandomAccessFile(new File(context.getFilesDir(), str), "rw").getChannel();
            try {
                fileLockLock = channel.lock();
            } catch (IOException e) {
                e = e;
                fileLockLock = null;
            }
        } catch (IOException e2) {
            e = e2;
            channel = null;
            fileLockLock = null;
        }
        try {
            return new C5966(channel, fileLockLock);
        } catch (IOException e3) {
            e = e3;
            Log.e("CrossProcessLock", "encountered error while creating and acquiring the lock, ignoring", e);
            if (fileLockLock != null) {
                try {
                    fileLockLock.release();
                } catch (IOException unused) {
                }
            }
            if (channel != null) {
                try {
                    channel.close();
                } catch (IOException unused2) {
                }
            }
            return null;
        }
    }
}
