Skip to content

Commit

Permalink
Merge pull request #2 from genshen/develop
Browse files Browse the repository at this point in the history
Merge branch develop into master to fix network issue on android Pie+.
  • Loading branch information
genshen committed Jul 12, 2019
2 parents 3794b23 + 1e1bbc3 commit c3f24be
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
Expand All @@ -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">
<provider
android:name="androidx.core.content.FileProvider"
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/me/gensh/service/CampusNetworkTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/res/xml/network_security_config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config xmlns:android="http://schemas.android.com/apk/res/android">
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="false">teach.ustb.edu.cn</domain>
<domain includeSubdomains="false">elearning.ustb.edu.cn</domain>
<domain includeSubdomains="false">e.ustb.edu.cn</domain>
<domain includeSubdomains="false">h.ustb.edu.cn</domain>
<domain includeSubdomains="false">202.204.48.82</domain>
<domain includeSubdomains="false">202.204.48.66</domain>
<domain includeSubdomains="false">zhiyuan.ustb.edu.cn</domain>
<domain includeSubdomains="false">lib.ustb.edu.cn</domain>
<domain includeSubdomains="false">lib1.ustb.edu.cn</domain>
<domain includeSubdomains="false">connect.rom.miui.com</domain>
</domain-config>
</network-security-config>
2 changes: 1 addition & 1 deletion http-ustb/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
// <html><head><script type="text/javascript">location.href="http://202.204.48.66"</script></head><body><a href="http://202.204.48.66"></a></body></html>
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
}
Expand Down

0 comments on commit c3f24be

Please sign in to comment.