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)
|
||||
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
|
||||
-------
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@ android {
|
|||
applicationId "eu.faircode.netguard"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 23
|
||||
versionCode 19
|
||||
versionName "0.19"
|
||||
versionCode 21
|
||||
versionName "0.21"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
|
|
|
@ -352,7 +352,8 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
} else if ("whitelist_wifi".equals(name) ||
|
||||
"whitelist_other".equals(name) ||
|
||||
"whitelist_roaming".equals(name) ||
|
||||
"manage_system".equals(name))
|
||||
"manage_system".equals(name) ||
|
||||
"imported".equals(name))
|
||||
updateApplicationList();
|
||||
|
||||
else if ("dark_theme".equals(name))
|
||||
|
|
|
@ -213,11 +213,9 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere
|
|||
|
||||
@Override
|
||||
protected void onPostExecute(Throwable ex) {
|
||||
if (ex == null) {
|
||||
SinkholeService.reload(null, ActivitySettings.this);
|
||||
recreate();
|
||||
if (ex == null)
|
||||
Toast.makeText(ActivitySettings.this, R.string.msg_completed, Toast.LENGTH_LONG).show();
|
||||
} else
|
||||
else
|
||||
Toast.makeText(ActivitySettings.this, ex.toString(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}.execute();
|
||||
|
@ -255,35 +253,51 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere
|
|||
Map<String, ?> settings = prefs.getAll();
|
||||
for (String key : settings.keySet()) {
|
||||
Object value = settings.get(key);
|
||||
|
||||
if ("imported".equals(key))
|
||||
continue;
|
||||
|
||||
if (value instanceof Boolean) {
|
||||
serializer.startTag(null, "setting");
|
||||
serializer.attribute(null, "key", key);
|
||||
serializer.attribute(null, "type", "boolean");
|
||||
serializer.attribute(null, "value", value.toString());
|
||||
serializer.endTag(null, "setting");
|
||||
|
||||
} else
|
||||
Log.e(TAG, "Unknown key=" + key);
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
XmlImportHandler handler = new XmlImportHandler();
|
||||
reader.setContentHandler(handler);
|
||||
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.mobile, getSharedPreferences("other", 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) {
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
|
||||
// Clear existing setting
|
||||
for (String key : prefs.getAll().keySet())
|
||||
if (!"enabled".equals(key))
|
||||
editor.remove(key);
|
||||
|
||||
// Apply new settings
|
||||
for (String key : settings.keySet()) {
|
||||
Object value = settings.get(key);
|
||||
if (value instanceof Boolean)
|
||||
|
@ -296,10 +310,12 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere
|
|||
}
|
||||
|
||||
private class XmlImportHandler extends DefaultHandler {
|
||||
public boolean enabled = false;
|
||||
public Map<String, Object> application = new HashMap<>();
|
||||
public Map<String, Object> wifi = new HashMap<>();
|
||||
public Map<String, Object> mobile = new HashMap<>();
|
||||
public Map<String, Object> unused = new HashMap<>();
|
||||
public Map<String, Object> roaming = new HashMap<>();
|
||||
private Map<String, Object> current = null;
|
||||
|
||||
@Override
|
||||
|
@ -319,6 +335,9 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere
|
|||
else if (qName.equals("unused"))
|
||||
current = unused;
|
||||
|
||||
else if (qName.equals("roaming"))
|
||||
roaming = unused;
|
||||
|
||||
else if (qName.equals("setting")) {
|
||||
String key = attributes.getValue("key");
|
||||
String type = attributes.getValue("type");
|
||||
|
@ -326,12 +345,16 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere
|
|||
|
||||
if (current == null)
|
||||
Log.e(TAG, "No current key=" + key);
|
||||
else {
|
||||
if ("enabled".equals(key))
|
||||
enabled = Boolean.parseBoolean(value);
|
||||
else {
|
||||
if ("boolean".equals(type))
|
||||
current.put(key, Boolean.parseBoolean(value));
|
||||
else
|
||||
Log.e(TAG, "Unknown type key=" + key);
|
||||
}
|
||||
}
|
||||
|
||||
} else
|
||||
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));
|
||||
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) {
|
||||
case start:
|
||||
if (prefs.getBoolean("foreground", false)) {
|
||||
|
@ -114,7 +114,7 @@ public class SinkholeService extends VpnService {
|
|||
stopForeground(true);
|
||||
}
|
||||
Widget.updateWidgets(SinkholeService.this);
|
||||
stopSelf();
|
||||
// stopSelf();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="12dp" />
|
||||
android:layout_marginStart="12dp"
|
||||
android:saveEnabled="false" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/llIndicators"
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
package="com.android.vending"
|
||||
related="com.google.android.gms,com.android.providers.downloads"
|
||||
title="Google Play Store" />
|
||||
<relation
|
||||
package="com.android.chrome"
|
||||
related="com.android.providers.downloads"
|
||||
title="Chrome" />
|
||||
<!--rule
|
||||
blocked="true"
|
||||
package="com.android.chrome"
|
||||
|
|
Loading…
Reference in New Issue