package androidx.lifecycle;

import java.util.Iterator;
import s0.C1516b;

/* JADX INFO: loaded from: classes.dex */
public abstract class W {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final C1516b f8817a = new C1516b();

    public final void a(String str, AutoCloseable autoCloseable) {
        AutoCloseable autoCloseable2;
        C1516b c1516b = this.f8817a;
        if (c1516b != null) {
            if (c1516b.f16743d) {
                C1516b.a(autoCloseable);
                return;
            }
            synchronized (c1516b.f16740a) {
                autoCloseable2 = (AutoCloseable) c1516b.f16741b.put(str, autoCloseable);
            }
            C1516b.a(autoCloseable2);
        }
    }

    public final void b() {
        C1516b c1516b = this.f8817a;
        if (c1516b != null && !c1516b.f16743d) {
            c1516b.f16743d = true;
            synchronized (c1516b.f16740a) {
                try {
                    Iterator it = c1516b.f16741b.values().iterator();
                    while (it.hasNext()) {
                        C1516b.a((AutoCloseable) it.next());
                    }
                    Iterator it2 = c1516b.f16742c.iterator();
                    while (it2.hasNext()) {
                        C1516b.a((AutoCloseable) it2.next());
                    }
                    c1516b.f16742c.clear();
                } catch (Throwable th) {
                    throw th;
                }
            }
        }
        d();
    }

    public final AutoCloseable c(String str) {
        AutoCloseable autoCloseable;
        C1516b c1516b = this.f8817a;
        if (c1516b == null) {
            return null;
        }
        synchronized (c1516b.f16740a) {
            autoCloseable = (AutoCloseable) c1516b.f16741b.get(str);
        }
        return autoCloseable;
    }

    public void d() {
    }
}
