parameters: (device)
docstring: 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.
docstring_summary: Sets lock screen settings on the device.
docstring_tokens: Sets lock screen settings on the device .
function: 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 device.build_type not in _COMPATIBLE_BUILD_TYPES:
      logger.warning('Unable to disable lockscreen on %s builds.',
                     device.build_type)
      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')
      columns = ['name', 'user', 'value']
      generate_values = lambda k, v: [k, '0', v]
    elif device.FileExists(_ALTERNATE_LOCK_SCREEN_SETTINGS_PATH):
      db = _ALTERNATE_LOCK_SCREEN_SETTINGS_PATH
      locksettings = get_lock_settings('secure') + get_lock_settings('system')
      columns = ['name', 'value']
      generate_values = lambda k, v: [k, v]
    else:
      logger.warning('Unable to find database file to set lock screen settings.')
      return
  
    for table, key, value in locksettings:
      # Set the lockscreen setting for default user '0'
      values = generate_values(key, 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(columns),
        'values': ', '.join(["'%s'" % value for value in values])
      }
      output_msg = device.RunShellCommand(
          ['sqlite3', db, cmd], check_return=True, as_root=True)
      if output_msg:
        logger.info(' '.join(output_msg))
function_tokens: def SetLockScreenSettings ( device ) : if device . build_type not in _COMPATIBLE_BUILD_TYPES : logger . warning ( 'Unable to disable lockscreen on %s builds.' , device . build_type ) 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' ) columns = [ 'name' , 'user' , 'value' ] generate_values = lambda k , v : [ k , '0' , v ] elif device . FileExists ( _ALTERNATE_LOCK_SCREEN_SETTINGS_PATH ) : db = _ALTERNATE_LOCK_SCREEN_SETTINGS_PATH locksettings = get_lock_settings ( 'secure' ) + get_lock_settings ( 'system' ) columns = [ 'name' , 'value' ] generate_values = lambda k , v : [ k , v ] else : logger . warning ( 'Unable to find database file to set lock screen settings.' ) return for table , key , value in locksettings : # Set the lockscreen setting for default user '0' values = generate_values ( key , 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 ( columns ) , 'values' : ', ' . join ( [ "'%s'" % value for value in values ] ) } output_msg = device . RunShellCommand ( [ 'sqlite3' , db , cmd ] , check_return = True , as_root = True ) if output_msg : logger . info ( ' ' . join ( output_msg ) )