Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(583)

Side by Side Diff: build/android/pylib/android_commands.py

Issue 10965021: Add wrapper method for enabling adb root. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: add call to wait-for-device Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698