[tor-commits] [orbot/master] improve process id finding using android 'toolbox'
n8fr8 at torproject.org
n8fr8 at torproject.org
Wed Jun 11 15:28:00 UTC 2014
commit b4fa943fe924d669abd3d5a043eb702905ea1da4
Author: Nathan Freitas <nathan at freitas.net>
Date: Wed Jun 11 07:51:22 2014 -0400
improve process id finding using android 'toolbox'
---
src/org/torproject/android/service/TorService.java | 8 ++++++--
src/org/torproject/android/service/TorServiceConstants.java | 2 +-
src/org/torproject/android/service/TorServiceUtils.java | 11 +++++++----
3 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/src/org/torproject/android/service/TorService.java b/src/org/torproject/android/service/TorService.java
index ce2d075..b43e5a2 100644
--- a/src/org/torproject/android/service/TorService.java
+++ b/src/org/torproject/android/service/TorService.java
@@ -966,9 +966,13 @@ public class TorService extends Service implements TorServiceConstants, TorConst
}
- catch (Exception e)
+ catch (FileNotFoundException e)
+ {
+ logNotice("unable to get control port: no file yet");
+ }
+ catch (IOException e)
{
- logException("unable to get control port",e);
+ logNotice("unable to get control port IOException");
}
diff --git a/src/org/torproject/android/service/TorServiceConstants.java b/src/org/torproject/android/service/TorServiceConstants.java
index 74b2ef7..449e535 100644
--- a/src/org/torproject/android/service/TorServiceConstants.java
+++ b/src/org/torproject/android/service/TorServiceConstants.java
@@ -35,7 +35,7 @@ public interface TorServiceConstants {
public final static String SHELL_CMD_CHMOD = "chmod";
public final static String SHELL_CMD_KILL = "kill -9";
public final static String SHELL_CMD_RM = "rm";
- public final static String SHELL_CMD_PS = "ps";
+ public final static String SHELL_CMD_PS = "toolbox ps";
//public final static String SHELL_CMD_PIDOF = "pidof";
public final static String SHELL_CMD_LINK = "ln -s";
public final static String SHELL_CMD_CP = "cp";
diff --git a/src/org/torproject/android/service/TorServiceUtils.java b/src/org/torproject/android/service/TorServiceUtils.java
index 70c5746..16a9a17 100644
--- a/src/org/torproject/android/service/TorServiceUtils.java
+++ b/src/org/torproject/android/service/TorServiceUtils.java
@@ -78,16 +78,19 @@ public class TorServiceUtils implements TorServiceConstants {
Process procPs = null;
- //String processKey = new File(command).getName();
+ String processKey = new File(command).getName();
- procPs = r.exec(SHELL_CMD_PS); // this is the android ps <name> command
+ procPs = r.exec(SHELL_CMD_PS + ' ' + processKey); // this is the android ps <name> command
BufferedReader reader = new BufferedReader(new InputStreamReader(procPs.getInputStream()));
- String line = reader.readLine(); //read first line "headers" USER PID PPID etc
+ String line = null;
while ((line = reader.readLine())!=null)
{
- if (line.contains(command))
+ if (line.contains("PID"))
+ continue;
+
+ if (line.contains(processKey))
{
String[] lineParts = line.split("\\s+");
More information about the tor-commits
mailing list