package defpackage;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
import java.util.HashMap;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/* JADX INFO: renamed from: ˊᵴʿ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C1410 {

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public static final HashMap f5813 = new HashMap();

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final File f5814;

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final Lock f5815;

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final boolean f5816;

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public FileChannel f5817;

    public C1410(String str, File file, boolean z) {
        Lock lock;
        this.f5816 = z;
        this.f5814 = file != null ? new File(file, str.concat(".lck")) : null;
        HashMap map = f5813;
        synchronized (map) {
            try {
                Object reentrantLock = map.get(str);
                if (reentrantLock == null) {
                    reentrantLock = new ReentrantLock();
                    map.put(str, reentrantLock);
                }
                lock = (Lock) reentrantLock;
            } catch (Throwable th) {
                throw th;
            }
        }
        this.f5815 = lock;
    }

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final void m4077() {
        try {
            FileChannel fileChannel = this.f5817;
            if (fileChannel != null) {
                fileChannel.close();
            }
        } catch (IOException unused) {
        }
        this.f5815.unlock();
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final void m4078(boolean z) {
        this.f5815.lock();
        if (z) {
            File file = this.f5814;
            try {
                if (file == null) {
                    throw new IOException("No lock directory was provided.");
                }
                File parentFile = file.getParentFile();
                if (parentFile != null) {
                    parentFile.mkdirs();
                }
                FileChannel channel = new FileOutputStream(file).getChannel();
                channel.lock();
                this.f5817 = channel;
            } catch (IOException unused) {
                this.f5817 = null;
            }
        }
    }
}
