package o;

import androidx.work.impl.WorkDatabase;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public abstract class H40 {
    public static final /* synthetic */ int a = 0;

    static {
        C0669Zu.l("Schedulers");
    }

    public static void a(Em0 em0, BP bp, ArrayList arrayList) {
        if (arrayList.size() > 0) {
            bp.getClass();
            long jCurrentTimeMillis = System.currentTimeMillis();
            int size = arrayList.size();
            int i = 0;
            while (i < size) {
                Object obj = arrayList.get(i);
                i++;
                em0.i(((Dm0) obj).a, jCurrentTimeMillis);
            }
        }
    }

    public static void b(C1414hl c1414hl, WorkDatabase workDatabase, List list) {
        if (list == null || list.size() == 0) {
            return;
        }
        Em0 em0S = workDatabase.s();
        workDatabase.c();
        try {
            ArrayList arrayListC = em0S.c();
            a(em0S, (BP) c1414hl.f, arrayListC);
            ArrayList arrayListB = em0S.b(c1414hl.c);
            a(em0S, (BP) c1414hl.f, arrayListB);
            arrayListB.addAll(arrayListC);
            ArrayList arrayListA = em0S.a();
            workDatabase.n();
            workDatabase.j();
            if (arrayListB.size() > 0) {
                Dm0[] dm0Arr = (Dm0[]) arrayListB.toArray(new Dm0[arrayListB.size()]);
                Iterator it = list.iterator();
                while (it.hasNext()) {
                    D40 d40 = (D40) it.next();
                    if (d40.e()) {
                        d40.d(dm0Arr);
                    }
                }
            }
            if (arrayListA.size() > 0) {
                Dm0[] dm0Arr2 = (Dm0[]) arrayListA.toArray(new Dm0[arrayListA.size()]);
                Iterator it2 = list.iterator();
                while (it2.hasNext()) {
                    D40 d402 = (D40) it2.next();
                    if (!d402.e()) {
                        d402.d(dm0Arr2);
                    }
                }
            }
        } catch (Throwable th) {
            workDatabase.j();
            throw th;
        }
    }
}
