Chromium Code Reviews| Index: build/android/pylib/device_settings.py |
| diff --git a/build/android/pylib/device_settings.py b/build/android/pylib/device_settings.py |
| index deb673b971dd9e8f9f736e197074a8f656b6f434..840471ae1b223b5d45e5f809db2fd92e0cbd85be 100644 |
| --- a/build/android/pylib/device_settings.py |
| +++ b/build/android/pylib/device_settings.py |
| @@ -6,6 +6,9 @@ import logging |
| from pylib import content_settings |
| +_LOCK_SCREEN_SETTINGS_PATH = '/data/system/locksettings.db' |
| +PASSWORD_QUALITY_UNSPECIFIED = 0 |
|
Yaron
2014/07/02 00:33:34
why not just make this a string literal and avoid
navabi
2014/07/02 04:41:14
Done.
|
| + |
| def ConfigureContentSettingsDict(device, desired_settings): |
| """Configures device content setings from a dictionary. |
| @@ -48,6 +51,55 @@ def ConfigureContentSettingsDict(device, desired_settings): |
| logging.info('\t%s: %s', key, value) |
| +def SetLockScreenSettings(device): |
| + """Sets lock screen settings on the device. |
| + |
| + On certain device/Android configurations we need to disable the lock screen in |
| + a different database. Additionally, the password type must be set to |
| + DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED. |
| + Lock screen settings are stored in sqlite on the device in: |
| + /data/system/locksettings.db |
| + |
| + IMPORTANT: The first column is used as a primary key so that all rows with the |
| + same value for that column are removed from the table prior to inserting the |
| + new values. |
| + |
| + Args: |
| + device: A DeviceUtils instance for the device to configure. |
| + |
| + Raises: |
| + Exception if the setting was not properly set. |
| + """ |
| + if (not device.old_interface.FileExistsOnDevice(_LOCK_SCREEN_SETTINGS_PATH) or |
| + device.old_interface.GetBuildType() != 'userdebug'): |
| + return |
| + |
| + db = _LOCK_SCREEN_SETTINGS_PATH |
| + locksettings = [('locksettings', 'lockscreen.disabled', '1'), |
| + ('locksettings', 'lockscreen.password_type', |
| + str(PASSWORD_QUALITY_UNSPECIFIED)), |
| + ('locksettings', 'lockscreen.password_type_alternate', |
| + str(PASSWORD_QUALITY_UNSPECIFIED))] |
| + for table, key, value in locksettings: |
| + # Set the lockscreen setting for default user '0' |
| + columns = ['name', 'user', 'value'] |
| + values = [key, '0', value] |
| + |
| + cmd = """begin transaction; |
| +delete from '%(table)s' where %(primary_key)s='%(primary_value)s'; |
| +insert into '%(table)s' (%(columns)s) values (%(values)s); |
| +commit transaction;""" % { |
| + 'table': table, |
| + 'primary_key': columns[0], |
| + 'primary_value': values[0], |
| + 'columns': ', '.join([column for column in columns]), |
|
jbudorick
2014/07/02 01:01:29
nit: this can just be
'columns': ', '.join(colu
navabi
2014/07/02 04:41:14
Done.
|
| + 'values': ', '.join(["'%s'" % value for value in values]) |
| + } |
| + output_msg = device.RunShellCommand('\'sqlite3 %s "%s"\'' % (db, cmd)) |
| + if output_msg: |
| + print ' '.join(output_msg) |
| + |
| + |
| ENABLE_LOCATION_SETTING = { |
| 'settings/secure': { |
| # Ensure Geolocation is enabled and allowed for tests. |