on start, check for running tor daemon, and if TorService stopped, then start

If Orbot was killed when the tor daemon was running, the tor daemon will
still be running when Orbot starts again.  OrbotMainActivity then checks to
see if tor daemon is running while TorService is stopped.  If so, TorService
is started so that the state of everything is in sync.
This commit is contained in:
Hans-Christoph Steiner 2015-06-17 12:08:52 -04:00
parent a81c0001d6
commit aa87e6712a
1 changed files with 17 additions and 0 deletions

View File

@ -59,6 +59,7 @@ import org.torproject.android.ui.ImageProgressView;
import org.torproject.android.ui.PromoAppsActivity;
import org.torproject.android.ui.Rotate3dAnimation;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
@ -1010,6 +1011,22 @@ public class OrbotMainActivity extends Activity
mBtnBridges.setChecked(Prefs.bridgesEnabled());
}
/*
* Check if the tor daemon is running and if TorService is stopped. If
* so, automatically start TorService to represent it
*/
try {
if (TorServiceUtils.findProcessId(OrbotApp.fileTor.getAbsolutePath()) != -1
&& !isTorServiceRunning()) {
Log.i(TAG, "Found tor daemon without TorService: starting TorService");
startTor();
}
} catch (IOException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
}
handleIntents();
}