package p447.p448.p457;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Arrays;
import java.util.List;
import javax.net.ssl.SSLSocket;
import kotlin.TypeCastException;
import kotlin.jvm.internal.DefaultConstructorMarker;
import p402.InterfaceC6540;
import p402.p411.p413.C6635;
import p447.EnumC6924;

/* JADX INFO: renamed from: ސ.ޣ.މ.ނ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
@InterfaceC6540
public final class C7062 extends C7069 {

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public static final C7064 f20572 = new C7064(null);

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public final Method f20573;

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public final Method f20574;

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public final Method f20575;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public final Class<?> f20576;

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public final Class<?> f20577;

    /* JADX INFO: renamed from: ސ.ޣ.މ.ނ$֏, reason: contains not printable characters */
    public static final class C7063 implements InvocationHandler {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public boolean f20578;

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public String f20579;

        /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
        public final List<String> f20580;

        public C7063(List<String> list) {
            if (list != null) {
                this.f20580 = list;
            } else {
                C6635.m9824("protocols");
                throw null;
            }
        }

        @Override // java.lang.reflect.InvocationHandler
        public Object invoke(Object obj, Method method, Object[] objArr) {
            if (obj == null) {
                C6635.m9824("proxy");
                throw null;
            }
            if (method == null) {
                C6635.m9824("method");
                throw null;
            }
            if (objArr == null) {
                objArr = new Object[0];
            }
            String name = method.getName();
            Class<?> returnType = method.getReturnType();
            if (C6635.m9825((Object) name, (Object) "supports") && C6635.m9825(Boolean.TYPE, returnType)) {
                return true;
            }
            if (C6635.m9825((Object) name, (Object) "unsupported") && C6635.m9825(Void.TYPE, returnType)) {
                this.f20578 = true;
                return null;
            }
            if (C6635.m9825((Object) name, (Object) "protocols")) {
                if (objArr.length == 0) {
                    return this.f20580;
                }
            }
            if ((!C6635.m9825((Object) name, (Object) "selectProtocol") && !C6635.m9825((Object) name, (Object) "select")) || !C6635.m9825(String.class, returnType) || objArr.length != 1 || !(objArr[0] instanceof List)) {
                if ((!C6635.m9825((Object) name, (Object) "protocolSelected") && !C6635.m9825((Object) name, (Object) "selected")) || objArr.length != 1) {
                    return method.invoke(this, Arrays.copyOf(objArr, objArr.length));
                }
                Object obj2 = objArr[0];
                if (obj2 == null) {
                    throw new TypeCastException("null cannot be cast to non-null type kotlin.String");
                }
                this.f20579 = (String) obj2;
                return null;
            }
            Object obj3 = objArr[0];
            if (obj3 == null) {
                throw new TypeCastException("null cannot be cast to non-null type kotlin.collections.List<*>");
            }
            List list = (List) obj3;
            int size = list.size();
            if (size >= 0) {
                int i = 0;
                while (true) {
                    Object obj4 = list.get(i);
                    if (obj4 == null) {
                        throw new TypeCastException("null cannot be cast to non-null type kotlin.String");
                    }
                    String str = (String) obj4;
                    if (!this.f20580.contains(str)) {
                        if (i == size) {
                            break;
                        }
                        i++;
                    } else {
                        this.f20579 = str;
                        return str;
                    }
                }
            }
            String str2 = this.f20580.get(0);
            this.f20579 = str2;
            return str2;
        }
    }

    /* JADX INFO: renamed from: ސ.ޣ.މ.ނ$ؠ, reason: contains not printable characters */
    public static final class C7064 {
        public C7064() {
        }

        public /* synthetic */ C7064(DefaultConstructorMarker defaultConstructorMarker) {
        }
    }

    public C7062(Method method, Method method2, Method method3, Class<?> cls, Class<?> cls2) {
        if (method == null) {
            C6635.m9824("putMethod");
            throw null;
        }
        if (method2 == null) {
            C6635.m9824("getMethod");
            throw null;
        }
        if (method3 == null) {
            C6635.m9824("removeMethod");
            throw null;
        }
        if (cls == null) {
            C6635.m9824("clientProviderClass");
            throw null;
        }
        if (cls2 == null) {
            C6635.m9824("serverProviderClass");
            throw null;
        }
        this.f20573 = method;
        this.f20574 = method2;
        this.f20575 = method3;
        this.f20576 = cls;
        this.f20577 = cls2;
    }

    @Override // p447.p448.p457.C7069
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public void mo10379(SSLSocket sSLSocket) {
        if (sSLSocket == null) {
            C6635.m9824("sslSocket");
            throw null;
        }
        try {
            this.f20575.invoke(null, sSLSocket);
        } catch (IllegalAccessException e) {
            throw new AssertionError("failed to remove ALPN", e);
        } catch (InvocationTargetException e2) {
            throw new AssertionError("failed to remove ALPN", e2);
        }
    }

    @Override // p447.p448.p457.C7069
    /* JADX INFO: renamed from: ֏ */
    public void mo10367(SSLSocket sSLSocket, String str, List<? extends EnumC6924> list) {
        if (sSLSocket == null) {
            C6635.m9824("sslSocket");
            throw null;
        }
        if (list == null) {
            C6635.m9824("protocols");
            throw null;
        }
        try {
            this.f20573.invoke(null, sSLSocket, Proxy.newProxyInstance(C7069.class.getClassLoader(), new Class[]{this.f20576, this.f20577}, new C7063(C7069.f20588.m10382(list))));
        } catch (IllegalAccessException e) {
            throw new AssertionError("failed to set ALPN", e);
        } catch (InvocationTargetException e2) {
            throw new AssertionError("failed to set ALPN", e2);
        }
    }

    @Override // p447.p448.p457.C7069
    /* JADX INFO: renamed from: ؠ */
    public String mo10368(SSLSocket sSLSocket) {
        if (sSLSocket == null) {
            C6635.m9824("sslSocket");
            throw null;
        }
        try {
            InvocationHandler invocationHandler = Proxy.getInvocationHandler(this.f20574.invoke(null, sSLSocket));
            if (invocationHandler == null) {
                throw new TypeCastException("null cannot be cast to non-null type okhttp3.internal.platform.Jdk8WithJettyBootPlatform.AlpnProvider");
            }
            C7063 c7063 = (C7063) invocationHandler;
            if (!c7063.f20578 && c7063.f20579 == null) {
                C7069.m10380(this, "ALPN callback dropped: HTTP/2 is disabled. Is alpn-boot on the boot class path?", 0, null, 6, null);
                return null;
            }
            if (c7063.f20578) {
                return null;
            }
            return c7063.f20579;
        } catch (IllegalAccessException e) {
            throw new AssertionError("failed to get ALPN selected protocol", e);
        } catch (InvocationTargetException e2) {
            throw new AssertionError("failed to get ALPN selected protocol", e2);
        }
    }
}
