mirror of
https://github.com/M66B/NetGuard.git
synced 2025-01-03 05:44:14 +00:00
Rebuild VPN on active network change
This commit is contained in:
parent
589b4828b1
commit
c5e9414bb4
1 changed files with 6 additions and 0 deletions
|
@ -104,6 +104,7 @@ import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
@ -3245,6 +3246,7 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Builder extends VpnService.Builder {
|
private class Builder extends VpnService.Builder {
|
||||||
|
private Network activeNetwork;
|
||||||
private NetworkInfo networkInfo;
|
private NetworkInfo networkInfo;
|
||||||
private int mtu;
|
private int mtu;
|
||||||
private List<String> listAddress = new ArrayList<>();
|
private List<String> listAddress = new ArrayList<>();
|
||||||
|
@ -3256,6 +3258,7 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
||||||
private Builder() {
|
private Builder() {
|
||||||
super();
|
super();
|
||||||
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
activeNetwork = (Build.VERSION.SDK_INT < Build.VERSION_CODES.M ? null : cm.getActiveNetwork());
|
||||||
networkInfo = cm.getActiveNetworkInfo();
|
networkInfo = cm.getActiveNetworkInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3314,6 +3317,9 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
||||||
if (other == null)
|
if (other == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (!Objects.equals(this.activeNetwork, other.activeNetwork))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (this.networkInfo == null || other.networkInfo == null ||
|
if (this.networkInfo == null || other.networkInfo == null ||
|
||||||
this.networkInfo.getType() != other.networkInfo.getType())
|
this.networkInfo.getType() != other.networkInfo.getType())
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue