package L1;

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;
import l1.C0825a;

/* JADX INFO: loaded from: classes.dex */
public final class A1 extends Q1 {

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

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public final C0099g0 f1295o;
    public final C0099g0 p;
    public final C0099g0 q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final C0099g0 f1296r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public final C0099g0 f1297s;

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

    public A1(W1 w12) {
        super(w12);
        this.f1294n = new HashMap();
        C0108j0 c0108j0 = ((C0146w0) this.f29k).f2036o;
        C0146w0.j(c0108j0);
        this.f1295o = new C0099g0(c0108j0, "last_delete_stale", 0L);
        C0108j0 c0108j02 = ((C0146w0) this.f29k).f2036o;
        C0146w0.j(c0108j02);
        this.p = new C0099g0(c0108j02, "last_delete_stale_batch", 0L);
        C0108j0 c0108j03 = ((C0146w0) this.f29k).f2036o;
        C0146w0.j(c0108j03);
        this.q = new C0099g0(c0108j03, "backoff", 0L);
        C0108j0 c0108j04 = ((C0146w0) this.f29k).f2036o;
        C0146w0.j(c0108j04);
        this.f1296r = new C0099g0(c0108j04, "last_upload", 0L);
        C0108j0 c0108j05 = ((C0146w0) this.f29k).f2036o;
        C0146w0.j(c0108j05);
        this.f1297s = new C0099g0(c0108j05, "last_upload_attempt", 0L);
        C0108j0 c0108j06 = ((C0146w0) this.f29k).f2036o;
        C0146w0.j(c0108j06);
        this.f1298t = new C0099g0(c0108j06, "midnight_offset", 0L);
    }

    public final Pair o(String str) {
        C0156z1 c0156z1;
        io.sentry.android.core.B bA;
        k();
        C0146w0 c0146w0 = (C0146w0) this.f29k;
        c0146w0.f2040u.getClass();
        long jElapsedRealtime = SystemClock.elapsedRealtime();
        HashMap map = this.f1294n;
        C0156z1 c0156z12 = (C0156z1) map.get(str);
        if (c0156z12 != null && jElapsedRealtime < c0156z12.f2092c) {
            return new Pair(c0156z12.f2090a, Boolean.valueOf(c0156z12.f2091b));
        }
        E e2 = F.f1396b;
        C0098g c0098g = c0146w0.f2035n;
        long jR = c0098g.r(str, e2) + jElapsedRealtime;
        try {
            try {
                bA = C0825a.a(c0146w0.f2032k);
            } catch (PackageManager.NameNotFoundException unused) {
                if (c0156z12 != null && jElapsedRealtime < c0156z12.f2092c + c0098g.r(str, F.f1399c)) {
                    return new Pair(c0156z12.f2090a, Boolean.valueOf(c0156z12.f2091b));
                }
                bA = null;
            }
        } catch (Exception e6) {
            X x5 = c0146w0.p;
            C0146w0.l(x5);
            x5.f1630w.c("Unable to get advertising id", e6);
            c0156z1 = new C0156z1("", false, jR);
        }
        if (bA == null) {
            return new Pair("00000000-0000-0000-0000-000000000000", Boolean.FALSE);
        }
        String str2 = bA.f7131b;
        boolean z5 = bA.f7132c;
        c0156z1 = str2 != null ? new C0156z1(str2, z5, jR) : new C0156z1("", z5, jR);
        map.put(str, c0156z1);
        return new Pair(c0156z1.f2090a, Boolean.valueOf(c0156z1.f2091b));
    }

    public final String p(String str, boolean z5) {
        k();
        String str2 = z5 ? (String) o(str).first : "00000000-0000-0000-0000-000000000000";
        MessageDigest messageDigestB = c2.B();
        if (messageDigestB == null) {
            return null;
        }
        return String.format(Locale.US, "%032X", new BigInteger(1, messageDigestB.digest(str2.getBytes())));
    }

    @Override // L1.Q1
    public final void n() {
    }
}
