diff --git a/src/main/res/values-zh/strings.xml b/src/main/res/values-zh/strings.xml
index e405acba..02bd0674 100755
--- a/src/main/res/values-zh/strings.xml
+++ b/src/main/res/values-zh/strings.xml
@@ -56,7 +56,7 @@
关于
影梭(shadowsocks)%s
刷新 DNS 缓存
- 需要 ROOT 权限
+ 需要 ROOT 权限
刷新中……
二维码
添加配置文件
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index e4c16cdc..cd88ddf2 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -80,7 +80,7 @@
Shadowsocks %s
QR Code
Flush DNS cache
- Requires ROOT permission
+ Requires ROOT permission
Flushing
Add Profile
Export to Clipboard
diff --git a/src/main/res/xml/pref_all.xml b/src/main/res/xml/pref_all.xml
index f2a6af85..aa33012e 100644
--- a/src/main/res/xml/pref_all.xml
+++ b/src/main/res/xml/pref_all.xml
@@ -104,8 +104,7 @@
android:summary="@string/nat_summary"/>
-
+
diff --git a/src/main/scala/com/github/shadowsocks/ShadowsocksSettings.scala b/src/main/scala/com/github/shadowsocks/ShadowsocksSettings.scala
index e7f9dfd6..79de4e4b 100644
--- a/src/main/scala/com/github/shadowsocks/ShadowsocksSettings.scala
+++ b/src/main/scala/com/github/shadowsocks/ShadowsocksSettings.scala
@@ -5,7 +5,7 @@ import java.util.Locale
import android.app.AlertDialog
import android.content.{DialogInterface, Intent}
import android.net.Uri
-import android.os.Bundle
+import android.os.{Build, Bundle}
import android.preference.{Preference, PreferenceFragment}
import android.webkit.{WebViewClient, WebView}
import com.github.shadowsocks.utils.Key
@@ -30,7 +30,11 @@ class ShadowsocksSettings extends PreferenceFragment {
true
})
- findPreference("flush_dnscache").setOnPreferenceClickListener((preference: Preference) => {
+ val flush = findPreference("flush_dnscache")
+ if (Build.VERSION.SDK_INT >= 17 && !ShadowsocksApplication.isRoot) {
+ flush.setEnabled(false)
+ flush.setSummary(R.string.flush_dnscache_summary_disabled)
+ } else flush.setOnPreferenceClickListener((preference: Preference) => {
ShadowsocksApplication.track(Shadowsocks.TAG, "flush_dnscache")
activity.flushDnsCache()
true
diff --git a/src/main/scala/com/github/shadowsocks/utils/Utils.scala b/src/main/scala/com/github/shadowsocks/utils/Utils.scala
index f2d5c981..1f1dceaf 100644
--- a/src/main/scala/com/github/shadowsocks/utils/Utils.scala
+++ b/src/main/scala/com/github/shadowsocks/utils/Utils.scala
@@ -55,7 +55,7 @@ import android.util.{DisplayMetrics, Base64, Log}
import android.view.View.MeasureSpec
import android.view.{Gravity, View, Window}
import android.widget.Toast
-import com.github.shadowsocks.BuildConfig
+import com.github.shadowsocks.{ShadowsocksApplication, BuildConfig}
import org.xbill.DNS._
@@ -155,24 +155,13 @@ object Utils {
// Blocked > 3 seconds
def toggleAirplaneMode(context: Context) {
- if (Build.VERSION.SDK_INT >= 17) {
- toggleAboveApiLevel17()
- } else {
+ if (ShadowsocksApplication.isRoot) {
+ Console.runRootCommand(Array("ndc resolver flushdefaultif", "ndc resolver flushif wlan0"))
+ } else if (Build.VERSION.SDK_INT < 17) {
toggleBelowApiLevel17(context)
}
}
- private def toggleAboveApiLevel17() {
- // Android 4.2 and above
-
- Console.runRootCommand(Array("ndc resolver flushdefaultif", "ndc resolver flushif wlan0"))
-
- //Utils.runRootCommand("settings put global airplane_mode_on 1\n"
- // + "am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true\n"
- // + "settings put global airplane_mode_on 0\n"
- // + "am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false\n")
- }
-
//noinspection ScalaDeprecation
private def toggleBelowApiLevel17(context: Context) {
// Android 4.2 below