package p037.p123.p124.p125.p127;

import android.content.Context;
import android.content.Intent;
import android.os.PowerManager;
import androidx.work.WorkerParameters;
import androidx.work.impl.background.systemalarm.SystemAlarmService;
import java.util.Collections;
import java.util.List;
import p037.p123.AbstractC2562;
import p037.p123.p124.InterfaceC2586;
import p037.p123.p124.p125.p127.C2616;
import p037.p123.p124.p129.C2627;
import p037.p123.p124.p129.InterfaceC2626;
import p037.p123.p124.p133.C2676;
import p037.p123.p124.p133.C2682;
import p037.p123.p124.p134.C2709;
import p037.p123.p124.p134.C2713;

/* JADX INFO: renamed from: މ.ޗ.ޘ.ތ.ؠ.ށ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public class C2615 implements InterfaceC2626, InterfaceC2586, C2713.InterfaceC2715 {

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

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

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

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

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public final C2616 f8210;

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

    /* JADX INFO: renamed from: ފ, reason: contains not printable characters */
    public PowerManager.WakeLock f8214;

    /* JADX INFO: renamed from: ދ, reason: contains not printable characters */
    public boolean f8215 = false;

    /* JADX INFO: renamed from: މ, reason: contains not printable characters */
    public int f8213 = 0;

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

    public C2615(Context context, int i, String str, C2616 c2616) {
        this.f8207 = context;
        this.f8208 = i;
        this.f8210 = c2616;
        this.f8209 = str;
        this.f8211 = new C2627(this.f8207, c2616.f8218, this);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m4693() {
        synchronized (this.f8212) {
            this.f8211.m4711();
            this.f8210.f8219.m4779(this.f8209);
            if (this.f8214 != null && this.f8214.isHeld()) {
                AbstractC2562.m4623().mo4625(f8206, String.format("Releasing wakelock %s for WorkSpec %s", this.f8214, this.f8209), new Throwable[0]);
                this.f8214.release();
            }
        }
    }

    @Override // p037.p123.p124.p134.C2713.InterfaceC2715
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public void mo4694(String str) {
        AbstractC2562.m4623().mo4625(f8206, String.format("Exceeded time limits on execution for %s", str), new Throwable[0]);
        m4696();
    }

    @Override // p037.p123.p124.InterfaceC2586
    /* JADX INFO: renamed from: ֏ */
    public void mo870(String str, boolean z) {
        AbstractC2562.m4623().mo4625(f8206, String.format("onExecuted %s, %s", str, Boolean.valueOf(z)), new Throwable[0]);
        m4693();
        if (z) {
            Intent intentM4688 = C2613.m4688(this.f8207, this.f8209);
            C2616 c2616 = this.f8210;
            c2616.f8223.post(new C2616.RunnableC2618(c2616, intentM4688, this.f8208));
        }
        if (this.f8215) {
            Intent intentM4684 = C2613.m4684(this.f8207);
            C2616 c26162 = this.f8210;
            c26162.f8223.post(new C2616.RunnableC2618(c26162, intentM4684, this.f8208));
        }
    }

    @Override // p037.p123.p124.p129.InterfaceC2626
    /* JADX INFO: renamed from: ֏ */
    public void mo879(List<String> list) {
        m4696();
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public void m4695() {
        this.f8214 = C2709.m4777(this.f8207, String.format("%s (%s)", this.f8209, Integer.valueOf(this.f8208)));
        AbstractC2562.m4623().mo4625(f8206, String.format("Acquiring wakelock %s for WorkSpec %s", this.f8214, this.f8209), new Throwable[0]);
        this.f8214.acquire();
        C2676 c2676M4761 = ((C2682) this.f8210.f8221.f8140.mo850()).m4761(this.f8209);
        if (c2676M4761 == null) {
            m4696();
            return;
        }
        boolean zM4745 = c2676M4761.m4745();
        this.f8215 = zM4745;
        if (zM4745) {
            this.f8211.m4712((Iterable<C2676>) Collections.singletonList(c2676M4761));
        } else {
            AbstractC2562.m4623().mo4625(f8206, String.format("No constraints for %s", this.f8209), new Throwable[0]);
            mo880(Collections.singletonList(this.f8209));
        }
    }

    @Override // p037.p123.p124.p129.InterfaceC2626
    /* JADX INFO: renamed from: ؠ */
    public void mo880(List<String> list) {
        if (list.contains(this.f8209)) {
            synchronized (this.f8212) {
                if (this.f8213 == 0) {
                    this.f8213 = 1;
                    AbstractC2562.m4623().mo4625(f8206, String.format("onAllConstraintsMet for %s", this.f8209), new Throwable[0]);
                    if (this.f8210.f8220.m4644(this.f8209, (WorkerParameters.C0245) null)) {
                        this.f8210.f8219.m4780(this.f8209, 600000L, this);
                    } else {
                        m4693();
                    }
                } else {
                    AbstractC2562.m4623().mo4625(f8206, String.format("Already started work for %s", this.f8209), new Throwable[0]);
                }
            }
        }
    }

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final void m4696() {
        synchronized (this.f8212) {
            if (this.f8213 < 2) {
                this.f8213 = 2;
                AbstractC2562.m4623().mo4625(f8206, String.format("Stopping work for WorkSpec %s", this.f8209), new Throwable[0]);
                Context context = this.f8207;
                String str = this.f8209;
                Intent intent = new Intent(context, (Class<?>) SystemAlarmService.class);
                intent.setAction("ACTION_STOP_WORK");
                intent.putExtra("KEY_WORKSPEC_ID", str);
                this.f8210.f8223.post(new C2616.RunnableC2618(this.f8210, intent, this.f8208));
                if (this.f8210.f8220.m4646(this.f8209)) {
                    AbstractC2562.m4623().mo4625(f8206, String.format("WorkSpec %s needs to be rescheduled", this.f8209), new Throwable[0]);
                    Intent intentM4688 = C2613.m4688(this.f8207, this.f8209);
                    this.f8210.f8223.post(new C2616.RunnableC2618(this.f8210, intentM4688, this.f8208));
                } else {
                    AbstractC2562.m4623().mo4625(f8206, String.format("Processor does not have WorkSpec %s. No need to reschedule ", this.f8209), new Throwable[0]);
                }
            } else {
                AbstractC2562.m4623().mo4625(f8206, String.format("Already stopped work for %s", this.f8209), new Throwable[0]);
            }
        }
    }
}
