make sure tor network is re-enabled when user tries to restart

This commit is contained in:
Nathan Freitas 2016-11-16 07:52:21 -05:00
parent d09c2b59b4
commit ff61d66bcf
1 changed files with 12 additions and 15 deletions

View File

@ -581,14 +581,13 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
if (mNotificationManager == null) if (mNotificationManager == null)
{ {
IntentFilter mNetworkStateFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
registerReceiver(mNetworkStateReceiver , mNetworkStateFilter);
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
} }
IntentFilter mNetworkStateFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
registerReceiver(mNetworkStateReceiver , mNetworkStateFilter);
new Thread(new Runnable () new Thread(new Runnable ()
{ {
public void run () public void run ()
@ -773,6 +772,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
} else if (mCurrentStatus == STATUS_ON) { } else if (mCurrentStatus == STATUS_ON) {
sendCallbackLogMessage("Ignoring start request, already started."); sendCallbackLogMessage("Ignoring start request, already started.");
setTorNetworkEnabled (true);
return; return;
} }
@ -1521,7 +1521,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
mNetworkType = newNetType; mNetworkType = newNetType;
mConnectivity = newConnectivityState; mConnectivity = newConnectivityState;
if (doNetworKSleep) if (doNetworKSleep && mCurrentStatus != STATUS_OFF)
{ {
setTorNetworkEnabled (mConnectivity); setTorNetworkEnabled (mConnectivity);
@ -1539,18 +1539,15 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
try { try {
if (mCurrentStatus != STATUS_OFF) if (mConnectivity)
{ {
if (mConnectivity) if (Prefs.useRoot() && Prefs.useTransparentProxying() && Prefs.transProxyNetworkRefresh())
{ {
if (Prefs.useRoot() && Prefs.useTransparentProxying() && Prefs.transProxyNetworkRefresh())
{
disableTransparentProxy(); disableTransparentProxy();
enableTransparentProxy(); enableTransparentProxy();
}
} }
} }