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

Side by Side Diff: build/android/pylib/android_commands.py

Issue 338353004: [Android] Switch KillAll, StartActivity, and BroadcastIntent to DeviceUtils. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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 unified diff | Download patch
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Provides an interface to communicate with the device via the adb command. 5 """Provides an interface to communicate with the device via the adb command.
6 6
7 Assumes adb binary is currently on system path. 7 Assumes adb binary is currently on system path.
8 """ 8 """
9 # pylint: disable-all 9 # pylint: disable-all
10 10
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 """ 771 """
772 pids = self.ExtractPid(process) 772 pids = self.ExtractPid(process)
773 if pids: 773 if pids:
774 cmd = 'kill -%d %s' % (signum, ' '.join(pids)) 774 cmd = 'kill -%d %s' % (signum, ' '.join(pids))
775 if with_su: 775 if with_su:
776 self.RunShellCommandWithSU(cmd) 776 self.RunShellCommandWithSU(cmd)
777 else: 777 else:
778 self.RunShellCommand(cmd) 778 self.RunShellCommand(cmd)
779 return len(pids) 779 return len(pids)
780 780
781 def KillAllBlocking(self, process, timeout_sec): 781 def KillAllBlocking(self, process, timeout_sec, signum=9, with_su=False):
Sami 2014/06/17 20:39:11 nit: use signal.SIGKILL instead of 9.
jbudorick 2014/06/17 21:09:27 Done. (and above in KillAll)
782 """Blocking version of killall, connected via adb. 782 """Blocking version of killall, connected via adb.
783 783
784 This waits until no process matching the corresponding name appears in ps' 784 This waits until no process matching the corresponding name appears in ps'
785 output anymore. 785 output anymore.
786 786
787 Args: 787 Args:
788 process: name of the process to kill off 788 process: name of the process to kill off
789 timeout_sec: the timeout in seconds 789 timeout_sec: the timeout in seconds
790 790 signum: same as |KillAll|
791 with_su: same as |KillAll|
791 Returns: 792 Returns:
792 the number of processes killed 793 the number of processes killed
793 """ 794 """
794 processes_killed = self.KillAll(process) 795 processes_killed = self.KillAll(process, signum=signum, with_su=with_su)
795 if processes_killed: 796 if processes_killed:
796 elapsed = 0 797 elapsed = 0
797 wait_period = 0.1 798 wait_period = 0.1
798 # Note that this doesn't take into account the time spent in ExtractPid(). 799 # Note that this doesn't take into account the time spent in ExtractPid().
799 while self.ExtractPid(process) and elapsed < timeout_sec: 800 while self.ExtractPid(process) and elapsed < timeout_sec:
800 time.sleep(wait_period) 801 time.sleep(wait_period)
801 elapsed += wait_period 802 elapsed += wait_period
802 if elapsed >= timeout_sec: 803 if elapsed >= timeout_sec:
803 return 0 804 return 0
804 return processes_killed 805 return processes_killed
(...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1983 """ 1984 """
1984 def __init__(self, output): 1985 def __init__(self, output):
1985 self._output = output 1986 self._output = output
1986 1987
1987 def write(self, data): 1988 def write(self, data):
1988 data = data.replace('\r\r\n', '\n') 1989 data = data.replace('\r\r\n', '\n')
1989 self._output.write(data) 1990 self._output.write(data)
1990 1991
1991 def flush(self): 1992 def flush(self):
1992 self._output.flush() 1993 self._output.flush()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698