fixed crashes on android 4.0

This commit is contained in:
Mariotaku Lee 2017-05-13 08:50:17 +08:00
parent 01b87a8da9
commit 5828cd9063
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
2 changed files with 5 additions and 1 deletions

View File

@ -19,6 +19,9 @@
package org.mariotaku.twidere.util.net;
import android.os.Build;
import android.support.annotation.RequiresApi;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
@ -32,6 +35,7 @@ import javax.net.ssl.SSLSocketFactory;
/**
* @author fkrauthan
*/
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN)
public class TLSSocketFactory extends SSLSocketFactory {
private SSLSocketFactory internalSSLSocketFactory;

View File

@ -42,7 +42,7 @@ object HttpClientFactory {
fun initOkHttpClient(conf: HttpClientConfiguration, builder: OkHttpClient.Builder, dns: Dns,
connectionPool: ConnectionPool, cache: Cache) {
updateHttpClientConfiguration(builder, conf, dns, connectionPool, cache)
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
if (Build.VERSION.SDK_INT in Build.VERSION_CODES.JELLY_BEAN until Build.VERSION_CODES.LOLLIPOP) {
val tlsSocketFactory = TLSSocketFactory()
val trustManager = Platform.get().trustManager(tlsSocketFactory) ?:
systemDefaultTrustManager()