package o0; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.nio.channels.FileChannel; import java.util.HashMap; import java.util.Map; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; /* loaded from: classes.dex */ public class a { /* renamed from: e, reason: collision with root package name */ private static final Map f12594e = new HashMap(); /* renamed from: a, reason: collision with root package name */ private final File f12595a; /* renamed from: b, reason: collision with root package name */ private final Lock f12596b; /* renamed from: c, reason: collision with root package name */ private final boolean f12597c; /* renamed from: d, reason: collision with root package name */ private FileChannel f12598d; public a(String str, File file, boolean z10) { File file2 = new File(file, str + ".lck"); this.f12595a = file2; this.f12596b = a(file2.getAbsolutePath()); this.f12597c = z10; } private static Lock a(String str) { Lock lock; Map map = f12594e; synchronized (map) { lock = (Lock) map.get(str); if (lock == null) { lock = new ReentrantLock(); map.put(str, lock); } } return lock; } public void b() { this.f12596b.lock(); if (this.f12597c) { try { FileChannel channel = new FileOutputStream(this.f12595a).getChannel(); this.f12598d = channel; channel.lock(); } catch (IOException e10) { throw new IllegalStateException("Unable to grab copy lock.", e10); } } } public void c() { FileChannel fileChannel = this.f12598d; if (fileChannel != null) { try { fileChannel.close(); } catch (IOException unused) { } } this.f12596b.unlock(); } }