package o5; 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: classes2.dex */ class d extends o5.a { /* renamed from: c, reason: collision with root package name */ private final Method f12699c; /* renamed from: d, reason: collision with root package name */ private final Method f12700d; /* renamed from: e, reason: collision with root package name */ private final Method f12701e; /* renamed from: f, reason: collision with root package name */ private final Class f12702f; /* renamed from: g, reason: collision with root package name */ private final Class f12703g; private static class a implements InvocationHandler { /* renamed from: a, reason: collision with root package name */ private final List f12704a; /* renamed from: b, reason: collision with root package name */ boolean f12705b; /* renamed from: c, reason: collision with root package name */ String f12706c; a(List list) { this.f12704a = list; } @Override // java.lang.reflect.InvocationHandler public Object invoke(Object obj, Method method, Object[] objArr) { Object obj2; String name = method.getName(); Class returnType = method.getReturnType(); if (objArr == null) { objArr = i5.c.f10872b; } if (name.equals("supports") && Boolean.TYPE == returnType) { return Boolean.TRUE; } if (name.equals("unsupported") && Void.TYPE == returnType) { this.f12705b = true; return null; } if (name.equals("protocols") && objArr.length == 0) { return this.f12704a; } if ((name.equals("selectProtocol") || name.equals("select")) && String.class == returnType && objArr.length == 1) { Object obj3 = objArr[0]; if (obj3 instanceof List) { List list = (List) obj3; int size = list.size(); int i10 = 0; while (true) { if (i10 >= size) { obj2 = this.f12704a.get(0); break; } if (this.f12704a.contains(list.get(i10))) { obj2 = list.get(i10); break; } i10++; } String str = (String) obj2; this.f12706c = str; return str; } } if ((!name.equals("protocolSelected") && !name.equals("selected")) || objArr.length != 1) { return method.invoke(this, objArr); } this.f12706c = (String) objArr[0]; return null; } } d(Method method, Method method2, Method method3, Class cls, Class cls2) { this.f12699c = method; this.f12700d = method2; this.f12701e = method3; this.f12702f = cls; this.f12703g = cls2; } public static o5.a q() { try { Class cls = Class.forName("org.eclipse.jetty.alpn.ALPN"); Class cls2 = Class.forName("org.eclipse.jetty.alpn.ALPN$Provider"); return new d(cls.getMethod("put", SSLSocket.class, cls2), cls.getMethod("get", SSLSocket.class), cls.getMethod("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; } } @Override // o5.a public void c(SSLSocket sSLSocket) { try { this.f12701e.invoke(null, sSLSocket); } catch (IllegalAccessException | InvocationTargetException e10) { throw i5.c.e("unable to remove alpn", e10); } } @Override // o5.a public void h(SSLSocket sSLSocket, String str, List list) { try { this.f12699c.invoke(null, sSLSocket, Proxy.newProxyInstance(o5.a.class.getClassLoader(), new Class[]{this.f12702f, this.f12703g}, new a(o5.a.d(list)))); } catch (IllegalAccessException | InvocationTargetException e10) { throw i5.c.e("unable to set alpn", e10); } } @Override // o5.a public String l(SSLSocket sSLSocket) { try { a aVar = (a) Proxy.getInvocationHandler(this.f12700d.invoke(null, sSLSocket)); boolean z10 = aVar.f12705b; if (!z10 && aVar.f12706c == null) { o5.a.j().o(4, "ALPN callback dropped: HTTP/2 is disabled. Is alpn-boot on the boot class path?", null); return null; } if (z10) { return null; } return aVar.f12706c; } catch (IllegalAccessException | InvocationTargetException e10) { throw i5.c.e("unable to get selected protocol", e10); } } }