static DBusConnection *dbus_conn = NULL;
-static bool kernel_conn_control = false;
-
-static bool kernel_blocked_keys_supported = false;
-
-static bool kernel_set_system_config = false;
-
-static bool kernel_exp_features = false;
+static uint32_t kernel_features = 0;
static GList *adapter_list = NULL;
static unsigned int adapter_remaining = 0;
DBG("sending set mode command for index %u", adapter->dev_id);
- if (kernel_conn_control) {
+ if (has_kernel_features(KERNEL_CONN_CONTROL)) {
if (mode)
set_mode(adapter, MGMT_OP_SET_CONNECTABLE, mode);
else
* no need to start any discovery. The kernel will keep scanning
* as long as devices are in its auto-connection list.
*/
- if (kernel_conn_control)
+ if (has_kernel_features(KERNEL_CONN_CONTROL))
return;
/*
* no need to stop any discovery. The kernel will handle the
* auto-connection by itself.
*/
- if (kernel_conn_control)
+ if (has_kernel_features(KERNEL_CONN_CONTROL))
return;
/*
static void clear_discoverable(struct btd_adapter *adapter)
{
- if (!kernel_conn_control)
+ if (!has_kernel_features(KERNEL_CONN_CONTROL))
return;
if (!(adapter->current_settings & MGMT_SETTING_DISCOVERABLE))
break;
case MGMT_SETTING_DISCOVERABLE:
#ifndef TIZEN_FEATURE_BLUEZ_MODIFY
- if (kernel_conn_control) {
+ if (has_kernel_features(KERNEL_CONN_CONTROL)) {
if (mode) {
set_mode(adapter, MGMT_OP_SET_CONNECTABLE,
mode);
size_t len = 0;
unsigned int err;
- if (!main_opts.default_params.num_entries || !kernel_set_system_config)
+ if (!main_opts.default_params.num_entries ||
+ !has_kernel_features(KERNEL_SET_SYSTEM_CONFIG))
return;
params = malloc0(sizeof(*params) *
* adapter_auto_connect_add() function is used to maintain what to
* connect.
*/
- if (kernel_conn_control)
+ if (has_kernel_features(KERNEL_CONN_CONTROL))
return 0;
if (g_slist_find(adapter->connect_list, device)) {
if (device == adapter->connect_le)
adapter->connect_le = NULL;
- if (kernel_conn_control)
+ if (has_kernel_features(KERNEL_CONN_CONTROL))
return;
if (!g_slist_find(adapter->connect_list, device)) {
{
struct mgmt_cp_add_device cp;
- if (!kernel_conn_control)
+ if (!has_kernel_features(KERNEL_CONN_CONTROL))
return;
memset(&cp, 0, sizeof(cp));
{
struct mgmt_cp_remove_device cp;
- if (!kernel_conn_control)
+ if (!has_kernel_features(KERNEL_CONN_CONTROL))
return;
memset(&cp, 0, sizeof(cp));
uint8_t bdaddr_type;
unsigned int id;
- if (!kernel_conn_control)
+ if (!has_kernel_features(KERNEL_CONN_CONTROL))
return;
if (g_slist_find(adapter->connect_list, device)) {
const bdaddr_t *bdaddr;
uint8_t bdaddr_type;
- if (!kernel_conn_control)
+ if (!has_kernel_features(KERNEL_CONN_CONTROL))
return;
bdaddr = device_get_address(device);
uint8_t bdaddr_type;
unsigned int id;
- if (!kernel_conn_control)
+ if (!has_kernel_features(KERNEL_CONN_CONTROL))
return;
if (!g_slist_find(adapter->connect_list, device)) {
* If kernel background scan is used then the kernel is
* responsible for connecting.
*/
- if (kernel_conn_control)
+ if (has_kernel_features(KERNEL_CONN_CONTROL))
return;
/*
{
struct mgmt_cp_remove_device cp;
- if (!kernel_conn_control)
+ if (!has_kernel_features(KERNEL_CONN_CONTROL))
return 0;
memset(&cp, 0, sizeof(cp));
adapter->central_rpa_res_support = 0x01;
#endif
- if (kernel_exp_features)
+ if (has_kernel_features(KERNEL_EXP_FEATURES))
read_exp_features(adapter);
err = adapter_register(adapter);
set_name(adapter, btd_adapter_get_name(adapter));
- if (kernel_blocked_keys_supported && !set_blocked_keys(adapter)) {
+ if (has_kernel_features(KERNEL_BLOCKED_KEYS_SUPPORTED) &&
+ !set_blocked_keys(adapter)) {
btd_error(adapter->dev_id,
"Failed to set blocked keys for index %u",
adapter->dev_id);
!(adapter->current_settings & MGMT_SETTING_BONDABLE))
set_mode(adapter, MGMT_OP_SET_BONDABLE, 0x01);
- if (!kernel_conn_control)
+ if (!has_kernel_features(KERNEL_CONN_CONTROL))
set_mode(adapter, MGMT_OP_SET_CONNECTABLE, 0x01);
else if (adapter->current_settings & MGMT_SETTING_CONNECTABLE)
set_mode(adapter, MGMT_OP_SET_CONNECTABLE, 0x00);
switch (op) {
case MGMT_OP_ADD_DEVICE:
DBG("enabling kernel-side connection control");
- kernel_conn_control = true;
+ kernel_features |= KERNEL_CONN_CONTROL;
break;
case MGMT_OP_SET_BLOCKED_KEYS:
DBG("kernel supports the set_blocked_keys op");
- kernel_blocked_keys_supported = true;
+ kernel_features |= KERNEL_BLOCKED_KEYS_SUPPORTED;
break;
case MGMT_OP_SET_DEF_SYSTEM_CONFIG:
DBG("kernel supports set system confic");
- kernel_set_system_config = true;
+ kernel_features |= KERNEL_SET_SYSTEM_CONFIG;
break;
case MGMT_OP_READ_EXP_FEATURES_INFO:
DBG("kernel supports exp features");
- kernel_exp_features = true;
+ kernel_features |= KERNEL_EXP_FEATURES;
break;
default:
break;
return false;
}
+bool has_kernel_features(uint32_t features)
+{
+ return !!(kernel_features & features);
+}
#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
int btd_adapter_set_streaming_mode(struct btd_adapter *adapter,
const bdaddr_t *bdaddr, gboolean enable)