diff options
author | primiano@chromium.org <primiano@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-10 21:36:16 +0000 |
---|---|---|
committer | primiano@chromium.org <primiano@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-10 21:36:16 +0000 |
commit | b16f0575aeb9a7f40ec1e3138be8114788c22b72 (patch) | |
tree | a4ba452f79d575d3cd0f6dbe6c1b29c96eb57020 /build | |
parent | b9304c64bdc1f43f13c2f167e7c1a84459e2be3e (diff) | |
download | chromium_src-b16f0575aeb9a7f40ec1e3138be8114788c22b72.zip chromium_src-b16f0575aeb9a7f40ec1e3138be8114788c22b72.tar.gz chromium_src-b16f0575aeb9a7f40ec1e3138be8114788c22b72.tar.bz2 |
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: svn://svn.chromium.org/chrome/trunk/src@222349 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'build')
-rw-r--r-- | build/android/pylib/android_commands.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/build/android/pylib/android_commands.py b/build/android/pylib/android_commands.py index 66f7bcf..d8d3be6 100644 --- a/build/android/pylib/android_commands.py +++ b/build/android/pylib/android_commands.py @@ -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. |