diff options
author | Christian Schneppe <christian.schneppe@pix-art.de> | 2020-04-07 21:26:49 +0200 |
---|---|---|
committer | Christian Schneppe <christian.schneppe@pix-art.de> | 2020-04-07 21:26:49 +0200 |
commit | dddff7965f30cbe944b1cb655a12e08b09b91484 (patch) | |
tree | db02b86bd4fef18b1183802e8e31f43abfbe99d0 /src/main/java/de/pixart/messenger/services | |
parent | a7fd6b31e20e722a524467cd93bf65900ee7af92 (diff) |
fix updater
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/pixart/messenger/services/UpdateService.java | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/main/java/de/pixart/messenger/services/UpdateService.java b/src/main/java/de/pixart/messenger/services/UpdateService.java index 64347bd5a..27b40e986 100644 --- a/src/main/java/de/pixart/messenger/services/UpdateService.java +++ b/src/main/java/de/pixart/messenger/services/UpdateService.java @@ -15,13 +15,18 @@ import org.json.JSONObject; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; import java.util.Arrays; import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSocketFactory; import de.pixart.messenger.BuildConfig; import de.pixart.messenger.Config; import de.pixart.messenger.R; +import de.pixart.messenger.http.NoSSLv3SocketFactory; import de.pixart.messenger.ui.UpdaterActivity; import me.drakeet.support.toast.ToastCompat; @@ -32,6 +37,7 @@ public class UpdateService extends AsyncTask<String, Object, UpdateService.Wrapp private Context context; private String store; private NotificationService getNotificationService; + public UpdateService() { } @@ -52,9 +58,19 @@ public class UpdateService extends AsyncTask<String, Object, UpdateService.Wrapp if (params[0].equals("true")) { showNoUpdateToast = true; } - + SSLContext sslcontext = null; + SSLSocketFactory NoSSLv3Factory = null; + try { + sslcontext = SSLContext.getInstance("TLSv1"); + if (sslcontext != null) { + sslcontext.init(null, null, null); + NoSSLv3Factory = new NoSSLv3SocketFactory(sslcontext.getSocketFactory()); + } + } catch (NoSuchAlgorithmException | KeyManagementException e) { + e.printStackTrace(); + } + HttpsURLConnection.setDefaultSSLSocketFactory(NoSSLv3Factory); HttpsURLConnection connection = null; - try { URL url = new URL(Config.UPDATE_URL); if (mUseTor) { @@ -163,7 +179,7 @@ public class UpdateService extends AsyncTask<String, Object, UpdateService.Wrapp String[] remoteV = null; String[] installedV = null; try { - installedV = installedVersion.split(" "); + installedV = installedVersion.split("-"); Log.d(Config.LOGTAG, "AppUpdater: Version installed: " + installedV[0]); installed = installedV[0].split("\\."); } catch (Exception e) { @@ -172,7 +188,7 @@ public class UpdateService extends AsyncTask<String, Object, UpdateService.Wrapp try { remoteV = remoteVersion.split(" "); if (installedV != null && installedV.length > 1) { - if (installedV[1] != null) { + if (installedV[1] != null && installedV[1].toLowerCase().contains("beta")) { remoteV[0] = remoteV[0] + ".1"; } } |