package m4;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.security.GeneralSecurityException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import k4.AbstractC2384C;
import k4.AbstractC2395h;
import k4.C2401n;
import k4.C2403p;
import k4.C2410x;
import m1.AbstractC2464a;

/* JADX INFO: loaded from: classes3.dex */
public final class T0 extends k4.X {

    /* JADX INFO: renamed from: E, reason: collision with root package name */
    public static final Method f20819E;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final l2.c f20822a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final l2.c f20823b;

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final k4.n0 f20825d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final ArrayList f20826e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final String f20827f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final String f20828g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final C2410x f20829h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public final C2403p f20830i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public final long f20831j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final int f20832k;
    public final int l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public final long f20833m;

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

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public final boolean f20835o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public final k4.G f20836p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final boolean f20837q;

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

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

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

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public final boolean f20841u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public final boolean f20842v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public final n4.f f20843w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public final n4.f f20844x;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public static final Logger f20820y = Logger.getLogger(T0.class.getName());

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public static final long f20821z = TimeUnit.MINUTES.toMillis(30);

    /* JADX INFO: renamed from: A, reason: collision with root package name */
    public static final long f20815A = TimeUnit.SECONDS.toMillis(1);

    /* JADX INFO: renamed from: B, reason: collision with root package name */
    public static final l2.c f20816B = new l2.c(AbstractC2504f0.f21009p, 6);

    /* JADX INFO: renamed from: C, reason: collision with root package name */
    public static final C2410x f20817C = C2410x.f19979d;

    /* JADX INFO: renamed from: D, reason: collision with root package name */
    public static final C2403p f20818D = C2403p.f19908b;

    static {
        Method declaredMethod;
        try {
            Class<?> cls = Class.forName("io.grpc.census.InternalCensusStatsAccessor");
            Class cls2 = Boolean.TYPE;
            declaredMethod = cls.getDeclaredMethod("getClientInterceptor", cls2, cls2, cls2, cls2);
        } catch (ClassNotFoundException e6) {
            f20820y.log(Level.FINE, "Unable to apply census stats", (Throwable) e6);
            declaredMethod = null;
        } catch (NoSuchMethodException e7) {
            f20820y.log(Level.FINE, "Unable to apply census stats", (Throwable) e7);
            declaredMethod = null;
        }
        f20819E = declaredMethod;
    }

    public T0(String str, n4.f fVar, n4.f fVar2) {
        k4.n0 n0Var;
        l2.c cVar = f20816B;
        this.f20822a = cVar;
        this.f20823b = cVar;
        this.f20824c = new ArrayList();
        Logger logger = k4.n0.f19900d;
        synchronized (k4.n0.class) {
            try {
                if (k4.n0.f19901e == null) {
                    ArrayList arrayList = new ArrayList();
                    try {
                        boolean z6 = V.f20881a;
                        arrayList.add(V.class);
                    } catch (ClassNotFoundException e6) {
                        k4.n0.f19900d.log(Level.FINE, "Unable to find DNS NameResolver", (Throwable) e6);
                    }
                    List<k4.m0> listE = AbstractC2395h.e(k4.m0.class, Collections.unmodifiableList(arrayList), k4.m0.class.getClassLoader(), new C2401n(9));
                    if (listE.isEmpty()) {
                        k4.n0.f19900d.warning("No NameResolverProviders found via ServiceLoader, including for DNS. This is probably due to a broken build. If using ProGuard, check your configuration");
                    }
                    k4.n0.f19901e = new k4.n0();
                    for (k4.m0 m0Var : listE) {
                        k4.n0.f19900d.fine("Service loader found " + m0Var);
                        k4.n0 n0Var2 = k4.n0.f19901e;
                        synchronized (n0Var2) {
                            m0Var.getClass();
                            n0Var2.f19903b.add(m0Var);
                        }
                    }
                    k4.n0.f19901e.a();
                }
                n0Var = k4.n0.f19901e;
            } catch (Throwable th) {
                throw th;
            }
        }
        this.f20825d = n0Var;
        this.f20826e = new ArrayList();
        this.f20828g = "pick_first";
        this.f20829h = f20817C;
        this.f20830i = f20818D;
        this.f20831j = f20821z;
        this.f20832k = 5;
        this.l = 5;
        this.f20833m = 16777216L;
        this.f20834n = 1048576L;
        this.f20835o = true;
        this.f20836p = k4.G.f19801e;
        this.f20837q = true;
        this.f20838r = true;
        this.f20839s = true;
        this.f20840t = true;
        this.f20841u = true;
        this.f20842v = true;
        A4.g.o(str, "target");
        this.f20827f = str;
        this.f20843w = fVar;
        this.f20844x = fVar2;
    }

