improve VPN clean-up code

This commit is contained in:
Nathan Freitas 2015-02-14 00:44:02 -05:00
parent a2662c325d
commit 1e5651eec3
1 changed files with 10 additions and 9 deletions

View File

@ -137,14 +137,8 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
mProxyServer = null; mProxyServer = null;
} }
if (mInterface != null){ if (mInterface != null){
try { onRevoke();
Log.d(TAG,"closing interface, destroying VPN interface");
mInterface.close();
mInterface = null;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }
} }
@ -221,8 +215,15 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
public void run() public void run()
{ {
try try
{
Log.d(TAG,"closing interface, destroying VPN interface");
if (mInterface != null)
{ {
mInterface.close(); mInterface.close();
mInterface = null;
}
Tun2Socks.Stop(); Tun2Socks.Stop();
} }
catch (Exception e) catch (Exception e)