From bd782dae98ce9f0b17ac2d6f4ff32eaaf6369c6a Mon Sep 17 00:00:00 2001 From: Max Lv Date: Fri, 28 Apr 2017 08:04:40 +0800 Subject: [PATCH 1/4] Avoid too many reschedules --- mobile/build.sbt | 9 ++++++++- .../main/scala/com/github/shadowsocks/BaseService.scala | 1 - .../scala/com/github/shadowsocks/acl/AclSyncJob.scala | 9 ++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/mobile/build.sbt b/mobile/build.sbt index e467678d47..98043473ca 100644 --- a/mobile/build.sbt +++ b/mobile/build.sbt @@ -8,11 +8,18 @@ version := "4.1.5" versionCode := Some(185) proguardOptions ++= - "-keep class com.github.shadowsocks.JniHelper { *; }" :: + "-dontwarn com.evernote.android.job.gcm.**" :: + "-dontwarn com.evernote.android.job.util.GcmAvailableHelper" :: "-dontwarn com.google.android.gms.internal.**" :: "-dontwarn com.j256.ormlite.**" :: "-dontwarn okio.**" :: "-dontwarn org.xbill.**" :: + "-keep public class com.evernote.android.job.v21.PlatformJobService" :: + "-keep public class com.evernote.android.job.v14.PlatformAlarmService" :: + "-keep public class com.evernote.android.job.v14.PlatformAlarmReceiver" :: + "-keep public class com.evernote.android.job.JobBootReceiver" :: + "-keep public class com.evernote.android.job.JobRescheduleService" :: + "-keep class com.github.shadowsocks.JniHelper { *; }" :: Nil val playServicesVersion = "10.2.1" diff --git a/mobile/src/main/scala/com/github/shadowsocks/BaseService.scala b/mobile/src/main/scala/com/github/shadowsocks/BaseService.scala index 439c1c1927..3462aa468a 100644 --- a/mobile/src/main/scala/com/github/shadowsocks/BaseService.scala +++ b/mobile/src/main/scala/com/github/shadowsocks/BaseService.scala @@ -271,7 +271,6 @@ trait BaseService extends Service { override def onCreate() { super.onCreate() - app.remoteConfig.fetch() app.updateAssets() } diff --git a/mobile/src/main/scala/com/github/shadowsocks/acl/AclSyncJob.scala b/mobile/src/main/scala/com/github/shadowsocks/acl/AclSyncJob.scala index 54129aef65..8dcc67495c 100644 --- a/mobile/src/main/scala/com/github/shadowsocks/acl/AclSyncJob.scala +++ b/mobile/src/main/scala/com/github/shadowsocks/acl/AclSyncJob.scala @@ -34,6 +34,7 @@ import scala.io.Source */ object AclSyncJob { final val TAG = "AclSyncJob" + final val MAX_RESCHEDULE = 3 def schedule(route: String): Int = new JobRequest.Builder(AclSyncJob.TAG + ':' + route) .setExecutionWindow(TimeUnit.SECONDS.toMillis(10), TimeUnit.DAYS.toMillis(28)) @@ -45,6 +46,8 @@ object AclSyncJob { } class AclSyncJob(route: String) extends Job { + var rescheduled = 0 + override def onRunJob(params: Params): Result = { try { //noinspection JavaAccessorMethodCalledAsEmptyParen @@ -54,7 +57,11 @@ class AclSyncJob(route: String) extends Job { } catch { case e: IOException => e.printStackTrace() - Result.RESCHEDULE + rescheduled += 1 + if (rescheduled < AclSyncJob.MAX_RESCHEDULE) + Result.RESCHEDULE + else + Result.FAILURE case e: Exception => // unknown failures, probably shouldn't retry e.printStackTrace() Result.FAILURE From 59f02cfa53e9561ca691ff8a1c626bae54554968 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Fri, 28 Apr 2017 16:50:41 +0800 Subject: [PATCH 2/4] Refine Firebase remote config --- build.sbt | 2 +- mobile/build.sbt | 4 ++-- mobile/src/main/res/xml/default_configs.xml | 7 +++++++ .../main/scala/com/github/shadowsocks/BaseService.scala | 3 ++- .../main/scala/com/github/shadowsocks/MainActivity.scala | 2 ++ .../com/github/shadowsocks/ShadowsocksApplication.scala | 1 + 6 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 mobile/src/main/res/xml/default_configs.xml diff --git a/build.sbt b/build.sbt index a237e2d39a..32e3ca64ac 100644 --- a/build.sbt +++ b/build.sbt @@ -20,7 +20,7 @@ lazy val commonSettings = Seq( resConfigs := Seq("ja", "ko", "ru", "zh-rCN", "zh-rTW") ) -val supportLibsVersion = "25.2.0" +val supportLibsVersion = "25.3.1" lazy val root = Project(id = "shadowsocks-android", base = file(".")) .settings(commonSettings) .aggregate(plugin, mobile) diff --git a/mobile/build.sbt b/mobile/build.sbt index 98043473ca..fc17f4ab47 100644 --- a/mobile/build.sbt +++ b/mobile/build.sbt @@ -4,8 +4,8 @@ enablePlugins(AndroidGms) android.useSupportVectors name := "shadowsocks" -version := "4.1.5" -versionCode := Some(185) +version := "4.1.6" +versionCode := Some(186) proguardOptions ++= "-dontwarn com.evernote.android.job.gcm.**" :: diff --git a/mobile/src/main/res/xml/default_configs.xml b/mobile/src/main/res/xml/default_configs.xml new file mode 100644 index 0000000000..2f71ea5e35 --- /dev/null +++ b/mobile/src/main/res/xml/default_configs.xml @@ -0,0 +1,7 @@ + + + + proxy_url + https://www.socks123.pw/get.php + + diff --git a/mobile/src/main/scala/com/github/shadowsocks/BaseService.scala b/mobile/src/main/scala/com/github/shadowsocks/BaseService.scala index 3462aa468a..4b7df91edb 100644 --- a/mobile/src/main/scala/com/github/shadowsocks/BaseService.scala +++ b/mobile/src/main/scala/com/github/shadowsocks/BaseService.scala @@ -126,6 +126,7 @@ trait BaseService extends Service { def connect() { profile.name = profile.getName // save original name before it's (possibly) overwritten by IP addresses + if (profile.host == "198.199.101.152") { val client = new OkHttpClient.Builder() .dns(hostname => Utils.resolve(hostname, enableIPv6 = false) match { @@ -353,7 +354,7 @@ trait BaseService extends Service { .put("PrimaryDNS", new JSONArray().put(makeDns("Primary", "119.29.29.29"))) .put("AlternativeDNS", remoteDns) case _ => config - .put("PrimaryDNS", new JSONArray(remoteDns)) + .put("PrimaryDNS", remoteDns) // no need to setup AlternativeDNS in Acl.ALL/BYPASS_LAN mode .put("OnlyPrimaryDNS", true) } diff --git a/mobile/src/main/scala/com/github/shadowsocks/MainActivity.scala b/mobile/src/main/scala/com/github/shadowsocks/MainActivity.scala index 7f4745fefb..ab815924d2 100644 --- a/mobile/src/main/scala/com/github/shadowsocks/MainActivity.scala +++ b/mobile/src/main/scala/com/github/shadowsocks/MainActivity.scala @@ -384,12 +384,14 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe displayFragment(new AboutFragment) case DRAWER_FAQ => launchUrl(getString(R.string.faq_url)) case DRAWER_CUSTOM_RULES => displayFragment(new CustomRulesFragment) + case _ => // ignore } true // unexpected cases will throw exception } protected override def onResume() { super.onResume() + app.remoteConfig.fetch() state match { case State.STOPPING | State.CONNECTING => case _ => hideCircle() diff --git a/mobile/src/main/scala/com/github/shadowsocks/ShadowsocksApplication.scala b/mobile/src/main/scala/com/github/shadowsocks/ShadowsocksApplication.scala index 631cadceea..47dfa13c4c 100644 --- a/mobile/src/main/scala/com/github/shadowsocks/ShadowsocksApplication.scala +++ b/mobile/src/main/scala/com/github/shadowsocks/ShadowsocksApplication.scala @@ -148,6 +148,7 @@ class ShadowsocksApplication extends Application { checkChineseLocale(getResources.getConfiguration) FirebaseApp.initializeApp(this) + remoteConfig.setDefaults(R.xml.default_configs); remoteConfig.fetch().addOnCompleteListener(task => if (task.isSuccessful) remoteConfig.activateFetched()) JobManager.create(this).addJobCreator(DonaldTrump) From 92af48f528ace1bd0693d1622aebb9cb08837dbb Mon Sep 17 00:00:00 2001 From: Max Lv Date: Sat, 29 Apr 2017 18:46:38 +0800 Subject: [PATCH 3/4] Fix #1236 --- README.md | 4 ++-- mobile/src/main/assets/pages/about.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a873cccdb8..f2ea0345a5 100644 --- a/README.md +++ b/README.md @@ -47,13 +47,13 @@ Translators can go to [POEditor](https://poeditor.com/join/project/u5VHO9vhSf) t diff --git a/mobile/src/main/assets/pages/about.html b/mobile/src/main/assets/pages/about.html index fa7441fc86..5020f9ef14 100644 --- a/mobile/src/main/assets/pages/about.html +++ b/mobile/src/main/assets/pages/about.html @@ -291,13 +291,13 @@

Open Source Licenses

From 5633ae7b2164172880fde21918751090bf33eeef Mon Sep 17 00:00:00 2001 From: Max Lv Date: Sat, 29 Apr 2017 18:51:54 +0800 Subject: [PATCH 4/4] Fix #1233 --- .../scala/com/github/shadowsocks/ShadowsocksVpnService.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mobile/src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala b/mobile/src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala index e5e143d49f..033cd6bac3 100644 --- a/mobile/src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala +++ b/mobile/src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala @@ -214,7 +214,9 @@ class ShadowsocksVpnService extends VpnService with BaseService { } } - if (profile.route == Acl.ALL || profile.route == Acl.BYPASS_CHN) { + if (profile.route == Acl.ALL + || profile.route == Acl.BYPASS_CHN + || profile.route == Acl.CUSTOM_RULES) { builder.addRoute("0.0.0.0", 0) } else { getResources.getStringArray(R.array.bypass_private_route).foreach(cidr => {