package g3;

import P2.w;
import com.google.android.gms.internal.measurement.B1;
import java.util.concurrent.CancellationException;
import java.util.concurrent.Executor;

/* JADX INFO: loaded from: classes.dex */
public final class o {

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final B1 f12944b = new B1(5);

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public boolean f12945c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public volatile boolean f12946d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public Object f12947e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public Exception f12948f;

    public final void a(Executor executor, InterfaceC0984b interfaceC0984b) {
        this.f12944b.j(new m(executor, interfaceC0984b));
        p();
    }

    public final void b(Executor executor, d dVar) {
        this.f12944b.j(new m(executor, dVar));
        p();
    }

    public final void c(Executor executor, e eVar) {
        this.f12944b.j(new m(executor, eVar));
        p();
    }

    public final o d(Executor executor, InterfaceC0983a interfaceC0983a) {
        o oVar = new o();
        this.f12944b.j(new l(executor, interfaceC0983a, oVar, 0));
        p();
        return oVar;
    }

    public final o e(Executor executor, InterfaceC0983a interfaceC0983a) {
        o oVar = new o();
        this.f12944b.j(new l(executor, interfaceC0983a, oVar, 1));
        p();
        return oVar;
    }

    public final Exception f() {
        Exception exc;
        synchronized (this.f12943a) {
            exc = this.f12948f;
        }
        return exc;
    }

    public final Object g() {
        Object obj;
        synchronized (this.f12943a) {
            try {
                w.h("Task is not yet complete", this.f12945c);
                if (this.f12946d) {
                    throw new CancellationException("Task is already canceled.");
                }
                Exception exc = this.f12948f;
                if (exc != null) {
                    throw new f(exc);
                }
                obj = this.f12947e;
            } catch (Throwable th) {
                throw th;
            }
        }
        return obj;
    }

    public final boolean h() {
        boolean z8;
        synchronized (this.f12943a) {
            z8 = this.f12945c;
        }
        return z8;
    }

    public final boolean i() {
        boolean z8;
        synchronized (this.f12943a) {
            try {
                z8 = false;
                if (this.f12945c && !this.f12946d && this.f12948f == null) {
                    z8 = true;
                }
            } finally {
            }
        }
        return z8;
    }

    public final o j(Executor executor, g gVar) {
        o oVar = new o();
        this.f12944b.j(new m(executor, gVar, oVar));
        p();
        return oVar;
    }

    public final void k(Exception exc) {
        w.g(exc, "Exception must not be null");
        synchronized (this.f12943a) {
            o();
            this.f12945c = true;
            this.f12948f = exc;
        }
        this.f12944b.k(this);
    }

    public final void l(Object obj) {
        synchronized (this.f12943a) {
            o();
            this.f12945c = true;
            this.f12947e = obj;
        }
        this.f12944b.k(this);
    }

    public final void m() {
        synchronized (this.f12943a) {
            try {
                if (this.f12945c) {
                    return;
                }
                this.f12945c = true;
                this.f12946d = true;
                this.f12944b.k(this);
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    public final boolean n(Object obj) {
        synchronized (this.f12943a) {
            try {
                if (this.f12945c) {
                    return false;
                }
                this.f12945c = true;
                this.f12947e = obj;
                this.f12944b.k(this);
                return true;
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    public final void o() {
        if (this.f12945c) {
            int i = b7.p.f9267q;
            if (!h()) {
                throw new IllegalStateException("DuplicateTaskCompletionException can only be created from completed Task.");
            }
            Exception excF = f();
        }
    }

    public final void p() {
        synchronized (this.f12943a) {
            try {
                if (this.f12945c) {
                    this.f12944b.k(this);
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }
}
