package androidx.core.os;

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

/* JADX INFO: compiled from: CancellationSignal.java */
/* JADX INFO: loaded from: classes.dex */
public final class e {

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

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

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

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

    /* JADX INFO: compiled from: CancellationSignal.java */
    static class a {
        static void a(Object obj) {
            ((CancellationSignal) obj).cancel();
        }

        static CancellationSignal b() {
            return new CancellationSignal();
        }
    }

    /* JADX INFO: compiled from: CancellationSignal.java */
    public interface b {
        void a();
    }

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

    public void a() {
        synchronized (this) {
            if (this.f1741a) {
                return;
            }
            this.f1741a = true;
            this.f1744d = true;
            b bVar = this.f1742b;
            Object obj = this.f1743c;
            if (bVar != null) {
                try {
                    bVar.a();
                } catch (Throwable th) {
                    synchronized (this) {
                        this.f1744d = false;
                        notifyAll();
                        throw th;
                    }
                }
            }
            if (obj != null && Build.VERSION.SDK_INT >= 16) {
                a.a(obj);
            }
            synchronized (this) {
                this.f1744d = false;
                notifyAll();
            }
        }
    }

    public boolean b() {
        boolean z2;
        synchronized (this) {
            z2 = this.f1741a;
        }
        return z2;
    }

    public void c(b bVar) {
        synchronized (this) {
            d();
            if (this.f1742b == bVar) {
                return;
            }
            this.f1742b = bVar;
            if (this.f1741a && bVar != null) {
                bVar.a();
            }
        }
    }
}
