| 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 # pylint: disable-all | 9 # pylint: disable-all |
| 10 | 10 |
| (...skipping 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1350 # Do not assert here. Devices (e.g. emulators) may not have a WifiIP. | 1350 # Do not assert here. Devices (e.g. emulators) may not have a WifiIP. |
| 1351 return wifi_ip | 1351 return wifi_ip |
| 1352 | 1352 |
| 1353 def GetSubscriberInfo(self): | 1353 def GetSubscriberInfo(self): |
| 1354 """Returns the device subscriber info (e.g. GSM and device ID) as string.""" | 1354 """Returns the device subscriber info (e.g. GSM and device ID) as string.""" |
| 1355 iphone_sub = self.RunShellCommand('dumpsys iphonesubinfo') | 1355 iphone_sub = self.RunShellCommand('dumpsys iphonesubinfo') |
| 1356 assert iphone_sub | 1356 assert iphone_sub |
| 1357 return '\n'.join(iphone_sub) | 1357 return '\n'.join(iphone_sub) |
| 1358 | 1358 |
| 1359 def GetBatteryInfo(self): | 1359 def GetBatteryInfo(self): |
| 1360 """Returns the device battery info (e.g. status, level, etc) as string.""" | 1360 """Returns a {str: str} dict of battery info (e.g. status, level, etc).""" |
| 1361 battery = self.RunShellCommand('dumpsys battery') | 1361 battery = self.RunShellCommand('dumpsys battery') |
| 1362 assert battery | 1362 assert battery |
| 1363 return '\n'.join(battery) | 1363 battery_info = {} |
| 1364 for line in battery[1:]: |
| 1365 k, _, v = line.partition(': ') |
| 1366 battery_info[k.strip()] = v.strip() |
| 1367 return battery_info |
| 1364 | 1368 |
| 1365 def GetSetupWizardStatus(self): | 1369 def GetSetupWizardStatus(self): |
| 1366 """Returns the status of the device setup wizard (e.g. DISABLED).""" | 1370 """Returns the status of the device setup wizard (e.g. DISABLED).""" |
| 1367 status = self.system_properties['ro.setupwizard.mode'] | 1371 status = self.system_properties['ro.setupwizard.mode'] |
| 1368 # On some devices, the status is empty if not otherwise set. In such cases | 1372 # On some devices, the status is empty if not otherwise set. In such cases |
| 1369 # the caller should expect an empty string to be returned. | 1373 # the caller should expect an empty string to be returned. |
| 1370 return status | 1374 return status |
| 1371 | 1375 |
| 1372 def StartMonitoringLogcat(self, clear=True, logfile=None, filters=None): | 1376 def StartMonitoringLogcat(self, clear=True, logfile=None, filters=None): |
| 1373 """Starts monitoring the output of logcat, for use with WaitForLogMatch. | 1377 """Starts monitoring the output of logcat, for use with WaitForLogMatch. |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1981 """ | 1985 """ |
| 1982 def __init__(self, output): | 1986 def __init__(self, output): |
| 1983 self._output = output | 1987 self._output = output |
| 1984 | 1988 |
| 1985 def write(self, data): | 1989 def write(self, data): |
| 1986 data = data.replace('\r\r\n', '\n') | 1990 data = data.replace('\r\r\n', '\n') |
| 1987 self._output.write(data) | 1991 self._output.write(data) |
| 1988 | 1992 |
| 1989 def flush(self): | 1993 def flush(self): |
| 1990 self._output.flush() | 1994 self._output.flush() |
| OLD | NEW |