Closed all4coding closed 6 years ago
private static SSLParametersImpl reflectSSLParaImpl(SSLSocketFactory sslSocketFactory) {
SSLParametersImpl sslParameters;
try {
sslParameters = (SSLParametersImpl) ReflectUtil.getTheFieldValue(
ReflectUtil.getAssignableField(
sslSocketFactory.getClass(), SSLParametersImpl.class, false),
sslSocketFactory);
} catch (Throwable throwable) {
sslParameters = null;
}
parameters = sslParameters;
return reflectSSLParaImpl(sslParameters);
}
private static SSLParametersImpl reflectSSLParaImpl(SSLParametersImpl sslParameters) {
try {
Method method = SSLParametersImpl.class.getDeclaredMethod("clone", new Class[0]);
method.setAccessible(true);
return ((SSLParametersImpl) method.invoke(sslParameters, new Object[0]));
} catch (Throwable throwable) {
QLog.enet("reflectSSLParaImpl Throwable:", throwable);
}
return parameters;
}
SSLParametersImpl is public below Android 8.1 and change to private at Android 8.1 and Android P?
Android is restricting the ability of apps to call non-SDK interfaces starting in P. See https://developer.android.com/about/versions/pie/restrictions-non-sdk-interfaces for details.
We use reflect to access SSLParametersImpl to Hook the OpenSSLSocketImpl.So we can monitor the SSL handShake time in startHandshake().But it does not work at Android 8.1 and Android P.I know it is not a part of Android Public API. But why the "reflect" is not work at Android 8.1 and Android P