From 3af3fc9495491c6263fb5794e10aa72a47b727c5 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Thu, 6 Oct 2016 17:48:53 -0700 Subject: Move to using Google Play Services SSL by default where available --- .../github/daneren2005/dsub/service/RESTMusicService.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'app') diff --git a/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java b/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java index 72faa7e1..178b8d13 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java +++ b/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java @@ -40,6 +40,8 @@ import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.util.Log; +import com.google.android.gms.security.ProviderInstaller; + import github.daneren2005.dsub.R; import github.daneren2005.dsub.domain.*; import github.daneren2005.dsub.fragments.MainFragment; @@ -105,6 +107,7 @@ public class RESTMusicService implements MusicService { private String redirectFrom; private String redirectTo; private Integer instance; + private boolean hasInstalledGoogleSSL = false; public RESTMusicService() { selfSignedHostnameVerifier = new HostnameVerifier() { @@ -1831,6 +1834,16 @@ public class RESTMusicService implements MusicService { } private HttpURLConnection getConnectionDirect(Context context, String url, int minNetworkTimeout) throws Exception { + if(!hasInstalledGoogleSSL) { + try { + ProviderInstaller.installIfNeeded(context); + } catch(Exception e) { + // Just continue on anyways, doesn't really harm anything if this fails + Log.w(TAG, "Failed to update to use Google Play SSL", e); + } + hasInstalledGoogleSSL = true; + } + // Connect and add headers URL urlObj = new URL(url); HttpURLConnection connection = (HttpURLConnection) urlObj.openConnection(); -- cgit v1.2.3