| 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 | 9 |
| 10 _LOCK_SCREEN_SETTINGS_PATH = '/data/system/locksettings.db' | 10 _LOCK_SCREEN_SETTINGS_PATH = '/data/system/locksettings.db' |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 def get_lock_settings(table): | 75 def get_lock_settings(table): |
| 76 return [(table, 'lockscreen.disabled', '1'), | 76 return [(table, 'lockscreen.disabled', '1'), |
| 77 (table, 'lockscreen.password_type', PASSWORD_QUALITY_UNSPECIFIED), | 77 (table, 'lockscreen.password_type', PASSWORD_QUALITY_UNSPECIFIED), |
| 78 (table, 'lockscreen.password_type_alternate', | 78 (table, 'lockscreen.password_type_alternate', |
| 79 PASSWORD_QUALITY_UNSPECIFIED)] | 79 PASSWORD_QUALITY_UNSPECIFIED)] |
| 80 | 80 |
| 81 if device.FileExists(_LOCK_SCREEN_SETTINGS_PATH): | 81 if device.FileExists(_LOCK_SCREEN_SETTINGS_PATH): |
| 82 db = _LOCK_SCREEN_SETTINGS_PATH | 82 db = _LOCK_SCREEN_SETTINGS_PATH |
| 83 locksettings = get_lock_settings('locksettings') | 83 locksettings = get_lock_settings('locksettings') |
| 84 columns = ['name', 'user', 'value'] |
| 85 generate_values = lambda k, v: [k, '0', v] |
| 84 elif device.FileExists(_ALTERNATE_LOCK_SCREEN_SETTINGS_PATH): | 86 elif device.FileExists(_ALTERNATE_LOCK_SCREEN_SETTINGS_PATH): |
| 85 db = _ALTERNATE_LOCK_SCREEN_SETTINGS_PATH | 87 db = _ALTERNATE_LOCK_SCREEN_SETTINGS_PATH |
| 86 locksettings = get_lock_settings('secure') + get_lock_settings('system') | 88 locksettings = get_lock_settings('secure') + get_lock_settings('system') |
| 89 columns = ['name', 'value'] |
| 90 generate_values = lambda k, v: [k, v] |
| 87 else: | 91 else: |
| 88 logging.warning('Unable to find database file to set lock screen settings.') | 92 logging.warning('Unable to find database file to set lock screen settings.') |
| 89 return | 93 return |
| 90 | 94 |
| 91 for table, key, value in locksettings: | 95 for table, key, value in locksettings: |
| 92 # Set the lockscreen setting for default user '0' | 96 # Set the lockscreen setting for default user '0' |
| 93 columns = ['name', 'user', 'value'] | 97 values = generate_values(key, value) |
| 94 values = [key, '0', value] | |
| 95 | 98 |
| 96 cmd = """begin transaction; | 99 cmd = """begin transaction; |
| 97 delete from '%(table)s' where %(primary_key)s='%(primary_value)s'; | 100 delete from '%(table)s' where %(primary_key)s='%(primary_value)s'; |
| 98 insert into '%(table)s' (%(columns)s) values (%(values)s); | 101 insert into '%(table)s' (%(columns)s) values (%(values)s); |
| 99 commit transaction;""" % { | 102 commit transaction;""" % { |
| 100 'table': table, | 103 'table': table, |
| 101 'primary_key': columns[0], | 104 'primary_key': columns[0], |
| 102 'primary_value': values[0], | 105 'primary_value': values[0], |
| 103 'columns': ', '.join(columns), | 106 'columns': ', '.join(columns), |
| 104 'values': ', '.join(["'%s'" % value for value in values]) | 107 'values': ', '.join(["'%s'" % value for value in values]) |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 ('user_rotation', 0), | 187 ('user_rotation', 0), |
| 185 ]), | 188 ]), |
| 186 ] | 189 ] |
| 187 | 190 |
| 188 NETWORK_DISABLED_SETTINGS = [ | 191 NETWORK_DISABLED_SETTINGS = [ |
| 189 ('settings/global', [ | 192 ('settings/global', [ |
| 190 ('airplane_mode_on', 1), | 193 ('airplane_mode_on', 1), |
| 191 ('wifi_on', 0), | 194 ('wifi_on', 0), |
| 192 ]), | 195 ]), |
| 193 ] | 196 ] |
| OLD | NEW |