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

Unified Diff: build/android/pylib/android_commands.py

Issue 23477053: Telemetry: fix permission check when setting Android command line. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove wrapper method from adb_commands Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/telemetry/telemetry/core/backends/chrome/android_browser_backend.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/android_commands.py
diff --git a/build/android/pylib/android_commands.py b/build/android/pylib/android_commands.py
index 4228b035f134187443d9fff1d89363d635677b33..76d8ca3fea010304a4a8ff9da859ae0f1592b11a 100644
--- a/build/android/pylib/android_commands.py
+++ b/build/android/pylib/android_commands.py
@@ -1473,6 +1473,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.
« no previous file with comments | « no previous file | tools/telemetry/telemetry/core/backends/chrome/android_browser_backend.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698