OLD | NEW |
---|---|
(Empty) | |
1 # Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
2 # Use of this source code is governed by a BSD-style license that can be | |
3 # found in the LICENSE file. | |
4 | |
5 import android_commands | |
6 import content_settings | |
7 | |
8 | |
9 def ConfigureDevice(adb): | |
10 """Configures device settings into a deterministic state for testing | |
11 and benchmarking on bots. | |
12 """ | |
13 _ConfigureLocalProperties(adb) | |
14 adb.EnableAdbRoot() | |
15 _ConfigureContentSettings(adb, { | |
16 'com.google.settings/partner': { | |
17 'use_location_for_services': 1, | |
18 }, | |
19 'settings/global': { | |
20 # TODO(tonyg): We eventually want this off. However, currently radios | |
21 # can cause lab devices to drain faster than they charge. | |
22 'airplane_mode_on': 1, | |
bulach
2014/02/25 11:53:18
iirc, there are some functional tests / bots that
| |
23 | |
24 # Disable "auto time" and "auto time zone" to avoid network-provided time | |
25 # to overwrite the device's datetime and timezone synchronized from host | |
26 # when running tests later. See b/6569849. | |
27 'auto_time': 0, | |
28 'auto_time_zone': 0, | |
29 | |
30 'stay_on_while_plugged_in': 3, | |
31 | |
32 'verifier_verify_adb_installs' : 0, | |
33 }, | |
34 'settings/secure': { | |
35 # Ensure that we never get random dialogs like "Unfortunately the process | |
36 # android.process.acore has stopped", which steal the focus, and make our | |
37 # automation fail (because the dialog steals the focus then mistakenly | |
38 # receives the injected user input events). | |
39 'anr_show_background': 0, | |
40 | |
41 # Ensure Geolocation is enabled and allowed for tests. | |
42 'location_providers_allowed': 'gps,network', | |
43 | |
44 'lockscreen.disabled': 1, | |
45 | |
46 'screensaver_enabled': 0, | |
47 }, | |
48 'settings/system': { | |
49 # Don't want devices to accidentally rotate the screen as that could | |
50 # affect performance measurements. | |
51 'accelerometer_rotation': 0, | |
52 | |
53 'lockscreen.disabled': 1, | |
54 | |
55 # Turn down brightness and disable auto-adjust so that devices run cooler. | |
56 'screen_brightness': 5, | |
57 'screen_brightness_mode': 0, | |
58 | |
59 'user_rotation': 0, | |
60 }, | |
61 }) | |
62 | |
63 | |
64 def _ConfigureLocalProperties(adb): | |
65 """Set standard readonly testing device properties prior to reboot.""" | |
66 local_props = ['ro.monkey=1', | |
67 'ro.test_harness=1', | |
68 'ro.audio.silent=1', | |
69 'ro.setupwizard.mode=DISABLED'] | |
70 adb.SetProtectedFileContents(android_commands.LOCAL_PROPERTIES_PATH, | |
71 '\n'.join(local_props)) | |
72 # Android will not respect the local props file if it is world writable. | |
73 adb.RunShellCommandWithSU('chmod 644 %s' % | |
74 android_commands.LOCAL_PROPERTIES_PATH) | |
75 | |
76 | |
77 def _ConfigureContentSettings(adb, desired_settings): | |
78 for table, key_value in sorted(desired_settings.iteritems()): | |
79 settings = content_settings.ContentSettings(table, adb) | |
80 for key, value in key_value.iteritems(): | |
81 settings[key] = value | |
82 | |
83 print '\n', table, (80 - len(table)) * '-' | |
84 for key, value in sorted(settings.iteritems()): | |
85 print '\t', key, ':', value | |
OLD | NEW |