Index: build/android/pylib/device_settings.py |
diff --git a/build/android/pylib/device_settings.py b/build/android/pylib/device_settings.py |
index 4050694ecdeaea653f1bdcd01f57c650fce7b16c..0580fcfdc3835a6ad319cd27ef0754247023413d 100644 |
--- a/build/android/pylib/device_settings.py |
+++ b/build/android/pylib/device_settings.py |
@@ -8,6 +8,8 @@ from pylib import constants |
from pylib import content_settings |
_LOCK_SCREEN_SETTINGS_PATH = '/data/system/locksettings.db' |
+_ALTERNATE_LOCK_SCREEN_SETTINGS_PATH = ( |
+ '/data/data/com.android.providers.settings/databases/settings.db') |
PASSWORD_QUALITY_UNSPECIFIED = '0' |
@@ -66,16 +68,26 @@ def SetLockScreenSettings(device): |
Raises: |
Exception if the setting was not properly set. |
""" |
- if (not device.old_interface.FileExistsOnDevice(_LOCK_SCREEN_SETTINGS_PATH) or |
- device.GetProp('ro.build.type') != 'userdebug'): |
+ if device.GetProp('ro.build.type') != 'userdebug': |
+ logging.warning('Unable to disable lockscreen on user builds.') |
+ return |
+ |
+ def get_lock_settings(table): |
+ return [(table, 'lockscreen.disabled', '1'), |
+ (table, 'lockscreen.password_type', PASSWORD_QUALITY_UNSPECIFIED), |
+ (table, 'lockscreen.password_type_alternate', |
+ PASSWORD_QUALITY_UNSPECIFIED)] |
+ |
+ if device.FileExists(_LOCK_SCREEN_SETTINGS_PATH): |
+ db = _LOCK_SCREEN_SETTINGS_PATH |
+ locksettings = get_lock_settings('locksettings') |
+ elif device.FileExists(_ALTERNATE_LOCK_SCREEN_SETTINGS_PATH): |
+ db = _ALTERNATE_LOCK_SCREEN_SETTINGS_PATH |
+ locksettings = get_lock_settings('secure') + get_lock_settings('system') |
+ else: |
+ logging.warning('Unable to find database file to set lock screen settings.') |
return |
- db = _LOCK_SCREEN_SETTINGS_PATH |
- locksettings = [('locksettings', 'lockscreen.disabled', '1'), |
- ('locksettings', 'lockscreen.password_type', |
- PASSWORD_QUALITY_UNSPECIFIED), |
- ('locksettings', 'lockscreen.password_type_alternate', |
- PASSWORD_QUALITY_UNSPECIFIED)] |
for table, key, value in locksettings: |
# Set the lockscreen setting for default user '0' |
columns = ['name', 'user', 'value'] |
@@ -91,9 +103,10 @@ commit transaction;""" % { |
'columns': ', '.join(columns), |
'values': ', '.join(["'%s'" % value for value in values]) |
} |
- output_msg = device.RunShellCommand('sqlite3 %s "%s"' % (db, cmd)) |
+ output_msg = device.RunShellCommand('sqlite3 %s "%s"' % (db, cmd), |
+ as_root=True) |
if output_msg: |
- print ' '.join(output_msg) |
+ logging.info(' '.join(output_msg)) |
ENABLE_LOCATION_SETTINGS = [ |