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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
217 | 217 |
218 Args: | 218 Args: |
219 device: If given, adb commands are only send to the device of this ID. | 219 device: If given, adb commands are only send to the device of this ID. |
220 Otherwise commands are sent to all attached devices. | 220 Otherwise commands are sent to all attached devices. |
221 """ | 221 """ |
222 | 222 |
223 def __init__(self, device=None): | 223 def __init__(self, device=None): |
224 self._adb = adb_interface.AdbInterface() | 224 self._adb = adb_interface.AdbInterface() |
225 if device: | 225 if device: |
226 self._adb.SetTargetSerial(device) | 226 self._adb.SetTargetSerial(device) |
227 # So many users require root that we just always do it. This could | 227 # So many users require root that we just always do it. This could |
Yaron
2012/08/16 23:49:24
Please update this comment.
| |
228 # be made more fine grain if necessary. | 228 # be made more fine grain if necessary. |
229 self._root_enabled = self._adb.EnableAdbRoot() | 229 root_test_output = self.RunShellCommand('ls /root')[0] |
230 self._root_enabled = not 'Permission denied' in root_test_output | |
230 self._logcat = None | 231 self._logcat = None |
231 self._original_governor = None | 232 self._original_governor = None |
232 self._pushed_files = [] | 233 self._pushed_files = [] |
233 self._device_utc_offset = self.RunShellCommand('date +%z')[0] | 234 self._device_utc_offset = self.RunShellCommand('date +%z')[0] |
234 | 235 |
235 def Adb(self): | 236 def Adb(self): |
236 """Returns our AdbInterface to avoid us wrapping all its methods.""" | 237 """Returns our AdbInterface to avoid us wrapping all its methods.""" |
237 return self._adb | 238 return self._adb |
238 | 239 |
240 def EnableAdbRoot(self): | |
241 self._root_enabled = self.Adb().EnableAdbRoot() | |
242 self._adb.SendCommand('wait-for-device') | |
243 | |
239 def IsRootEnabled(self): | 244 def IsRootEnabled(self): |
240 """Returns whether or not _adb.EnabledAdbRoot() has succeeded.""" | 245 """Returns whether or not _adb.EnabledAdbRoot() has succeeded.""" |
241 return self._root_enabled | 246 return self._root_enabled |
242 | 247 |
243 def GetDeviceYear(self): | 248 def GetDeviceYear(self): |
244 """Returns the year information of the date on device""" | 249 """Returns the year information of the date on device""" |
245 return self.RunShellCommand('date +%Y')[0] | 250 return self.RunShellCommand('date +%Y')[0] |
246 | 251 |
247 def WaitForDevicePm(self): | 252 def WaitForDevicePm(self): |
248 """Blocks until the device's package manager is available. | 253 """Blocks until the device's package manager is available. |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
945 if len(process_results) <= 8: | 950 if len(process_results) <= 8: |
946 continue | 951 continue |
947 # Column 0 is the executable name | 952 # Column 0 is the executable name |
948 # Column 1 is the pid | 953 # Column 1 is the pid |
949 # Column 8 is the Inode in use | 954 # Column 8 is the Inode in use |
950 if process_results[8] == socket_name: | 955 if process_results[8] == socket_name: |
951 pids.append( (int(process_results[1]), process_results[0]) ) | 956 pids.append( (int(process_results[1]), process_results[0]) ) |
952 break | 957 break |
953 logging.info('PidsUsingDevicePort: %s', pids) | 958 logging.info('PidsUsingDevicePort: %s', pids) |
954 return pids | 959 return pids |
OLD | NEW |