Chromium Code Reviews| Index: build/android/pylib/android_commands.py | 
| diff --git a/build/android/pylib/android_commands.py b/build/android/pylib/android_commands.py | 
| index 8a1562caad5e298bff78291404890ead877ecd40..e919c48b54c2dc79551b637d6a70e726003f1872 100644 | 
| --- a/build/android/pylib/android_commands.py | 
| +++ b/build/android/pylib/android_commands.py | 
| @@ -107,6 +107,12 @@ def GetAttachedDevices(): | 
| devices.insert(0, preferred_device) | 
| return devices | 
| +def IsDeviceAttached(device): | 
| 
 
Isaac (away)
2012/10/24 17:33:12
We can simplify this to:
def IsDeviceAttached(dev
 
yongsheng
2012/10/25 01:20:06
yes, that's good. I'll change it.
 
 | 
| + devices = GetAttachedDevices() | 
| + if device in devices: | 
| + return True | 
| + return False | 
| + | 
| def _GetFilesFromRecursiveLsOutput(path, ls_output, re_file, utc_offset=None): | 
| """Gets a list of files from `ls` command output. | 
| @@ -196,6 +202,7 @@ class AndroidCommands(object): | 
| self._adb = adb_interface.AdbInterface() | 
| if device: | 
| self._adb.SetTargetSerial(device) | 
| + self._device = device | 
| self._logcat = None | 
| self.logcat_process = None | 
| self._pushed_files = [] | 
| @@ -1040,14 +1047,20 @@ class AndroidCommands(object): | 
| True if the file exists, False otherwise. | 
| """ | 
| assert '"' not in file_name, 'file_name cannot contain double quotes' | 
| - status = self._adb.SendShellCommand( | 
| - '\'test -e "%s"; echo $?\'' % (file_name)) | 
| - if 'test: not found' not in status: | 
| + try: | 
| + status = self._adb.SendShellCommand( | 
| + '\'test -e "%s"; echo $?\'' % (file_name)) | 
| + if 'test: not found' not in status: | 
| + return int(status) == 0 | 
| + | 
| + status = self._adb.SendShellCommand( | 
| + '\'ls "%s" >/dev/null 2>&1; echo $?\'' % (file_name)) | 
| return int(status) == 0 | 
| + except ValueError: | 
| + if IsDeviceAttached(self._device): | 
| + raise errors.DeviceUnresponsiveError('Device may be offline.') | 
| - status = self._adb.SendShellCommand( | 
| - '\'ls "%s" >/dev/null 2>&1; echo $?\'' % (file_name)) | 
| - return int(status) == 0 | 
| + return False | 
| class NewLineNormalizer(object): |