package t7;

import d3.C;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;
import javax.net.ssl.SSLSocket;

/* JADX INFO: loaded from: classes.dex */
public class f implements m {

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public static final e f17032f = new e();

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final Class f17033a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final Method f17034b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final Method f17035c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final Method f17036d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final Method f17037e;

    public f(Class cls) throws NoSuchMethodException {
        this.f17033a = cls;
        Method declaredMethod = cls.getDeclaredMethod("setUseSessionTickets", Boolean.TYPE);
        P6.g.d(declaredMethod, "sslSocketClass.getDeclar…:class.javaPrimitiveType)");
        this.f17034b = declaredMethod;
        this.f17035c = cls.getMethod("setHostname", String.class);
        this.f17036d = cls.getMethod("getAlpnSelectedProtocol", null);
        this.f17037e = cls.getMethod("setAlpnProtocols", byte[].class);
    }

    @Override // t7.m
    public final boolean a(SSLSocket sSLSocket) {
        return this.f17033a.isInstance(sSLSocket);
    }

    @Override // t7.m
    public final String b(SSLSocket sSLSocket) {
        if (this.f17033a.isInstance(sSLSocket)) {
            try {
                byte[] bArr = (byte[]) this.f17036d.invoke(sSLSocket, null);
                if (bArr != null) {
                    return new String(bArr, X6.a.f7235a);
                }
            } catch (IllegalAccessException e8) {
                throw new AssertionError(e8);
            } catch (InvocationTargetException e9) {
                Throwable cause = e9.getCause();
                if (!(cause instanceof NullPointerException) || !P6.g.a(((NullPointerException) cause).getMessage(), "ssl == null")) {
                    throw new AssertionError(e9);
                }
            }
        }
        return null;
    }

    @Override // t7.m
    public final boolean c() {
        boolean z8 = s7.c.f16912e;
        return s7.c.f16912e;
    }

    @Override // t7.m
    public final void d(SSLSocket sSLSocket, String str, List list) {
        P6.g.e(list, "protocols");
        if (this.f17033a.isInstance(sSLSocket)) {
            try {
                this.f17034b.invoke(sSLSocket, Boolean.TRUE);
                if (str != null) {
                    this.f17035c.invoke(sSLSocket, str);
                }
                Method method = this.f17037e;
                s7.n nVar = s7.n.f16942a;
                method.invoke(sSLSocket, C.f(list));
            } catch (IllegalAccessException e8) {
                throw new AssertionError(e8);
            } catch (InvocationTargetException e9) {
                throw new AssertionError(e9);
            }
        }
    }
}
