diff options
author | Adithya Abraham Philip <adithyaphilip@gmail.com> | 2015-06-16 14:36:18 +0530 |
---|---|---|
committer | Adithya Abraham Philip <adithyaphilip@gmail.com> | 2015-07-03 20:46:15 +0530 |
commit | 2402c6d3c72b19b8eded017ff3fbeb83c30ae0a8 (patch) | |
tree | 3b6e9eb10f21be97e94582616e309c230ae5f327 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/orbot/TorServiceUtils.java | |
parent | f6d0f88ac973328b3b7a9d426214beb76efefb3f (diff) | |
download | open-keychain-2402c6d3c72b19b8eded017ff3fbeb83c30ae0a8.tar.gz open-keychain-2402c6d3c72b19b8eded017ff3fbeb83c30ae0a8.tar.bz2 open-keychain-2402c6d3c72b19b8eded017ff3fbeb83c30ae0a8.zip |
ensuring code style is preserved
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/orbot/TorServiceUtils.java')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/orbot/TorServiceUtils.java | 42 |
1 files changed, 15 insertions, 27 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/orbot/TorServiceUtils.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/orbot/TorServiceUtils.java index 127e9d43f..b1d8327fb 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/orbot/TorServiceUtils.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/orbot/TorServiceUtils.java @@ -49,14 +49,14 @@ package org.sufficientlysecure.keychain.util.orbot; +import android.util.Log; + import java.io.BufferedReader; import java.io.File; import java.io.InputStreamReader; import java.net.URLEncoder; import java.util.StringTokenizer; -import android.util.Log; - /** * This class is taken from the NetCipher library: https://github.com/guardianproject/NetCipher/ */ @@ -68,23 +68,18 @@ public class TorServiceUtils { public final static String SHELL_CMD_PS = "ps"; public final static String SHELL_CMD_PIDOF = "pidof"; - public static int findProcessId(String command) - { + public static int findProcessId(String command) { int procId = -1; - try - { + try { procId = findProcessIdWithPidOf(command); if (procId == -1) procId = findProcessIdWithPS(command); - } catch (Exception e) - { - try - { + } catch (Exception e) { + try { procId = findProcessIdWithPS(command); - } catch (Exception e2) - { + } catch (Exception e2) { Log.e(TAG, "Unable to get proc id for command: " + URLEncoder.encode(command), e2); } } @@ -93,8 +88,7 @@ public class TorServiceUtils { } // use 'pidof' command - public static int findProcessIdWithPidOf(String command) throws Exception - { + public static int findProcessIdWithPidOf(String command) throws Exception { int procId = -1; @@ -104,7 +98,7 @@ public class TorServiceUtils { String baseName = new File(command).getName(); // fix contributed my mikos on 2010.12.10 - procPs = r.exec(new String[] { + procPs = r.exec(new String[]{ SHELL_CMD_PIDOF, baseName }); // procPs = r.exec(SHELL_CMD_PIDOF); @@ -112,16 +106,13 @@ public class TorServiceUtils { BufferedReader reader = new BufferedReader(new InputStreamReader(procPs.getInputStream())); String line = null; - while ((line = reader.readLine()) != null) - { + while ((line = reader.readLine()) != null) { - try - { + try { // this line should just be the process id procId = Integer.parseInt(line.trim()); break; - } catch (NumberFormatException e) - { + } catch (NumberFormatException e) { Log.e("TorServiceUtils", "unable to parse process pid: " + line, e); } } @@ -131,8 +122,7 @@ public class TorServiceUtils { } // use 'ps' command - public static int findProcessIdWithPS(String command) throws Exception - { + public static int findProcessIdWithPS(String command) throws Exception { int procId = -1; @@ -145,10 +135,8 @@ public class TorServiceUtils { BufferedReader reader = new BufferedReader(new InputStreamReader(procPs.getInputStream())); String line = null; - while ((line = reader.readLine()) != null) - { - if (line.indexOf(' ' + command) != -1) - { + while ((line = reader.readLine()) != null) { + if (line.indexOf(' ' + command) != -1) { StringTokenizer st = new StringTokenizer(line, " "); st.nextToken(); // proc owner |