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

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

Issue 360183002: Set lockscreen settings in the locksettings db. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed reviews. Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « build/android/provision_devices.py ('k') | 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'
10 PASSWORD_QUALITY_UNSPECIFIED = '0'
11
9 12
10 def ConfigureContentSettingsDict(device, desired_settings): 13 def ConfigureContentSettingsDict(device, desired_settings):
11 """Configures device content setings from a dictionary. 14 """Configures device content setings from a dictionary.
12 15
13 Many settings are documented at: 16 Many settings are documented at:
14 http://developer.android.com/reference/android/provider/Settings.Global.html 17 http://developer.android.com/reference/android/provider/Settings.Global.html
15 http://developer.android.com/reference/android/provider/Settings.Secure.html 18 http://developer.android.com/reference/android/provider/Settings.Secure.html
16 http://developer.android.com/reference/android/provider/Settings.System.html 19 http://developer.android.com/reference/android/provider/Settings.System.html
17 20
18 Many others are undocumented. 21 Many others are undocumented.
(...skipping 22 matching lines...) Expand all
41 if device.old_interface.GetBuildType() == 'userdebug': 44 if device.old_interface.GetBuildType() == 'userdebug':
42 for table, key_value in sorted(desired_settings.iteritems()): 45 for table, key_value in sorted(desired_settings.iteritems()):
43 settings = content_settings.ContentSettings(table, device) 46 settings = content_settings.ContentSettings(table, device)
44 for key, value in key_value.iteritems(): 47 for key, value in key_value.iteritems():
45 settings[key] = value 48 settings[key] = value
46 logging.info('\n%s %s', table, (80 - len(table)) * '-') 49 logging.info('\n%s %s', table, (80 - len(table)) * '-')
47 for key, value in sorted(settings.iteritems()): 50 for key, value in sorted(settings.iteritems()):
48 logging.info('\t%s: %s', key, value) 51 logging.info('\t%s: %s', key, value)
49 52
50 53
54 def SetLockScreenSettings(device):
55 """Sets lock screen settings on the device.
56
57 On certain device/Android configurations we need to disable the lock screen in
58 a different database. Additionally, the password type must be set to
59 DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED.
60 Lock screen settings are stored in sqlite on the device in:
61 /data/system/locksettings.db
62
63 IMPORTANT: The first column is used as a primary key so that all rows with the
64 same value for that column are removed from the table prior to inserting the
65 new values.
66
67 Args:
68 device: A DeviceUtils instance for the device to configure.
69
70 Raises:
71 Exception if the setting was not properly set.
72 """
73 if (not device.old_interface.FileExistsOnDevice(_LOCK_SCREEN_SETTINGS_PATH) or
74 device.old_interface.GetBuildType() != 'userdebug'):
75 return
76
77 db = _LOCK_SCREEN_SETTINGS_PATH
78 locksettings = [('locksettings', 'lockscreen.disabled', '1'),
79 ('locksettings', 'lockscreen.password_type',
80 PASSWORD_QUALITY_UNSPECIFIED),
81 ('locksettings', 'lockscreen.password_type_alternate',
82 PASSWORD_QUALITY_UNSPECIFIED)]
83 for table, key, value in locksettings:
84 # Set the lockscreen setting for default user '0'
85 columns = ['name', 'user', 'value']
86 values = [key, '0', value]
87
88 cmd = """begin transaction;
89 delete from '%(table)s' where %(primary_key)s='%(primary_value)s';
90 insert into '%(table)s' (%(columns)s) values (%(values)s);
91 commit transaction;""" % {
92 'table': table,
93 'primary_key': columns[0],
94 'primary_value': values[0],
95 'columns': ', '.join(columns),
96 'values': ', '.join(["'%s'" % value for value in values])
97 }
98 output_msg = device.RunShellCommand('\'sqlite3 %s "%s"\'' % (db, cmd))
99 if output_msg:
100 print ' '.join(output_msg)
101
102
51 ENABLE_LOCATION_SETTING = { 103 ENABLE_LOCATION_SETTING = {
52 'settings/secure': { 104 'settings/secure': {
53 # Ensure Geolocation is enabled and allowed for tests. 105 # Ensure Geolocation is enabled and allowed for tests.
54 'location_providers_allowed': 'gps,network', 106 'location_providers_allowed': 'gps,network',
55 } 107 }
56 } 108 }
57 109
58 DISABLE_LOCATION_SETTING = { 110 DISABLE_LOCATION_SETTING = {
59 'settings/secure': { 111 'settings/secure': {
60 # Ensure Geolocation is disabled. 112 # Ensure Geolocation is disabled.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 }, 169 },
118 } 170 }
119 171
120 172
121 NETWORK_DISABLED_SETTINGS = { 173 NETWORK_DISABLED_SETTINGS = {
122 'settings/global': { 174 'settings/global': {
123 'airplane_mode_on': 1, 175 'airplane_mode_on': 1,
124 'wifi_on': 0, 176 'wifi_on': 0,
125 }, 177 },
126 } 178 }
OLDNEW
« no previous file with comments | « build/android/provision_devices.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698