package o;

import android.content.pm.PackageManager;
import android.util.Pair;
import com.google.android.gms.common.util.Clock;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Locale;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class Xt0 extends Iu0 {
    public final HashMap d;
    public final C1235fr0 e;
    public final C1235fr0 f;
    public final C1235fr0 g;
    public final C1235fr0 h;
    public final C1235fr0 i;
    public final C1235fr0 j;

    public Xt0(C1051dv0 c1051dv0) {
        super(c1051dv0);
        this.d = new HashMap();
        C1617jr0 c1617jr0 = ((Kr0) this.a).e;
        Kr0.j(c1617jr0);
        this.e = new C1235fr0(c1617jr0, "last_delete_stale", 0L);
        C1617jr0 c1617jr02 = ((Kr0) this.a).e;
        Kr0.j(c1617jr02);
        this.f = new C1235fr0(c1617jr02, "last_delete_stale_batch", 0L);
        C1617jr0 c1617jr03 = ((Kr0) this.a).e;
        Kr0.j(c1617jr03);
        this.g = new C1235fr0(c1617jr03, "backoff", 0L);
        C1617jr0 c1617jr04 = ((Kr0) this.a).e;
        Kr0.j(c1617jr04);
        this.h = new C1235fr0(c1617jr04, "last_upload", 0L);
        C1617jr0 c1617jr05 = ((Kr0) this.a).e;
        Kr0.j(c1617jr05);
        this.i = new C1235fr0(c1617jr05, "last_upload_attempt", 0L);
        C1617jr0 c1617jr06 = ((Kr0) this.a).e;
        Kr0.j(c1617jr06);
        this.j = new C1235fr0(c1617jr06, "midnight_offset", 0L);
    }

    public final Pair w(String str) {
        W1 w1A;
        Wt0 wt0;
        r();
        Kr0 kr0 = (Kr0) this.a;
        Clock clock = kr0.k;
        C1421ho0 c1421ho0 = kr0.d;
        long jElapsedRealtime = clock.elapsedRealtime();
        HashMap map = this.d;
        Wt0 wt02 = (Wt0) map.get(str);
        if (wt02 != null && jElapsedRealtime < wt02.c) {
            return new Pair(wt02.a, Boolean.valueOf(wt02.b));
        }
        long jZ = c1421ho0.z(str, AbstractC1900mq0.b) + jElapsedRealtime;
        try {
            try {
                w1A = X1.a(kr0.a);
            } catch (PackageManager.NameNotFoundException unused) {
                if (wt02 != null && jElapsedRealtime < wt02.c + c1421ho0.z(str, AbstractC1900mq0.c)) {
                    return new Pair(wt02.a, Boolean.valueOf(wt02.b));
                }
                w1A = null;
            }
        } catch (Exception e) {
            Nq0 nq0 = kr0.f;
            Kr0.l(nq0);
            nq0.m.c(e, "Unable to get advertising id");
            wt0 = new Wt0("", false, jZ);
        }
        if (w1A == null) {
            return new Pair("00000000-0000-0000-0000-000000000000", Boolean.FALSE);
        }
        String str2 = w1A.c;
        wt0 = str2 != null ? new Wt0(str2, w1A.b, jZ) : new Wt0("", w1A.b, jZ);
        map.put(str, wt0);
        return new Pair(wt0.a, Boolean.valueOf(wt0.b));
    }

    public final String x(String str, boolean z) throws NoSuchAlgorithmException {
        r();
        String str2 = z ? (String) w(str).first : "00000000-0000-0000-0000-000000000000";
        MessageDigest messageDigestJ = C2574tv0.J();
        if (messageDigestJ == null) {
            return null;
        }
        return String.format(Locale.US, "%032X", new BigInteger(1, messageDigestJ.digest(str2.getBytes())));
    }

    @Override // o.Iu0
    public final void v() {
    }
}
