only set mCurrentStatus in sendCallbackStatus(), the one stop shop

Make sendCallbackStatus() the one thing that updates the all of the bits
related to running status.
This commit is contained in:
Hans-Christoph Steiner 2015-06-09 13:33:57 -04:00
parent 780abf003e
commit 3580cbe05d
1 changed files with 7 additions and 12 deletions

View File

@ -178,10 +178,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
if (mLastProcessId != -1 && conn != null) if (mLastProcessId != -1 && conn != null)
{ {
sendCallbackLogMessage (getString(R.string.found_existing_tor_process)); sendCallbackLogMessage (getString(R.string.found_existing_tor_process));
sendCallbackStatus(STATUS_ON);
mCurrentStatus = STATUS_ON;
sendCallbackStatus(mCurrentStatus);
return true; return true;
} }
@ -394,8 +391,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
private void stopTor() { private void stopTor() {
Log.i("TorService", "stopTor"); Log.i("TorService", "stopTor");
try { try {
mCurrentStatus = STATUS_STOPPING; sendCallbackStatus(STATUS_STOPPING);
sendCallbackStatus(mCurrentStatus);
sendCallbackLogMessage(getString(R.string.status_shutting_down)); sendCallbackLogMessage(getString(R.string.status_shutting_down));
Log.d(TAG,"Tor is stopping NOW"); Log.d(TAG,"Tor is stopping NOW");
@ -431,8 +427,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
sendCallbackLogMessage(getString(R.string.something_bad_happened)); sendCallbackLogMessage(getString(R.string.something_bad_happened));
} }
mCurrentStatus = STATUS_OFF; sendCallbackStatus(STATUS_OFF);
sendCallbackStatus(mCurrentStatus);
} }
@ -758,8 +753,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
return; return;
} }
mCurrentStatus = STATUS_STARTING; sendCallbackStatus(STATUS_STARTING);
sendCallbackStatus(mCurrentStatus);
sendCallbackLogMessage(getString(R.string.status_starting_up)); sendCallbackLogMessage(getString(R.string.status_starting_up));
logNotice(getString(R.string.status_starting_up)); logNotice(getString(R.string.status_starting_up));
@ -814,8 +808,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
} }
shellUser.close(); shellUser.close();
mCurrentStatus = STATUS_ON; sendCallbackStatus(STATUS_ON);
sendCallbackStatus(mCurrentStatus);
} catch (CannotKillException e) { } catch (CannotKillException e) {
logException(e.getMessage(), e); logException(e.getMessage(), e);
showToolbarNotification(getString(R.string.unable_to_reset_tor), showToolbarNotification(getString(R.string.unable_to_reset_tor),
@ -1885,6 +1878,8 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
} }
private void sendCallbackStatus(String currentStatus) { private void sendCallbackStatus(String currentStatus) {
mCurrentStatus = currentStatus;
Intent intent = new Intent(ACTION_STATUS); Intent intent = new Intent(ACTION_STATUS);
intent.putExtra(EXTRA_STATUS, currentStatus); intent.putExtra(EXTRA_STATUS, currentStatus);
LocalBroadcastManager.getInstance(this).sendBroadcast(intent); LocalBroadcastManager.getInstance(this).sendBroadcast(intent);