package i6;

import androidx.work.impl.WorkDatabase;
import h6.s;
import z5.t;

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

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

    /* renamed from: p, reason: collision with root package name */
    private final a6.i f22468p;

    /* renamed from: q, reason: collision with root package name */
    private final String f22469q;

    /* renamed from: r, reason: collision with root package name */
    private final boolean f22470r;

    public k(a6.i iVar, String str, boolean z10) {
        this.f22468p = iVar;
        this.f22469q = str;
        this.f22470r = z10;
    }

    @Override // java.lang.Runnable
    public void run() {
        boolean n10;
        WorkDatabase s10 = this.f22468p.s();
        a6.d q10 = this.f22468p.q();
        s O = s10.O();
        s10.e();
        try {
            boolean g10 = q10.g(this.f22469q);
            if (this.f22470r) {
                n10 = this.f22468p.q().m(this.f22469q);
            } else {
                if (!g10 && O.n(this.f22469q) == t.a.RUNNING) {
                    O.i(t.a.ENQUEUED, this.f22469q);
                }
                n10 = this.f22468p.q().n(this.f22469q);
            }
            z5.k.c().a(f22467s, String.format("StopWorkRunnable for %s; Processor.stopWork = %s", this.f22469q, Boolean.valueOf(n10)), new Throwable[0]);
            s10.C();
        } finally {
            s10.i();
        }
    }
}
