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 0fee10a7fb0c701551179ae6f057ce2729318053..d3e270bdd9496f803b291964b4dcb44945c66107 100644 |
--- a/build/android/pylib/device/device_utils.py |
+++ b/build/android/pylib/device/device_utils.py |
@@ -298,6 +298,89 @@ class DeviceUtils(object): |
output = self.old_interface.RunShellCommand(cmd, timeout_time=timeout) |
return output |
+ @decorators.WithTimeoutAndRetriesFromInstance() |
+ def KillAll(self, process_name, signum=9, root=False, blocking=False, |
Sami
2014/06/17 20:39:11
ditto about signal.SIGKILL.
jbudorick
2014/06/17 21:09:27
Done.
|
+ timeout=None, retries=None): |
+ """Kill all processes with the given name on the device. |
+ |
+ Args: |
+ process_name: A string containing the name of the process to kill. |
+ signum: An integer containing the signal number to send to kill. Defaults |
+ to 9 (SIGKILL). |
+ root: A boolean indicating whether the kill should be executed with root |
+ priveleges. |
+ blocking: A boolean indicating whether we should wait until all processes |
+ with the given |process_name| are dead. |
+ timeout: Same as for |IsOnline|. |
+ retries: Same as for |IsOnline|. |
+ """ |
+ if blocking: |
+ self.old_interface.KillAllBlocking(process_name, signum=signum, |
+ with_su=root, timeout_sec=timeout) |
+ else: |
+ self.old_interface.KillAll(process_name, signum=signum, with_su=root) |
+ |
+ @decorators.WithTimeoutAndRetriesFromInstance() |
+ def StartActivity(self, intent, blocking=False, trace_file_name=None, |
+ force_stop=False, timeout=None, retries=None): |
+ """Start package's activity on the device. |
+ |
+ Args: |
+ intent: An Intent to send. |
+ blocking: A boolean indicating whether we should wait for the activity to |
+ finish launching. |
+ trace_file_name: If present, a string that both indicates that we want to |
+ profile the activity and contains the path to which the |
+ trace should be saved. |
+ force_stop: A boolean indicating whether we should stop the activity |
+ before starting it. |
+ timeout: Same as for |IsOnline|. |
+ retries: Same as for |IsOnline|. |
+ """ |
+ self.old_interface.StartActivity( |
+ intent.package, intent.activity, wait_for_completion=blocking, |
+ action=intent.action, category=intent.category, data=intent.data, |
+ extras=intent.extras, trace_file_name=trace_file_name, |
+ force_stop=force_stop, flags=intent.flags) |
+ |
+ @decorators.WithTimeoutAndRetriesFromInstance() |
+ def StartActivityTimed(self, intent, blocking=False, trace_file_name=None, |
+ force_stop=False, timeout=None, retries=None): |
Victor Starodub
2014/06/17 18:43:42
Why do we need both this and previous method? Can'
jbudorick
2014/06/17 21:09:27
This is a good question, and one to which I don't
|
+ """Start package's activity on the device and return the start time. |
+ |
+ Args: |
+ intent: Same as for |StartActivity|. |
+ blocking: Same as for |StartActivity|. |
+ trace_file_name: Same as for |StartActivity|. |
+ force_stop: Same as for |StartActivity|. |
+ timeout: Same as for |IsOnline|. |
+ retries: Same as for |IsOnline|. |
+ Returns: |
+ The start time of the activity. |
frankf
2014/06/17 18:45:44
can you clarify whether this is device or host tim
jbudorick
2014/06/17 21:09:27
removing this function as noted above
|
+ """ |
+ return self.old_interface.StartActivityTimed( |
+ intent.package, intent.activity, wait_for_completion=blocking, |
+ action=intent.action, category=intent.category, data=intent.data, |
+ extras=intent.extras, trace_file_name=trace_file_name, |
+ force_stop=force_stop, flags=intent.flags) |
+ |
+ @decorators.WithTimeoutAndRetriesFromInstance() |
+ def BroadcastIntent(self, intent, timeout=None, retries=None): |
+ """Send a broadcast intent. |
+ |
+ Args: |
+ intent: An Intent to broadcast. |
+ timeout: Same as for |IsOnline|. |
+ retries: Same as for |IsOnline|. |
+ """ |
+ package, old_intent = intent.action.rsplit('.', 1) |
+ if intent.extras is None: |
+ args = [] |
+ else: |
+ args = ['-e %s%s' % (k, ' "%s"' % v if v else '') |
+ for k, v in intent.extras.items() if len(k) > 0] |
+ self.old_interface.BroadcastIntent(package, old_intent, *args) |
+ |
def __str__(self): |
"""Returns the device serial.""" |
return self.old_interface.GetDevice() |