Merge branch 'master' of s416084/find-my-tutor-android into develop
This commit is contained in:
commit
15529eccb4
@ -7,12 +7,16 @@ import com.jakewharton.retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
|
|||||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import okhttp3.CipherSuite;
|
||||||
|
import okhttp3.ConnectionSpec;
|
||||||
import okhttp3.Interceptor;
|
import okhttp3.Interceptor;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
import okhttp3.TlsVersion;
|
||||||
import okhttp3.logging.HttpLoggingInterceptor;
|
import okhttp3.logging.HttpLoggingInterceptor;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
import retrofit2.converter.gson.GsonConverterFactory;
|
import retrofit2.converter.gson.GsonConverterFactory;
|
||||||
@ -41,11 +45,20 @@ public class ApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void initOkHttp(final Context context) {
|
private static void initOkHttp(final Context context) {
|
||||||
|
|
||||||
OkHttpClient.Builder httpClient = new OkHttpClient().newBuilder()
|
OkHttpClient.Builder httpClient = new OkHttpClient().newBuilder()
|
||||||
.connectTimeout(REQUEST_TIMEOUT, TimeUnit.SECONDS)
|
.connectTimeout(REQUEST_TIMEOUT, TimeUnit.SECONDS)
|
||||||
.readTimeout(REQUEST_TIMEOUT, TimeUnit.SECONDS)
|
.readTimeout(REQUEST_TIMEOUT, TimeUnit.SECONDS)
|
||||||
.writeTimeout(REQUEST_TIMEOUT, TimeUnit.SECONDS);
|
.writeTimeout(REQUEST_TIMEOUT, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
// Android 7.0.0 fix: https://stackoverflow.com/questions/39133437/sslhandshakeexception-handshake-failed-on-android-n-7-0?fbclid=IwAR1FpUjQlE_iP_2hiZ3okHoFs-Ik4AilVcJaKDKs4FHNFIxn7wb-Uxb_WWY
|
||||||
|
ConnectionSpec spec = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
|
||||||
|
.tlsVersions(TlsVersion.TLS_1_2)
|
||||||
|
.cipherSuites(CipherSuite.TLS_DHE_RSA_WITH_AES_256_CBC_SHA)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
httpClient.connectionSpecs(Collections.singletonList(spec));
|
||||||
|
|
||||||
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
|
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
|
||||||
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
|
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user