Index: build/android/pylib/flag_changer.py |
diff --git a/build/android/pylib/flag_changer.py b/build/android/pylib/flag_changer.py |
index 6c4883a76dc3a97fb5b9991b6cbf8b793e51f654..8b2d4a5027791135252969062f9981cbdff0f5da 100644 |
--- a/build/android/pylib/flag_changer.py |
+++ b/build/android/pylib/flag_changer.py |
@@ -92,14 +92,25 @@ class FlagChanger(object): |
def _UpdateCommandLineFile(self): |
"""Writes out the command line to the file, or removes it if empty.""" |
logging.info('Current flags: %s', self._current_flags) |
- |
+ # Root is not required to write to /data/local/tmp/. |
+ use_root = '/data/local/tmp/' not in self._cmdline_file |
if self._current_flags: |
# The first command line argument doesn't matter as we are not actually |
# launching the chrome executable using this command line. |
- self._adb.SetProtectedFileContents(self._cmdline_file, |
- ' '.join(['_'] + self._current_flags)) |
+ cmd_line = ' '.join(['_'] + self._current_flags) |
+ if use_root: |
+ self._adb.SetProtectedFileContents(self._cmdline_file, cmd_line) |
+ file_contents = self._adb.GetProtectedFileContents(self._cmdline_file) |
+ else: |
+ self._adb.SetFileContents(self._cmdline_file, cmd_line) |
frankf
2013/10/07 22:09:03
as part of API cleanup, you should just have SetFi
|
+ file_contents = self._adb.GetFileContents(self._cmdline_file) |
+ assert file_contents == cmd_line, ( |
+ 'Failed to set the command line file at %s' % self._cmdline_file) |
else: |
- self._adb.RunShellCommand('su -c rm ' + self._cmdline_file) |
+ prefix = 'su -c ' if use_root else '' |
+ self._adb.RunShellCommand(prefix + 'rm ' + self._cmdline_file) |
frankf
2013/10/07 22:09:03
We have something like RunShellCommandSu which you
craigdh
2013/10/07 22:36:28
Done.
|
+ assert not self._adb.FileExistsOnDevice(self._cmdline_file), ( |
frankf
2013/10/07 22:09:03
as part of API cleanup, rm'ing should guarantee th
|
+ 'Failed to remove the command line file at %s' % self._cmdline_file) |
def _TokenizeFlags(self, line): |
"""Changes the string containing the command line into a list of flags. |