Skip to content

Commit c5e9414

Browse files
committed
Rebuild VPN on active network change
1 parent 589b482 commit c5e9414

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
import java.util.HashSet;
105105
import java.util.List;
106106
import java.util.Map;
107+
import java.util.Objects;
107108
import java.util.Set;
108109
import java.util.TreeMap;
109110
import java.util.concurrent.ExecutorService;
@@ -3245,6 +3246,7 @@ private void removeWarningNotifications() {
32453246
}
32463247

32473248
private class Builder extends VpnService.Builder {
3249+
private Network activeNetwork;
32483250
private NetworkInfo networkInfo;
32493251
private int mtu;
32503252
private List<String> listAddress = new ArrayList<>();
@@ -3256,6 +3258,7 @@ private class Builder extends VpnService.Builder {
32563258
private Builder() {
32573259
super();
32583260
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
3261+
activeNetwork = (Build.VERSION.SDK_INT < Build.VERSION_CODES.M ? null : cm.getActiveNetwork());
32593262
networkInfo = cm.getActiveNetworkInfo();
32603263
}
32613264

@@ -3314,6 +3317,9 @@ public boolean equals(Object obj) {
33143317
if (other == null)
33153318
return false;
33163319

3320+
if (!Objects.equals(this.activeNetwork, other.activeNetwork))
3321+
return false;
3322+
33173323
if (this.networkInfo == null || other.networkInfo == null ||
33183324
this.networkInfo.getType() != other.networkInfo.getType())
33193325
return false;

0 commit comments

Comments
 (0)