From 3c78eb9c21b8137a9c6985f690896137d83fb613 Mon Sep 17 00:00:00 2001 From: genshen Date: Thu, 11 Jul 2019 22:30:05 +0800 Subject: [PATCH 1/2] fix(network): add network security config for Pie+ version for http requesting. --- app/src/main/AndroidManifest.xml | 2 +- app/src/main/res/xml/network_security_config.xml | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 app/src/main/res/xml/network_security_config.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index dd7699b..757942a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -5,7 +5,6 @@ - @@ -18,6 +17,7 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" + android:networkSecurityConfig="@xml/network_security_config" android:theme="@style/AppTheme"> + + + teach.ustb.edu.cn + elearning.ustb.edu.cn + e.ustb.edu.cn + h.ustb.edu.cn + 202.204.48.82 + 202.204.48.66 + zhiyuan.ustb.edu.cn + lib.ustb.edu.cn + lib1.ustb.edu.cn + connect.rom.miui.com + + From 1e1bbc375f25bd621d63e39fd5cd29e9f03c3fc9 Mon Sep 17 00:00:00 2001 From: genshen Date: Thu, 11 Jul 2019 22:30:46 +0800 Subject: [PATCH 2/2] fix(dependency): update okhttp version to 4.0.0 --- app/src/main/java/me/gensh/service/CampusNetworkTest.java | 2 -- http-ustb/build.gradle | 2 +- .../main/java/me/gensh/helloustb/http/portal/WifiPortal.kt | 6 +++--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/me/gensh/service/CampusNetworkTest.java b/app/src/main/java/me/gensh/service/CampusNetworkTest.java index a3d9bb0..7a74ad1 100644 --- a/app/src/main/java/me/gensh/service/CampusNetworkTest.java +++ b/app/src/main/java/me/gensh/service/CampusNetworkTest.java @@ -39,8 +39,6 @@ */ public class CampusNetworkTest extends IntentService implements HttpRequestTask.OnTaskFinished { - final String TEST_URL = "http://www.sohu.com"; - final String TEST_TAG = "test connection"; final static String INTENT_EXTRA_SSID = "ssid"; final int NETWORK_SING_IN_NOTIFY_ID = 10; final int AUTO_SIGN_IN_ERROR_NOTIFY_ID = 12; diff --git a/http-ustb/build.gradle b/http-ustb/build.gradle index df36e76..93f5069 100644 --- a/http-ustb/build.gradle +++ b/http-ustb/build.gradle @@ -7,7 +7,7 @@ tasks.withType(JavaCompile) { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.squareup.okhttp3:okhttp:3.10.0' + compile 'com.squareup.okhttp3:okhttp:4.0.0' compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" } sourceCompatibility = "1.7" diff --git a/http-ustb/src/main/java/me/gensh/helloustb/http/portal/WifiPortal.kt b/http-ustb/src/main/java/me/gensh/helloustb/http/portal/WifiPortal.kt index 180ef16..cb82eef 100644 --- a/http-ustb/src/main/java/me/gensh/helloustb/http/portal/WifiPortal.kt +++ b/http-ustb/src/main/java/me/gensh/helloustb/http/portal/WifiPortal.kt @@ -28,12 +28,12 @@ class WifiPortal { try { val response: Response = client.newCall(request).execute() val status = Status() - if (response.code() == 200) { //not 204. + if (response.code == 200) { //not 204. status.needAuth = true // try to resolve html content. // - if (response.body() != null) { - val body = response.body()!!.string() + if (response.body != null) { + val body = response.body !!.string() if (body.contains(REDIRECT_URL1) || body.contains(REDIRECT_URL2)) { status.isInnerNet = true }