Eliminate unused arguments to btif_config and clarify variable names
diff --git a/system/btif/co/bta_hh_co.c b/system/btif/co/bta_hh_co.c
index 6e9a91f..4edf52b 100644
--- a/system/btif/co/bta_hh_co.c
+++ b/system/btif/co/bta_hh_co.c
@@ -478,17 +478,17 @@
remote_bda[0], remote_bda[1], remote_bda[2],
remote_bda[3], remote_bda[4], remote_bda[5]);
- size_t len = btif_config_get_bin_length("Remote", bdstr, "HidReport");
+ size_t len = btif_config_get_bin_length(bdstr, "HidReport");
if (len >= sizeof(tBTA_HH_RPT_CACHE_ENTRY) && len <= sizeof(sReportCache))
{
- btif_config_get_bin("Remote", bdstr, "HidReport", (uint8_t *)sReportCache, &len);
+ btif_config_get_bin(bdstr, "HidReport", (uint8_t *)sReportCache, &len);
idx = len / sizeof(tBTA_HH_RPT_CACHE_ENTRY);
}
if (idx < BTA_HH_NV_LOAD_MAX)
{
memcpy(&sReportCache[idx++], p_entry, sizeof(tBTA_HH_RPT_CACHE_ENTRY));
- btif_config_set_bin("Remote", bdstr, "HidReport", (const uint8_t *)sReportCache,
+ btif_config_set_bin(bdstr, "HidReport", (const uint8_t *)sReportCache,
idx * sizeof(tBTA_HH_RPT_CACHE_ENTRY));
BTIF_TRACE_DEBUG("%s() - Saving report; dev=%s, idx=%d", __FUNCTION__, bdstr, idx);
}
@@ -522,13 +522,13 @@
remote_bda[0], remote_bda[1], remote_bda[2],
remote_bda[3], remote_bda[4], remote_bda[5]);
- size_t len = btif_config_get_bin_length("Remote", bdstr, "HidReport");
+ size_t len = btif_config_get_bin_length(bdstr, "HidReport");
if (!p_num_rpt && len < sizeof(tBTA_HH_RPT_CACHE_ENTRY))
return NULL;
if (len > sizeof(sReportCache))
len = sizeof(sReportCache);
- btif_config_get_bin("Remote", bdstr, "HidReport", (uint8_t *)sReportCache, &len);
+ btif_config_get_bin(bdstr, "HidReport", (uint8_t *)sReportCache, &len);
*p_num_rpt = len / sizeof(tBTA_HH_RPT_CACHE_ENTRY);
BTIF_TRACE_DEBUG("%s() - Loaded %d reports; dev=%s", __FUNCTION__, *p_num_rpt, bdstr);
@@ -555,7 +555,7 @@
sprintf(bdstr, "%02x:%02x:%02x:%02x:%02x:%02x",
remote_bda[0], remote_bda[1], remote_bda[2],
remote_bda[3], remote_bda[4], remote_bda[5]);
- btif_config_remove("Remote", bdstr, "HidReport");
+ btif_config_remove(bdstr, "HidReport");
BTIF_TRACE_DEBUG("%s() - Reset cache for bda %s", __FUNCTION__, bdstr);
}
diff --git a/system/btif/include/btif_config.h b/system/btif/include/btif_config.h
index cdb848e..2e0839a 100644
--- a/system/btif/include/btif_config.h
+++ b/system/btif/include/btif_config.h
@@ -28,17 +28,17 @@
bool btif_config_init(void);
void btif_config_cleanup(void);
-bool btif_config_has_key(const char *section, const char *key);
-bool btif_config_exist(const char *section, const char *key, const char *name);
-bool btif_config_get_int(const char *section, const char *key, const char *name, int *value);
-bool btif_config_set_int(const char *section, const char *key, const char *name, int value);
-bool btif_config_get_str(const char *section, const char *key, const char *name, char *value, int *length);
-bool btif_config_set_str(const char *section, const char *key, const char *name, const char *value);
-bool btif_config_get_bin(const char *section, const char *key, const char *name, uint8_t *value, size_t *length);
-bool btif_config_set_bin(const char *section, const char *key, const char *name, const uint8_t *value, size_t length);
-bool btif_config_remove(const char *section, const char *key, const char *name);
+bool btif_config_has_section(const char *section);
+bool btif_config_exist(const char *section, const char *key);
+bool btif_config_get_int(const char *section, const char *key, int *value);
+bool btif_config_set_int(const char *section, const char *key, int value);
+bool btif_config_get_str(const char *section, const char *key, char *value, int *length);
+bool btif_config_set_str(const char *section, const char *key, const char *value);
+bool btif_config_get_bin(const char *section, const char *key, uint8_t *value, size_t *length);
+bool btif_config_set_bin(const char *section, const char *key, const uint8_t *value, size_t length);
+bool btif_config_remove(const char *section, const char *key);
-size_t btif_config_get_bin_length(const char *section, const char *key, const char *name);
+size_t btif_config_get_bin_length(const char *section, const char *key);
const btif_config_section_iter_t *btif_config_section_begin(void);
const btif_config_section_iter_t *btif_config_section_end(void);
diff --git a/system/btif/include/btif_storage.h b/system/btif/include/btif_storage.h
index f64c695..30628a1 100644
--- a/system/btif/include/btif_storage.h
+++ b/system/btif/include/btif_storage.h
@@ -30,8 +30,6 @@
#define BTIF_STORAGE_FILL_PROPERTY(p_prop, t, l, p_v) \
(p_prop)->type = t;(p_prop)->len = l; (p_prop)->val = (p_v);
-#define BTIF_STORAGE_MAX_ALLOWED_REMOTE_DEVICE 512
-
/*******************************************************************************
** Functions
********************************************************************************/
diff --git a/system/btif/src/btif_config.c b/system/btif/src/btif_config.c
index 820356c..38c319c 100644
--- a/system/btif/src/btif_config.c
+++ b/system/btif/src/btif_config.c
@@ -53,7 +53,7 @@
char bd_addr_str[18] = {0};
bd2str(&bda, &bd_addr_str);
- if (!btif_config_get_int("Remote", bd_addr_str, "DevType", p_device_type))
+ if (!btif_config_get_int(bd_addr_str, "DevType", p_device_type))
return FALSE;
ALOGD("%s: Device [%s] type %d", __FUNCTION__, bd_addr_str, *p_device_type);
@@ -71,7 +71,7 @@
char bd_addr_str[18] = {0};
bd2str(&bda, &bd_addr_str);
- if (!btif_config_get_int("Remote", bd_addr_str, "AddrType", p_addr_type))
+ if (!btif_config_get_int(bd_addr_str, "AddrType", p_addr_type))
return FALSE;
ALOGD("%s: Device [%s] address type %d", __FUNCTION__, bd_addr_str, *p_addr_type);
@@ -131,65 +131,65 @@
config = NULL;
}
-bool btif_config_has_key(UNUSED_ATTR const char *section, const char *key) {
+bool btif_config_has_section(const char *section) {
assert(config != NULL);
- assert(key != NULL);
+ assert(section != NULL);
pthread_mutex_lock(&lock);
- bool ret = config_has_section(config, key);
+ bool ret = config_has_section(config, section);
pthread_mutex_unlock(&lock);
return ret;
}
-bool btif_config_exist(UNUSED_ATTR const char *section, const char *key, const char *name) {
+bool btif_config_exist(const char *section, const char *key) {
assert(config != NULL);
+ assert(section != NULL);
assert(key != NULL);
- assert(name != NULL);
pthread_mutex_lock(&lock);
- bool ret = config_has_key(config, key, name);
+ bool ret = config_has_key(config, section, key);
pthread_mutex_unlock(&lock);
return ret;
}
-bool btif_config_get_int(UNUSED_ATTR const char *section, const char *key, const char *name, int *value) {
+bool btif_config_get_int(const char *section, const char *key, int *value) {
assert(config != NULL);
+ assert(section != NULL);
assert(key != NULL);
- assert(name != NULL);
assert(value != NULL);
pthread_mutex_lock(&lock);
- bool ret = config_has_key(config, key, name);
+ bool ret = config_has_key(config, section, key);
if (ret)
- *value = config_get_int(config, key, name, *value);
+ *value = config_get_int(config, section, key, *value);
pthread_mutex_unlock(&lock);
return ret;
}
-bool btif_config_set_int(UNUSED_ATTR const char *section, const char *key, const char *name, int value) {
+bool btif_config_set_int(const char *section, const char *key, int value) {
assert(config != NULL);
+ assert(section != NULL);
assert(key != NULL);
- assert(name != NULL);
pthread_mutex_lock(&lock);
- config_set_int(config, key, name, value);
+ config_set_int(config, section, key, value);
pthread_mutex_unlock(&lock);
return true;
}
-bool btif_config_get_str(UNUSED_ATTR const char *section, const char *key, const char *name, char *value, int *length) {
+bool btif_config_get_str(const char *section, const char *key, char *value, int *length) {
assert(config != NULL);
+ assert(section != NULL);
assert(key != NULL);
- assert(name != NULL);
assert(value != NULL);
assert(length != NULL);
pthread_mutex_lock(&lock);
- const char *stored_value = config_get_string(config, key, name, NULL);
+ const char *stored_value = config_get_string(config, section, key, NULL);
pthread_mutex_unlock(&lock);
if (!stored_value)
@@ -201,28 +201,28 @@
return true;
}
-bool btif_config_set_str(UNUSED_ATTR const char *section, const char *key, const char *name, const char *value) {
+bool btif_config_set_str(const char *section, const char *key, const char *value) {
assert(config != NULL);
+ assert(section != NULL);
assert(key != NULL);
- assert(name != NULL);
assert(value != NULL);
pthread_mutex_lock(&lock);
- config_set_string(config, key, name, value);
+ config_set_string(config, section, key, value);
pthread_mutex_unlock(&lock);
return true;
}
-bool btif_config_get_bin(UNUSED_ATTR const char *section, const char *key, const char *name, uint8_t *value, size_t *length) {
+bool btif_config_get_bin(const char *section, const char *key, uint8_t *value, size_t *length) {
assert(config != NULL);
+ assert(section != NULL);
assert(key != NULL);
- assert(name != NULL);
assert(value != NULL);
assert(length != NULL);
pthread_mutex_lock(&lock);
- const char *value_str = config_get_string(config, key, name, NULL);
+ const char *value_str = config_get_string(config, section, key, NULL);
pthread_mutex_unlock(&lock);
if (!value_str)
@@ -242,13 +242,13 @@
return true;
}
-size_t btif_config_get_bin_length(UNUSED_ATTR const char *section, const char *key, const char *name) {
+size_t btif_config_get_bin_length(const char *section, const char *key) {
assert(config != NULL);
+ assert(section != NULL);
assert(key != NULL);
- assert(name != NULL);
pthread_mutex_lock(&lock);
- const char *value_str = config_get_string(config, key, name, NULL);
+ const char *value_str = config_get_string(config, section, key, NULL);
pthread_mutex_unlock(&lock);
if (!value_str)
@@ -258,12 +258,12 @@
return ((value_len % 2) != 0) ? 0 : (value_len / 2);
}
-bool btif_config_set_bin(UNUSED_ATTR const char *section, const char *key, const char *name, const uint8_t *value, size_t length) {
+bool btif_config_set_bin(const char *section, const char *key, const uint8_t *value, size_t length) {
static const char *lookup = "0123456789abcdef";
assert(config != NULL);
+ assert(section != NULL);
assert(key != NULL);
- assert(name != NULL);
assert(value != NULL);
char *str = (char *)calloc(length * 2 + 1, 1);
@@ -276,7 +276,7 @@
}
pthread_mutex_lock(&lock);
- config_set_string(config, key, name, str);
+ config_set_string(config, section, key, str);
pthread_mutex_unlock(&lock);
free(str);
@@ -305,13 +305,13 @@
return config_section_name((const config_section_node_t *)section);
}
-bool btif_config_remove(UNUSED_ATTR const char *section, const char *key, const char *name) {
+bool btif_config_remove(const char *section, const char *key) {
assert(config != NULL);
+ assert(section != NULL);
assert(key != NULL);
- assert(name != NULL);
pthread_mutex_lock(&lock);
- bool ret = config_remove_key(config, key, name);
+ bool ret = config_remove_key(config, section, key);
pthread_mutex_unlock(&lock);
return ret;
diff --git a/system/btif/src/btif_core.c b/system/btif/src/btif_core.c
index e917b80..0740f4a 100644
--- a/system/btif/src/btif_core.c
+++ b/system/btif/src/btif_core.c
@@ -398,7 +398,7 @@
if(!valid_bda)
{
val_size = sizeof(val);
- if(btif_config_get_str("Local", "Adapter", "Address", val, &val_size))
+ if(btif_config_get_str("Adapter", "Address", val, &val_size))
{
str2bd(val, local_addr);
BTIF_TRACE_DEBUG("local bdaddr from bt_config.xml is %s", val);
@@ -446,7 +446,7 @@
bdstr_t bdstr;
bd2str(local_addr, &bdstr);
val_size = sizeof(val);
- if (btif_config_get_str("Local", "Adapter", "Address", val, &val_size))
+ if (btif_config_get_str("Adapter", "Address", val, &val_size))
{
if (strcmp(bdstr, val) ==0)
{
@@ -454,7 +454,7 @@
return;
}
}
- btif_config_set_str("Local", "Adapter", "Address", bdstr);
+ btif_config_set_str("Adapter", "Address", bdstr);
}
/*****************************************************************************
@@ -588,7 +588,7 @@
//save the bd address to config file
bd2str(&btif_local_bd_addr, &buf);
- btif_config_set_str("Local", "Adapter", "Address", buf);
+ btif_config_set_str("Adapter", "Address", buf);
btif_config_save();
//fire HAL callback for property change
diff --git a/system/btif/src/btif_dm.c b/system/btif/src/btif_dm.c
index 4930017..3e047d9 100644
--- a/system/btif/src/btif_dm.c
+++ b/system/btif/src/btif_dm.c
@@ -410,7 +410,7 @@
{
bdstr_t bdstr;
bd2str(remote_bdaddr, &bdstr);
- if(btif_config_exist("Remote", bdstr, "HidAppId"))
+ if(btif_config_exist(bdstr, "HidAppId"))
return TRUE;
}
}
@@ -638,16 +638,16 @@
bd2str(bd_addr, &bdstr);
if (transport == BT_TRANSPORT_LE)
{
- if (!btif_config_get_int("Remote", (char const *)&bdstr,"DevType", &device_type))
+ if (!btif_config_get_int((char const *)&bdstr,"DevType", &device_type))
{
- btif_config_set_int("Remote", bdstr, "DevType", BT_DEVICE_TYPE_BLE);
+ btif_config_set_int(bdstr, "DevType", BT_DEVICE_TYPE_BLE);
}
if (btif_storage_get_remote_addr_type(bd_addr, &addr_type) != BT_STATUS_SUCCESS)
{
btif_storage_set_remote_addr_type(bd_addr, BLE_ADDR_PUBLIC);
}
}
- if((btif_config_get_int("Remote", (char const *)&bdstr,"DevType", &device_type) &&
+ if((btif_config_get_int((char const *)&bdstr,"DevType", &device_type) &&
(btif_storage_get_remote_addr_type(bd_addr, &addr_type) == BT_STATUS_SUCCESS) &&
(device_type == BT_DEVICE_TYPE_BLE)) || (transport == BT_TRANSPORT_LE))
{
diff --git a/system/btif/src/btif_gatt_client.c b/system/btif/src/btif_gatt_client.c
index 644c80f..7bbc473 100644
--- a/system/btif/src/btif_gatt_client.c
+++ b/system/btif/src/btif_gatt_client.c
@@ -2093,7 +2093,7 @@
char bd_addr_str[18] = {0};
bd2str(bd_addr, &bd_addr_str);
- if (btif_config_get_int("Remote", bd_addr_str, "DevType", &device_type))
+ if (btif_config_get_int(bd_addr_str, "DevType", &device_type))
return device_type;
return 0;
}
diff --git a/system/btif/src/btif_storage.c b/system/btif/src/btif_storage.c
index e7ec65a..266f72f 100644
--- a/system/btif/src/btif_storage.c
+++ b/system/btif/src/btif_storage.c
@@ -230,16 +230,16 @@
switch(prop->type)
{
case BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP:
- btif_config_set_int("Remote", bdstr,
+ btif_config_set_int(bdstr,
BTIF_STORAGE_PATH_REMOTE_DEVTIME, (int)time(NULL));
break;
case BT_PROPERTY_BDNAME:
strncpy(value, (char*)prop->val, prop->len);
value[prop->len]='\0';
if(remote_bd_addr)
- btif_config_set_str("Remote", bdstr,
+ btif_config_set_str(bdstr,
BTIF_STORAGE_PATH_REMOTE_NAME, value);
- else btif_config_set_str("Local", "Adapter",
+ else btif_config_set_str("Adapter",
BTIF_STORAGE_KEY_ADAPTER_NAME, value);
/* save name immediately */
btif_config_save();
@@ -247,24 +247,24 @@
case BT_PROPERTY_REMOTE_FRIENDLY_NAME:
strncpy(value, (char*)prop->val, prop->len);
value[prop->len]='\0';
- btif_config_set_str("Remote", bdstr, BTIF_STORAGE_PATH_REMOTE_ALIASE, value);
+ btif_config_set_str(bdstr, BTIF_STORAGE_PATH_REMOTE_ALIASE, value);
/* save friendly name immediately */
btif_config_save();
break;
case BT_PROPERTY_ADAPTER_SCAN_MODE:
- btif_config_set_int("Local", "Adapter",
+ btif_config_set_int("Adapter",
BTIF_STORAGE_KEY_ADAPTER_SCANMODE, *(int*)prop->val);
break;
case BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT:
- btif_config_set_int("Local", "Adapter",
+ btif_config_set_int("Adapter",
BTIF_STORAGE_KEY_ADAPTER_DISC_TIMEOUT, *(int*)prop->val);
break;
case BT_PROPERTY_CLASS_OF_DEVICE:
- btif_config_set_int("Remote", bdstr,
+ btif_config_set_int(bdstr,
BTIF_STORAGE_PATH_REMOTE_DEVCLASS, *(int*)prop->val);
break;
case BT_PROPERTY_TYPE_OF_DEVICE:
- btif_config_set_int("Remote", bdstr,
+ btif_config_set_int(bdstr,
BTIF_STORAGE_PATH_REMOTE_DEVTYPE, *(int*)prop->val);
break;
case BT_PROPERTY_UUIDS:
@@ -281,7 +281,7 @@
//strcat(value, ";");
strcat(value, " ");
}
- btif_config_set_str("Remote", bdstr, BTIF_STORAGE_PATH_REMOTE_SERVICE, value);
+ btif_config_set_str(bdstr, BTIF_STORAGE_PATH_REMOTE_SERVICE, value);
btif_config_save();
break;
}
@@ -292,11 +292,11 @@
if (!info)
return FALSE;
- btif_config_set_int("Remote", bdstr,
+ btif_config_set_int(bdstr,
BTIF_STORAGE_PATH_REMOTE_VER_MFCT, info->manufacturer);
- btif_config_set_int("Remote", bdstr,
+ btif_config_set_int(bdstr,
BTIF_STORAGE_PATH_REMOTE_VER_VER, info->version);
- btif_config_set_int("Remote", bdstr,
+ btif_config_set_int(bdstr,
BTIF_STORAGE_PATH_REMOTE_VER_SUBVER, info->sub_ver);
btif_config_save();
} break;
@@ -323,16 +323,16 @@
{
case BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP:
if(prop->len >= (int)sizeof(int))
- ret = btif_config_get_int("Remote", bdstr,
+ ret = btif_config_get_int(bdstr,
BTIF_STORAGE_PATH_REMOTE_DEVTIME, (int*)prop->val);
break;
case BT_PROPERTY_BDNAME:
{
int len = prop->len;
if(remote_bd_addr)
- ret = btif_config_get_str("Remote", bdstr,
+ ret = btif_config_get_str(bdstr,
BTIF_STORAGE_PATH_REMOTE_NAME, (char*)prop->val, &len);
- else ret = btif_config_get_str("Local", "Adapter",
+ else ret = btif_config_get_str("Adapter",
BTIF_STORAGE_KEY_ADAPTER_NAME, (char*)prop->val, &len);
if(ret && len && len <= prop->len)
prop->len = len - 1;
@@ -346,7 +346,7 @@
case BT_PROPERTY_REMOTE_FRIENDLY_NAME:
{
int len = prop->len;
- ret = btif_config_get_str("Remote", bdstr,
+ ret = btif_config_get_str(bdstr,
BTIF_STORAGE_PATH_REMOTE_ALIASE, (char*)prop->val, &len);
if(ret && len && len <= prop->len)
prop->len = len - 1;
@@ -359,29 +359,28 @@
}
case BT_PROPERTY_ADAPTER_SCAN_MODE:
if(prop->len >= (int)sizeof(int))
- ret = btif_config_get_int("Local", "Adapter",
+ ret = btif_config_get_int("Adapter",
BTIF_STORAGE_KEY_ADAPTER_SCANMODE, (int*)prop->val);
break;
case BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT:
if(prop->len >= (int)sizeof(int))
- ret = btif_config_get_int("Local", "Adapter",
+ ret = btif_config_get_int("Adapter",
BTIF_STORAGE_KEY_ADAPTER_DISC_TIMEOUT, (int*)prop->val);
break;
case BT_PROPERTY_CLASS_OF_DEVICE:
if(prop->len >= (int)sizeof(int))
- ret = btif_config_get_int("Remote", bdstr,
+ ret = btif_config_get_int(bdstr,
BTIF_STORAGE_PATH_REMOTE_DEVCLASS, (int*)prop->val);
break;
case BT_PROPERTY_TYPE_OF_DEVICE:
if(prop->len >= (int)sizeof(int))
- ret = btif_config_get_int("Remote",
- bdstr, BTIF_STORAGE_PATH_REMOTE_DEVTYPE, (int*)prop->val);
+ ret = btif_config_get_int(bdstr, BTIF_STORAGE_PATH_REMOTE_DEVTYPE, (int*)prop->val);
break;
case BT_PROPERTY_UUIDS:
{
char value[1280];
int size = sizeof(value);
- if(btif_config_get_str("Remote", bdstr,
+ if(btif_config_get_str(bdstr,
BTIF_STORAGE_PATH_REMOTE_SERVICE, value, &size))
{
bt_uuid_t *p_uuid = (bt_uuid_t*)prop->val;
@@ -403,15 +402,15 @@
if(prop->len >= (int)sizeof(bt_remote_version_t))
{
- ret = btif_config_get_int("Remote", bdstr,
+ ret = btif_config_get_int(bdstr,
BTIF_STORAGE_PATH_REMOTE_VER_MFCT, &info->manufacturer);
if (ret == TRUE)
- ret = btif_config_get_int("Remote", bdstr,
+ ret = btif_config_get_int(bdstr,
BTIF_STORAGE_PATH_REMOTE_VER_VER, &info->version);
if (ret == TRUE)
- ret = btif_config_get_int("Remote", bdstr,
+ ret = btif_config_get_int(bdstr,
BTIF_STORAGE_PATH_REMOTE_VER_SUBVER, &info->sub_ver);
}
} break;
@@ -440,10 +439,10 @@
LINK_KEY link_key;
size_t size = sizeof(link_key);
- if(btif_config_get_bin("Remote", bdstr, "LinkKey", (uint8_t *)link_key, &size))
+ if(btif_config_get_bin(bdstr, "LinkKey", (uint8_t *)link_key, &size))
{
int linkkey_type;
- if(btif_config_get_int("Remote", bdstr, "LinkKeyType", &linkkey_type))
+ if(btif_config_get_int(bdstr, "LinkKeyType", &linkkey_type))
{
bt_linkkey_file_found = TRUE;
}
@@ -494,25 +493,25 @@
BTIF_TRACE_DEBUG("Remote device:%s", name);
LINK_KEY link_key;
size_t size = sizeof(link_key);
- if(btif_config_get_bin("Remote", name, "LinkKey", link_key, &size))
+ if(btif_config_get_bin(name, "LinkKey", link_key, &size))
{
int linkkey_type;
- if(btif_config_get_int("Remote", name, "LinkKeyType", &linkkey_type))
+ if(btif_config_get_int(name, "LinkKeyType", &linkkey_type))
{
//int pin_len;
- //btif_config_get_int("Remote", name, "PinLength", &pin_len))
+ //btif_config_get_int(name, "PinLength", &pin_len))
bt_bdaddr_t bd_addr;
str2bd(name, &bd_addr);
if(add)
{
DEV_CLASS dev_class = {0, 0, 0};
int cod;
- if(btif_config_get_int("Remote", name, "DevClass", &cod))
+ if(btif_config_get_int(name, "DevClass", &cod))
uint2devclass((UINT32)cod, dev_class);
BTA_DmAddDevice(bd_addr.address, dev_class, link_key, 0, 0, (UINT8)linkkey_type, 0);
#if BLE_INCLUDED == TRUE
- if (btif_config_get_int("Remote", name, "DevType", &device_type) &&
+ if (btif_config_get_int(name, "DevType", &device_type) &&
(device_type == BT_DEVICE_TYPE_DUMO) )
{
btif_gatts_add_bonded_dev_from_nv(bd_addr.address);
@@ -770,9 +769,9 @@
{
bdstr_t bdstr;
bd2str(remote_bd_addr, &bdstr);
- int ret = btif_config_set_int("Remote", bdstr, "LinkKeyType", (int)key_type);
- ret &= btif_config_set_int("Remote", bdstr, "PinLength", (int)pin_length);
- ret &= btif_config_set_bin("Remote", bdstr, "LinkKey", link_key, sizeof(LINK_KEY));
+ int ret = btif_config_set_int(bdstr, "LinkKeyType", (int)key_type);
+ ret &= btif_config_set_int(bdstr, "PinLength", (int)pin_length);
+ ret &= btif_config_set_bin(bdstr, "LinkKey", link_key, sizeof(LINK_KEY));
/* write bonded info immediately */
btif_config_flush();
return ret ? BT_STATUS_SUCCESS : BT_STATUS_FAIL;
@@ -794,12 +793,12 @@
bd2str(remote_bd_addr, &bdstr);
BTIF_TRACE_DEBUG("in bd addr:%s", bdstr);
int ret = 1;
- if(btif_config_exist("Remote", bdstr, "LinkKeyType"))
- ret &= btif_config_remove("Remote", bdstr, "LinkKeyType");
- if(btif_config_exist("Remote", bdstr, "PinLength"))
- ret &= btif_config_remove("Remote", bdstr, "PinLength");
- if(btif_config_exist("Remote", bdstr, "LinkKey"))
- ret &= btif_config_remove("Remote", bdstr, "LinkKey");
+ if(btif_config_exist(bdstr, "LinkKeyType"))
+ ret &= btif_config_remove(bdstr, "LinkKeyType");
+ if(btif_config_exist(bdstr, "PinLength"))
+ ret &= btif_config_remove(bdstr, "PinLength");
+ if(btif_config_exist(bdstr, "LinkKey"))
+ ret &= btif_config_remove(bdstr, "LinkKey");
/* write bonded info immediately */
btif_config_flush();
return ret ? BT_STATUS_SUCCESS : BT_STATUS_FAIL;
@@ -974,7 +973,7 @@
default:
return BT_STATUS_FAIL;
}
- int ret = btif_config_set_bin("Remote", bdstr, name, (const uint8_t *)key, key_length);
+ int ret = btif_config_set_bin(bdstr, name, (const uint8_t *)key, key_length);
btif_config_save();
return ret ? BT_STATUS_SUCCESS : BT_STATUS_FAIL;
}
@@ -1018,7 +1017,7 @@
return BT_STATUS_FAIL;
}
size_t length = key_length;
- int ret = btif_config_get_bin("Remote", bdstr, name, (uint8_t *)key_value, &length);
+ int ret = btif_config_get_bin(bdstr, name, (uint8_t *)key_value, &length);
return ret ? BT_STATUS_SUCCESS : BT_STATUS_FAIL;
}
@@ -1039,16 +1038,16 @@
bd2str(remote_bd_addr, &bdstr);
BTIF_TRACE_DEBUG(" %s in bd addr:%s",__FUNCTION__, bdstr);
int ret = 1;
- if(btif_config_exist("Remote", bdstr, "LE_KEY_PENC"))
- ret &= btif_config_remove("Remote", bdstr, "LE_KEY_PENC");
- if(btif_config_exist("Remote", bdstr, "LE_KEY_PID"))
- ret &= btif_config_remove("Remote", bdstr, "LE_KEY_PID");
- if(btif_config_exist("Remote", bdstr, "LE_KEY_PCSRK"))
- ret &= btif_config_remove("Remote", bdstr, "LE_KEY_PCSRK");
- if(btif_config_exist("Remote", bdstr, "LE_KEY_LENC"))
- ret &= btif_config_remove("Remote", bdstr, "LE_KEY_LENC");
- if(btif_config_exist("Remote", bdstr, "LE_KEY_LCSRK"))
- ret &= btif_config_remove("Remote", bdstr, "LE_KEY_LCSRK");
+ if(btif_config_exist(bdstr, "LE_KEY_PENC"))
+ ret &= btif_config_remove(bdstr, "LE_KEY_PENC");
+ if(btif_config_exist(bdstr, "LE_KEY_PID"))
+ ret &= btif_config_remove(bdstr, "LE_KEY_PID");
+ if(btif_config_exist(bdstr, "LE_KEY_PCSRK"))
+ ret &= btif_config_remove(bdstr, "LE_KEY_PCSRK");
+ if(btif_config_exist(bdstr, "LE_KEY_LENC"))
+ ret &= btif_config_remove(bdstr, "LE_KEY_LENC");
+ if(btif_config_exist(bdstr, "LE_KEY_LCSRK"))
+ ret &= btif_config_remove(bdstr, "LE_KEY_LCSRK");
btif_config_save();
return ret ? BT_STATUS_SUCCESS : BT_STATUS_FAIL;
}
@@ -1085,7 +1084,7 @@
default:
return BT_STATUS_FAIL;
}
- int ret = btif_config_set_bin("Local", "Adapter", name, (const uint8_t *)key, key_length);
+ int ret = btif_config_set_bin("Adapter", name, (const uint8_t *)key, key_length);
btif_config_save();
return ret ? BT_STATUS_SUCCESS : BT_STATUS_FAIL;
}
@@ -1123,7 +1122,7 @@
return BT_STATUS_FAIL;
}
size_t length = key_length;
- int ret = btif_config_get_bin("Local", "Adapter", name, (uint8_t *)key_value, &length);
+ int ret = btif_config_get_bin("Adapter", name, (uint8_t *)key_value, &length);
return ret ? BT_STATUS_SUCCESS : BT_STATUS_FAIL;
}
@@ -1140,14 +1139,14 @@
bt_status_t btif_storage_remove_ble_local_keys(void)
{
int ret = 1;
- if(btif_config_exist("Local", "Adapter", "LE_LOCAL_KEY_IR"))
- ret &= btif_config_remove("Local", "Adapter", "LE_LOCAL_KEY_IR");
- if(btif_config_exist("Local", "Adapter", "LE_LOCAL_KEY_IRK"))
- ret &= btif_config_remove("Local", "Adapter", "LE_LOCAL_KEY_IRK");
- if(btif_config_exist("Local", "Adapter", "LE_LOCAL_KEY_DHK"))
- ret &= btif_config_remove("Local", "Adapter", "LE_LOCAL_KEY_DHK");
- if(btif_config_exist("Local", "Adapter", "LE_LOCAL_KEY_ER"))
- ret &= btif_config_remove("Local", "Adapter", "LE_LOCAL_KEY_ER");
+ if(btif_config_exist("Adapter", "LE_LOCAL_KEY_IR"))
+ ret &= btif_config_remove("Adapter", "LE_LOCAL_KEY_IR");
+ if(btif_config_exist("Adapter", "LE_LOCAL_KEY_IRK"))
+ ret &= btif_config_remove("Adapter", "LE_LOCAL_KEY_IRK");
+ if(btif_config_exist("Adapter", "LE_LOCAL_KEY_DHK"))
+ ret &= btif_config_remove("Adapter", "LE_LOCAL_KEY_DHK");
+ if(btif_config_exist("Adapter", "LE_LOCAL_KEY_ER"))
+ ret &= btif_config_remove("Adapter", "LE_LOCAL_KEY_ER");
btif_config_save();
return ret ? BT_STATUS_SUCCESS : BT_STATUS_FAIL;
}
@@ -1164,7 +1163,7 @@
BOOLEAN key_found = FALSE;
tBTA_LE_KEY_VALUE *p;
- if(!btif_config_get_int("Remote", remote_bd_addr,"DevType", &device_type))
+ if(!btif_config_get_int(remote_bd_addr,"DevType", &device_type))
return BT_STATUS_FAIL;
if(device_type == BT_DEVICE_TYPE_BLE)
{
@@ -1330,7 +1329,7 @@
{
bdstr_t bdstr;
bd2str(remote_bd_addr, &bdstr);
- int ret = btif_config_set_int("Remote", bdstr, "AddrType", (int)addr_type);
+ int ret = btif_config_set_int(bdstr, "AddrType", (int)addr_type);
btif_config_save();
return ret ? BT_STATUS_SUCCESS : BT_STATUS_FAIL;
}
@@ -1350,7 +1349,7 @@
{
bdstr_t bdstr;
bd2str(remote_bd_addr, &bdstr);
- int ret = btif_config_get_int("Remote", bdstr, "AddrType", addr_type);
+ int ret = btif_config_get_int(bdstr, "AddrType", addr_type);
return ret ? BT_STATUS_SUCCESS : BT_STATUS_FAIL;
}
#endif
@@ -1375,17 +1374,17 @@
bdstr_t bdstr;
BTIF_TRACE_DEBUG("btif_storage_add_hid_device_info:");
bd2str(remote_bd_addr, &bdstr);
- btif_config_set_int("Remote", bdstr, "HidAttrMask", attr_mask);
- btif_config_set_int("Remote", bdstr, "HidSubClass", sub_class);
- btif_config_set_int("Remote", bdstr, "HidAppId", app_id);
- btif_config_set_int("Remote", bdstr, "HidVendorId", vendor_id);
- btif_config_set_int("Remote", bdstr, "HidProductId", product_id);
- btif_config_set_int("Remote", bdstr, "HidVersion", version);
- btif_config_set_int("Remote", bdstr, "HidCountryCode", ctry_code);
- btif_config_set_int("Remote", bdstr, "HidSSRMaxLatency", ssr_max_latency);
- btif_config_set_int("Remote", bdstr, "HidSSRMinTimeout", ssr_min_tout);
+ btif_config_set_int(bdstr, "HidAttrMask", attr_mask);
+ btif_config_set_int(bdstr, "HidSubClass", sub_class);
+ btif_config_set_int(bdstr, "HidAppId", app_id);
+ btif_config_set_int(bdstr, "HidVendorId", vendor_id);
+ btif_config_set_int(bdstr, "HidProductId", product_id);
+ btif_config_set_int(bdstr, "HidVersion", version);
+ btif_config_set_int(bdstr, "HidCountryCode", ctry_code);
+ btif_config_set_int(bdstr, "HidSSRMaxLatency", ssr_max_latency);
+ btif_config_set_int(bdstr, "HidSSRMinTimeout", ssr_min_tout);
if(dl_len > 0)
- btif_config_set_bin("Remote", bdstr, "HidDescriptor", dsc_list, dl_len);
+ btif_config_set_bin(bdstr, "HidDescriptor", dsc_list, dl_len);
btif_config_save();
return BT_STATUS_SUCCESS;
}
@@ -1419,42 +1418,42 @@
int value;
if(btif_in_fetch_bonded_device(name) == BT_STATUS_SUCCESS)
{
- if(btif_config_get_int("Remote", name, "HidAttrMask", &value))
+ if(btif_config_get_int(name, "HidAttrMask", &value))
{
attr_mask = (uint16_t)value;
- btif_config_get_int("Remote", name, "HidSubClass", &value);
+ btif_config_get_int(name, "HidSubClass", &value);
sub_class = (uint8_t)value;
- btif_config_get_int("Remote", name, "HidAppId", &value);
+ btif_config_get_int(name, "HidAppId", &value);
app_id = (uint8_t)value;
- btif_config_get_int("Remote", name, "HidVendorId", &value);
+ btif_config_get_int(name, "HidVendorId", &value);
dscp_info.vendor_id = (uint16_t) value;
- btif_config_get_int("Remote", name, "HidProductId", &value);
+ btif_config_get_int(name, "HidProductId", &value);
dscp_info.product_id = (uint16_t) value;
- btif_config_get_int("Remote", name, "HidVersion", &value);
+ btif_config_get_int(name, "HidVersion", &value);
dscp_info.version = (uint8_t) value;
- btif_config_get_int("Remote", name, "HidCountryCode", &value);
+ btif_config_get_int(name, "HidCountryCode", &value);
dscp_info.ctry_code = (uint8_t) value;
value = 0;
- btif_config_get_int("Remote", name, "HidSSRMaxLatency", &value);
+ btif_config_get_int(name, "HidSSRMaxLatency", &value);
dscp_info.ssr_max_latency = (uint16_t) value;
value = 0;
- btif_config_get_int("Remote", name, "HidSSRMinTimeout", &value);
+ btif_config_get_int(name, "HidSSRMinTimeout", &value);
dscp_info.ssr_min_tout = (uint16_t) value;
- size_t len = btif_config_get_bin_length("Remote", name, "HidDescriptor");
+ size_t len = btif_config_get_bin_length(name, "HidDescriptor");
if(len > 0)
{
dscp_info.descriptor.dl_len = (uint16_t)len;
dscp_info.descriptor.dsc_list = (uint8_t*)alloca(len);
- btif_config_get_bin("Remote", name, "HidDescriptor", (uint8_t *)dscp_info.descriptor.dsc_list, &len);
+ btif_config_get_bin(name, "HidDescriptor", (uint8_t *)dscp_info.descriptor.dsc_list, &len);
}
str2bd(name, &bd_addr);
// add extracted information to BTA HH
@@ -1467,7 +1466,7 @@
}
else
{
- if(btif_config_get_int("Remote", name, "HidAttrMask", &value))
+ if(btif_config_get_int(name, "HidAttrMask", &value))
{
btif_storage_remove_hid_info(&bd_addr);
str2bd(name, &bd_addr);
@@ -1495,16 +1494,16 @@
bdstr_t bdstr;
bd2str(remote_bd_addr, &bdstr);
- btif_config_remove("Remote", bdstr, "HidAttrMask");
- btif_config_remove("Remote", bdstr, "HidSubClass");
- btif_config_remove("Remote", bdstr, "HidAppId");
- btif_config_remove("Remote", bdstr, "HidVendorId");
- btif_config_remove("Remote", bdstr, "HidProductId");
- btif_config_remove("Remote", bdstr, "HidVersion");
- btif_config_remove("Remote", bdstr, "HidCountryCode");
- btif_config_remove("Remote", bdstr, "HidSSRMaxLatency");
- btif_config_remove("Remote", bdstr, "HidSSRMinTimeout");
- btif_config_remove("Remote", bdstr, "HidDescriptor");
+ btif_config_remove(bdstr, "HidAttrMask");
+ btif_config_remove(bdstr, "HidSubClass");
+ btif_config_remove(bdstr, "HidAppId");
+ btif_config_remove(bdstr, "HidVendorId");
+ btif_config_remove(bdstr, "HidProductId");
+ btif_config_remove(bdstr, "HidVersion");
+ btif_config_remove(bdstr, "HidCountryCode");
+ btif_config_remove(bdstr, "HidSSRMaxLatency");
+ btif_config_remove(bdstr, "HidSSRMinTimeout");
+ btif_config_remove(bdstr, "HidDescriptor");
btif_config_save();
return BT_STATUS_SUCCESS;
}
@@ -1523,10 +1522,10 @@
{
bt_status_t bt_status = BT_STATUS_SUCCESS;
- if (!btif_config_exist("Local", BTIF_STORAGE_HL_APP, BTIF_STORAGE_HL_APP_CB))
+ if (!btif_config_exist(BTIF_STORAGE_HL_APP, BTIF_STORAGE_HL_APP_CB))
{
memset(value, 0, value_size);
- if (!btif_config_set_bin("Local", BTIF_STORAGE_HL_APP,BTIF_STORAGE_HL_APP_CB,
+ if (!btif_config_set_bin(BTIF_STORAGE_HL_APP,BTIF_STORAGE_HL_APP_CB,
(const uint8_t *)value, value_size))
{
bt_status = BT_STATUS_FAIL;
@@ -1539,7 +1538,7 @@
else
{
size_t read_size = value_size;
- if (!btif_config_get_bin("Local", BTIF_STORAGE_HL_APP, BTIF_STORAGE_HL_APP_CB,
+ if (!btif_config_get_bin(BTIF_STORAGE_HL_APP, BTIF_STORAGE_HL_APP_CB,
(uint8_t *)value, &read_size))
{
bt_status = BT_STATUS_FAIL;
@@ -1573,7 +1572,7 @@
*******************************************************************************/
bt_status_t btif_storage_load_autopair_device_list() {
// Configuration has already been loaded. No need to reload.
- if (btif_config_has_key("Local", BTIF_STORAGE_PATH_AUTOPAIR_BLACKLIST)) {
+ if (btif_config_has_section(BTIF_STORAGE_PATH_AUTOPAIR_BLACKLIST)) {
return BT_STATUS_SUCCESS;
}
@@ -1594,7 +1593,7 @@
for (size_t i = 0; i < ARRAY_SIZE(key_names); ++i) {
const char *value = config_get_string(config, CONFIG_DEFAULT_SECTION, key_names[i], NULL);
if (value) {
- btif_config_set_str("Local", BTIF_STORAGE_PATH_AUTOPAIR_BLACKLIST, key_names[i], value);
+ btif_config_set_str(BTIF_STORAGE_PATH_AUTOPAIR_BLACKLIST, key_names[i], value);
}
}
@@ -1627,7 +1626,7 @@
/* Consider only Lower Address Part from BD Address */
bdstr[8] = '\0';
- if(btif_config_get_str("Local", BTIF_STORAGE_PATH_AUTOPAIR_BLACKLIST,
+ if(btif_config_get_str(BTIF_STORAGE_PATH_AUTOPAIR_BLACKLIST,
BTIF_STORAGE_KEY_AUTOPAIR_BLACKLIST_ADDR, value, &value_size))
{
if (strcasestr(value,bdstr) != NULL)
@@ -1639,14 +1638,14 @@
if (dev_name_str != NULL)
{
value_size = sizeof(value);
- if(btif_config_get_str("Local", BTIF_STORAGE_PATH_AUTOPAIR_BLACKLIST,
+ if(btif_config_get_str(BTIF_STORAGE_PATH_AUTOPAIR_BLACKLIST,
BTIF_STORAGE_KEY_AUTOPAIR_BLACKLIST_EXACTNAME, value, &value_size))
{
if (strstr(value,dev_name_str) != NULL)
return TRUE;
}
value_size = sizeof(value);
- if(btif_config_get_str("Local", BTIF_STORAGE_PATH_AUTOPAIR_BLACKLIST,
+ if(btif_config_get_str(BTIF_STORAGE_PATH_AUTOPAIR_BLACKLIST,
BTIF_STORAGE_KEY_AUTOPAIR_BLACKLIST_PARTIALNAME, value, &value_size))
{
token = strtok(value, BTIF_AUTO_PAIR_CONF_VALUE_SEPARATOR);
@@ -1659,7 +1658,7 @@
}
}
}
- if(btif_config_get_str("Local", BTIF_STORAGE_PATH_AUTOPAIR_BLACKLIST,
+ if(btif_config_get_str(BTIF_STORAGE_PATH_AUTOPAIR_BLACKLIST,
BTIF_STORAGE_KEY_AUTOPAIR_DYNAMIC_BLACKLIST_ADDR, value, &value_size))
{
if (strstr(value,bdstr) != NULL)
@@ -1690,7 +1689,7 @@
strlcat(input_value,BTIF_AUTO_PAIR_CONF_VALUE_SEPARATOR, sizeof(input_value));
int line_size = sizeof(linebuf);
- if(btif_config_get_str("Local", BTIF_STORAGE_PATH_AUTOPAIR_BLACKLIST,
+ if(btif_config_get_str(BTIF_STORAGE_PATH_AUTOPAIR_BLACKLIST,
BTIF_STORAGE_KEY_AUTOPAIR_DYNAMIC_BLACKLIST_ADDR, linebuf, &line_size))
{
/* Append this address to the dynamic List of BD address */
@@ -1702,7 +1701,7 @@
}
/* Write back the key value */
- ret = btif_config_set_str("Local", BTIF_STORAGE_PATH_AUTOPAIR_BLACKLIST,
+ ret = btif_config_set_str(BTIF_STORAGE_PATH_AUTOPAIR_BLACKLIST,
BTIF_STORAGE_KEY_AUTOPAIR_DYNAMIC_BLACKLIST_ADDR, linebuf);
return ret ? BT_STATUS_SUCCESS:BT_STATUS_FAIL;
@@ -1732,7 +1731,7 @@
bdstr[8] = '\0';
int line_size = sizeof(linebuf);
- if(btif_config_get_str("Local", BTIF_STORAGE_PATH_AUTOPAIR_BLACKLIST,
+ if(btif_config_get_str(BTIF_STORAGE_PATH_AUTOPAIR_BLACKLIST,
BTIF_STORAGE_KEY_AUTOPAIR_FIXPIN_KBLIST, linebuf, &line_size))
{
if (strcasestr(linebuf,bdstr) != NULL)
@@ -1768,7 +1767,7 @@
return BT_STATUS_FAIL;
}
- ret = btif_config_set_int("Remote", bdstr,"DMTSupported", (int)dmt_supported);
+ ret = btif_config_set_int(bdstr,"DMTSupported", (int)dmt_supported);
return ret ? BT_STATUS_SUCCESS:BT_STATUS_FAIL;
}
@@ -1800,7 +1799,7 @@
return FALSE;
}
- btif_config_get_int("Remote", bdstr,"DMTSupported", &dmt_supported);
+ btif_config_get_int(bdstr,"DMTSupported", &dmt_supported);
return dmt_supported == 1 ? TRUE:FALSE;
}