fix handling of network connectivity state management

This commit is contained in:
Nathan Freitas 2015-04-08 16:46:40 -04:00
parent 02a42e425e
commit 384fe1c21e
1 changed files with 24 additions and 23 deletions

View File

@ -2105,20 +2105,13 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
isChanged = ((mNetworkType != newNetType)||(mConnectivity != newConnectivityState)); isChanged = ((mNetworkType != newNetType)||(mConnectivity != newConnectivityState));
//is this a change in state?
if (isChanged)
{
mNetworkType = newNetType; mNetworkType = newNetType;
mConnectivity = newConnectivityState; mConnectivity = newConnectivityState;
if (doNetworKSleep) if (doNetworKSleep)
{ {
try {
setTorNetworkEnabled (mConnectivity); setTorNetworkEnabled (mConnectivity);
if (mCurrentStatus != STATUS_OFF)
{
if (!mConnectivity) if (!mConnectivity)
{ {
logNotice(context.getString(R.string.no_network_connectivity_putting_tor_to_sleep_)); logNotice(context.getString(R.string.no_network_connectivity_putting_tor_to_sleep_));
@ -2129,7 +2122,17 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
{ {
logNotice(context.getString(R.string.network_connectivity_is_good_waking_tor_up_)); logNotice(context.getString(R.string.network_connectivity_is_good_waking_tor_up_));
showToolbarNotification(getString(R.string.status_activated),NOTIFY_ID,R.drawable.ic_stat_tor); showToolbarNotification(getString(R.string.status_activated),NOTIFY_ID,R.drawable.ic_stat_tor);
}
//is this a change in state?
if (isChanged)
{
try {
if (mCurrentStatus != STATUS_OFF)
{
if (mConnectivity)
{
if (mHasRoot && mEnableTransparentProxy && mTransProxyNetworkRefresh) if (mHasRoot && mEnableTransparentProxy && mTransProxyNetworkRefresh)
{ {
@ -2144,7 +2147,6 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
if (mUseVPN) //we need to turn on VPN here so the proxy is running if (mUseVPN) //we need to turn on VPN here so the proxy is running
refreshVpnProxy(); refreshVpnProxy();
} }
} }
@ -2153,9 +2155,8 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
} catch (Exception e) { } catch (Exception e) {
logException ("error updating state after network restart",e); logException ("error updating state after network restart",e);
} }
} }
} }
@ -2467,7 +2468,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
updateConfiguration("DNSListenAddress","10.0.0.1:" + TorServiceConstants.TOR_DNS_PORT_DEFAULT,false); updateConfiguration("DNSListenAddress","10.0.0.1:" + TorServiceConstants.TOR_DNS_PORT_DEFAULT,false);
} }
// updateConfiguration("DisableNetwork","0", false); updateConfiguration("DisableNetwork","0", false);
saveConfiguration(); saveConfiguration();