Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(844)

Unified Diff: build/android/pylib/device/device_utils.py

Issue 536343003: Kill old browser rather than close (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: apply change that caused conflict Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/android/pylib/device/device_utils_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/device/device_utils.py
diff --git a/build/android/pylib/device/device_utils.py b/build/android/pylib/device/device_utils.py
index 8a8de22519f3d69bc93681657494ed076eaeba05..0009b5de7d41535e33c8ad42357d592a6d71e81e 100644
--- a/build/android/pylib/device/device_utils.py
+++ b/build/android/pylib/device/device_utils.py
@@ -364,20 +364,20 @@ class DeviceUtils(object):
CommandTimeoutError on timeout.
DeviceUnreachableError on missing device.
"""
- pids = self.old_interface.ExtractPid(process_name)
- if len(pids) == 0:
+ pids = self._GetPidsImpl(process_name)
+ if not pids:
raise device_errors.CommandFailedError(
'No process "%s"' % process_name, device=str(self))
+ cmd = 'kill -%d %s' % (signum, ' '.join(pids.values()))
+ self._RunShellCommandImpl(cmd, as_root=as_root)
+
if blocking:
- total_killed = self.old_interface.KillAllBlocking(
- process_name, signum=signum, with_su=as_root, timeout_sec=timeout)
- else:
- total_killed = self.old_interface.KillAll(
- process_name, signum=signum, with_su=as_root)
- if total_killed == 0:
- raise device_errors.CommandFailedError(
- 'Failed to kill "%s"' % process_name, device=str(self))
+ wait_period = 0.1
+ while self._GetPidsImpl(process_name):
+ time.sleep(wait_period)
+
+ return len(pids)
@decorators.WithTimeoutAndRetriesFromInstance()
def StartActivity(self, intent, blocking=False, trace_file_name=None,
@@ -722,6 +722,24 @@ class DeviceUtils(object):
CommandTimeoutError on timeout.
DeviceUnreachableError on missing device.
"""
+ return self._GetPidsImpl(process_name)
+
+ def _GetPidsImpl(self, process_name):
+ """Implementation of GetPids.
+
+ This is split from GetPids to allow other DeviceUtils methods to call
+ GetPids without spawning a new timeout thread.
+
+ Args:
+ process_name: A string containing the process name to get the PIDs for.
+
+ Returns:
+ A dict mapping process name to PID for each process that contained the
+ provided |process_name|.
+
+ Raises:
+ DeviceUnreachableError on missing device.
+ """
procs_pids = {}
for line in self._RunShellCommandImpl('ps'):
try:
« no previous file with comments | « no previous file | build/android/pylib/device/device_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698