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

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

Issue 392983003: Add a workaround for broken adb get-state call. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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 | build/android/pylib/device/device_utils_test.py » ('j') | 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 # pylint: disable-all 9 # pylint: disable-all
10 10
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 def GetDevice(self): 348 def GetDevice(self):
349 """Returns the device serial.""" 349 """Returns the device serial."""
350 return self._device 350 return self._device
351 351
352 def IsOnline(self): 352 def IsOnline(self):
353 """Checks whether the device is online. 353 """Checks whether the device is online.
354 354
355 Returns: 355 Returns:
356 True if device is in 'device' mode, False otherwise. 356 True if device is in 'device' mode, False otherwise.
357 """ 357 """
358 out = self._adb.SendCommand('get-state') 358 # TODO(aurimas): revert to using adb get-state when android L adb is fixed.
359 return out.strip() == 'device' 359 #out = self._adb.SendCommand('get-state')
360 #return out.strip() == 'device'
361
362 out = self._adb.SendCommand('devices')
363 for line in out.split('\n'):
364 if self._device in line and 'device' in line:
365 return True
366 return False
360 367
361 def IsRootEnabled(self): 368 def IsRootEnabled(self):
362 """Checks if root is enabled on the device.""" 369 """Checks if root is enabled on the device."""
363 root_test_output = self.RunShellCommand('ls /root') or [''] 370 root_test_output = self.RunShellCommand('ls /root') or ['']
364 return not 'Permission denied' in root_test_output[0] 371 return not 'Permission denied' in root_test_output[0]
365 372
366 def EnableAdbRoot(self): 373 def EnableAdbRoot(self):
367 """Enables adb root on the device. 374 """Enables adb root on the device.
368 375
369 Returns: 376 Returns:
(...skipping 1599 matching lines...) Expand 10 before | Expand all | Expand 10 after
1969 """ 1976 """
1970 def __init__(self, output): 1977 def __init__(self, output):
1971 self._output = output 1978 self._output = output
1972 1979
1973 def write(self, data): 1980 def write(self, data):
1974 data = data.replace('\r\r\n', '\n') 1981 data = data.replace('\r\r\n', '\n')
1975 self._output.write(data) 1982 self._output.write(data)
1976 1983
1977 def flush(self): 1984 def flush(self):
1978 self._output.flush() 1985 self._output.flush()
OLDNEW
« no previous file with comments | « no previous file | build/android/pylib/device/device_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698