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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 return self._adb | 212 return self._adb |
213 | 213 |
214 def IsRootEnabled(self): | 214 def IsRootEnabled(self): |
215 """Checks if root is enabled on the device.""" | 215 """Checks if root is enabled on the device.""" |
216 root_test_output = self.RunShellCommand('ls /root') or [''] | 216 root_test_output = self.RunShellCommand('ls /root') or [''] |
217 return not 'Permission denied' in root_test_output[0] | 217 return not 'Permission denied' in root_test_output[0] |
218 | 218 |
219 def EnableAdbRoot(self): | 219 def EnableAdbRoot(self): |
220 """Enables adb root on the device. | 220 """Enables adb root on the device. |
221 | 221 |
222 Returns: | 222 Returns: |
223 True: if output from executing adb reboot was as expected. | 223 True: if output from executing adb root was as expected. |
224 False: otherwise. | 224 False: otherwise. |
225 """ | 225 """ |
226 return_value = self._adb.EnableAdbRoot() | 226 return_value = self._adb.EnableAdbRoot() |
227 # EnableAdbRoot inserts a call for wait-for-device only when adb logcat | 227 # EnableAdbRoot inserts a call for wait-for-device only when adb logcat |
228 # output matches what is expected. Just to be safe add a call to | 228 # output matches what is expected. Just to be safe add a call to |
229 # wait-for-device. | 229 # wait-for-device. |
230 self._adb.SendCommand('wait-for-device') | 230 self._adb.SendCommand('wait-for-device') |
231 return return_value | 231 return return_value |
232 | 232 |
233 def GetDeviceYear(self): | 233 def GetDeviceYear(self): |
234 """Returns the year information of the date on device.""" | 234 """Returns the year information of the date on device.""" |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1010 """ | 1010 """ |
1011 def __init__(self, output): | 1011 def __init__(self, output): |
1012 self._output = output | 1012 self._output = output |
1013 | 1013 |
1014 def write(self, data): | 1014 def write(self, data): |
1015 data = data.replace('\r\r\n', '\n') | 1015 data = data.replace('\r\r\n', '\n') |
1016 self._output.write(data) | 1016 self._output.write(data) |
1017 | 1017 |
1018 def flush(self): | 1018 def flush(self): |
1019 self._output.flush() | 1019 self._output.flush() |
OLD | NEW |