set STATUS_STARTING in TorService.onCreate(), that's where it begins

The very first place that the whole tor start sequence starts is from
TorService's onCreate(), so that is where STATUS_STARTING should be
announced from.  The open question is whether Intents besides ACTION_START
ever cause TorService to start.  In theory, TorService should already be
running when any Intent is sent besides ACTION_START.
This commit is contained in:
Hans-Christoph Steiner 2015-06-12 14:49:19 -04:00
parent 8f57b42e68
commit 232098eeaf
1 changed files with 6 additions and 6 deletions

View File

@ -608,7 +608,10 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
@Override
public void onCreate() {
super.onCreate();
Log.i("TorService", "onCreate");
sendCallbackStatus(STATUS_STARTING);
sendCallbackLogMessage(getString(R.string.status_starting_up));
logNotice(getString(R.string.status_starting_up));
try
{
@ -776,7 +779,8 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
* The entire process for starting tor and related services is run from this method.
*/
private void startTor() {
if (mCurrentStatus == STATUS_STARTING || mCurrentStatus == STATUS_STOPPING) {
// STATUS_STARTING is set in onCreate()
if (mCurrentStatus == STATUS_STOPPING) {
// these states should probably be handled better
sendCallbackLogMessage("Ignoring start request, currently " + mCurrentStatus);
return;
@ -784,10 +788,6 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
sendCallbackLogMessage("Ignoring start request, already started.");
return;
}
sendCallbackStatus(STATUS_STARTING);
sendCallbackLogMessage(getString(R.string.status_starting_up));
logNotice(getString(R.string.status_starting_up));
if (findExistingTorDaemon()) {
return; // an old tor is already running, nothing to do