mirror of https://github.com/M66B/NetGuard.git
Merge branch 'master' of https://github.com/M66B/NetGuard
This commit is contained in:
commit
a254aa8b73
|
@ -151,6 +151,12 @@ but once you close it, it will not use any bandwidth.
|
||||||
The VPN service will be restarted when you turn the screen on or off and when connectivity changes (WiFi, mobile)
|
The VPN service will be restarted when you turn the screen on or off and when connectivity changes (WiFi, mobile)
|
||||||
to apply the rules with the conditions '*Allow when device is in use*' and '*Block when roaming*'.
|
to apply the rules with the conditions '*Allow when device is in use*' and '*Block when roaming*'.
|
||||||
|
|
||||||
|
<a name="FAQ10"></a>
|
||||||
|
**(10) Will you provide a Tasker plug-in?**
|
||||||
|
|
||||||
|
If disabling NetGuard is allowed to Tasker, any application can disabled NetGuard too.
|
||||||
|
Allowing to disable a security application from other applications is not a good idea.
|
||||||
|
|
||||||
Support
|
Support
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,8 @@ android {
|
||||||
applicationId "eu.faircode.netguard"
|
applicationId "eu.faircode.netguard"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 23
|
targetSdkVersion 23
|
||||||
versionCode 19
|
versionCode 21
|
||||||
versionName "0.19"
|
versionName "0.21"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
|
|
|
@ -352,7 +352,8 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
||||||
} else if ("whitelist_wifi".equals(name) ||
|
} else if ("whitelist_wifi".equals(name) ||
|
||||||
"whitelist_other".equals(name) ||
|
"whitelist_other".equals(name) ||
|
||||||
"whitelist_roaming".equals(name) ||
|
"whitelist_roaming".equals(name) ||
|
||||||
"manage_system".equals(name))
|
"manage_system".equals(name) ||
|
||||||
|
"imported".equals(name))
|
||||||
updateApplicationList();
|
updateApplicationList();
|
||||||
|
|
||||||
else if ("dark_theme".equals(name))
|
else if ("dark_theme".equals(name))
|
||||||
|
|
|
@ -213,11 +213,9 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Throwable ex) {
|
protected void onPostExecute(Throwable ex) {
|
||||||
if (ex == null) {
|
if (ex == null)
|
||||||
SinkholeService.reload(null, ActivitySettings.this);
|
|
||||||
recreate();
|
|
||||||
Toast.makeText(ActivitySettings.this, R.string.msg_completed, Toast.LENGTH_LONG).show();
|
Toast.makeText(ActivitySettings.this, R.string.msg_completed, Toast.LENGTH_LONG).show();
|
||||||
} else
|
else
|
||||||
Toast.makeText(ActivitySettings.this, ex.toString(), Toast.LENGTH_LONG).show();
|
Toast.makeText(ActivitySettings.this, ex.toString(), Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
}.execute();
|
}.execute();
|
||||||
|
@ -255,35 +253,51 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere
|
||||||
Map<String, ?> settings = prefs.getAll();
|
Map<String, ?> settings = prefs.getAll();
|
||||||
for (String key : settings.keySet()) {
|
for (String key : settings.keySet()) {
|
||||||
Object value = settings.get(key);
|
Object value = settings.get(key);
|
||||||
|
|
||||||
|
if ("imported".equals(key))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (value instanceof Boolean) {
|
if (value instanceof Boolean) {
|
||||||
serializer.startTag(null, "setting");
|
serializer.startTag(null, "setting");
|
||||||
serializer.attribute(null, "key", key);
|
serializer.attribute(null, "key", key);
|
||||||
serializer.attribute(null, "type", "boolean");
|
serializer.attribute(null, "type", "boolean");
|
||||||
serializer.attribute(null, "value", value.toString());
|
serializer.attribute(null, "value", value.toString());
|
||||||
serializer.endTag(null, "setting");
|
serializer.endTag(null, "setting");
|
||||||
|
|
||||||
} else
|
} else
|
||||||
Log.e(TAG, "Unknown key=" + key);
|
Log.e(TAG, "Unknown key=" + key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void xmlImport(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
private void xmlImport(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
prefs.edit().putBoolean("enabled", false).apply();
|
||||||
|
SinkholeService.stop(this);
|
||||||
|
|
||||||
XMLReader reader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
|
XMLReader reader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
|
||||||
XmlImportHandler handler = new XmlImportHandler();
|
XmlImportHandler handler = new XmlImportHandler();
|
||||||
reader.setContentHandler(handler);
|
reader.setContentHandler(handler);
|
||||||
reader.parse(new InputSource(in));
|
reader.parse(new InputSource(in));
|
||||||
|
|
||||||
xmlImport(handler.application, PreferenceManager.getDefaultSharedPreferences(this));
|
xmlImport(handler.application, prefs);
|
||||||
xmlImport(handler.wifi, getSharedPreferences("wifi", Context.MODE_PRIVATE));
|
xmlImport(handler.wifi, getSharedPreferences("wifi", Context.MODE_PRIVATE));
|
||||||
xmlImport(handler.mobile, getSharedPreferences("other", Context.MODE_PRIVATE));
|
xmlImport(handler.mobile, getSharedPreferences("other", Context.MODE_PRIVATE));
|
||||||
xmlImport(handler.unused, getSharedPreferences("unused", Context.MODE_PRIVATE));
|
xmlImport(handler.unused, getSharedPreferences("unused", Context.MODE_PRIVATE));
|
||||||
|
xmlImport(handler.roaming, getSharedPreferences("roaming", Context.MODE_PRIVATE));
|
||||||
|
|
||||||
|
// Refresh UI
|
||||||
|
prefs.edit().putBoolean("imported", true).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void xmlImport(Map<String, Object> settings, SharedPreferences prefs) {
|
private void xmlImport(Map<String, Object> settings, SharedPreferences prefs) {
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
SharedPreferences.Editor editor = prefs.edit();
|
||||||
|
|
||||||
|
// Clear existing setting
|
||||||
for (String key : prefs.getAll().keySet())
|
for (String key : prefs.getAll().keySet())
|
||||||
|
if (!"enabled".equals(key))
|
||||||
editor.remove(key);
|
editor.remove(key);
|
||||||
|
|
||||||
|
// Apply new settings
|
||||||
for (String key : settings.keySet()) {
|
for (String key : settings.keySet()) {
|
||||||
Object value = settings.get(key);
|
Object value = settings.get(key);
|
||||||
if (value instanceof Boolean)
|
if (value instanceof Boolean)
|
||||||
|
@ -296,10 +310,12 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere
|
||||||
}
|
}
|
||||||
|
|
||||||
private class XmlImportHandler extends DefaultHandler {
|
private class XmlImportHandler extends DefaultHandler {
|
||||||
|
public boolean enabled = false;
|
||||||
public Map<String, Object> application = new HashMap<>();
|
public Map<String, Object> application = new HashMap<>();
|
||||||
public Map<String, Object> wifi = new HashMap<>();
|
public Map<String, Object> wifi = new HashMap<>();
|
||||||
public Map<String, Object> mobile = new HashMap<>();
|
public Map<String, Object> mobile = new HashMap<>();
|
||||||
public Map<String, Object> unused = new HashMap<>();
|
public Map<String, Object> unused = new HashMap<>();
|
||||||
|
public Map<String, Object> roaming = new HashMap<>();
|
||||||
private Map<String, Object> current = null;
|
private Map<String, Object> current = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -319,6 +335,9 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere
|
||||||
else if (qName.equals("unused"))
|
else if (qName.equals("unused"))
|
||||||
current = unused;
|
current = unused;
|
||||||
|
|
||||||
|
else if (qName.equals("roaming"))
|
||||||
|
roaming = unused;
|
||||||
|
|
||||||
else if (qName.equals("setting")) {
|
else if (qName.equals("setting")) {
|
||||||
String key = attributes.getValue("key");
|
String key = attributes.getValue("key");
|
||||||
String type = attributes.getValue("type");
|
String type = attributes.getValue("type");
|
||||||
|
@ -326,12 +345,16 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere
|
||||||
|
|
||||||
if (current == null)
|
if (current == null)
|
||||||
Log.e(TAG, "No current key=" + key);
|
Log.e(TAG, "No current key=" + key);
|
||||||
|
else {
|
||||||
|
if ("enabled".equals(key))
|
||||||
|
enabled = Boolean.parseBoolean(value);
|
||||||
else {
|
else {
|
||||||
if ("boolean".equals(type))
|
if ("boolean".equals(type))
|
||||||
current.put(key, Boolean.parseBoolean(value));
|
current.put(key, Boolean.parseBoolean(value));
|
||||||
else
|
else
|
||||||
Log.e(TAG, "Unknown type key=" + key);
|
Log.e(TAG, "Unknown type key=" + key);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else
|
} else
|
||||||
Log.e(TAG, "Unknown element qname=" + qName);
|
Log.e(TAG, "Unknown element qname=" + qName);
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class SinkholeService extends VpnService {
|
||||||
Command cmd = (intent == null ? Command.start : (Command) intent.getSerializableExtra(EXTRA_COMMAND));
|
Command cmd = (intent == null ? Command.start : (Command) intent.getSerializableExtra(EXTRA_COMMAND));
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(SinkholeService.this);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(SinkholeService.this);
|
||||||
|
|
||||||
Log.i(TAG, "Executing command=" + cmd + " vpn=" + (vpn != null));
|
Log.i(TAG, "Executing intent=" + intent + " command=" + cmd + " vpn=" + (vpn != null));
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case start:
|
case start:
|
||||||
if (prefs.getBoolean("foreground", false)) {
|
if (prefs.getBoolean("foreground", false)) {
|
||||||
|
@ -114,7 +114,7 @@ public class SinkholeService extends VpnService {
|
||||||
stopForeground(true);
|
stopForeground(true);
|
||||||
}
|
}
|
||||||
Widget.updateWidgets(SinkholeService.this);
|
Widget.updateWidgets(SinkholeService.this);
|
||||||
stopSelf();
|
// stopSelf();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_marginStart="12dp" />
|
android:layout_marginStart="12dp"
|
||||||
|
android:saveEnabled="false" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/llIndicators"
|
android:id="@+id/llIndicators"
|
||||||
|
|
|
@ -9,6 +9,10 @@
|
||||||
package="com.android.vending"
|
package="com.android.vending"
|
||||||
related="com.google.android.gms,com.android.providers.downloads"
|
related="com.google.android.gms,com.android.providers.downloads"
|
||||||
title="Google Play Store" />
|
title="Google Play Store" />
|
||||||
|
<relation
|
||||||
|
package="com.android.chrome"
|
||||||
|
related="com.android.providers.downloads"
|
||||||
|
title="Chrome" />
|
||||||
<!--rule
|
<!--rule
|
||||||
blocked="true"
|
blocked="true"
|
||||||
package="com.android.chrome"
|
package="com.android.chrome"
|
||||||
|
|
Loading…
Reference in New Issue