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,13 +581,12 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
if (mNotificationManager == null) if (mNotificationManager == null)
{ {
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
}
IntentFilter mNetworkStateFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); IntentFilter mNetworkStateFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
registerReceiver(mNetworkStateReceiver , mNetworkStateFilter); registerReceiver(mNetworkStateReceiver , mNetworkStateFilter);
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
}
new Thread(new Runnable () new Thread(new Runnable ()
{ {
@ -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,8 +1539,6 @@ 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())
@ -1552,7 +1550,6 @@ 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);