package ng;

import com.adobe.marketing.mobile.AdobeCallback;
import java.util.Timer;
import java.util.TimerTask;
import kotlin.jvm.internal.t;
import rm.n0;

/* loaded from: classes4.dex */
public final class m {

    /* renamed from: e, reason: collision with root package name */
    public static final a f30015e = new a(null);

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

    /* renamed from: b, reason: collision with root package name */
    private Timer f30017b;

    /* renamed from: c, reason: collision with root package name */
    private final Object f30018c;

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

    /* loaded from: classes4.dex */
    public static final class a {
        private a() {
        }

        public /* synthetic */ a(kotlin.jvm.internal.k kVar) {
            this();
        }
    }

    /* loaded from: classes4.dex */
    public static final class b extends TimerTask {

        /* renamed from: q, reason: collision with root package name */
        final /* synthetic */ AdobeCallback f30021q;

        /* renamed from: r, reason: collision with root package name */
        final /* synthetic */ long f30022r;

        b(AdobeCallback adobeCallback, long j10) {
            this.f30021q = adobeCallback;
            this.f30022r = j10;
        }

        @Override // java.util.TimerTask, java.lang.Runnable
        public void run() {
            m.this.f30016a = false;
            this.f30021q.a(Boolean.TRUE);
        }
    }

    public m(String debugName) {
        t.g(debugName, "debugName");
        this.f30019d = debugName;
        this.f30018c = new Object();
    }

    public final void b() {
        synchronized (this.f30018c) {
            try {
                Timer timer = this.f30017b;
                if (timer != null) {
                    timer.cancel();
                }
                wg.t.e("Analytics", "TimerState", "%s timer was canceled", this.f30019d);
            } catch (Exception e10) {
                wg.t.f("Analytics", "TimerState", "Error cancelling %s timer, failed with error: (%s)", this.f30019d, e10);
            }
            this.f30016a = false;
            n0 n0Var = n0.f34904a;
        }
    }

    public final boolean c() {
        boolean z10;
        synchronized (this.f30018c) {
            z10 = this.f30016a;
        }
        return z10;
    }

    public final void d(long j10, AdobeCallback callback) {
        t.g(callback, "callback");
        synchronized (this.f30018c) {
            if (this.f30016a) {
                wg.t.a("Analytics", "TimerState", "Timer has already started.", new Object[0]);
                return;
            }
            this.f30016a = true;
            try {
                Timer timer = new Timer(this.f30019d);
                this.f30017b = timer;
                timer.schedule(new b(callback, j10), j10);
                wg.t.e("Analytics", "TimerState", "%s timer scheduled having timeout %s ms", this.f30019d, Long.valueOf(j10));
            } catch (Exception e10) {
                wg.t.f("Analytics", "TimerState", "Error creating %s timer, failed with error: (%s)", this.f30019d, e10);
            }
            n0 n0Var = n0.f34904a;
        }
    }
}
