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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 | 208 |
| 209 def Adb(self): | 209 def Adb(self): |
| 210 """Returns our AdbInterface to avoid us wrapping all its methods.""" | 210 """Returns our AdbInterface to avoid us wrapping all its methods.""" |
| 211 return self._adb | 211 return self._adb |
| 212 | 212 |
| 213 def IsRootEnabled(self): | 213 def IsRootEnabled(self): |
| 214 """Checks if root is enabled on the device.""" | 214 """Checks if root is enabled on the device.""" |
| 215 root_test_output = self.RunShellCommand('ls /root') or [''] | 215 root_test_output = self.RunShellCommand('ls /root') or [''] |
| 216 return not 'Permission denied' in root_test_output[0] | 216 return not 'Permission denied' in root_test_output[0] |
| 217 | 217 |
| 218 def EnableAdbRoot(self): | |
| 219 """Enables adb root on the device. | |
| 220 | |
| 221 Returns: | |
| 222 True: if output from executing adb reboot was as expected. | |
|
bulach
2012/09/21 10:36:46
nit: s/reboot/root/ :)
also, I think 221-223 needs
shashi
2012/09/24 18:33:28
Oops my bad, I have a CL to fix this.
On 2012/09/2
| |
| 223 False: otherwise. | |
| 224 """ | |
| 225 return_value = self._adb.EnableAdbRoot() | |
| 226 # EnableAdbRoot inserts a call for wait-for-device only when adb logcat | |
| 227 # output matches what is expected. Just to be safe add a call to | |
| 228 # wait-for-device. | |
| 229 self._adb.SendCommand('wait-for-device') | |
| 230 return return_value | |
| 231 | |
| 218 def GetDeviceYear(self): | 232 def GetDeviceYear(self): |
| 219 """Returns the year information of the date on device.""" | 233 """Returns the year information of the date on device.""" |
| 220 return self.RunShellCommand('date +%Y')[0] | 234 return self.RunShellCommand('date +%Y')[0] |
| 221 | 235 |
| 222 def GetExternalStorage(self): | 236 def GetExternalStorage(self): |
| 223 if not self._external_storage: | 237 if not self._external_storage: |
| 224 self._external_storage = self.RunShellCommand('echo $EXTERNAL_STORAGE')[0] | 238 self._external_storage = self.RunShellCommand('echo $EXTERNAL_STORAGE')[0] |
| 225 assert self._external_storage, 'Unable to find $EXTERNAL_STORAGE' | 239 assert self._external_storage, 'Unable to find $EXTERNAL_STORAGE' |
| 226 return self._external_storage | 240 return self._external_storage |
| 227 | 241 |
| (...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 994 """ | 1008 """ |
| 995 assert '"' not in file_name, 'file_name cannot contain double quotes' | 1009 assert '"' not in file_name, 'file_name cannot contain double quotes' |
| 996 status = self._adb.SendShellCommand( | 1010 status = self._adb.SendShellCommand( |
| 997 '\'test -e "%s"; echo $?\'' % (file_name)) | 1011 '\'test -e "%s"; echo $?\'' % (file_name)) |
| 998 if 'test: not found' not in status: | 1012 if 'test: not found' not in status: |
| 999 return int(status) == 0 | 1013 return int(status) == 0 |
| 1000 | 1014 |
| 1001 status = self._adb.SendShellCommand( | 1015 status = self._adb.SendShellCommand( |
| 1002 '\'ls "%s" >/dev/null 2>&1; echo $?\'' % (file_name)) | 1016 '\'ls "%s" >/dev/null 2>&1; echo $?\'' % (file_name)) |
| 1003 return int(status) == 0 | 1017 return int(status) == 0 |
| OLD | NEW |