package androidx.work.impl.utils.futures;

import androidx.annotation.Nullable;
import com.google.common.util.concurrent.w;

/* JADX INFO: loaded from: classes.dex */
public final class i extends h {
    public final boolean i(Throwable th) {
        if (!h.f4677c.f(this, null, new b((Throwable) h.checkNotNull(th)))) {
            return false;
        }
        h.b(this);
        return true;
    }

    public final boolean j(w wVar) {
        b bVar;
        h.checkNotNull(wVar);
        Object obj = this.value;
        if (obj == null) {
            if (wVar.isDone()) {
                if (!h.f4677c.f(this, null, h.e(wVar))) {
                    return false;
                }
                h.b(this);
            } else {
                e eVar = new e(this, wVar);
                if (h.f4677c.f(this, null, eVar)) {
                    try {
                        wVar.g(eVar, DirectExecutor.f4657a);
                    } catch (Throwable th) {
                        try {
                            bVar = new b(th);
                        } catch (Throwable unused) {
                            bVar = b.f4662b;
                        }
                        h.f4677c.f(this, eVar, bVar);
                    }
                } else {
                    obj = this.value;
                }
            }
            return true;
        }
        if (!(obj instanceof a)) {
            return false;
        }
        wVar.cancel(((a) obj).f4661a);
        return false;
    }

    @Override // androidx.work.impl.utils.futures.h
    public boolean set(@Nullable Object obj) {
        return super.set(obj);
    }
}
