mirror of
https://github.com/M66B/NetGuard.git
synced 2025-02-24 15:21:19 +00:00
Fix for Always on VPN on Android N
Thanks @pulser for testing
This commit is contained in:
parent
3bda1ec249
commit
ad63878bc6
1 changed files with 6 additions and 4 deletions
|
@ -1786,14 +1786,14 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
|||
// Keep awake
|
||||
getLock(this).acquire();
|
||||
|
||||
// Get state
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
boolean enabled = prefs.getBoolean("enabled", false);
|
||||
|
||||
// Handle service restart
|
||||
if (intent == null) {
|
||||
Log.i(TAG, "Restart");
|
||||
|
||||
// Get enabled
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
boolean enabled = prefs.getBoolean("enabled", false);
|
||||
|
||||
// Recreate intent
|
||||
intent = new Intent(this, ServiceSinkhole.class);
|
||||
intent.putExtra(EXTRA_COMMAND, enabled ? Command.start : Command.stop);
|
||||
|
@ -1803,6 +1803,8 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
|||
intent.putExtra(EXTRA_COMMAND, Command.householding);
|
||||
|
||||
Command cmd = (Command) intent.getSerializableExtra(EXTRA_COMMAND);
|
||||
if (cmd == null)
|
||||
intent.putExtra(EXTRA_COMMAND, enabled ? Command.start : Command.stop);
|
||||
String reason = intent.getStringExtra(EXTRA_REASON);
|
||||
Log.i(TAG, "Start intent=" + intent + " command=" + cmd + " reason=" + reason +
|
||||
" vpn=" + (vpn != null) + " user=" + (Process.myUid() / 100000));
|
||||
|
|
Loading…
Reference in a new issue