mirror of https://github.com/M66B/NetGuard.git
parent
6cdbba92b9
commit
f008bd6028
|
@ -599,8 +599,6 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS
|
||||||
metered = false;
|
metered = false;
|
||||||
if (unmetered_4g && "4G".equals(generation))
|
if (unmetered_4g && "4G".equals(generation))
|
||||||
metered = false;
|
metered = false;
|
||||||
if (!last_connected)
|
|
||||||
metered = true;
|
|
||||||
last_metered = metered;
|
last_metered = metered;
|
||||||
|
|
||||||
// Update roaming state
|
// Update roaming state
|
||||||
|
@ -629,22 +627,23 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS
|
||||||
// Add list of allowed applications
|
// Add list of allowed applications
|
||||||
int nAllowed = 0;
|
int nAllowed = 0;
|
||||||
int nBlocked = 0;
|
int nBlocked = 0;
|
||||||
for (Rule rule : Rule.getRules(true, TAG, this)) {
|
if (last_connected)
|
||||||
boolean blocked = (metered ? rule.other_blocked : rule.wifi_blocked);
|
for (Rule rule : Rule.getRules(true, TAG, this)) {
|
||||||
boolean screen = (metered ? rule.screen_other : rule.screen_wifi);
|
boolean blocked = (metered ? rule.other_blocked : rule.wifi_blocked);
|
||||||
if ((!blocked || (screen && last_interactive)) && (!metered || !(rule.roaming && roaming))) {
|
boolean screen = (metered ? rule.screen_other : rule.screen_wifi);
|
||||||
nAllowed++;
|
if ((!blocked || (screen && last_interactive)) && (!metered || !(rule.roaming && roaming))) {
|
||||||
if (Util.isDebuggable(this))
|
nAllowed++;
|
||||||
Log.i(TAG, "Allowing " + rule.info.packageName);
|
if (Util.isDebuggable(this))
|
||||||
try {
|
Log.i(TAG, "Allowing " + rule.info.packageName);
|
||||||
builder.addDisallowedApplication(rule.info.packageName);
|
try {
|
||||||
} catch (PackageManager.NameNotFoundException ex) {
|
builder.addDisallowedApplication(rule.info.packageName);
|
||||||
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
} catch (PackageManager.NameNotFoundException ex) {
|
||||||
Util.sendCrashReport(ex, this);
|
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
||||||
}
|
Util.sendCrashReport(ex, this);
|
||||||
} else
|
}
|
||||||
nBlocked++;
|
} else
|
||||||
}
|
nBlocked++;
|
||||||
|
}
|
||||||
Log.i(TAG, "Allowed=" + nAllowed + " blocked=" + nBlocked);
|
Log.i(TAG, "Allowed=" + nAllowed + " blocked=" + nBlocked);
|
||||||
|
|
||||||
// Update notification
|
// Update notification
|
||||||
|
@ -1053,13 +1052,10 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS
|
||||||
.setOngoing(true)
|
.setOngoing(true)
|
||||||
.setAutoCancel(false);
|
.setAutoCancel(false);
|
||||||
|
|
||||||
if (allowed > 0 || blocked > 0) {
|
NotificationCompat.BigTextStyle notification = new NotificationCompat.BigTextStyle(builder);
|
||||||
NotificationCompat.BigTextStyle notification = new NotificationCompat.BigTextStyle(builder);
|
notification.bigText(getString(R.string.msg_started));
|
||||||
notification.bigText(getString(R.string.msg_started));
|
notification.setSummaryText(getString(R.string.msg_packages, allowed, blocked));
|
||||||
notification.setSummaryText(getString(R.string.msg_packages, allowed, blocked));
|
return notification.build();
|
||||||
return notification.build();
|
|
||||||
} else
|
|
||||||
return builder.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Notification getWaitingNotification() {
|
private Notification getWaitingNotification() {
|
||||||
|
|
Loading…
Reference in New Issue