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 constants |
8 from pylib import content_settings | 8 from pylib import content_settings |
9 from pylib.device import device_errors | 9 from pylib.device import device_errors |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 http://developer.android.com/reference/android/provider/Settings.Secure.html | 22 http://developer.android.com/reference/android/provider/Settings.Secure.html |
23 http://developer.android.com/reference/android/provider/Settings.System.html | 23 http://developer.android.com/reference/android/provider/Settings.System.html |
24 | 24 |
25 Many others are undocumented. | 25 Many others are undocumented. |
26 | 26 |
27 Args: | 27 Args: |
28 device: A DeviceUtils instance for the device to configure. | 28 device: A DeviceUtils instance for the device to configure. |
29 desired_settings: A list of (table, [(key: value), ...]) for all | 29 desired_settings: A list of (table, [(key: value), ...]) for all |
30 settings to configure. | 30 settings to configure. |
31 """ | 31 """ |
32 try: | |
33 sdk_version = device.build_version_sdk | |
34 except device_errors.CommandFailedError as exc: | |
35 logging.error('Skipping content settings configuration: %s', str(exc)) | |
36 return | |
37 | |
38 if sdk_version < constants.ANDROID_SDK_VERSION_CODES.JELLY_BEAN: | |
39 logging.error('Skipping content settings configuration due to outdated sdk') | |
40 return | |
41 | |
42 if device.build_type == 'userdebug': | 32 if device.build_type == 'userdebug': |
43 for table, key_value in desired_settings: | 33 for table, key_value in desired_settings: |
44 settings = content_settings.ContentSettings(table, device) | 34 settings = content_settings.ContentSettings(table, device) |
45 for key, value in key_value: | 35 for key, value in key_value: |
46 settings[key] = value | 36 settings[key] = value |
47 logging.info('\n%s %s', table, (80 - len(table)) * '-') | 37 logging.info('\n%s %s', table, (80 - len(table)) * '-') |
48 for key, value in sorted(settings.iteritems()): | 38 for key, value in sorted(settings.iteritems()): |
49 logging.info('\t%s: %s', key, value) | 39 logging.info('\t%s: %s', key, value) |
50 | 40 |
51 | 41 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 ('user_rotation', 0), | 177 ('user_rotation', 0), |
188 ]), | 178 ]), |
189 ] | 179 ] |
190 | 180 |
191 NETWORK_DISABLED_SETTINGS = [ | 181 NETWORK_DISABLED_SETTINGS = [ |
192 ('settings/global', [ | 182 ('settings/global', [ |
193 ('airplane_mode_on', 1), | 183 ('airplane_mode_on', 1), |
194 ('wifi_on', 0), | 184 ('wifi_on', 0), |
195 ]), | 185 ]), |
196 ] | 186 ] |
OLD | NEW |