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

Side by Side Diff: build/android/pylib/device_settings.py

Issue 434193002: [Android] Parallelize provision_devices.py. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 unified diff | Download patch
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6 6
7 from pylib import content_settings 7 from pylib import content_settings
8 8
9 _LOCK_SCREEN_SETTINGS_PATH = '/data/system/locksettings.db' 9 _LOCK_SCREEN_SETTINGS_PATH = '/data/system/locksettings.db'
10 PASSWORD_QUALITY_UNSPECIFIED = '0' 10 PASSWORD_QUALITY_UNSPECIFIED = '0'
11 11
12 12
13 def ConfigureContentSettingsDict(device, desired_settings): 13 def ConfigureContentSettings(device, desired_settings):
14 """Configures device content setings from a dictionary. 14 """Configures device content setings from a list.
15 15
16 Many settings are documented at: 16 Many settings are documented at:
17 http://developer.android.com/reference/android/provider/Settings.Global.html 17 http://developer.android.com/reference/android/provider/Settings.Global.html
18 http://developer.android.com/reference/android/provider/Settings.Secure.html 18 http://developer.android.com/reference/android/provider/Settings.Secure.html
19 http://developer.android.com/reference/android/provider/Settings.System.html 19 http://developer.android.com/reference/android/provider/Settings.System.html
20 20
21 Many others are undocumented. 21 Many others are undocumented.
22 22
23 Args: 23 Args:
24 device: A DeviceUtils instance for the device to configure. 24 device: A DeviceUtils instance for the device to configure.
25 desired_settings: A dict of {table: {key: value}} for all 25 desired_settings: A list of (table, [(key: value), ...]) for all
26 settings to configure. 26 settings to configure.
27 """ 27 """
28 try: 28 try:
29 sdk_version = int(device.GetProp('ro.build.version.sdk')) 29 sdk_version = int(device.GetProp('ro.build.version.sdk'))
30 except ValueError: 30 except ValueError:
31 logging.error('Skipping content settings configuration, unknown sdk %s', 31 logging.error('Skipping content settings configuration, unknown sdk %s',
32 device.GetProp('ro.build.version.sdk')) 32 device.GetProp('ro.build.version.sdk'))
33 return 33 return
34 34
35 if sdk_version < 16: 35 if sdk_version < 16:
36 logging.error('Skipping content settings configuration due to outdated sdk') 36 logging.error('Skipping content settings configuration due to outdated sdk')
37 return 37 return
38 38
39 device.SetProp('persist.sys.usb.config', 'adb') 39 device.SetProp('persist.sys.usb.config', 'adb')
40 device.old_interface.WaitForDevicePm()
41 40
42 if device.GetProp('ro.build.type') == 'userdebug': 41 if device.GetProp('ro.build.type') == 'userdebug':
43 for table, key_value in sorted(desired_settings.iteritems()): 42 for table, key_value in desired_settings:
44 settings = content_settings.ContentSettings(table, device) 43 settings = content_settings.ContentSettings(table, device)
45 for key, value in key_value.iteritems(): 44 for key, value in key_value:
46 settings[key] = value 45 settings[key] = value
47 logging.info('\n%s %s', table, (80 - len(table)) * '-') 46 logging.info('\n%s %s', table, (80 - len(table)) * '-')
48 for key, value in sorted(settings.iteritems()): 47 for key, value in sorted(settings.iteritems()):
49 logging.info('\t%s: %s', key, value) 48 logging.info('\t%s: %s', key, value)
50 49
51 50
52 def SetLockScreenSettings(device): 51 def SetLockScreenSettings(device):
53 """Sets lock screen settings on the device. 52 """Sets lock screen settings on the device.
54 53
55 On certain device/Android configurations we need to disable the lock screen in 54 On certain device/Android configurations we need to disable the lock screen in
(...skipping 30 matching lines...) Expand all
86 cmd = """begin transaction; 85 cmd = """begin transaction;
87 delete from '%(table)s' where %(primary_key)s='%(primary_value)s'; 86 delete from '%(table)s' where %(primary_key)s='%(primary_value)s';
88 insert into '%(table)s' (%(columns)s) values (%(values)s); 87 insert into '%(table)s' (%(columns)s) values (%(values)s);
89 commit transaction;""" % { 88 commit transaction;""" % {
90 'table': table, 89 'table': table,
91 'primary_key': columns[0], 90 'primary_key': columns[0],
92 'primary_value': values[0], 91 'primary_value': values[0],
93 'columns': ', '.join(columns), 92 'columns': ', '.join(columns),
94 'values': ', '.join(["'%s'" % value for value in values]) 93 'values': ', '.join(["'%s'" % value for value in values])
95 } 94 }
96 output_msg = device.RunShellCommand('\'sqlite3 %s "%s"\'' % (db, cmd)) 95 output_msg = device.RunShellCommand('sqlite3 %s "%s"' % (db, cmd))
97 if output_msg: 96 if output_msg:
98 print ' '.join(output_msg) 97 print ' '.join(output_msg)
99 98
100 99
101 ENABLE_LOCATION_SETTING = { 100 ENABLE_LOCATION_SETTINGS = [
tonyg 2014/08/15 17:19:43 Seems like another good thing to land separately.
102 'settings/secure': { 101 # Note that setting these in this order is required in order for all of
102 # them to take and stick through a reboot.
103 ('com.google.settings/partner', [
104 ('use_location_for_services', 1),
105 ]),
106 ('settings/secure', [
103 # Ensure Geolocation is enabled and allowed for tests. 107 # Ensure Geolocation is enabled and allowed for tests.
104 'location_providers_allowed': 'gps,network', 108 ('location_providers_allowed', 'gps,network'),
105 } 109 ]),
106 } 110 ('com.google.settings/partner', [
111 ('network_location_opt_in', 1),
112 ])
113 ]
107 114
108 DISABLE_LOCATION_SETTING = { 115 DISABLE_LOCATION_SETTINGS = [
109 'settings/secure': { 116 ('com.google.settings/partner', [
117 ('use_location_for_services', 0),
118 ]),
119 ('settings/secure', [
110 # Ensure Geolocation is disabled. 120 # Ensure Geolocation is disabled.
111 'location_providers_allowed': '', 121 ('location_providers_allowed', ''),
112 } 122 ]),
113 } 123 ]
114 124
115 DETERMINISTIC_DEVICE_SETTINGS = { 125 DETERMINISTIC_DEVICE_SETTINGS = [
116 'com.google.settings/partner': { 126 ('settings/global', [
117 'network_location_opt_in': 0, 127 ('assisted_gps_enabled', 0),
118 'use_location_for_services': 1,
119 },
120 'settings/global': {
121 'assisted_gps_enabled': 0,
122 128
123 # Disable "auto time" and "auto time zone" to avoid network-provided time 129 # Disable "auto time" and "auto time zone" to avoid network-provided time
124 # to overwrite the device's datetime and timezone synchronized from host 130 # to overwrite the device's datetime and timezone synchronized from host
125 # when running tests later. See b/6569849. 131 # when running tests later. See b/6569849.
126 'auto_time': 0, 132 ('auto_time', 0),
127 'auto_time_zone': 0, 133 ('auto_time_zone', 0),
128 134
129 'development_settings_enabled': 1, 135 ('development_settings_enabled', 1),
130 136
131 # Flag for allowing ActivityManagerService to send ACTION_APP_ERROR intents 137 # Flag for allowing ActivityManagerService to send ACTION_APP_ERROR intents
132 # on application crashes and ANRs. If this is disabled, the crash/ANR dialog 138 # on application crashes and ANRs. If this is disabled, the crash/ANR dialog
133 # will never display the "Report" button. 139 # will never display the "Report" button.
134 # Type: int ( 0 = disallow, 1 = allow ) 140 # Type: int ( 0 = disallow, 1 = allow )
135 'send_action_app_error': 0, 141 ('send_action_app_error', 0),
136 142
137 'stay_on_while_plugged_in': 3, 143 ('stay_on_while_plugged_in', 3),
138 144
139 'verifier_verify_adb_installs' : 0, 145 ('verifier_verify_adb_installs', 0),
140 }, 146 ]),
141 'settings/secure': { 147 ('settings/secure', [
142 'allowed_geolocation_origins': 148 ('allowed_geolocation_origins',
143 'http://www.google.co.uk http://www.google.com', 149 'http://www.google.co.uk http://www.google.com'),
144 150
145 # Ensure that we never get random dialogs like "Unfortunately the process 151 # Ensure that we never get random dialogs like "Unfortunately the process
146 # android.process.acore has stopped", which steal the focus, and make our 152 # android.process.acore has stopped", which steal the focus, and make our
147 # automation fail (because the dialog steals the focus then mistakenly 153 # automation fail (because the dialog steals the focus then mistakenly
148 # receives the injected user input events). 154 # receives the injected user input events).
149 'anr_show_background': 0, 155 ('anr_show_background', 0),
150 156
151 'lockscreen.disabled': 1, 157 ('lockscreen.disabled', 1),
152 158
153 'screensaver_enabled': 0, 159 ('screensaver_enabled', 0),
154 }, 160 ]),
155 'settings/system': { 161 ('settings/system', [
156 # Don't want devices to accidentally rotate the screen as that could 162 # Don't want devices to accidentally rotate the screen as that could
157 # affect performance measurements. 163 # affect performance measurements.
158 'accelerometer_rotation': 0, 164 ('accelerometer_rotation', 0),
159 165
160 'lockscreen.disabled': 1, 166 ('lockscreen.disabled', 1),
161 167
162 # Turn down brightness and disable auto-adjust so that devices run cooler. 168 # Turn down brightness and disable auto-adjust so that devices run cooler.
163 'screen_brightness': 5, 169 ('screen_brightness', 5),
164 'screen_brightness_mode': 0, 170 ('screen_brightness_mode', 0),
165 171
166 'user_rotation': 0, 172 ('user_rotation', 0),
167 }, 173 ]),
168 } 174 ]
169 175
170 176 NETWORK_DISABLED_SETTINGS = [
171 NETWORK_DISABLED_SETTINGS = { 177 ('settings/global', [
172 'settings/global': { 178 ('airplane_mode_on', 1),
173 'airplane_mode_on': 1, 179 ('wifi_on', 0),
174 'wifi_on': 0, 180 ]),
175 }, 181 ]
176 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698