make start and stop of Tor service all hanlded through executor

This commit is contained in:
Nathan Freitas 2016-10-21 14:53:58 -04:00
parent d8648a5864
commit 2125db1504
2 changed files with 5 additions and 6 deletions

View File

@ -42,7 +42,6 @@ public class OnBootReceiver extends BroadcastReceiver {
torService.setAction(action); torService.setAction(action);
context.startService(torService); context.startService(torService);
} }

View File

@ -109,8 +109,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
boolean mIsLollipop = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP; boolean mIsLollipop = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
private ExecutorService mExecutor = Executors.newFixedThreadPool(1); private ExecutorService mExecutor = Executors.newFixedThreadPool(3);
TorEventHandler mEventHandler; TorEventHandler mEventHandler;
@ -296,7 +295,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
*/ */
public int onStartCommand(Intent intent, int flags, int startId) { public int onStartCommand(Intent intent, int flags, int startId) {
if (intent != null) if (intent != null)
new Thread (new IncomingIntentRouter(intent)).start(); exec (new IncomingIntentRouter(intent));
else else
Log.d(OrbotConstants.TAG, "Got null onStartCommand() intent"); Log.d(OrbotConstants.TAG, "Got null onStartCommand() intent");
@ -363,13 +362,14 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
private void stopTor () private void stopTor ()
{ {
mExecutor.execute(new Runnable () exec(new Runnable ()
{ {
public void run () public void run ()
{ {
stopTorAsync(); stopTorAsync();
} }
}); });
} }
private void stopTorAsync () { private void stopTorAsync () {