ensure settings are updated and binary paths are on service restart

This commit is contained in:
Nathan Freitas 2014-08-26 23:01:46 -04:00
parent af433d37ba
commit 6e6546972a
1 changed files with 28 additions and 15 deletions

View File

@ -340,6 +340,12 @@ public class TorService extends Service implements TorServiceConstants, TorConst
try try
{ {
if (fileTor == null)
initBinariesAndDirectories();
updateSettings ();
mExecutor.execute (new TorStarter(intent)); mExecutor.execute (new TorStarter(intent));
return Service.START_STICKY; return Service.START_STICKY;
@ -568,13 +574,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
try try
{ {
initBinariesAndDirectories(); initBinariesAndDirectories();
} updateSettings();
catch (Exception e)
{
//what error here
Log.e(TAG, "Error installing Orbot binaries",e);
logNotice("There was an error installing Orbot binaries");
}
new Thread(new Runnable () new Thread(new Runnable ()
{ {
@ -592,6 +592,15 @@ public class TorService extends Service implements TorServiceConstants, TorConst
} }
}).start(); }).start();
}
catch (Exception e)
{
//what error here
Log.e(TAG, "Error installing Orbot binaries",e);
logNotice("There was an error installing Orbot binaries");
}
} }
private void initBinariesAndDirectories () throws Exception private void initBinariesAndDirectories () throws Exception
@ -712,6 +721,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
private void updateSettings () throws TimeoutException, IOException private void updateSettings () throws TimeoutException, IOException
{ {
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext()); SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
mHasRoot = prefs.getBoolean(PREF_HAS_ROOT,false); mHasRoot = prefs.getBoolean(PREF_HAS_ROOT,false);
@ -736,6 +746,9 @@ public class TorService extends Service implements TorServiceConstants, TorConst
currentStatus = STATUS_CONNECTING; currentStatus = STATUS_CONNECTING;
if (fileTor == null)
initBinariesAndDirectories();
enableBinExec(fileTor); enableBinExec(fileTor);
enableBinExec(filePolipo); enableBinExec(filePolipo);
enableBinExec(fileObfsclient); enableBinExec(fileObfsclient);