OLD | NEW |
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 | 9 |
10 import collections | 10 import collections |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 action, category, data, extras, | 731 action, category, data, extras, |
732 trace_file_name, force_stop, flags) | 732 trace_file_name, force_stop, flags) |
733 self.StartMonitoringLogcat() | 733 self.StartMonitoringLogcat() |
734 self.RunShellCommand('log starting activity; ' + cmd) | 734 self.RunShellCommand('log starting activity; ' + cmd) |
735 activity_started_re = re.compile('.*starting activity.*') | 735 activity_started_re = re.compile('.*starting activity.*') |
736 m = self.WaitForLogMatch(activity_started_re, None) | 736 m = self.WaitForLogMatch(activity_started_re, None) |
737 assert m | 737 assert m |
738 start_line = m.group(0) | 738 start_line = m.group(0) |
739 return GetLogTimestamp(start_line, self.GetDeviceYear()) | 739 return GetLogTimestamp(start_line, self.GetDeviceYear()) |
740 | 740 |
| 741 def StartCrashUploadService(self, package): |
| 742 # TODO(frankf): We really need a python wrapper around Intent |
| 743 # to be shared with StartActivity/BroadcastIntent. |
| 744 cmd = ( |
| 745 'am startservice -a %s.crash.ACTION_FIND_ALL -n ' |
| 746 '%s/%s.crash.MinidumpUploadService' % |
| 747 (constants.PACKAGE_INFO['chrome'].package, |
| 748 package, |
| 749 constants.PACKAGE_INFO['chrome'].package)) |
| 750 am_output = self.RunShellCommand(cmd) |
| 751 assert am_output and 'Starting' in am_output[-1], 'Service failed to start' |
| 752 time.sleep(15) |
| 753 |
741 def BroadcastIntent(self, package, intent, *args): | 754 def BroadcastIntent(self, package, intent, *args): |
742 """Send a broadcast intent. | 755 """Send a broadcast intent. |
743 | 756 |
744 Args: | 757 Args: |
745 package: Name of package containing the intent. | 758 package: Name of package containing the intent. |
746 intent: Name of the intent. | 759 intent: Name of the intent. |
747 args: Optional extra arguments for the intent. | 760 args: Optional extra arguments for the intent. |
748 """ | 761 """ |
749 cmd = 'am broadcast -a %s.%s %s' % (package, intent, ' '.join(args)) | 762 cmd = 'am broadcast -a %s.%s %s' % (package, intent, ' '.join(args)) |
750 self.RunShellCommand(cmd) | 763 self.RunShellCommand(cmd) |
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1672 """ | 1685 """ |
1673 def __init__(self, output): | 1686 def __init__(self, output): |
1674 self._output = output | 1687 self._output = output |
1675 | 1688 |
1676 def write(self, data): | 1689 def write(self, data): |
1677 data = data.replace('\r\r\n', '\n') | 1690 data = data.replace('\r\r\n', '\n') |
1678 self._output.write(data) | 1691 self._output.write(data) |
1679 | 1692 |
1680 def flush(self): | 1693 def flush(self): |
1681 self._output.flush() | 1694 self._output.flush() |
OLD | NEW |