@SuppressLint("NewApi") // AbstractConscryptSocket defines getHandshakeSession()
    public static void checkServerTrusted(X509TrustManager tm, X509Certificate[] chain,
            String authType, AbstractConscryptSocket socket) throws CertificateException {
        if (!checkTrusted("checkServerTrusted", tm, chain, authType, Socket.class, socket)
                && !checkTrusted("checkServerTrusted", tm, chain, authType, String.class,
                           socket.getHandshakeSession().getPeerHost())) {
            tm.checkServerTrusted(chain, authType);
        }
    }
Helper function to unify calls to the different names used for each function taking a
Socket, SSLEngine, or String (legacy Android).
android/src/main/java/org/conscrypt/Platform.java