mirror of https://github.com/M66B/NetGuard.git
parent
50be022cbc
commit
12eab96394
|
@ -73,25 +73,27 @@ public class Receiver extends BroadcastReceiver {
|
|||
}
|
||||
|
||||
} else {
|
||||
// Boot completed
|
||||
// My package replaced
|
||||
|
||||
// Upgrade settings
|
||||
upgrade(true, context);
|
||||
|
||||
// Start service
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
if (prefs.getBoolean("enabled", false))
|
||||
try {
|
||||
if (VpnService.prepare(context) == null)
|
||||
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction()))
|
||||
SinkholeService.run("receiver", context);
|
||||
else
|
||||
try {
|
||||
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
|
||||
if (prefs.getBoolean("enabled", false) || prefs.getBoolean("show_stats", false))
|
||||
SinkholeService.run("receiver", context);
|
||||
|
||||
} else if (Intent.ACTION_MY_PACKAGE_REPLACED.equals(intent.getAction())) {
|
||||
if (prefs.getBoolean("enabled", false)) {
|
||||
if (VpnService.prepare(context) == null)
|
||||
SinkholeService.start("receiver", context);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
||||
Util.sendCrashReport(ex, context);
|
||||
} else if (prefs.getBoolean("show_stats", false))
|
||||
SinkholeService.run("receiver", context);
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
||||
Util.sendCrashReport(ex, context);
|
||||
}
|
||||
|
||||
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
if (pm.isInteractive())
|
||||
|
|
|
@ -268,9 +268,12 @@ public class SinkholeService extends VpnService {
|
|||
if (state == State.enforcing) {
|
||||
Log.d(TAG, "Stop foreground state=" + state.toString());
|
||||
stopForeground(true);
|
||||
startForeground(NOTIFY_WAITING, getWaitingNotification());
|
||||
state = State.waiting;
|
||||
Log.d(TAG, "Start foreground state=" + state.toString());
|
||||
if (prefs.getBoolean("show_stats", false)) {
|
||||
startForeground(NOTIFY_WAITING, getWaitingNotification());
|
||||
state = State.waiting;
|
||||
Log.d(TAG, "Start foreground state=" + state.toString());
|
||||
} else
|
||||
state = State.none;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -346,9 +349,7 @@ public class SinkholeService extends VpnService {
|
|||
if (state == State.stats) {
|
||||
Log.d(TAG, "Stop foreground state=" + state.toString());
|
||||
stopForeground(true);
|
||||
startForeground(NOTIFY_WAITING, getWaitingNotification());
|
||||
state = State.waiting;
|
||||
Log.d(TAG, "Start foreground state=" + state.toString());
|
||||
state = State.none;
|
||||
} else
|
||||
NotificationManagerCompat.from(SinkholeService.this).cancel(NOTIFY_TRAFFIC);
|
||||
}
|
||||
|
@ -567,10 +568,8 @@ public class SinkholeService extends VpnService {
|
|||
}
|
||||
if (state == State.enforcing)
|
||||
startForeground(NOTIFY_ENFORCING, getEnforcingNotification(0, 0));
|
||||
else {
|
||||
else if (state != State.none)
|
||||
startForeground(NOTIFY_WAITING, getWaitingNotification());
|
||||
state = State.waiting;
|
||||
}
|
||||
Log.d(TAG, "Start foreground state=" + state.toString());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue