From bcab321dd3852e0089eec0fa2c9dbd85d2e7de59 Mon Sep 17 00:00:00 2001 From: dosse91 Date: Mon, 12 Apr 2021 15:05:31 +0200 Subject: [PATCH] Fixed bug that could cause Connection to use HTTP instead of HTTPS on servers that support both; Updated to latest gradle, android studio, etc; Bumped version to 1.2.3 --- Speedtest-Android/.idea/compiler.xml | 6 ++++++ Speedtest-Android/.idea/gradle.xml | 1 + Speedtest-Android/.idea/misc.xml | 2 +- Speedtest-Android/app/build.gradle | 4 ++-- .../java/com/fdossena/speedtest/core/base/Connection.java | 6 +++--- Speedtest-Android/build.gradle | 2 +- Speedtest-Android/gradle/wrapper/gradle-wrapper.properties | 4 ++-- 7 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 Speedtest-Android/.idea/compiler.xml diff --git a/Speedtest-Android/.idea/compiler.xml b/Speedtest-Android/.idea/compiler.xml new file mode 100644 index 0000000..61a9130 --- /dev/null +++ b/Speedtest-Android/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Speedtest-Android/.idea/gradle.xml b/Speedtest-Android/.idea/gradle.xml index 5cd135a..9bba60d 100644 --- a/Speedtest-Android/.idea/gradle.xml +++ b/Speedtest-Android/.idea/gradle.xml @@ -14,6 +14,7 @@ diff --git a/Speedtest-Android/.idea/misc.xml b/Speedtest-Android/.idea/misc.xml index 37a7509..d5d35ec 100644 --- a/Speedtest-Android/.idea/misc.xml +++ b/Speedtest-Android/.idea/misc.xml @@ -1,6 +1,6 @@ - + diff --git a/Speedtest-Android/app/build.gradle b/Speedtest-Android/app/build.gradle index 8ed4777..78bbc7e 100644 --- a/Speedtest-Android/app/build.gradle +++ b/Speedtest-Android/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "your.name.here.speedtest" minSdkVersion 15 targetSdkVersion 28 - versionCode 8 - versionName '1.2.2' + versionCode 9 + versionName '1.2.3' testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { diff --git a/Speedtest-Android/app/src/main/java/com/fdossena/speedtest/core/base/Connection.java b/Speedtest-Android/app/src/main/java/com/fdossena/speedtest/core/base/Connection.java index fad0bf0..6e722e2 100644 --- a/Speedtest-Android/app/src/main/java/com/fdossena/speedtest/core/base/Connection.java +++ b/Speedtest-Android/app/src/main/java/com/fdossena/speedtest/core/base/Connection.java @@ -21,7 +21,7 @@ public class Connection { private int mode=MODE_NOT_SET; private static final int MODE_NOT_SET=0, MODE_HTTP=1, MODE_HTTPS=2; - private static final String USER_AGENT="Speedtest-Android/1.2 (SDK "+Build.VERSION.SDK_INT+"; "+Build.PRODUCT+"; Android "+Build.VERSION.RELEASE+")", + private static final String USER_AGENT="Speedtest-Android/1.2.3 (SDK "+Build.VERSION.SDK_INT+"; "+Build.PRODUCT+"; Android "+Build.VERSION.RELEASE+")", LOCALE= Build.VERSION.SDK_INT>=21?Locale.getDefault().toLanguageTag():null; public Connection(String url, int connectTimeout, int soTimeout, int recvBuffer, int sendBuffer){ @@ -59,7 +59,7 @@ public Connection(String url, int connectTimeout, int soTimeout, int recvBuffer, throw new IllegalArgumentException("Malformed URL (Unknown or unspecified protocol)"); } try{ - if(tryHTTPS){ + if(mode == MODE_NOT_SET && tryHTTPS){ SocketFactory factory = SSLSocketFactory.getDefault(); socket=factory.createSocket(); if(connectTimeout>0){ @@ -71,7 +71,7 @@ public Connection(String url, int connectTimeout, int soTimeout, int recvBuffer, } }catch(Throwable t){} try{ - if(tryHTTP){ + if(mode == MODE_NOT_SET && tryHTTP){ SocketFactory factory = SocketFactory.getDefault(); socket=factory.createSocket(); if(connectTimeout>0) { diff --git a/Speedtest-Android/build.gradle b/Speedtest-Android/build.gradle index 95a3996..801467d 100644 --- a/Speedtest-Android/build.gradle +++ b/Speedtest-Android/build.gradle @@ -7,7 +7,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:4.0.1' + classpath 'com.android.tools.build:gradle:4.1.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/Speedtest-Android/gradle/wrapper/gradle-wrapper.properties b/Speedtest-Android/gradle/wrapper/gradle-wrapper.properties index 4142380..5f38c9b 100644 --- a/Speedtest-Android/gradle/wrapper/gradle-wrapper.properties +++ b/Speedtest-Android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sun Sep 27 20:23:36 CEST 2020 +#Mon Apr 12 15:03:57 CEST 2021 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip