Skip to content

Commit

Permalink
Fixed bug that could cause Connection to use HTTP instead of HTTPS on…
Browse files Browse the repository at this point in the history
… servers that support both; Updated to latest gradle, android studio, etc; Bumped version to 1.2.3
  • Loading branch information
adolfintel committed Apr 12, 2021
1 parent 65e0c4c commit bcab321
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 9 deletions.
6 changes: 6 additions & 0 deletions Speedtest-Android/.idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Speedtest-Android/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Speedtest-Android/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Speedtest-Android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -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){
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion Speedtest-Android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Speedtest-Android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit bcab321

Please sign in to comment.