Full restart on network type change

Refs #345
This commit is contained in:
M66B 2016-02-29 08:25:58 +01:00
parent 15f82a4a50
commit f62cb96d1f
1 changed files with 12 additions and 0 deletions

View File

@ -40,6 +40,7 @@ import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Typeface;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.TrafficStats;
import android.net.VpnService;
import android.os.Build;
@ -2013,11 +2014,18 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS
}
private class Builder extends VpnService.Builder {
private NetworkInfo networkInfo;
private List<String> listAddress = new ArrayList<>();
private List<String> listRoute = new ArrayList<>();
private List<InetAddress> listDns = new ArrayList<>();
private List<String> listDisallowed = new ArrayList<>();
private Builder() {
super();
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
networkInfo = cm.getActiveNetworkInfo();
}
@Override
public Builder addAddress(String address, int prefixLength) {
listAddress.add(address + "/" + prefixLength);
@ -2053,6 +2061,10 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS
if (other == null)
return false;
if (this.networkInfo == null || other.networkInfo == null ||
this.networkInfo.getType() != other.networkInfo.getType())
return false;
if (this.listAddress.size() != other.listAddress.size())
return false;