Block all on no connection

Refs #225
This commit is contained in:
M66B 2016-01-09 17:10:57 +01:00
parent 6cdbba92b9
commit f008bd6028
1 changed files with 21 additions and 25 deletions

View File

@ -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,6 +627,7 @@ 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;
if (last_connected)
for (Rule rule : Rule.getRules(true, TAG, this)) { for (Rule rule : Rule.getRules(true, TAG, this)) {
boolean blocked = (metered ? rule.other_blocked : rule.wifi_blocked); boolean blocked = (metered ? rule.other_blocked : rule.wifi_blocked);
boolean screen = (metered ? rule.screen_other : rule.screen_wifi); boolean screen = (metered ? rule.screen_other : rule.screen_wifi);
@ -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() {