package com.facetec.sdk; import com.google.android.gms.analytics.ecommerce.ProductAction; 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; /* loaded from: classes.dex */ final class me extends mi { private final Method a; private final Method b; private final Class c; private final Method d; private final Class e; private me(Method method, Method method2, Method method3, Class cls, Class cls2) { this.d = method; this.b = method2; this.a = method3; this.c = cls; this.e = cls2; } @Override // com.facetec.sdk.mi public final void e(SSLSocket sSLSocket, String str, List list) { try { this.d.invoke(null, sSLSocket, Proxy.newProxyInstance(mi.class.getClassLoader(), new Class[]{this.c, this.e}, new c(b(list)))); } catch (IllegalAccessException | InvocationTargetException e) { throw km.e("unable to set alpn", e); } } @Override // com.facetec.sdk.mi public final void b(SSLSocket sSLSocket) { try { this.a.invoke(null, sSLSocket); } catch (IllegalAccessException | InvocationTargetException e) { throw km.e("unable to remove alpn", e); } } @Override // com.facetec.sdk.mi public final String c(SSLSocket sSLSocket) { try { c cVar = (c) Proxy.getInvocationHandler(this.b.invoke(null, sSLSocket)); if (!cVar.d && cVar.e == null) { mi.c().d(4, "ALPN callback dropped: HTTP/2 is disabled. Is alpn-boot on the boot class path?", null); return null; } if (cVar.d) { return null; } return cVar.e; } catch (IllegalAccessException | InvocationTargetException e) { throw km.e("unable to get selected protocol", e); } } public static mi b() { try { Class cls = Class.forName("org.eclipse.jetty.alpn.ALPN"); Class cls2 = Class.forName("org.eclipse.jetty.alpn.ALPN$Provider"); return new me(cls.getMethod("put", SSLSocket.class, cls2), cls.getMethod("get", SSLSocket.class), cls.getMethod(ProductAction.ACTION_REMOVE, SSLSocket.class), Class.forName("org.eclipse.jetty.alpn.ALPN$ClientProvider"), Class.forName("org.eclipse.jetty.alpn.ALPN$ServerProvider")); } catch (ClassNotFoundException | NoSuchMethodException unused) { return null; } } /* loaded from: classes.dex */ static final class c implements InvocationHandler { private final List c; boolean d; String e; c(List list) { this.c = list; } @Override // java.lang.reflect.InvocationHandler public final Object invoke(Object obj, Method method, Object[] objArr) throws Throwable { String name = method.getName(); Class returnType = method.getReturnType(); if (objArr == null) { objArr = km.a; } if (name.equals("supports") && Boolean.TYPE == returnType) { return Boolean.TRUE; } if (name.equals("unsupported") && Void.TYPE == returnType) { this.d = true; return null; } if (name.equals("protocols") && objArr.length == 0) { return this.c; } if ((name.equals("selectProtocol") || name.equals("select")) && String.class == returnType && objArr.length == 1) { Object obj2 = objArr[0]; if (obj2 instanceof List) { List list = (List) obj2; int size = list.size(); for (int i = 0; i < size; i++) { if (this.c.contains(list.get(i))) { String str = (String) list.get(i); this.e = str; return str; } } String str2 = this.c.get(0); this.e = str2; return str2; } } if ((name.equals("protocolSelected") || name.equals("selected")) && objArr.length == 1) { this.e = (String) objArr[0]; return null; } return method.invoke(this, objArr); } } }