Merge "service: Parametrize LowEnergyClient with Adapter for tests"
diff --git a/bta/dm/bta_dm_act.c b/bta/dm/bta_dm_act.c
index 4199144..f182551 100644
--- a/bta/dm/bta_dm_act.c
+++ b/bta/dm/bta_dm_act.c
@@ -1210,7 +1210,7 @@
if (BTM_IsInquiryActive())
{
- if (BTM_CancelInquiry() != BTM_CMD_STARTED)
+ if (BTM_CancelInquiry() == BTM_SUCCESS)
{
bta_dm_search_cancel_notify(NULL);
p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG));
diff --git a/btif/src/btif_config.c b/btif/src/btif_config.c
index 81bc660..d8cfc62 100644
--- a/btif/src/btif_config.c
+++ b/btif/src/btif_config.c
@@ -30,6 +30,8 @@
#include "bt_types.h"
#include "btcore/include/bdaddr.h"
#include "btcore/include/module.h"
+#include "btif_common.h"
+#include "btif_config.h"
#include "btif_config_transcode.h"
#include "btif_util.h"
#include "osi/include/alarm.h"
@@ -49,7 +51,7 @@
static const period_ms_t CONFIG_SETTLE_PERIOD_MS = 3000;
static void timer_config_save_cb(void *data);
-static void btif_config_write(void);
+static void btif_config_write(UINT16 event, char *p_param);
static void btif_config_devcache_cleanup(void);
// TODO(zachoverflow): Move these two functions out, because they are too specific for this file
@@ -364,8 +366,11 @@
assert(alarm_timer != NULL);
alarm_cancel(alarm_timer);
+ btif_config_write(0, NULL);
- btif_config_write();
+ pthread_mutex_lock(&lock);
+ config_save(config, CONFIG_FILE_PATH);
+ pthread_mutex_unlock(&lock);
}
int btif_config_clear(void){
@@ -389,10 +394,13 @@
}
static void timer_config_save_cb(UNUSED_ATTR void *data) {
- btif_config_write();
+ // Moving file I/O to btif context instead of timer callback because
+ // it usually takes a lot of time to be completed, introducing
+ // delays during A2DP playback causing blips or choppiness.
+ btif_transfer_context(btif_config_write, 0, NULL, 0, NULL);
}
-static void btif_config_write(void) {
+static void btif_config_write(UNUSED_ATTR UINT16 event, UNUSED_ATTR char *p_param) {
assert(config != NULL);
assert(alarm_timer != NULL);