mirror of
https://github.com/M66B/NetGuard.git
synced 2025-01-03 05:44:14 +00:00
Check for private DNS in filtering mode only
This commit is contained in:
parent
ce61dd8e84
commit
dbdd20de30
1 changed files with 22 additions and 8 deletions
|
@ -193,7 +193,6 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
prefs.edit().putBoolean("enabled", isChecked).apply();
|
||||
|
||||
if (isChecked) {
|
||||
|
||||
String alwaysOn = Settings.Secure.getString(getContentResolver(), "always_on_vpn_app");
|
||||
Log.i(TAG, "Always-on=" + alwaysOn);
|
||||
if (!TextUtils.isEmpty(alwaysOn))
|
||||
|
@ -213,13 +212,8 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
return;
|
||||
}
|
||||
|
||||
String dns_mode = Settings.Global.getString(getContentResolver(), "private_dns_mode");
|
||||
Log.i(TAG, "Private DNS mode=" + dns_mode);
|
||||
if (dns_mode == null)
|
||||
dns_mode = "off";
|
||||
if (!"off".equals(dns_mode)) {
|
||||
if (hasPrivateDns()) {
|
||||
swEnabled.setChecked(false);
|
||||
Toast.makeText(ActivityMain.this, R.string.msg_private_dns, Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -270,8 +264,12 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
ServiceSinkhole.stop("switch off", ActivityMain.this, false);
|
||||
}
|
||||
});
|
||||
if (enabled)
|
||||
if (enabled) {
|
||||
checkDoze();
|
||||
if (hasPrivateDns()) {
|
||||
swEnabled.setChecked(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Network is metered
|
||||
ivMetered.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
|
@ -1117,6 +1115,22 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
}
|
||||
}
|
||||
|
||||
private boolean hasPrivateDns() {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
boolean filter = prefs.getBoolean("filter", false);
|
||||
if (filter) {
|
||||
String dns_mode = Settings.Global.getString(getContentResolver(), "private_dns_mode");
|
||||
Log.i(TAG, "Private DNS mode=" + dns_mode);
|
||||
if (dns_mode == null)
|
||||
dns_mode = "off";
|
||||
if (!"off".equals(dns_mode)) {
|
||||
Toast.makeText(ActivityMain.this, R.string.msg_private_dns, Toast.LENGTH_LONG).show();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void menu_legend() {
|
||||
TypedValue tv = new TypedValue();
|
||||
getTheme().resolveAttribute(R.attr.colorOn, tv, true);
|
||||
|
|
Loading…
Reference in a new issue