package androidx.work.impl.background.systemalarm;

import android.content.Intent;
import android.os.PowerManager;
import androidx.lifecycle.LifecycleService;
import java.util.LinkedHashMap;
import java.util.Map;
import o.C0669Zu;
import o.C1205fc0;
import o.Mk0;
import o.Nk0;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public class SystemAlarmService extends LifecycleService {
    public C1205fc0 m;
    public boolean n;

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

    public final void a() {
        this.n = true;
        C0669Zu.e().getClass();
        int i = Mk0.a;
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        synchronized (Nk0.a) {
            linkedHashMap.putAll(Nk0.b);
        }
        for (Map.Entry entry : linkedHashMap.entrySet()) {
            PowerManager.WakeLock wakeLock = (PowerManager.WakeLock) entry.getKey();
            if (wakeLock != null && wakeLock.isHeld()) {
                C0669Zu.e().getClass();
            }
        }
        stopSelf();
    }

    @Override // androidx.lifecycle.LifecycleService, android.app.Service
    public final void onCreate() {
        super.onCreate();
        C1205fc0 c1205fc0 = new C1205fc0(this);
        this.m = c1205fc0;
        if (c1205fc0.t != null) {
            C0669Zu.e().getClass();
        } else {
            c1205fc0.t = this;
        }
        this.n = false;
    }

    @Override // androidx.lifecycle.LifecycleService, android.app.Service
    public final void onDestroy() {
        super.onDestroy();
        this.n = true;
        C1205fc0 c1205fc0 = this.m;
        c1205fc0.getClass();
        C0669Zu.e().getClass();
        c1205fc0.f526o.e(c1205fc0);
        c1205fc0.t = null;
    }

    @Override // android.app.Service
    public final int onStartCommand(Intent intent, int i, int i2) {
        super.onStartCommand(intent, i, i2);
        if (this.n) {
            C0669Zu.e().getClass();
            C1205fc0 c1205fc0 = this.m;
            c1205fc0.getClass();
            C0669Zu.e().getClass();
            c1205fc0.f526o.e(c1205fc0);
            c1205fc0.t = null;
            C1205fc0 c1205fc02 = new C1205fc0(this);
            this.m = c1205fc02;
            if (c1205fc02.t != null) {
                C0669Zu.e().getClass();
            } else {
                c1205fc02.t = this;
            }
            this.n = false;
        }
        if (intent == null) {
            return 3;
        }
        this.m.a(intent, i2);
        return 3;
    }
}
