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

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

Issue 1428543004: [Android] Attempt to set device settings on eng builds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 _ALTERNATE_LOCK_SCREEN_SETTINGS_PATH = ( 10 _ALTERNATE_LOCK_SCREEN_SETTINGS_PATH = (
11 '/data/data/com.android.providers.settings/databases/settings.db') 11 '/data/data/com.android.providers.settings/databases/settings.db')
12 PASSWORD_QUALITY_UNSPECIFIED = '0' 12 PASSWORD_QUALITY_UNSPECIFIED = '0'
13 _COMPATIBLE_BUILD_TYPES = ['userdebug', 'eng']
13 14
14 15
15 def ConfigureContentSettings(device, desired_settings): 16 def ConfigureContentSettings(device, desired_settings):
16 """Configures device content setings from a list. 17 """Configures device content setings from a list.
17 18
18 Many settings are documented at: 19 Many settings are documented at:
19 http://developer.android.com/reference/android/provider/Settings.Global.html 20 http://developer.android.com/reference/android/provider/Settings.Global.html
20 http://developer.android.com/reference/android/provider/Settings.Secure.html 21 http://developer.android.com/reference/android/provider/Settings.Secure.html
21 http://developer.android.com/reference/android/provider/Settings.System.html 22 http://developer.android.com/reference/android/provider/Settings.System.html
22 23
23 Many others are undocumented. 24 Many others are undocumented.
24 25
25 Args: 26 Args:
26 device: A DeviceUtils instance for the device to configure. 27 device: A DeviceUtils instance for the device to configure.
27 desired_settings: A list of (table, [(key: value), ...]) for all 28 desired_settings: A list of (table, [(key: value), ...]) for all
28 settings to configure. 29 settings to configure.
29 """ 30 """
30 if device.build_type == 'userdebug': 31 if device.build_type in _COMPATIBLE_BUILD_TYPES:
31 for table, key_value in desired_settings: 32 for table, key_value in desired_settings:
32 settings = content_settings.ContentSettings(table, device) 33 settings = content_settings.ContentSettings(table, device)
33 for key, value in key_value: 34 for key, value in key_value:
34 settings[key] = value 35 settings[key] = value
35 logging.info('\n%s %s', table, (80 - len(table)) * '-') 36 logging.info('\n%s %s', table, (80 - len(table)) * '-')
36 for key, value in sorted(settings.iteritems()): 37 for key, value in sorted(settings.iteritems()):
37 logging.info('\t%s: %s', key, value) 38 logging.info('\t%s: %s', key, value)
38 39
39 40
40 def SetLockScreenSettings(device): 41 def SetLockScreenSettings(device):
41 """Sets lock screen settings on the device. 42 """Sets lock screen settings on the device.
42 43
43 On certain device/Android configurations we need to disable the lock screen in 44 On certain device/Android configurations we need to disable the lock screen in
44 a different database. Additionally, the password type must be set to 45 a different database. Additionally, the password type must be set to
45 DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED. 46 DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED.
46 Lock screen settings are stored in sqlite on the device in: 47 Lock screen settings are stored in sqlite on the device in:
47 /data/system/locksettings.db 48 /data/system/locksettings.db
48 49
49 IMPORTANT: The first column is used as a primary key so that all rows with the 50 IMPORTANT: The first column is used as a primary key so that all rows with the
50 same value for that column are removed from the table prior to inserting the 51 same value for that column are removed from the table prior to inserting the
51 new values. 52 new values.
52 53
53 Args: 54 Args:
54 device: A DeviceUtils instance for the device to configure. 55 device: A DeviceUtils instance for the device to configure.
55 56
56 Raises: 57 Raises:
57 Exception if the setting was not properly set. 58 Exception if the setting was not properly set.
58 """ 59 """
59 if device.build_type != 'userdebug': 60 if device.build_type not in _COMPATIBLE_BUILD_TYPES:
60 logging.warning('Unable to disable lockscreen on user builds.') 61 logging.warning('Unable to disable lockscreen on %s builds.',
62 device.build_type)
61 return 63 return
62 64
63 def get_lock_settings(table): 65 def get_lock_settings(table):
64 return [(table, 'lockscreen.disabled', '1'), 66 return [(table, 'lockscreen.disabled', '1'),
65 (table, 'lockscreen.password_type', PASSWORD_QUALITY_UNSPECIFIED), 67 (table, 'lockscreen.password_type', PASSWORD_QUALITY_UNSPECIFIED),
66 (table, 'lockscreen.password_type_alternate', 68 (table, 'lockscreen.password_type_alternate',
67 PASSWORD_QUALITY_UNSPECIFIED)] 69 PASSWORD_QUALITY_UNSPECIFIED)]
68 70
69 if device.FileExists(_LOCK_SCREEN_SETTINGS_PATH): 71 if device.FileExists(_LOCK_SCREEN_SETTINGS_PATH):
70 db = _LOCK_SCREEN_SETTINGS_PATH 72 db = _LOCK_SCREEN_SETTINGS_PATH
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 ('user_rotation', 0), 189 ('user_rotation', 0),
188 ]), 190 ]),
189 ] 191 ]
190 192
191 NETWORK_DISABLED_SETTINGS = [ 193 NETWORK_DISABLED_SETTINGS = [
192 ('settings/global', [ 194 ('settings/global', [
193 ('airplane_mode_on', 1), 195 ('airplane_mode_on', 1),
194 ('wifi_on', 0), 196 ('wifi_on', 0),
195 ]), 197 ]),
196 ] 198 ]
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698