package p011d0;

import android.os.CancellationSignal;

/* renamed from: d0.h */
/* loaded from: classes.dex */
public final class C0605h {

    /* renamed from: a */
    public boolean f2135a;

    /* renamed from: b */
    public InterfaceC0607b f2136b;

    /* renamed from: c */
    public Object f2137c;

    /* renamed from: d */
    public boolean f2138d;

    /* renamed from: d0.h$a */
    /* loaded from: classes.dex */
    public static class C0606a {
        /* renamed from: a */
        public static void m3277a(Object obj) {
            ((CancellationSignal) obj).cancel();
        }

        /* renamed from: b */
        public static CancellationSignal m3276b() {
            return new CancellationSignal();
        }
    }

    /* renamed from: d0.h$b */
    /* loaded from: classes.dex */
    public interface InterfaceC0607b {
        void onCancel();
    }

    /* renamed from: a */
    public void m3281a() {
        synchronized (this) {
            if (this.f2135a) {
                return;
            }
            this.f2135a = true;
            this.f2138d = true;
            InterfaceC0607b interfaceC0607b = this.f2136b;
            Object obj = this.f2137c;
            if (interfaceC0607b != null) {
                try {
                    interfaceC0607b.onCancel();
                } catch (Throwable th) {
                    synchronized (this) {
                        this.f2138d = false;
                        notifyAll();
                        throw th;
                    }
                }
            }
            if (obj != null) {
                C0606a.m3277a(obj);
            }
            synchronized (this) {
                this.f2138d = false;
                notifyAll();
            }
        }
    }

    /* renamed from: b */
    public boolean m3280b() {
        boolean z;
        synchronized (this) {
            z = this.f2135a;
        }
        return z;
    }

    /* renamed from: c */
    public void m3279c(InterfaceC0607b interfaceC0607b) {
        synchronized (this) {
            m3278d();
            if (this.f2136b == interfaceC0607b) {
                return;
            }
            this.f2136b = interfaceC0607b;
            if (this.f2135a && interfaceC0607b != null) {
                interfaceC0607b.onCancel();
            }
        }
    }

    /* renamed from: d */
    public final void m3278d() {
        while (this.f2138d) {
            try {
                wait();
            } catch (InterruptedException unused) {
            }
        }
    }
}