package o;

import android.net.http.X509TrustManagerExtensions;
import android.os.Build;
import android.security.NetworkSecurityPolicy;
import java.util.ArrayList;
import java.util.List;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.X509TrustManager;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class K2 extends ZW {
    public static final boolean d;
    public final ArrayList c;

    static {
        d = C2616uQ.v() && Build.VERSION.SDK_INT >= 29;
    }

    public K2() {
        int i = 0;
        ArrayList arrayListQ = AbstractC2219q9.Q(new K90[]{(!C2616uQ.v() || Build.VERSION.SDK_INT < 29) ? null : new L2(), new C0353Nq(C2305r5.f), new C0353Nq(C2838wl.a), new C0353Nq(C2824we.a)});
        ArrayList arrayList = new ArrayList();
        int size = arrayListQ.size();
        while (i < size) {
            Object obj = arrayListQ.get(i);
            i++;
            if (((K90) obj).c()) {
                arrayList.add(obj);
            }
        }
        this.c = arrayList;
    }

    @Override // o.ZW
    public final AbstractC1155f00 b(X509TrustManager x509TrustManager) {
        X509TrustManagerExtensions x509TrustManagerExtensions;
        try {
            x509TrustManagerExtensions = new X509TrustManagerExtensions(x509TrustManager);
        } catch (IllegalArgumentException unused) {
            x509TrustManagerExtensions = null;
        }
        V2 v2 = x509TrustManagerExtensions != null ? new V2(x509TrustManager, x509TrustManagerExtensions) : null;
        return v2 != null ? v2 : super.b(x509TrustManager);
    }

    @Override // o.ZW
    public final void d(SSLSocket sSLSocket, String str, List list) {
        Object obj;
        ArrayList arrayList = this.c;
        int size = arrayList.size();
        int i = 0;
        while (true) {
            if (i >= size) {
                obj = null;
                break;
            }
            obj = arrayList.get(i);
            i++;
            if (((K90) obj).b(sSLSocket)) {
                break;
            }
        }
        K90 k90 = (K90) obj;
        if (k90 != null) {
            k90.d(sSLSocket, str, list);
        }
    }

    @Override // o.ZW
    public final String f(SSLSocket sSLSocket) {
        Object obj;
        ArrayList arrayList = this.c;
        int size = arrayList.size();
        int i = 0;
        while (true) {
            if (i >= size) {
                obj = null;
                break;
            }
            obj = arrayList.get(i);
            i++;
            if (((K90) obj).b(sSLSocket)) {
                break;
            }
        }
        K90 k90 = (K90) obj;
        if (k90 != null) {
            return k90.a(sSLSocket);
        }
        return null;
    }

    @Override // o.ZW
    public final boolean h(String str) {
        return NetworkSecurityPolicy.getInstance().isCleartextTrafficPermitted(str);
    }
}