    @Override // k4.X
    public final k4.W a() {
        SSLSocketFactory sSLSocketFactory;
        Method method;
        n4.h hVar = this.f20843w.f21649a;
        boolean z6 = hVar.f21673h != Long.MAX_VALUE;
        int iC = AbstractC2464a.c(hVar.f21672g);
        if (iC == 0) {
            try {
                if (hVar.f21670e == null) {
                    hVar.f21670e = SSLContext.getInstance("Default", o4.l.f21870d.f21871a).getSocketFactory();
                }
                sSLSocketFactory = hVar.f21670e;
            } catch (GeneralSecurityException e6) {
                throw new RuntimeException("TLS Provider failure", e6);
            }
        } else {
            if (iC != 1) {
                throw new RuntimeException("Unknown negotiation type: ".concat(com.google.android.recaptcha.internal.a.z(hVar.f21672g)));
            }
            sSLSocketFactory = null;
        }
        n4.g gVar = new n4.g(hVar.f21668c, hVar.f21669d, sSLSocketFactory, hVar.f21671f, hVar.f21676k, z6, hVar.f21673h, hVar.f21674i, hVar.f21675j, hVar.l, hVar.f21667b);
        i2 i2Var = new i2(7);
        l2.c cVar = new l2.c(AbstractC2504f0.f21009p, 6);
        C2498d0 c2498d0 = AbstractC2504f0.f21011r;
        ArrayList arrayList = new ArrayList(this.f20824c);
        synchronized (AbstractC2384C.class) {
        }
        if (this.f20838r && (method = f20819E) != null) {
            try {
                if (method.invoke(null, Boolean.valueOf(this.f20839s), Boolean.valueOf(this.f20840t), Boolean.FALSE, Boolean.valueOf(this.f20841u)) != null) {
                    throw new ClassCastException();
                }
            } catch (IllegalAccessException e7) {
                f20820y.log(Level.FINE, "Unable to apply census stats", (Throwable) e7);
            } catch (InvocationTargetException e8) {
                f20820y.log(Level.FINE, "Unable to apply census stats", (Throwable) e8);
            }
        }
        if (this.f20842v) {
            try {
                if (Class.forName("io.grpc.census.InternalCensusTracingAccessor").getDeclaredMethod("getClientInterceptor", new Class[0]).invoke(null, new Object[0]) != null) {
                    throw new ClassCastException();
                }
            } catch (ClassNotFoundException e9) {
                f20820y.log(Level.FINE, "Unable to apply census stats", (Throwable) e9);
            } catch (IllegalAccessException e10) {
                f20820y.log(Level.FINE, "Unable to apply census stats", (Throwable) e10);
            } catch (NoSuchMethodException e11) {
                f20820y.log(Level.FINE, "Unable to apply census stats", (Throwable) e11);
            } catch (InvocationTargetException e12) {
                f20820y.log(Level.FINE, "Unable to apply census stats", (Throwable) e12);
            }
        }
        return new V0(new S0(this, gVar, i2Var, cVar, c2498d0, arrayList));
    }
}
