Skip to content

Commit

Permalink
Fixes #431 unmetered VpnService on Android Q+ - removed small warning…
Browse files Browse the repository at this point in the history
…s in OrbotVpnManager.java
  • Loading branch information
bitmold committed Feb 3, 2021
1 parent fe69a31 commit 729bffd
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ public class OrbotVpnManager implements Handler.Callback {
boolean isStarted = false;
File filePdnsPid;
private Thread mThreadVPN;
private String mSessionName = "OrbotVPN";
private final static String mSessionName = "OrbotVPN";
private ParcelFileDescriptor mInterface;
private int mTorSocks = -1;
private int mTorDns = -1;
private int pdnsdPort = 8091;
private ProxyServer mSocksProxyServer;
private File filePdnsd;
private final File filePdnsd;
private boolean isRestart = false;
private VpnService mService;
private final VpnService mService;

public OrbotVpnManager(VpnService service) throws IOException, TimeoutException {
mService = service;
Expand Down Expand Up @@ -291,6 +291,11 @@ public void run() {
if (mIsLollipop)
doLollipopAppRouting(builder);

// https://developer.android.com/reference/android/net/VpnService.Builder#setMetered(boolean)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
builder.setMetered(false);
}

// Create a new interface using the builder and save the parameters.
ParcelFileDescriptor newInterface = builder.setSession(mSessionName)
.setConfigureIntent(null) // previously this was set to a null member variable
Expand Down Expand Up @@ -380,7 +385,7 @@ private void startDNS(String pdnsPath, String torDnsHost, int torDnsPort, String

}

private boolean stopDns() {
private void stopDns() {
if (filePdnsPid != null && filePdnsPid.exists()) {
List<String> lines;
try {
Expand All @@ -393,7 +398,6 @@ private boolean stopDns() {
Log.e("OrbotVPN", "error killing dns process", e);
}
}
return false;
}

public boolean isStarted() {
Expand Down

0 comments on commit 729bffd

Please sign in to comment.