package o;

import android.app.job.JobInfo;
import android.app.job.JobScheduler;
import android.content.BroadcastReceiver;
import android.content.Context;
import androidx.work.impl.WorkDatabase;
import androidx.work.impl.WorkDatabase_Impl;
import java.util.ArrayList;
import java.util.List;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.um0, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C2651um0 extends AbstractC2461sm0 {
    public static C2651um0 u;
    public static C2651um0 v;
    public static final Object w;
    public final Context k;
    public final C1414hl l;
    public final WorkDatabase m;
    public final C2062oc0 n;

    /* renamed from: o, reason: collision with root package name */
    public final List f748o;
    public final XY p;
    public final C2132pG q;
    public boolean r = false;
    public BroadcastReceiver.PendingResult s;
    public final C2062oc0 t;

    static {
        C0669Zu.l("WorkManagerImpl");
        u = null;
        v = null;
        w = new Object();
    }

    public C2651um0(Context context, final C1414hl c1414hl, C2062oc0 c2062oc0, final WorkDatabase workDatabase, final List list, XY xy, C2062oc0 c2062oc02) {
        Context applicationContext = context.getApplicationContext();
        if (AbstractC2556tm0.a(applicationContext)) {
            throw new IllegalStateException("Cannot initialize WorkManager in direct boot mode");
        }
        C0669Zu c0669Zu = new C0669Zu(11);
        synchronized (C0669Zu.L) {
            C0669Zu.M = c0669Zu;
        }
        this.k = applicationContext;
        this.n = c2062oc0;
        this.m = workDatabase;
        this.p = xy;
        this.t = c2062oc02;
        this.l = c1414hl;
        this.f748o = list;
        this.q = new C2132pG(workDatabase);
        final E7 e7 = (E7) c2062oc0.a;
        int i = H40.a;
        xy.a(new InterfaceC0645Yw() { // from class: o.G40
            @Override // o.InterfaceC0645Yw
            public final void b(C2366rm0 c2366rm0, boolean z) {
                e7.execute(new RunnableC2373rq(list, c2366rm0, c1414hl, workDatabase, 1));
            }
        });
        c2062oc0.c(new TA(applicationContext, this));
    }

    public static C2651um0 H(Context context) {
        C2651um0 c2651um0;
        Object obj = w;
        synchronized (obj) {
            try {
                synchronized (obj) {
                    c2651um0 = u;
                    if (c2651um0 == null) {
                        c2651um0 = v;
                    }
                }
                return c2651um0;
            } catch (Throwable th) {
                throw th;
            } finally {
            }
        }
        if (c2651um0 != null) {
            return c2651um0;
        }
        context.getApplicationContext();
        throw new IllegalStateException("WorkManager is not initialized properly.  You have explicitly disabled WorkManagerInitializer in your manifest, have not manually called WorkManager#initialize at this point, and your Application does not implement Configuration.Provider.");
    }

    public final void I() {
        synchronized (w) {
            try {
                this.r = true;
                BroadcastReceiver.PendingResult pendingResult = this.s;
                if (pendingResult != null) {
                    pendingResult.finish();
                    this.s = null;
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    public final void J() {
        ArrayList arrayListC;
        int i = C2252qc0.q;
        Context context = this.k;
        JobScheduler jobScheduler = (JobScheduler) context.getSystemService("jobscheduler");
        if (jobScheduler != null && (arrayListC = C2252qc0.c(context, jobScheduler)) != null && !arrayListC.isEmpty()) {
            int size = arrayListC.size();
            int i2 = 0;
            while (i2 < size) {
                Object obj = arrayListC.get(i2);
                i2++;
                C2252qc0.b(jobScheduler, ((JobInfo) obj).getId());
            }
        }
        WorkDatabase workDatabase = this.m;
        Em0 em0S = workDatabase.s();
        WorkDatabase_Impl workDatabase_Impl = em0S.a;
        workDatabase_Impl.b();
        C1967nc0 c1967nc0 = em0S.m;
        LC lcA = c1967nc0.a();
        workDatabase_Impl.c();
        try {
            lcA.b();
            workDatabase_Impl.n();
            workDatabase_Impl.j();
            c1967nc0.c(lcA);
            H40.b(this.l, workDatabase, this.f748o);
        } catch (Throwable th) {
            workDatabase_Impl.j();
            c1967nc0.c(lcA);
            throw th;
        }
    }
}
