package B0;

import android.content.SharedPreferences;
import android.os.SystemClock;
import d3.C0785g0;

/* JADX INFO: loaded from: classes.dex */
public final class s0 implements U {

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public long f890q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public boolean f891r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public long f892s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public final Object f893t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public Object f894u;

    public s0(C0785g0 c0785g0, String str, long j8) {
        this.f894u = c0785g0;
        P2.w.c(str);
        this.f893t = str;
        this.f890q = j8;
    }

    @Override // B0.U
    public void a(u0.H h8) {
        if (this.f891r) {
            d(e());
        }
        this.f894u = h8;
    }

    @Override // B0.U
    public u0.H b() {
        return (u0.H) this.f894u;
    }

    @Override // B0.U
    public /* synthetic */ boolean c() {
        return false;
    }

    public void d(long j8) {
        this.f890q = j8;
        if (this.f891r) {
            ((x0.q) this.f893t).getClass();
            this.f892s = SystemClock.elapsedRealtime();
        }
    }

    @Override // B0.U
    public long e() {
        long j8 = this.f890q;
        if (!this.f891r) {
            return j8;
        }
        ((x0.q) this.f893t).getClass();
        long jElapsedRealtime = SystemClock.elapsedRealtime() - this.f892s;
        u0.H h8 = (u0.H) this.f894u;
        return h8.f17159a == 1.0f ? x0.v.L(jElapsedRealtime) + j8 : (jElapsedRealtime * ((long) h8.f17161c)) + j8;
    }

    public void f() {
        if (this.f891r) {
            return;
        }
        ((x0.q) this.f893t).getClass();
        this.f892s = SystemClock.elapsedRealtime();
        this.f891r = true;
    }

    public long g() {
        if (!this.f891r) {
            this.f891r = true;
            this.f892s = ((C0785g0) this.f894u).J().getLong((String) this.f893t, this.f890q);
        }
        return this.f892s;
    }

    public void h(long j8) {
        SharedPreferences.Editor editorEdit = ((C0785g0) this.f894u).J().edit();
        editorEdit.putLong((String) this.f893t, j8);
        editorEdit.apply();
        this.f892s = j8;
    }

    public s0(x0.q qVar) {
        this.f893t = qVar;
        this.f894u = u0.H.f17158d;
    }
}
