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 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1344 | 1344 |
1345 def GetWifiIP(self): | 1345 def GetWifiIP(self): |
1346 """Returns the wifi IP on the device.""" | 1346 """Returns the wifi IP on the device.""" |
1347 wifi_ip = self.system_properties['dhcp.wlan0.ipaddress'] | 1347 wifi_ip = self.system_properties['dhcp.wlan0.ipaddress'] |
1348 # Do not assert here. Devices (e.g. emulators) may not have a WifiIP. | 1348 # Do not assert here. Devices (e.g. emulators) may not have a WifiIP. |
1349 return wifi_ip | 1349 return wifi_ip |
1350 | 1350 |
1351 def GetSubscriberInfo(self): | 1351 def GetSubscriberInfo(self): |
1352 """Returns the device subscriber info (e.g. GSM and device ID) as string.""" | 1352 """Returns the device subscriber info (e.g. GSM and device ID) as string.""" |
1353 iphone_sub = self.RunShellCommand('dumpsys iphonesubinfo') | 1353 iphone_sub = self.RunShellCommand('dumpsys iphonesubinfo') |
1354 assert iphone_sub | 1354 # Do not assert here. Devices (e.g. Nakasi on K) may not have iphonesubinfo. |
1355 return '\n'.join(iphone_sub) | 1355 return '\n'.join(iphone_sub) |
1356 | 1356 |
1357 def GetBatteryInfo(self): | 1357 def GetBatteryInfo(self): |
1358 """Returns a {str: str} dict of battery info (e.g. status, level, etc).""" | 1358 """Returns a {str: str} dict of battery info (e.g. status, level, etc).""" |
1359 battery = self.RunShellCommand('dumpsys battery') | 1359 battery = self.RunShellCommand('dumpsys battery') |
1360 assert battery | 1360 assert battery |
1361 battery_info = {} | 1361 battery_info = {} |
1362 for line in battery[1:]: | 1362 for line in battery[1:]: |
1363 k, _, v = line.partition(': ') | 1363 k, _, v = line.partition(': ') |
1364 battery_info[k.strip()] = v.strip() | 1364 battery_info[k.strip()] = v.strip() |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1983 """ | 1983 """ |
1984 def __init__(self, output): | 1984 def __init__(self, output): |
1985 self._output = output | 1985 self._output = output |
1986 | 1986 |
1987 def write(self, data): | 1987 def write(self, data): |
1988 data = data.replace('\r\r\n', '\n') | 1988 data = data.replace('\r\r\n', '\n') |
1989 self._output.write(data) | 1989 self._output.write(data) |
1990 | 1990 |
1991 def flush(self): | 1991 def flush(self): |
1992 self._output.flush() | 1992 self._output.flush() |
OLD | NEW |