package i6;

import android.content.Context;
import androidx.work.impl.WorkDatabase;
import h6.s;
import java.util.UUID;
import z5.t;

/* loaded from: classes.dex */
public class n implements z5.f {

    /* renamed from: d, reason: collision with root package name */
    private static final String f22484d = z5.k.f("WMFgUpdater");

    /* renamed from: a, reason: collision with root package name */
    private final j6.a f22485a;

    /* renamed from: b, reason: collision with root package name */
    final g6.a f22486b;

    /* renamed from: c, reason: collision with root package name */
    final s f22487c;

    /* loaded from: classes.dex */
    class a implements Runnable {

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ androidx.work.impl.utils.futures.c f22488p;

        /* renamed from: q, reason: collision with root package name */
        final /* synthetic */ UUID f22489q;

        /* renamed from: r, reason: collision with root package name */
        final /* synthetic */ z5.e f22490r;

        /* renamed from: s, reason: collision with root package name */
        final /* synthetic */ Context f22491s;

        a(androidx.work.impl.utils.futures.c cVar, UUID uuid, z5.e eVar, Context context) {
            this.f22488p = cVar;
            this.f22489q = uuid;
            this.f22490r = eVar;
            this.f22491s = context;
        }

        @Override // java.lang.Runnable
        public void run() {
            try {
                if (!this.f22488p.isCancelled()) {
                    String uuid = this.f22489q.toString();
                    t.a n10 = n.this.f22487c.n(uuid);
                    if (n10 == null || n10.isFinished()) {
                        throw new IllegalStateException("Calls to setForegroundAsync() must complete before a ListenableWorker signals completion of work by returning an instance of Result.");
                    }
                    n.this.f22486b.b(uuid, this.f22490r);
                    this.f22491s.startService(androidx.work.impl.foreground.a.c(this.f22491s, uuid, this.f22490r));
                }
                this.f22488p.o(null);
            } catch (Throwable th2) {
                this.f22488p.p(th2);
            }
        }
    }

    public n(WorkDatabase workDatabase, g6.a aVar, j6.a aVar2) {
        this.f22486b = aVar;
        this.f22485a = aVar2;
        this.f22487c = workDatabase.O();
    }

    @Override // z5.f
    public ek.d a(Context context, UUID uuid, z5.e eVar) {
        androidx.work.impl.utils.futures.c s10 = androidx.work.impl.utils.futures.c.s();
        this.f22485a.b(new a(s10, uuid, eVar, context));
        return s10;
    }
}
