[tor-commits] [orbot/master] improve resource installer ability to update torrc
n8fr8 at torproject.org
n8fr8 at torproject.org
Sat Jun 14 10:01:22 UTC 2014
commit f3d21eec4f447d895e060f405fb1b2be48ac188f
Author: Nathan Freitas <nathan at freitas.net>
Date: Fri Jun 13 12:59:36 2014 -0400
improve resource installer ability to update torrc
---
.../android/service/TorResourceInstaller.java | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/src/org/torproject/android/service/TorResourceInstaller.java b/src/org/torproject/android/service/TorResourceInstaller.java
index c2fcb6a..fa00b1e 100644
--- a/src/org/torproject/android/service/TorResourceInstaller.java
+++ b/src/org/torproject/android/service/TorResourceInstaller.java
@@ -116,34 +116,32 @@ public class TorResourceInstaller implements TorServiceConstants {
return true;
}
- public boolean installTorrc (String extraLines) throws IOException, FileNotFoundException, TimeoutException
+ public boolean updateTorConfig (File fileTorRc, String extraLines) throws IOException, FileNotFoundException, TimeoutException
{
InputStream is;
- File outFile;
Shell shell = Shell.startShell(new ArrayList<String>(),installFolder.getAbsolutePath());
- is = context.getResources().openRawResource(R.raw.torrc);
- outFile = new File(installFolder, TORRC_ASSET_KEY);
- shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
- streamToFile(is,outFile, false, false);
+ is = context.getResources().openRawResource(R.raw.torrc);
+ shell.add(new SimpleCommand(COMMAND_RM_FORCE + fileTorRc.getAbsolutePath())).waitForFinish();
+ streamToFile(is,fileTorRc, false, false);
if (extraLines != null && extraLines.length() > 0)
{
StringBufferInputStream sbis = new StringBufferInputStream('\n' + extraLines + '\n');
- streamToFile(sbis,outFile,true,false);
+ streamToFile(sbis,fileTorRc,true,false);
}
is = context.getResources().openRawResource(R.raw.torrcdiag);
- outFile = new File(installFolder, TORRCDIAG_ASSET_KEY);
- shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
- streamToFile(is,outFile, false, false);
+ fileTorRc = new File(installFolder, TORRCDIAG_ASSET_KEY);
+ shell.add(new SimpleCommand(COMMAND_RM_FORCE + fileTorRc.getAbsolutePath())).waitForFinish();
+ streamToFile(is,fileTorRc, false, false);
if (extraLines != null && extraLines.length() > 0)
{
StringBufferInputStream sbis = new StringBufferInputStream('\n' + extraLines + '\n');
- streamToFile(sbis,outFile,true,false);
+ streamToFile(sbis,fileTorRc,true,false);
}
shell.close();
More information about the tor-commits
mailing list