package com.adobe.marketing.mobile.lifecycle;

import com.adobe.marketing.mobile.AdobeCallback;
import java.util.Timer;
import java.util.TimerTask;

/* loaded from: classes4.dex */
class g {

    /* renamed from: c, reason: collision with root package name */
    private TimerTask f12347c;

    /* renamed from: d, reason: collision with root package name */
    private Timer f12348d;

    /* renamed from: e, reason: collision with root package name */
    private AdobeCallback f12349e;

    /* renamed from: f, reason: collision with root package name */
    private final String f12350f;

    /* renamed from: b, reason: collision with root package name */
    private long f12346b = 0;

    /* renamed from: a, reason: collision with root package name */
    private boolean f12345a = false;

    /* renamed from: g, reason: collision with root package name */
    private final Object f12351g = new Object();

    /* loaded from: classes4.dex */
    class a extends TimerTask {
        a() {
        }

        @Override // java.util.TimerTask, java.lang.Runnable
        public void run() {
            g.this.f12345a = false;
            if (g.this.f12349e != null) {
                g.this.f12349e.a(Boolean.TRUE);
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public g(String str) {
        this.f12350f = str;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void c() {
        synchronized (this.f12351g) {
            Timer timer = this.f12348d;
            if (timer != null) {
                try {
                    timer.cancel();
                    wg.t.e("Lifecycle", "LifecycleTimerState", "%s timer was canceled", this.f12350f);
                } catch (Exception e10) {
                    wg.t.f("Lifecycle", "LifecycleTimerState", "Error cancelling %s timer, failed with error: (%s)", this.f12350f, e10);
                }
                this.f12347c = null;
            }
            this.f12345a = false;
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public boolean d() {
        boolean z10;
        synchronized (this.f12351g) {
            z10 = this.f12347c != null && this.f12345a;
        }
        return z10;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void e(long j10, AdobeCallback adobeCallback) {
        synchronized (this.f12351g) {
            if (this.f12347c != null) {
                wg.t.a("Lifecycle", "LifecycleTimerState", "Timer has already started.", new Object[0]);
                return;
            }
            this.f12346b = j10;
            this.f12345a = true;
            this.f12349e = adobeCallback;
            try {
                this.f12347c = new a();
                Timer timer = new Timer(this.f12350f);
                this.f12348d = timer;
                timer.schedule(this.f12347c, j10);
                wg.t.e("Lifecycle", "LifecycleTimerState", "%s timer scheduled having timeout %s ms", this.f12350f, Long.valueOf(this.f12346b));
            } catch (Exception e10) {
                wg.t.f("Lifecycle", "LifecycleTimerState", "Error creating %s timer, failed with error: (%s)", this.f12350f, e10);
            }
        }
    }
}
