Chromium Code Reviews| Index: build/android/pylib/bot_device_settings.py |
| diff --git a/build/android/pylib/bot_device_settings.py b/build/android/pylib/bot_device_settings.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9b1d01ca0d128d4f81867f6e1d7faf6704b408d4 |
| --- /dev/null |
| +++ b/build/android/pylib/bot_device_settings.py |
| @@ -0,0 +1,85 @@ |
| +# Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +import android_commands |
| +import content_settings |
| + |
| + |
| +def ConfigureDevice(adb): |
| + """Configures device settings into a deterministic state for testing |
| + and benchmarking on bots. |
| + """ |
| + _ConfigureLocalProperties(adb) |
| + adb.EnableAdbRoot() |
| + _ConfigureContentSettings(adb, { |
| + 'com.google.settings/partner': { |
| + 'use_location_for_services': 1, |
| + }, |
| + 'settings/global': { |
| + # TODO(tonyg): We eventually want this off. However, currently radios |
| + # can cause lab devices to drain faster than they charge. |
| + 'airplane_mode_on': 1, |
|
bulach
2014/02/25 11:53:18
iirc, there are some functional tests / bots that
|
| + |
| + # Disable "auto time" and "auto time zone" to avoid network-provided time |
| + # to overwrite the device's datetime and timezone synchronized from host |
| + # when running tests later. See b/6569849. |
| + 'auto_time': 0, |
| + 'auto_time_zone': 0, |
| + |
| + 'stay_on_while_plugged_in': 3, |
| + |
| + 'verifier_verify_adb_installs' : 0, |
| + }, |
| + 'settings/secure': { |
| + # Ensure that we never get random dialogs like "Unfortunately the process |
| + # android.process.acore has stopped", which steal the focus, and make our |
| + # automation fail (because the dialog steals the focus then mistakenly |
| + # receives the injected user input events). |
| + 'anr_show_background': 0, |
| + |
| + # Ensure Geolocation is enabled and allowed for tests. |
| + 'location_providers_allowed': 'gps,network', |
| + |
| + 'lockscreen.disabled': 1, |
| + |
| + 'screensaver_enabled': 0, |
| + }, |
| + 'settings/system': { |
| + # Don't want devices to accidentally rotate the screen as that could |
| + # affect performance measurements. |
| + 'accelerometer_rotation': 0, |
| + |
| + 'lockscreen.disabled': 1, |
| + |
| + # Turn down brightness and disable auto-adjust so that devices run cooler. |
| + 'screen_brightness': 5, |
| + 'screen_brightness_mode': 0, |
| + |
| + 'user_rotation': 0, |
| + }, |
| + }) |
| + |
| + |
| +def _ConfigureLocalProperties(adb): |
| + """Set standard readonly testing device properties prior to reboot.""" |
| + local_props = ['ro.monkey=1', |
| + 'ro.test_harness=1', |
| + 'ro.audio.silent=1', |
| + 'ro.setupwizard.mode=DISABLED'] |
| + adb.SetProtectedFileContents(android_commands.LOCAL_PROPERTIES_PATH, |
| + '\n'.join(local_props)) |
| + # Android will not respect the local props file if it is world writable. |
| + adb.RunShellCommandWithSU('chmod 644 %s' % |
| + android_commands.LOCAL_PROPERTIES_PATH) |
| + |
| + |
| +def _ConfigureContentSettings(adb, desired_settings): |
| + for table, key_value in sorted(desired_settings.iteritems()): |
| + settings = content_settings.ContentSettings(table, adb) |
| + for key, value in key_value.iteritems(): |
| + settings[key] = value |
| + |
| + print '\n', table, (80 - len(table)) * '-' |
| + for key, value in sorted(settings.iteritems()): |
| + print '\t', key, ':', value |