package com.google.android.gms.internal.ads;

import android.content.Context;
import androidx.annotation.Nullable;
import java.util.Locale;

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

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

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public jv f11892c;

    @Nullable
    private jv zzc;

    public static final boolean c(Context context) {
        if (((Boolean) up.f17362c.j()).booleanValue()) {
            return false;
        }
        Context applicationContext = context.getApplicationContext();
        if (applicationContext != null) {
            context = applicationContext;
        }
        return ((String) p7.r0.F(context).f31762b).toLowerCase(Locale.ROOT).equals("ru");
    }

    public final jv a(Context context, q7.a aVar, nd1 nd1Var) {
        jv jvVar;
        String str;
        synchronized (this.f11891b) {
            try {
                if (this.f11892c == null) {
                    Context applicationContext = context.getApplicationContext();
                    if (applicationContext == null) {
                        applicationContext = context;
                    }
                    if (c(context)) {
                        str = (String) n7.y.f31093e.f31096c.b(ao.f8795c);
                    } else {
                        str = (String) za2.f19207i.j();
                    }
                    this.f11892c = new jv(applicationContext, aVar, str, nd1Var);
                }
                jvVar = this.f11892c;
            } catch (Throwable th) {
                throw th;
            }
        }
        return jvVar;
    }

    public final void b() {
        synchronized (this.f11890a) {
            try {
                jv jvVar = this.zzc;
                if (jvVar != null) {
                    jvVar.f13023a.a();
                    this.zzc = null;
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    public final jv zzb(Context context, q7.a aVar, @Nullable nd1 nd1Var) {
        jv jvVar;
        String str;
        synchronized (this.f11890a) {
            try {
                if (this.zzc == null) {
                    if (c(context)) {
                        str = (String) n7.y.f31093e.f31096c.b(ao.f8795c);
                    } else if (((Boolean) up.f17366g.j()).booleanValue()) {
                        str = (String) n7.y.f31093e.f31096c.b(ao.f8762a);
                    } else {
                        str = (String) n7.y.f31093e.f31096c.b(ao.f8778b);
                    }
                    Context applicationContext = context.getApplicationContext();
                    if (applicationContext != null) {
                        context = applicationContext;
                    }
                    this.zzc = new jv(context, aVar, str, nd1Var);
                }
                jvVar = this.zzc;
            } catch (Throwable th) {
                throw th;
            }
        }
        return jvVar;
    }
}
