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

Side by Side Diff: build/android/pylib/flag_changer.py

Issue 26364002: [android] FlagChanger should only require root to set flags for Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bug Created 7 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « build/android/pylib/constants.py ('k') | build/android/tombstones.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import constants 5 import constants
6 import logging 6 import logging
7 import traceback 7 import traceback
8 8
9 9
10 class FlagChanger(object): 10 class FlagChanger(object):
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 self._UpdateCommandLineFile() 85 self._UpdateCommandLineFile()
86 86
87 def Restore(self): 87 def Restore(self):
88 """Restores the flags to their original state.""" 88 """Restores the flags to their original state."""
89 self._current_flags = self._TokenizeFlags(self._orig_line) 89 self._current_flags = self._TokenizeFlags(self._orig_line)
90 self._UpdateCommandLineFile() 90 self._UpdateCommandLineFile()
91 91
92 def _UpdateCommandLineFile(self): 92 def _UpdateCommandLineFile(self):
93 """Writes out the command line to the file, or removes it if empty.""" 93 """Writes out the command line to the file, or removes it if empty."""
94 logging.info('Current flags: %s', self._current_flags) 94 logging.info('Current flags: %s', self._current_flags)
95 95 # Root is not required to write to /data/local/tmp/.
96 use_root = '/data/local/tmp/' not in self._cmdline_file
96 if self._current_flags: 97 if self._current_flags:
97 # The first command line argument doesn't matter as we are not actually 98 # The first command line argument doesn't matter as we are not actually
98 # launching the chrome executable using this command line. 99 # launching the chrome executable using this command line.
99 self._adb.SetProtectedFileContents(self._cmdline_file, 100 cmd_line = ' '.join(['_'] + self._current_flags)
100 ' '.join(['_'] + self._current_flags)) 101 if use_root:
102 self._adb.SetProtectedFileContents(self._cmdline_file, cmd_line)
frankf 2013/10/08 23:44:52 BTW, why do you need this every time? Can't you ju
craigdh 2013/10/08 23:53:30 Let's look at cleaning up all of the *Protected/*S
103 file_contents = self._adb.GetProtectedFileContents(self._cmdline_file)
104 else:
105 self._adb.SetFileContents(self._cmdline_file, cmd_line)
106 file_contents = self._adb.GetFileContents(self._cmdline_file)
107 assert len(file_contents) == 1 and file_contents[0] == cmd_line, (
108 'Failed to set the command line file at %s' % self._cmdline_file)
101 else: 109 else:
102 self._adb.RunShellCommand('su -c rm ' + self._cmdline_file) 110 if use_root:
111 self._adb.RunShellCommandWithSU('rm ' + self._cmdline_file)
112 else:
113 self._adb.RunShellCommand('rm ' + self._cmdline_file)
114 assert not self._adb.FileExistsOnDevice(self._cmdline_file), (
115 'Failed to remove the command line file at %s' % self._cmdline_file)
103 116
104 def _TokenizeFlags(self, line): 117 def _TokenizeFlags(self, line):
105 """Changes the string containing the command line into a list of flags. 118 """Changes the string containing the command line into a list of flags.
106 119
107 Follows similar logic to CommandLine.java::tokenizeQuotedArguments: 120 Follows similar logic to CommandLine.java::tokenizeQuotedArguments:
108 * Flags are split using whitespace, unless the whitespace is within a 121 * Flags are split using whitespace, unless the whitespace is within a
109 pair of quotation marks. 122 pair of quotation marks.
110 * Unlike the Java version, we keep the quotation marks around switch 123 * Unlike the Java version, we keep the quotation marks around switch
111 values since we need them to re-create the file when new flags are 124 values since we need them to re-create the file when new flags are
112 appended. 125 appended.
(...skipping 28 matching lines...) Expand all
141 154
142 # Tack on the last flag. 155 # Tack on the last flag.
143 if not current_flag: 156 if not current_flag:
144 if within_quotations: 157 if within_quotations:
145 logging.warn('Unterminated quoted argument: ' + line) 158 logging.warn('Unterminated quoted argument: ' + line)
146 else: 159 else:
147 tokenized_flags.append(current_flag) 160 tokenized_flags.append(current_flag)
148 161
149 # Return everything but the program name. 162 # Return everything but the program name.
150 return tokenized_flags[1:] 163 return tokenized_flags[1:]
OLDNEW
« no previous file with comments | « build/android/pylib/constants.py ('k') | build/android/tombstones.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698