OLD | NEW |
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 constants |
7 from pylib import content_settings | 8 from pylib import content_settings |
8 | 9 |
9 _LOCK_SCREEN_SETTINGS_PATH = '/data/system/locksettings.db' | 10 _LOCK_SCREEN_SETTINGS_PATH = '/data/system/locksettings.db' |
10 PASSWORD_QUALITY_UNSPECIFIED = '0' | 11 PASSWORD_QUALITY_UNSPECIFIED = '0' |
11 | 12 |
12 | 13 |
13 def ConfigureContentSettings(device, desired_settings): | 14 def ConfigureContentSettings(device, desired_settings): |
14 """Configures device content setings from a list. | 15 """Configures device content setings from a list. |
15 | 16 |
16 Many settings are documented at: | 17 Many settings are documented at: |
17 http://developer.android.com/reference/android/provider/Settings.Global.html | 18 http://developer.android.com/reference/android/provider/Settings.Global.html |
18 http://developer.android.com/reference/android/provider/Settings.Secure.html | 19 http://developer.android.com/reference/android/provider/Settings.Secure.html |
19 http://developer.android.com/reference/android/provider/Settings.System.html | 20 http://developer.android.com/reference/android/provider/Settings.System.html |
20 | 21 |
21 Many others are undocumented. | 22 Many others are undocumented. |
22 | 23 |
23 Args: | 24 Args: |
24 device: A DeviceUtils instance for the device to configure. | 25 device: A DeviceUtils instance for the device to configure. |
25 desired_settings: A list of (table, [(key: value), ...]) for all | 26 desired_settings: A list of (table, [(key: value), ...]) for all |
26 settings to configure. | 27 settings to configure. |
27 """ | 28 """ |
28 try: | 29 try: |
29 sdk_version = int(device.GetProp('ro.build.version.sdk')) | 30 sdk_version = int(device.GetProp('ro.build.version.sdk')) |
30 except ValueError: | 31 except ValueError: |
31 logging.error('Skipping content settings configuration, unknown sdk %s', | 32 logging.error('Skipping content settings configuration, unknown sdk %s', |
32 device.GetProp('ro.build.version.sdk')) | 33 device.GetProp('ro.build.version.sdk')) |
33 return | 34 return |
34 | 35 |
35 if sdk_version < 16: | 36 if sdk_version < constants.ANDROID_SDK_VERSION_CODES.JELLY_BEAN: |
36 logging.error('Skipping content settings configuration due to outdated sdk') | 37 logging.error('Skipping content settings configuration due to outdated sdk') |
37 return | 38 return |
38 | 39 |
39 if device.GetProp('ro.build.type') == 'userdebug': | 40 if device.GetProp('ro.build.type') == 'userdebug': |
40 for table, key_value in desired_settings: | 41 for table, key_value in desired_settings: |
41 settings = content_settings.ContentSettings(table, device) | 42 settings = content_settings.ContentSettings(table, device) |
42 for key, value in key_value: | 43 for key, value in key_value: |
43 settings[key] = value | 44 settings[key] = value |
44 logging.info('\n%s %s', table, (80 - len(table)) * '-') | 45 logging.info('\n%s %s', table, (80 - len(table)) * '-') |
45 for key, value in sorted(settings.iteritems()): | 46 for key, value in sorted(settings.iteritems()): |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 ('user_rotation', 0), | 171 ('user_rotation', 0), |
171 ]), | 172 ]), |
172 ] | 173 ] |
173 | 174 |
174 NETWORK_DISABLED_SETTINGS = [ | 175 NETWORK_DISABLED_SETTINGS = [ |
175 ('settings/global', [ | 176 ('settings/global', [ |
176 ('airplane_mode_on', 1), | 177 ('airplane_mode_on', 1), |
177 ('wifi_on', 0), | 178 ('wifi_on', 0), |
178 ]), | 179 ]), |
179 ] | 180 ] |
OLD | NEW |