package d3;

import android.content.pm.PackageManager;
import android.os.SystemClock;
import android.util.Pair;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.util.HashMap;
import java.util.Locale;

/* JADX INFO: renamed from: d3.v1, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C0830v1 extends K1 {

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

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public final B0.s0 f12204u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public final B0.s0 f12205v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public final B0.s0 f12206w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public final B0.s0 f12207x;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public final B0.s0 f12208y;

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public final B0.s0 f12209z;

    public C0830v1(Q1 q12) {
        super(q12);
        this.f12203t = new HashMap();
        C0785g0 c0785g0 = ((C0817r0) this.f5146q).f12149x;
        C0817r0.i(c0785g0);
        this.f12204u = new B0.s0(c0785g0, "last_delete_stale", 0L);
        C0785g0 c0785g02 = ((C0817r0) this.f5146q).f12149x;
        C0817r0.i(c0785g02);
        this.f12205v = new B0.s0(c0785g02, "last_delete_stale_batch", 0L);
        C0785g0 c0785g03 = ((C0817r0) this.f5146q).f12149x;
        C0817r0.i(c0785g03);
        this.f12206w = new B0.s0(c0785g03, "backoff", 0L);
        C0785g0 c0785g04 = ((C0817r0) this.f5146q).f12149x;
        C0817r0.i(c0785g04);
        this.f12207x = new B0.s0(c0785g04, "last_upload", 0L);
        C0785g0 c0785g05 = ((C0817r0) this.f5146q).f12149x;
        C0817r0.i(c0785g05);
        this.f12208y = new B0.s0(c0785g05, "last_upload_attempt", 0L);
        C0785g0 c0785g06 = ((C0817r0) this.f5146q).f12149x;
        C0817r0.i(c0785g06);
        this.f12209z = new B0.s0(c0785g06, "midnight_offset", 0L);
    }

    public final Pair I(String str) {
        C0827u1 c0827u1;
        L2.a aVarA;
        E();
        C0817r0 c0817r0 = (C0817r0) this.f5146q;
        c0817r0.D.getClass();
        long jElapsedRealtime = SystemClock.elapsedRealtime();
        HashMap map = this.f12203t;
        C0827u1 c0827u12 = (C0827u1) map.get(str);
        if (c0827u12 != null && jElapsedRealtime < c0827u12.f12192c) {
            return new Pair(c0827u12.f12190a, Boolean.valueOf(c0827u12.f12191b));
        }
        H h8 = I.f11536b;
        C0784g c0784g = c0817r0.f12148w;
        long jM = c0784g.M(str, h8) + jElapsedRealtime;
        try {
            try {
                aVarA = L2.b.a(c0817r0.f12142q);
            } catch (PackageManager.NameNotFoundException unused) {
                if (c0827u12 != null && jElapsedRealtime < c0827u12.f12192c + c0784g.M(str, I.f11539c)) {
                    return new Pair(c0827u12.f12190a, Boolean.valueOf(c0827u12.f12191b));
                }
                aVarA = null;
            }
        } catch (Exception e8) {
            Z z8 = c0817r0.f12150y;
            C0817r0.k(z8);
            z8.f11871C.c(e8, "Unable to get advertising id");
            c0827u1 = new C0827u1(jM, "", false);
        }
        if (aVarA == null) {
            return new Pair("00000000-0000-0000-0000-000000000000", Boolean.FALSE);
        }
        String str2 = aVarA.f3979c;
        boolean z9 = aVarA.f3978b;
        c0827u1 = str2 != null ? new C0827u1(jM, str2, z9) : new C0827u1(jM, "", z9);
        map.put(str, c0827u1);
        return new Pair(c0827u1.f12190a, Boolean.valueOf(c0827u1.f12191b));
    }

    public final String J(String str, boolean z8) {
        E();
        String str2 = z8 ? (String) I(str).first : "00000000-0000-0000-0000-000000000000";
        MessageDigest messageDigestP = W1.P();
        if (messageDigestP == null) {
            return null;
        }
        return String.format(Locale.US, "%032X", new BigInteger(1, messageDigestP.digest(str2.getBytes())));
    }

    @Override // d3.K1
    public final void H() {
    }
}
