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

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

Issue 23467004: [android] Update FlagChanger to work with additional apks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comments Created 7 years, 4 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
Index: build/android/pylib/flag_changer.py
diff --git a/build/android/pylib/flag_changer.py b/build/android/pylib/flag_changer.py
index 6eb9f0b3c675f93feb2a827fc1aa31f5a8e1fb48..e00d8918cbf5c258f4abda5d346e1a723187a922 100644
--- a/build/android/pylib/flag_changer.py
+++ b/build/android/pylib/flag_changer.py
@@ -5,12 +5,8 @@
import constants
import logging
import traceback
-import warnings
-# Location where chrome reads command line flags from
-CHROME_COMMAND_FILE = '/data/local/chrome-command-line'
-
class FlagChanger(object):
"""Changes the flags Chrome runs with.
@@ -21,11 +17,18 @@ class FlagChanger(object):
once the tests have completed.
"""
- def __init__(self, android_cmd):
- self._android_cmd = android_cmd
+ def __init__(self, adb, cmdline_file):
craigdh 2013/08/28 00:03:03 make cmdline_file optional so as not to break down
craigdh 2013/08/28 19:17:10 Done.
+ """Initializes the FlagChanger and records the original arguments.
+
+ Args:
+ adb: An instance of AndroidCommands.
+ cmdline_file: Path to the command line file on the device.
+ """
+ self._adb = adb
+ self._cmdline_file = cmdline_file
# Save the original flags.
- self._orig_line = self._android_cmd.GetFileContents(CHROME_COMMAND_FILE)
+ self._orig_line = self._adb.GetFileContents(self._cmdline_file)
if self._orig_line:
self._orig_line = self._orig_line[0].strip()
@@ -90,11 +93,12 @@ class FlagChanger(object):
logging.info('Current flags: %s', self._current_flags)
if self._current_flags:
- self._android_cmd.SetProtectedFileContents(CHROME_COMMAND_FILE,
- 'chrome ' +
- ' '.join(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))
else:
- self._android_cmd.RunShellCommand('su -c rm ' + CHROME_COMMAND_FILE)
+ self._adb.RunShellCommand('su -c rm ' + self._cmdline_file)
def _TokenizeFlags(self, line):
"""Changes the string containing the command line into a list of flags.
@@ -137,7 +141,7 @@ class FlagChanger(object):
# Tack on the last flag.
if not current_flag:
if within_quotations:
- warnings.warn("Unterminated quoted string: " + current_flag)
+ logging.warn("Unterminated quoted argument: " + current_flag)
frankf 2013/08/27 23:57:46 single quote
craigdh 2013/08/28 19:17:10 Done.
else:
tokenized_flags.append(current_flag)

Powered by Google App Engine
This is Rietveld 408576698