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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 | 128 |
129 preferred_device = os.environ.get('ANDROID_SERIAL') | 129 preferred_device = os.environ.get('ANDROID_SERIAL') |
130 if preferred_device in devices: | 130 if preferred_device in devices: |
131 devices.remove(preferred_device) | 131 devices.remove(preferred_device) |
132 devices.insert(0, preferred_device) | 132 devices.insert(0, preferred_device) |
133 return devices | 133 return devices |
134 | 134 |
135 | 135 |
136 def IsDeviceAttached(device): | 136 def IsDeviceAttached(device): |
137 """Return true if the device is attached and online.""" | 137 """Return true if the device is attached and online.""" |
138 return device in GetAttachedDevices() | 138 return device in GetAttachedDevices(emulator=True) |
frankf
2013/07/22 22:43:13
Why is this needed?
navabi
2013/07/22 23:11:05
It's called by /src/build/android/pylib/base/test_
frankf
2013/07/22 23:19:44
why emulator=True is needed? It's the default.
On
navabi
2013/07/22 23:44:07
Done.
| |
139 | 139 |
140 | 140 |
141 def _GetFilesFromRecursiveLsOutput(path, ls_output, re_file, utc_offset=None): | 141 def _GetFilesFromRecursiveLsOutput(path, ls_output, re_file, utc_offset=None): |
142 """Gets a list of files from `ls` command output. | 142 """Gets a list of files from `ls` command output. |
143 | 143 |
144 Python's os.walk isn't used because it doesn't work over adb shell. | 144 Python's os.walk isn't used because it doesn't work over adb shell. |
145 | 145 |
146 Args: | 146 Args: |
147 path: The path to list. | 147 path: The path to list. |
148 ls_output: A list of lines returned by an `ls -lR` command. | 148 ls_output: A list of lines returned by an `ls -lR` command. |
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1008 | 1008 |
1009 def GetProductModel(self): | 1009 def GetProductModel(self): |
1010 """Returns the name of the product model (e.g. "Galaxy Nexus") """ | 1010 """Returns the name of the product model (e.g. "Galaxy Nexus") """ |
1011 model = self.RunShellCommand('getprop ro.product.model')[0] | 1011 model = self.RunShellCommand('getprop ro.product.model')[0] |
1012 assert model | 1012 assert model |
1013 return model | 1013 return model |
1014 | 1014 |
1015 def GetWifiIP(self): | 1015 def GetWifiIP(self): |
1016 """Returns the wifi IP on the device.""" | 1016 """Returns the wifi IP on the device.""" |
1017 wifi_ip = self.RunShellCommand('getprop dhcp.wlan0.ipaddress')[0] | 1017 wifi_ip = self.RunShellCommand('getprop dhcp.wlan0.ipaddress')[0] |
1018 assert wifi_ip | 1018 # Do not assert here. Devices (e.g. emulators) may not have a WifiIP. |
1019 return wifi_ip | 1019 return wifi_ip |
1020 | 1020 |
1021 def GetSubscriberInfo(self): | 1021 def GetSubscriberInfo(self): |
1022 """Returns the device subscriber info (e.g. GSM and device ID) as string.""" | 1022 """Returns the device subscriber info (e.g. GSM and device ID) as string.""" |
1023 iphone_sub = self.RunShellCommand('dumpsys iphonesubinfo') | 1023 iphone_sub = self.RunShellCommand('dumpsys iphonesubinfo') |
1024 assert iphone_sub | 1024 assert iphone_sub |
1025 return '\n'.join(iphone_sub) | 1025 return '\n'.join(iphone_sub) |
1026 | 1026 |
1027 def GetBatteryInfo(self): | 1027 def GetBatteryInfo(self): |
1028 """Returns the device battery info (e.g. status, level, etc) as string.""" | 1028 """Returns the device battery info (e.g. status, level, etc) as string.""" |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1469 """ | 1469 """ |
1470 def __init__(self, output): | 1470 def __init__(self, output): |
1471 self._output = output | 1471 self._output = output |
1472 | 1472 |
1473 def write(self, data): | 1473 def write(self, data): |
1474 data = data.replace('\r\r\n', '\n') | 1474 data = data.replace('\r\r\n', '\n') |
1475 self._output.write(data) | 1475 self._output.write(data) |
1476 | 1476 |
1477 def flush(self): | 1477 def flush(self): |
1478 self._output.flush() | 1478 self._output.flush() |
OLD | NEW |