package c.f.h;

import android.os.Build;
import android.os.CancellationSignal;

/* JADX INFO: compiled from: CancellationSignal.java */
/* JADX INFO: loaded from: classes.dex */
public final class a {
    private boolean a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private InterfaceC0027a f1394b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private Object f1395c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    private boolean f1396d;

    /* JADX INFO: renamed from: c.f.h.a$a, reason: collision with other inner class name */
    /* JADX INFO: compiled from: CancellationSignal.java */
    public interface InterfaceC0027a {
        void a();
    }

    private void d() {
        while (this.f1396d) {
            try {
                wait();
            } catch (InterruptedException unused) {
            }
        }
    }

    public void a() {
        synchronized (this) {
            if (this.a) {
                return;
            }
            this.a = true;
            this.f1396d = true;
            InterfaceC0027a interfaceC0027a = this.f1394b;
            Object obj = this.f1395c;
            if (interfaceC0027a != null) {
                try {
                    interfaceC0027a.a();
                } catch (Throwable th) {
                    synchronized (this) {
                        this.f1396d = false;
                        notifyAll();
                        throw th;
                    }
                }
            }
            if (obj != null && Build.VERSION.SDK_INT >= 16) {
                ((CancellationSignal) obj).cancel();
            }
            synchronized (this) {
                this.f1396d = false;
                notifyAll();
            }
        }
    }

    public boolean b() {
        boolean z;
        synchronized (this) {
            z = this.a;
        }
        return z;
    }

    public void c(InterfaceC0027a interfaceC0027a) {
        synchronized (this) {
            d();
            if (this.f1394b == interfaceC0027a) {
                return;
            }
            this.f1394b = interfaceC0027a;
            if (this.a && interfaceC0027a != null) {
                interfaceC0027a.a();
            }
        }
    }
}
