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 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 722 self.GetExternalStorage() + '/' + base_name % i): | 722 self.GetExternalStorage() + '/' + base_name % i): |
| 723 i += 1 | 723 i += 1 |
| 724 return self.GetExternalStorage() + '/' + base_name % i | 724 return self.GetExternalStorage() + '/' + base_name % i |
| 725 | 725 |
| 726 def CanAccessProtectedFileContents(self): | 726 def CanAccessProtectedFileContents(self): |
| 727 """Returns True if Get/SetProtectedFileContents would work via "su". | 727 """Returns True if Get/SetProtectedFileContents would work via "su". |
| 728 | 728 |
| 729 Devices running user builds don't have adb root, but may provide "su" which | 729 Devices running user builds don't have adb root, but may provide "su" which |
| 730 can be used for accessing protected files. | 730 can be used for accessing protected files. |
| 731 """ | 731 """ |
| 732 return self.RunShellCommand('su -c echo') == [''] | 732 return self.RunShellCommand('su -c cat /dev/null') == [''] |
|
Sami
2013/02/13 11:05:34
This could be slightly more reliable if we tried t
bulach
2013/02/13 11:08:57
:)
| |
| 733 | 733 |
| 734 def GetProtectedFileContents(self, filename, log_result=False): | 734 def GetProtectedFileContents(self, filename, log_result=False): |
| 735 """Gets contents from the protected file specified by |filename|. | 735 """Gets contents from the protected file specified by |filename|. |
| 736 | 736 |
| 737 This is less efficient than GetFileContents, but will work for protected | 737 This is less efficient than GetFileContents, but will work for protected |
| 738 files and device files. | 738 files and device files. |
| 739 """ | 739 """ |
| 740 # Run the script as root | 740 # Run the script as root |
| 741 return self.RunShellCommand('su -c cat "%s" 2> /dev/null' % filename) | 741 return self.RunShellCommand('su -c cat "%s" 2> /dev/null' % filename) |
| 742 | 742 |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1217 """ | 1217 """ |
| 1218 def __init__(self, output): | 1218 def __init__(self, output): |
| 1219 self._output = output | 1219 self._output = output |
| 1220 | 1220 |
| 1221 def write(self, data): | 1221 def write(self, data): |
| 1222 data = data.replace('\r\r\n', '\n') | 1222 data = data.replace('\r\r\n', '\n') |
| 1223 self._output.write(data) | 1223 self._output.write(data) |
| 1224 | 1224 |
| 1225 def flush(self): | 1225 def flush(self): |
| 1226 self._output.flush() | 1226 self._output.flush() |
| OLD | NEW |