package p037.p123.p124.p125.p126;

import android.app.ActivityManager;
import android.content.Context;
import android.os.Build;
import android.os.Process;
import android.text.TextUtils;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import p037.p123.AbstractC2562;
import p037.p123.C2544;
import p037.p123.C2578;
import p037.p123.p124.C2604;
import p037.p123.p124.InterfaceC2586;
import p037.p123.p124.InterfaceC2590;
import p037.p123.p124.p129.C2627;
import p037.p123.p124.p129.InterfaceC2626;
import p037.p123.p124.p133.C2676;
import p037.p123.p124.p134.RunnableC2707;
import p037.p123.p124.p134.p136.C2731;
import p037.p123.p124.p134.p136.InterfaceC2730;

/* JADX INFO: renamed from: މ.ޗ.ޘ.ތ.֏.ހ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public class C2611 implements InterfaceC2590, InterfaceC2626, InterfaceC2586 {

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

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public final Context f8188;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public final C2604 f8189;

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public final C2627 f8190;

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public C2610 f8192;

    /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
    public boolean f8193;

    /* JADX INFO: renamed from: ފ, reason: contains not printable characters */
    public Boolean f8195;

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public final Set<C2676> f8191 = new HashSet();

    /* JADX INFO: renamed from: މ, reason: contains not printable characters */
    public final Object f8194 = new Object();

    public C2611(Context context, C2544 c2544, InterfaceC2730 interfaceC2730, C2604 c2604) {
        this.f8188 = context;
        this.f8189 = c2604;
        this.f8190 = new C2627(context, interfaceC2730, this);
        this.f8192 = new C2610(this, c2544.f8010);
    }

    @Override // p037.p123.p124.InterfaceC2590
    /* JADX INFO: renamed from: ֏ */
    public void mo4652(String str) {
        Runnable runnableRemove;
        if (this.f8195 == null) {
            this.f8195 = Boolean.valueOf(TextUtils.equals(this.f8188.getPackageName(), m4678()));
        }
        if (!this.f8195.booleanValue()) {
            AbstractC2562.m4623().mo4627(f8187, "Ignoring schedule request in non-main process", new Throwable[0]);
            return;
        }
        if (!this.f8193) {
            this.f8189.f8143.m4642(this);
            this.f8193 = true;
        }
        AbstractC2562.m4623().mo4625(f8187, String.format("Cancelling work ID %s", str), new Throwable[0]);
        C2610 c2610 = this.f8192;
        if (c2610 != null && (runnableRemove = c2610.f8186.remove(str)) != null) {
            c2610.f8185.f8096.removeCallbacks(runnableRemove);
        }
        this.f8189.m4668(str);
    }

    @Override // p037.p123.p124.InterfaceC2586
    /* JADX INFO: renamed from: ֏ */
    public void mo870(String str, boolean z) {
        m4679(str);
    }

    @Override // p037.p123.p124.p129.InterfaceC2626
    /* JADX INFO: renamed from: ֏ */
    public void mo879(List<String> list) {
        for (String str : list) {
            AbstractC2562.m4623().mo4625(f8187, String.format("Constraints not met: Cancelling work ID %s", str), new Throwable[0]);
            this.f8189.m4668(str);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:39:0x00e7  */
    @Override // p037.p123.p124.InterfaceC2590
    /* JADX INFO: renamed from: ֏ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void mo4653(C2676... c2676Arr) {
        if (this.f8195 == null) {
            this.f8195 = Boolean.valueOf(TextUtils.equals(this.f8188.getPackageName(), m4678()));
        }
        if (!this.f8195.booleanValue()) {
            AbstractC2562.m4623().mo4627(f8187, "Ignoring schedule request in non-main process", new Throwable[0]);
            return;
        }
        if (!this.f8193) {
            this.f8189.f8143.m4642(this);
            this.f8193 = true;
        }
        HashSet hashSet = new HashSet();
        HashSet hashSet2 = new HashSet();
        for (C2676 c2676 : c2676Arr) {
            long jM4744 = c2676.m4744();
            long jCurrentTimeMillis = System.currentTimeMillis();
            if (c2676.f8321 == C2578.EnumC2579.ENQUEUED) {
                if (jCurrentTimeMillis < jM4744) {
                    C2610 c2610 = this.f8192;
                    if (c2610 != null) {
                        Runnable runnableRemove = c2610.f8186.remove(c2676.f8320);
                        if (runnableRemove != null) {
                            c2610.f8185.f8096.removeCallbacks(runnableRemove);
                        }
                        RunnableC2609 runnableC2609 = new RunnableC2609(c2610, c2676);
                        c2610.f8186.put(c2676.f8320, runnableC2609);
                        c2610.f8185.f8096.postDelayed(runnableC2609, c2676.m4744() - System.currentTimeMillis());
                    }
                } else if (!c2676.m4745()) {
                    AbstractC2562.m4623().mo4625(f8187, String.format("Starting work for %s", c2676.f8320), new Throwable[0]);
                    C2604 c2604 = this.f8189;
                    ((C2731) c2604.f8141).f8440.execute(new RunnableC2707(c2604, c2676.f8320, null));
                } else if (Build.VERSION.SDK_INT >= 23 && c2676.f8329.f8027) {
                    AbstractC2562.m4623().mo4625(f8187, String.format("Ignoring WorkSpec %s, Requires device idle.", c2676), new Throwable[0]);
                } else if (Build.VERSION.SDK_INT < 24) {
                    hashSet.add(c2676);
                    hashSet2.add(c2676.f8320);
                } else if (c2676.f8329.f8032.m4608() > 0) {
                    AbstractC2562.m4623().mo4625(f8187, String.format("Ignoring WorkSpec %s, Requires ContentUri triggers.", c2676), new Throwable[0]);
                }
            }
        }
        synchronized (this.f8194) {
            if (!hashSet.isEmpty()) {
                AbstractC2562.m4623().mo4625(f8187, String.format("Starting tracking for [%s]", TextUtils.join(",", hashSet2)), new Throwable[0]);
                this.f8191.addAll(hashSet);
                this.f8190.m4712(this.f8191);
            }
        }
    }

    @Override // p037.p123.p124.InterfaceC2590
    /* JADX INFO: renamed from: ֏ */
    public boolean mo4654() {
        return false;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final String m4678() {
        List<ActivityManager.RunningAppProcessInfo> runningAppProcesses;
        int iMyPid = Process.myPid();
        ActivityManager activityManager = (ActivityManager) this.f8188.getSystemService("activity");
        if (activityManager == null || (runningAppProcesses = activityManager.getRunningAppProcesses()) == null || runningAppProcesses.isEmpty()) {
            return null;
        }
        for (ActivityManager.RunningAppProcessInfo runningAppProcessInfo : runningAppProcesses) {
            if (runningAppProcessInfo.pid == iMyPid) {
                return runningAppProcessInfo.processName;
            }
        }
        return null;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final void m4679(String str) {
        synchronized (this.f8194) {
            Iterator<C2676> it = this.f8191.iterator();
            while (true) {
                if (!it.hasNext()) {
                    break;
                }
                C2676 next = it.next();
                if (next.f8320.equals(str)) {
                    AbstractC2562.m4623().mo4625(f8187, String.format("Stopping tracking for %s", str), new Throwable[0]);
                    this.f8191.remove(next);
                    this.f8190.m4712(this.f8191);
                    break;
                }
            }
        }
    }

    @Override // p037.p123.p124.p129.InterfaceC2626
    /* JADX INFO: renamed from: ؠ */
    public void mo880(List<String> list) {
        for (String str : list) {
            AbstractC2562.m4623().mo4625(f8187, String.format("Constraints met: Scheduling work ID %s", str), new Throwable[0]);
            C2604 c2604 = this.f8189;
            ((C2731) c2604.f8141).f8440.execute(new RunnableC2707(c2604, str, null));
        }
    }
}
