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

Unified Diff: tools/telemetry/telemetry/core/backends/android_command_line_backend.py

Issue 806843002: Reland of Migrate DeviceUtils.ReadFile to adb_wrapper (try 3) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: enable command line test only for android Created 5 years, 11 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: tools/telemetry/telemetry/core/backends/android_command_line_backend.py
diff --git a/tools/telemetry/telemetry/core/backends/android_command_line_backend.py b/tools/telemetry/telemetry/core/backends/android_command_line_backend.py
index e2c3e1a1d4b6983732bbe1226638ac6601ad0e66..e05c0bbb1dc10bcd0281c9377f3c9f61e25cf5c4 100644
--- a/tools/telemetry/telemetry/core/backends/android_command_line_backend.py
+++ b/tools/telemetry/telemetry/core/backends/android_command_line_backend.py
@@ -63,7 +63,7 @@ class _AndroidCommandLineBackend(object):
self._adb = adb
self._backend_settings = backend_settings
self._startup_args = startup_args
- self._saved_command_line_file_contents = ''
+ self._saved_command_line_file_contents = None
@property
def command_line_file(self):
@@ -79,20 +79,32 @@ class _AndroidCommandLineBackend(object):
# be a Telemetry created one. This is to prevent a common bug where
# --host-resolver-rules borks people's browsers if something goes wrong
# with Telemetry.
- self._saved_command_line_file_contents = ''.join(self._ReadFile())
+ self._saved_command_line_file_contents = self._ReadFile()
if '--host-resolver-rules' in self._saved_command_line_file_contents:
- self._saved_command_line_file_contents = ''
- self._WriteFile(content)
+ self._saved_command_line_file_contents = None
except device_errors.CommandFailedError:
+ self._saved_command_line_file_contents = None
+
+ try:
+ self._WriteFile(content)
+ except device_errors.CommandFailedError as exc:
+ logging.critical(exc)
logging.critical('Cannot set Chrome command line. '
'Fix this by flashing to a userdebug build.')
sys.exit(1)
def RestoreCommandLineFlags(self):
- self._WriteFile(self._saved_command_line_file_contents)
+ if self._saved_command_line_file_contents is None:
+ self._RemoveFile()
+ else:
+ self._WriteFile(self._saved_command_line_file_contents)
def _ReadFile(self):
- return self._adb.device().ReadFile(self.command_line_file)
+ return self._adb.device().ReadFile(self.command_line_file, as_root=True)
def _WriteFile(self, contents):
self._adb.device().WriteFile(self.command_line_file, contents, as_root=True)
+
+ def _RemoveFile(self):
+ self._adb.device().RunShellCommand(['rm', '-f', self.command_line_file],
+ as_root=True, check_return=True)
« no previous file with comments | « build/android/tombstones.py ('k') | tools/telemetry/telemetry/core/backends/android_command_line_backend_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698