package 㿎.ሽ.ᨨ;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.List;
import javax.net.ssl.SSLSocket;
import okhttp3.Protocol;
import 㿎.ሽ.C2540;

/* renamed from: 㿎.ሽ.ᨨ.㸾  reason: contains not printable characters */
/* compiled from: JdkWithJettyBootPlatform */
public class C2559 extends C2558 {

    /* renamed from: ʬ  reason: contains not printable characters */
    public final Method f8644;

    /* renamed from: ඓ  reason: contains not printable characters */
    public final Method f8645;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public final Class<?> f8646;

    /* renamed from: 㴹  reason: contains not printable characters */
    public final Class<?> f8647;

    /* renamed from: 㸾  reason: contains not printable characters */
    public final Method f8648;

    /* renamed from: 㿎.ሽ.ᨨ.㸾$K  reason: contains not printable characters */
    /* compiled from: JdkWithJettyBootPlatform */
    public static class C2560 implements InvocationHandler {

        /* renamed from: ʬ  reason: contains not printable characters */
        public String f8649;

        /* renamed from: ῲ  reason: contains not printable characters */
        public boolean f8650;

        /* renamed from: K  reason: contains not printable characters */
        public final List<String> f8651;

        public C2560(List<String> list) {
            this.f8651 = list;
        }

        @Override // java.lang.reflect.InvocationHandler
        public Object invoke(Object obj, Method method, Object[] objArr) throws Throwable {
            String name = method.getName();
            Class<?> returnType = method.getReturnType();
            if (objArr == null) {
                objArr = C2540.f8567;
            }
            if (name.equals("supports") && Boolean.TYPE == returnType) {
                return true;
            }
            if (name.equals("unsupported") && Void.TYPE == returnType) {
                this.f8650 = true;
                return null;
            } else if (name.equals("protocols") && objArr.length == 0) {
                return this.f8651;
            } else {
                if ((name.equals("selectProtocol") || name.equals("select")) && String.class == returnType && objArr.length == 1 && (objArr[0] instanceof List)) {
                    List list = (List) objArr[0];
                    int size = list.size();
                    for (int i = 0; i < size; i++) {
                        if (this.f8651.contains(list.get(i))) {
                            String str = (String) list.get(i);
                            this.f8649 = str;
                            return str;
                        }
                    }
                    String str2 = this.f8651.get(0);
                    this.f8649 = str2;
                    return str2;
                } else if ((!name.equals("protocolSelected") && !name.equals("selected")) || objArr.length != 1) {
                    return method.invoke(this, objArr);
                } else {
                    this.f8649 = (String) objArr[0];
                    return null;
                }
            }
        }
    }

    public C2559(Method method, Method method2, Method method3, Class<?> cls, Class<?> cls2) {
        this.f8644 = method;
        this.f8648 = method2;
        this.f8645 = method3;
        this.f8647 = cls;
        this.f8646 = cls2;
    }

    @Override // 㿎.ሽ.ᨨ.C2558
    /* renamed from: ῲ  reason: contains not printable characters */
    public String m6738(SSLSocket sSLSocket) {
        try {
            C2560 k = (C2560) Proxy.getInvocationHandler(this.f8648.invoke(null, sSLSocket));
            if (!k.f8650 && k.f8649 == null) {
                C2558.f8643.m6731(4, "ALPN callback dropped: HTTP/2 is disabled. Is alpn-boot on the boot class path?", (Throwable) null);
                return null;
            } else if (k.f8650) {
                return null;
            } else {
                return k.f8649;
            }
        } catch (IllegalAccessException | InvocationTargetException e) {
            throw C2540.m6640("unable to get selected protocol", (Exception) e);
        }
    }

    @Override // 㿎.ሽ.ᨨ.C2558
    /* renamed from: K  reason: contains not printable characters */
    public void m6740(SSLSocket sSLSocket, String str, List<Protocol> list) {
        List<String> r7 = C2558.m6723(list);
        try {
            Object newProxyInstance = Proxy.newProxyInstance(C2558.class.getClassLoader(), new Class[]{this.f8647, this.f8646}, new C2560(r7));
            this.f8644.invoke(null, sSLSocket, newProxyInstance);
        } catch (IllegalAccessException | InvocationTargetException e) {
            throw C2540.m6640("unable to set alpn", (Exception) e);
        }
    }

    @Override // 㿎.ሽ.ᨨ.C2558
    /* renamed from: K  reason: contains not printable characters */
    public void m6739(SSLSocket sSLSocket) {
        try {
            this.f8645.invoke(null, sSLSocket);
        } catch (IllegalAccessException | InvocationTargetException e) {
            throw C2540.m6640("unable to remove alpn", (Exception) e);
        }
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public static C2558 m6737() {
        try {
            Class<?> cls = Class.forName("org.eclipse.jetty.alpn.ALPN");
            Class<?> cls2 = Class.forName("org.eclipse.jetty.alpn.ALPN" + "$Provider");
            Class<?> cls3 = Class.forName("org.eclipse.jetty.alpn.ALPN" + "$ClientProvider");
            Class<?> cls4 = Class.forName("org.eclipse.jetty.alpn.ALPN" + "$ServerProvider");
            return new C2559(cls.getMethod("put", SSLSocket.class, cls2), cls.getMethod("get", SSLSocket.class), cls.getMethod("remove", SSLSocket.class), cls3, cls4);
        } catch (ClassNotFoundException | NoSuchMethodException unused) {
            return null;
        }
    }
}
