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

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

Issue 12218091: Android Telemetry: automates devices running "user" build. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tony's comments Created 7 years, 10 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/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 e3b8fa3e50d823a585094ed9074c1d67552b3da2..55b3fd6c04e7e306d963dab4ca01070f77e3942f 100644
--- a/build/android/pylib/android_commands.py
+++ b/build/android/pylib/android_commands.py
@@ -694,8 +694,8 @@ class AndroidCommands(object):
def GetFileContents(self, filename, log_result=False):
"""Gets contents from the file specified by |filename|."""
- return self.RunShellCommand('if [ -f "' + filename + '" ]; then cat "' +
- filename + '"; fi', log_result=log_result)
+ return self.RunShellCommand('cat "%s" 2>/dev/null' % filename,
+ log_result=log_result)
def SetFileContents(self, filename, contents):
"""Writes |contents| to the file specified by |filename|."""
@@ -714,6 +714,23 @@ class AndroidCommands(object):
i += 1
return self.GetExternalStorage() + '/' + base_name % i
+ def CanAccessProtectedFileContents(self):
+ """Returns True if Get/SetProtectedFileContents would work via "su".
+
+ Devices running user builds don't have adb root, but may provide "su" which
+ can be used for accessing protected files.
+ """
+ return self.RunShellCommand('su -c echo') == ['']
+
+ def GetProtectedFileContents(self, filename, log_result=False):
+ """Gets contents from the protected file specified by |filename|.
+
+ This is less efficient than GetFileContents, but will work for protected
+ files and device files.
+ """
+ # Run the script as root
+ return self.RunShellCommand('su -c cat "%s" 2> /dev/null' % filename)
+
def SetProtectedFileContents(self, filename, contents):
"""Writes |contents| to the protected file specified by |filename|.
« no previous file with comments | « no previous file | tools/telemetry/telemetry/android_browser_backend.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698