Can a custom module be used to assign permissions associated with a different module?
There are hooks* to revoke or change permissions so there is no need to set TRUE or FALSE in your snippet. 

Try this:

function mycustommodule_modules_enabled($modules) {
  if (in_array('contribmodule', $modules)) {
    $roleid = array_search('custom role', user_roles());
    if (is_int($roleid)) {
      user_role_grant_permissions($roleid, array(
        'permission from contrib module',
      ));
    }
  }
}


In this call, you are setting the array's value to the permission name -- Not the key. 

*: user_role_change_permissions() and user_role_revoke_permissions()