Telemetry: fix permission check when setting Android command line.

This is to fix a bug introduced by r221426 on the WebView telemetry bot.
The issue was related to the fact that ls -l can return no output if the
target folder exists but is empty.
This change makes the IsProtectedFile logic inside _SetCommandLineFile
more reliable, introducing the IsFileWritableOnDevice method in adb
commands.

BUG=284468
NOTRY=true

Review URL: https://chromiumcodereview.appspot.com/23477053

git-svn-id: http://src.chromium.org/svn/trunk/src/build@222349 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
This commit is contained in:
primiano@chromium.org 2013-09-10 21:36:16 +00:00
Родитель 436edf51e9
Коммит 30eacbbc8e
1 изменённых файлов: 23 добавлений и 0 удалений

Просмотреть файл

@ -1466,6 +1466,29 @@ class AndroidCommands(object):
return False
def IsFileWritableOnDevice(self, file_name):
"""Checks whether the given file (or directory) is writable on the device.
Args:
file_name: Full path of file/directory to check.
Returns:
True if writable, False otherwise.
"""
assert '"' not in file_name, 'file_name cannot contain double quotes'
try:
status = self._adb.SendShellCommand(
'\'test -w "%s"; echo $?\'' % (file_name))
if 'test: not found' not in status:
return int(status) == 0
raise errors.AbortError('"test" binary not found. OS too old.')
except ValueError:
if IsDeviceAttached(self._device):
raise errors.DeviceUnresponsiveError('Device may be offline.')
return False
def TakeScreenshot(self, host_file):
"""Saves a screenshot image to |host_file| on the host.