package p037.p123.p124;

import android.content.Context;
import android.os.Build;
import androidx.work.impl.WorkDatabase;
import androidx.work.impl.background.systemalarm.SystemAlarmService;
import androidx.work.impl.background.systemjob.SystemJobService;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import p037.p123.AbstractC2562;
import p037.p123.C2544;
import p037.p123.p124.p125.p127.C2621;
import p037.p123.p124.p125.p128.C2623;
import p037.p123.p124.p133.C2676;
import p037.p123.p124.p133.C2682;
import p037.p123.p124.p133.InterfaceC2680;
import p037.p123.p124.p134.C2703;

/* JADX INFO: renamed from: މ.ޗ.ޘ.ރ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public class C2591 {

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static final String f8114 = AbstractC2562.m4622("Schedulers");

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static InterfaceC2590 m4655(Context context, C2604 c2604) {
        InterfaceC2590 interfaceC2590;
        if (Build.VERSION.SDK_INT >= 23) {
            C2623 c2623 = new C2623(context, c2604);
            C2703.m4773(context, SystemJobService.class, true);
            AbstractC2562.m4623().mo4625(f8114, "Created SystemJobScheduler and enabled SystemJobService", new Throwable[0]);
            return c2623;
        }
        try {
            interfaceC2590 = (InterfaceC2590) Class.forName("androidx.work.impl.background.gcm.GcmScheduler").getConstructor(Context.class).newInstance(context);
            AbstractC2562.m4623().mo4625(f8114, String.format("Created %s", "androidx.work.impl.background.gcm.GcmScheduler"), new Throwable[0]);
        } catch (Throwable th) {
            AbstractC2562.m4623().mo4625(f8114, "Unable to create GCM Scheduler", th);
            interfaceC2590 = null;
        }
        InterfaceC2590 interfaceC25902 = interfaceC2590;
        if (interfaceC25902 != null) {
            return interfaceC25902;
        }
        C2621 c2621 = new C2621(context);
        C2703.m4773(context, SystemAlarmService.class, true);
        AbstractC2562.m4623().mo4625(f8114, "Created SystemAlarmScheduler", new Throwable[0]);
        return c2621;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static void m4656(C2544 c2544, WorkDatabase workDatabase, List<InterfaceC2590> list) {
        if (list == null || list.size() == 0) {
            return;
        }
        InterfaceC2680 interfaceC2680Mo850 = workDatabase.mo850();
        workDatabase.m4479();
        try {
            C2682 c2682 = (C2682) interfaceC2680Mo850;
            List<C2676> listM4750 = c2682.m4750(Build.VERSION.SDK_INT == 23 ? c2544.f8014 / 2 : c2544.f8014);
            List<C2676> listM4749 = c2682.m4749();
            ArrayList arrayList = (ArrayList) listM4750;
            if (arrayList.size() > 0) {
                long jCurrentTimeMillis = System.currentTimeMillis();
                Iterator it = arrayList.iterator();
                while (it.hasNext()) {
                    c2682.m4747(((C2676) it.next()).f8320, jCurrentTimeMillis);
                }
            }
            workDatabase.m4484();
            workDatabase.m4481();
            if (arrayList.size() > 0) {
                C2676[] c2676Arr = (C2676[]) arrayList.toArray(new C2676[arrayList.size()]);
                for (InterfaceC2590 interfaceC2590 : list) {
                    if (interfaceC2590.mo4654()) {
                        interfaceC2590.mo4653(c2676Arr);
                    }
                }
            }
            ArrayList arrayList2 = (ArrayList) listM4749;
            if (arrayList2.size() > 0) {
                C2676[] c2676Arr2 = (C2676[]) arrayList2.toArray(new C2676[arrayList2.size()]);
                for (InterfaceC2590 interfaceC25902 : list) {
                    if (!interfaceC25902.mo4654()) {
                        interfaceC25902.mo4653(c2676Arr2);
                    }
                }
            }
        } catch (Throwable th) {
            workDatabase.m4481();
            throw th;
        }
    }
}
