mirror of
https://github.com/M66B/NetGuard.git
synced 2024-12-28 10:51:14 +00:00
Keep NetGuard enabled on start failures
This commit is contained in:
parent
8cd746e0d4
commit
7ddff62bbe
1 changed files with 16 additions and 4 deletions
|
@ -439,8 +439,10 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
|||
showErrorNotification(ex.toString());
|
||||
|
||||
// Disable firewall
|
||||
prefs.edit().putBoolean("enabled", false).apply();
|
||||
WidgetMain.updateWidgets(ServiceSinkhole.this);
|
||||
if (!(ex instanceof StartFailedException)) {
|
||||
prefs.edit().putBoolean("enabled", false).apply();
|
||||
WidgetMain.updateWidgets(ServiceSinkhole.this);
|
||||
}
|
||||
}
|
||||
} else
|
||||
showErrorNotification(ex.toString());
|
||||
|
@ -471,7 +473,7 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
|||
last_builder = getBuilder(listAllowed, listRule);
|
||||
vpn = startVPN(last_builder);
|
||||
if (vpn == null)
|
||||
throw new IllegalStateException(getString((R.string.msg_start_failed)));
|
||||
throw new StartFailedException(getString((R.string.msg_start_failed)));
|
||||
|
||||
startNative(vpn, listAllowed, listRule);
|
||||
|
||||
|
@ -566,7 +568,7 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
|||
}
|
||||
|
||||
if (vpn == null)
|
||||
throw new IllegalStateException(getString((R.string.msg_start_failed)));
|
||||
throw new StartFailedException(getString((R.string.msg_start_failed)));
|
||||
|
||||
startNative(vpn, listAllowed, listRule);
|
||||
|
||||
|
@ -662,6 +664,16 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
|||
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
||||
}
|
||||
}
|
||||
|
||||
private class StartFailedException extends IllegalStateException {
|
||||
public StartFailedException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public StartFailedException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final class LogHandler extends Handler {
|
||||
|
|
Loading…
Reference in a new issue