change how we look for processes to kill. fixes tor trac #18502

This commit is contained in:
Nathan Freitas 2016-03-08 13:05:35 -05:00
parent cec82ec0de
commit 2973eaccd8
3 changed files with 5 additions and 15 deletions

View File

@ -488,15 +488,6 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
cannotKillFile = OrbotApp.fileObfsclient; cannotKillFile = OrbotApp.fileObfsclient;
} }
/**
try {
TorServiceUtils.killProcess(OrbotApp.fileMeekclient);
} catch (IOException e) {
e.printStackTrace();
cannotKillFile = OrbotApp.fileMeekclient;
}
*/
try { try {
TorServiceUtils.killProcess(OrbotApp.filePolipo); TorServiceUtils.killProcess(OrbotApp.filePolipo);
} catch (IOException e) { } catch (IOException e) {

View File

@ -85,9 +85,7 @@ public class TorServiceUtils implements TorServiceConstants {
Process procPs = null; Process procPs = null;
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())); BufferedReader reader = new BufferedReader(new InputStreamReader(procPs.getInputStream()));
String line = null; String line = null;
@ -97,7 +95,7 @@ public class TorServiceUtils implements TorServiceConstants {
if (line.contains("PID")) if (line.contains("PID"))
continue; continue;
if (line.contains('/' + processKey)) if (line.contains(command))
{ {
String[] lineParts = line.split("\\s+"); String[] lineParts = line.split("\\s+");

View File

@ -384,12 +384,13 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
@Override @Override
public void onRevoke() { public void onRevoke() {
Log.w(TAG,"VPNService REVOKED!");
if (!isRestart) if (!isRestart)
{ {
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext()); SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
prefs.edit().putBoolean("pref_vpn", false).commit(); prefs.edit().putBoolean("pref_vpn", false).commit();
stopVPN(); stopVPN();
} }
isRestart = false; isRestart = false;