package i6;

import android.content.Context;
import androidx.work.ListenableWorker;
import h6.r;

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

    /* renamed from: v, reason: collision with root package name */
    static final String f22473v = z5.k.f("WorkForegroundRunnable");

    /* renamed from: p, reason: collision with root package name */
    final androidx.work.impl.utils.futures.c f22474p = androidx.work.impl.utils.futures.c.s();

    /* renamed from: q, reason: collision with root package name */
    final Context f22475q;

    /* renamed from: r, reason: collision with root package name */
    final r f22476r;

    /* renamed from: s, reason: collision with root package name */
    final ListenableWorker f22477s;

    /* renamed from: t, reason: collision with root package name */
    final z5.f f22478t;

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

    /* 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 f22480p;

        a(androidx.work.impl.utils.futures.c cVar) {
            this.f22480p = cVar;
        }

        @Override // java.lang.Runnable
        public void run() {
            this.f22480p.q(m.this.f22477s.e());
        }
    }

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

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

        b(androidx.work.impl.utils.futures.c cVar) {
            this.f22482p = cVar;
        }

        @Override // java.lang.Runnable
        public void run() {
            try {
                z5.e eVar = (z5.e) this.f22482p.get();
                if (eVar == null) {
                    throw new IllegalStateException(String.format("Worker was marked important (%s) but did not provide ForegroundInfo", m.this.f22476r.f20892c));
                }
                z5.k.c().a(m.f22473v, String.format("Updating notification for %s", m.this.f22476r.f20892c), new Throwable[0]);
                m.this.f22477s.n(true);
                m mVar = m.this;
                mVar.f22474p.q(mVar.f22478t.a(mVar.f22475q, mVar.f22477s.f(), eVar));
            } catch (Throwable th2) {
                m.this.f22474p.p(th2);
            }
        }
    }

    public m(Context context, r rVar, ListenableWorker listenableWorker, z5.f fVar, j6.a aVar) {
        this.f22475q = context;
        this.f22476r = rVar;
        this.f22477s = listenableWorker;
        this.f22478t = fVar;
        this.f22479u = aVar;
    }

    public ek.d a() {
        return this.f22474p;
    }

    @Override // java.lang.Runnable
    public void run() {
        if (!this.f22476r.f20906q || androidx.core.os.a.b()) {
            this.f22474p.o(null);
            return;
        }
        androidx.work.impl.utils.futures.c s10 = androidx.work.impl.utils.futures.c.s();
        this.f22479u.a().execute(new a(s10));
        s10.addListener(new b(s10), this.f22479u.a());
    }
}
