Chromium Code Reviews| 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 root_test_output = self.RunShellCommand('ls /root')[0] |
| 228 # be made more fine grain if necessary. | 228 self._root_enabled = not 'Permission denied' in root_test_output |
| 229 self._root_enabled = self._adb.EnableAdbRoot() | |
| 230 self._logcat = None | 229 self._logcat = None |
| 231 self._original_governor = None | 230 self._original_governor = None |
| 232 self._pushed_files = [] | 231 self._pushed_files = [] |
| 233 self._device_utc_offset = self.RunShellCommand('date +%z')[0] | 232 self._device_utc_offset = self.RunShellCommand('date +%z')[0] |
| 234 | 233 |
| 235 def Adb(self): | 234 def Adb(self): |
| 236 """Returns our AdbInterface to avoid us wrapping all its methods.""" | 235 """Returns our AdbInterface to avoid us wrapping all its methods.""" |
| 237 return self._adb | 236 return self._adb |
| 238 | 237 |
| 238 def EnableAdbRoot(self): | |
| 239 self._root_enabled = self.Adb().EnableAdbRoot() | |
|
Satish
2012/08/17 09:32:58
I see in __init__ we check if adb is already in ro
Isaac (away)
2012/08/17 09:34:37
sure. This function isn't called right now and mi
| |
| 240 self._adb.SendCommand('wait-for-device') | |
| 241 | |
| 239 def IsRootEnabled(self): | 242 def IsRootEnabled(self): |
| 240 """Returns whether or not _adb.EnabledAdbRoot() has succeeded.""" | 243 """Returns whether or not _adb.EnabledAdbRoot() has succeeded.""" |
| 241 return self._root_enabled | 244 return self._root_enabled |
| 242 | 245 |
| 243 def GetDeviceYear(self): | 246 def GetDeviceYear(self): |
| 244 """Returns the year information of the date on device""" | 247 """Returns the year information of the date on device""" |
| 245 return self.RunShellCommand('date +%Y')[0] | 248 return self.RunShellCommand('date +%Y')[0] |
| 246 | 249 |
| 247 def WaitForDevicePm(self): | 250 def WaitForDevicePm(self): |
| 248 """Blocks until the device's package manager is available. | 251 """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: | 948 if len(process_results) <= 8: |
| 946 continue | 949 continue |
| 947 # Column 0 is the executable name | 950 # Column 0 is the executable name |
| 948 # Column 1 is the pid | 951 # Column 1 is the pid |
| 949 # Column 8 is the Inode in use | 952 # Column 8 is the Inode in use |
| 950 if process_results[8] == socket_name: | 953 if process_results[8] == socket_name: |
| 951 pids.append( (int(process_results[1]), process_results[0]) ) | 954 pids.append( (int(process_results[1]), process_results[0]) ) |
| 952 break | 955 break |
| 953 logging.info('PidsUsingDevicePort: %s', pids) | 956 logging.info('PidsUsingDevicePort: %s', pids) |
| 954 return pids | 957 return pids |
| OLD | NEW |