package com.google.android.gms.ads.nonagon.signalgeneration;

import android.content.Context;
import android.content.SharedPreferences;
import androidx.annotation.Nullable;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/* JADX INFO: loaded from: classes2.dex */
public final class h0 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public SharedPreferences f8037a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public SharedPreferences.Editor f8038b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final Context f8039c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final Object f8040d = new Object();

    public h0(Context context) {
        this.f8039c = context;
    }

    public final void a() {
        c();
        synchronized (this.f8040d) {
            this.f8038b.clear().commit();
        }
    }

    public final HashMap b() {
        HashMap map;
        c();
        synchronized (this.f8040d) {
            try {
                Map<String, ?> all = this.f8037a.getAll();
                map = new HashMap();
                for (Map.Entry<String, ?> entry : all.entrySet()) {
                    if ((entry.getValue() instanceof String) && !Objects.equals(entry.getKey(), "pn") && !Objects.equals(entry.getKey(), "vc") && !Objects.equals(entry.getKey(), "dm") && !Objects.equals(entry.getKey(), "aav")) {
                        map.put(entry.getKey(), (String) entry.getValue());
                    }
                }
            } catch (Throwable th) {
                throw th;
            }
        }
        return map;
    }

    public final void c() {
        synchronized (this.f8040d) {
            try {
                if (this.f8037a != null) {
                    return;
                }
                SharedPreferences sharedPreferences = this.f8039c.getSharedPreferences("query_info_shared_prefs", 0);
                this.f8037a = sharedPreferences;
                this.f8038b = sharedPreferences.edit();
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    @Nullable
    public final String zzb(String str) {
        String string;
        c();
        synchronized (this.f8040d) {
            string = this.f8037a.getString(str, null);
            this.f8038b.remove(str).commit();
        }
        return string;
    }

    @Nullable
    public final String zze() {
        String string;
        c();
        synchronized (this.f8040d) {
            string = this.f8037a.getString("pn", null);
        }
        return string;
    }

    @Nullable
    public final String zzg() {
        String string;
        c();
        synchronized (this.f8040d) {
            string = this.f8037a.getString("dm", null);
        }
        return string;
    }
}
