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 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1076 | 1076 |
1077 def GetBatteryInfo(self): | 1077 def GetBatteryInfo(self): |
1078 """Returns the device battery info (e.g. status, level, etc) as string.""" | 1078 """Returns the device battery info (e.g. status, level, etc) as string.""" |
1079 battery = self.RunShellCommand('dumpsys battery') | 1079 battery = self.RunShellCommand('dumpsys battery') |
1080 assert battery | 1080 assert battery |
1081 return '\n'.join(battery) | 1081 return '\n'.join(battery) |
1082 | 1082 |
1083 def GetSetupWizardStatus(self): | 1083 def GetSetupWizardStatus(self): |
1084 """Returns the status of the device setup wizard (e.g. DISABLED).""" | 1084 """Returns the status of the device setup wizard (e.g. DISABLED).""" |
1085 status = self.RunShellCommand('getprop ro.setupwizard.mode')[0] | 1085 status = self.RunShellCommand('getprop ro.setupwizard.mode')[0] |
1086 assert status | 1086 # On some devices, the status is empty if not otherwise set. In such cases |
| 1087 # the caller should expect an empty string to be returned. |
1087 return status | 1088 return status |
1088 | 1089 |
1089 def StartMonitoringLogcat(self, clear=True, logfile=None, filters=None): | 1090 def StartMonitoringLogcat(self, clear=True, logfile=None, filters=None): |
1090 """Starts monitoring the output of logcat, for use with WaitForLogMatch. | 1091 """Starts monitoring the output of logcat, for use with WaitForLogMatch. |
1091 | 1092 |
1092 Args: | 1093 Args: |
1093 clear: If True the existing logcat output will be cleared, to avoiding | 1094 clear: If True the existing logcat output will be cleared, to avoiding |
1094 matching historical output lurking in the log. | 1095 matching historical output lurking in the log. |
1095 filters: A list of logcat filters to be used. | 1096 filters: A list of logcat filters to be used. |
1096 """ | 1097 """ |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1519 """ | 1520 """ |
1520 def __init__(self, output): | 1521 def __init__(self, output): |
1521 self._output = output | 1522 self._output = output |
1522 | 1523 |
1523 def write(self, data): | 1524 def write(self, data): |
1524 data = data.replace('\r\r\n', '\n') | 1525 data = data.replace('\r\r\n', '\n') |
1525 self._output.write(data) | 1526 self._output.write(data) |
1526 | 1527 |
1527 def flush(self): | 1528 def flush(self): |
1528 self._output.flush() | 1529 self._output.flush() |
OLD | NEW |