Commit 38c524b9 authored by bulach@chromium.org's avatar bulach@chromium.org

Telemetry: start the activity in order to initialize the prefs file.

When running on a fresh install, there's no preferences available.
Rather than throwing an exception, start the browser and wait for the file to become available.

BUG=166176
TEST=tools/perf/run_multipage_benchmarks --browser=android-chrome --show-stdout sunspider tools/perf/page_sets/sunspider.json -vvv

Review URL: https://chromiumcodereview.appspot.com/11574039

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175515 0039d316-1c4b-4281-b951-d872f2087c98
parent 3d2a4dfa
# Copyright (c) 2012 The Chromium Authors. All rights reserved. # Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
import json import json
import logging import logging
import os import os
import subprocess import subprocess
import sys import sys
import tempfile import tempfile
import time
from telemetry import adb_commands from telemetry import adb_commands
from telemetry import browser_backend from telemetry import browser_backend
...@@ -72,11 +74,23 @@ class AndroidBrowserBackend(browser_backend.BrowserBackend): ...@@ -72,11 +74,23 @@ class AndroidBrowserBackend(browser_backend.BrowserBackend):
prefs_file = (app_data_dir + prefs_file = (app_data_dir +
'/app_chrome/Default/Preferences') '/app_chrome/Default/Preferences')
if not self._adb.FileExistsOnDevice(prefs_file): if not self._adb.FileExistsOnDevice(prefs_file):
logging.critical( # Start it up the first time so we can tweak the prefs.
'android_browser_backend: Could not find preferences file ' + self._adb.StartActivity(self._package,
'%s for %s' % (prefs_file, self._package)) self._activity,
raise browser_gone_exception.BrowserGoneException( True,
'Missing preferences file.') None,
None)
retries = 0
while not self._adb.Adb().GetFileContents(prefs_file):
time.sleep(3)
retries += 1
if retries == 3:
logging.critical('android_browser_backend: Could not find '
'preferences file %s for %s',
prefs_file, self._package)
raise browser_gone_exception.BrowserGoneException(
'Missing preferences file.')
self._adb.KillAll(self._package)
with tempfile.NamedTemporaryFile() as raw_f: with tempfile.NamedTemporaryFile() as raw_f:
self._adb.Pull(prefs_file, raw_f.name) self._adb.Pull(prefs_file, raw_f.name)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment