Merge "Fix ASAN issue multiple definition of variable" into tizen
[platform/core/connectivity/bluetooth-frwk.git] / bt-service-adaptation / services / adapter / bt-service-core-adapter.c
index 7ea4045..581c1b6 100644 (file)
@@ -1002,6 +1002,11 @@ int _bt_init_profiles()
        if (ret != BLUETOOTH_ERROR_NONE)
                BT_ERR("_bt_gatt_init Failed");
 
+       /* Initialize HF Client */
+       ret = _bt_audio_initialize(BT_HFP_MODULE);
+       if (ret != BLUETOOTH_ERROR_NONE)
+               BT_ERR("_bt_audio_initialize(BT_HFP_MODULE) Failed");
+
        return BLUETOOTH_ERROR_NONE;
 }
 
@@ -1094,8 +1099,9 @@ static void __bt_adapter_handle_pending_requests(int service_function, void *use
        BT_INFO("+");
 
        /* Get method invocation context */
-       for (l = _bt_get_invocation_list(); l != NULL; l = g_slist_next(l)) {
+       for (l = _bt_get_invocation_list(); l != NULL; ) {
                req_info = l->data;
+               l = g_slist_next(l);
                if (req_info == NULL || req_info->service_function != service_function)
                        continue;
 
@@ -1180,14 +1186,14 @@ static gboolean __bt_adapter_post_set_enabled(gpointer user_data)
                        BT_ERR("Fail to set discoverable mode");
        } else {
                __bt_set_visible_mode();
+       }
 
-               /* add the vconf noti handler */
-               if (0 != vconf_notify_key_changed(VCONFKEY_SETAPPL_DEVICE_NAME_STR,
-                               (vconf_callback_fn)__bt_phone_name_changed_cb, NULL))
-                       BT_ERR("DEVICE_NAME key changed notification registration failed");
+       /* add the vconf noti handler */
+       if (0 != vconf_notify_key_changed(VCONFKEY_SETAPPL_DEVICE_NAME_STR,
+                       (vconf_callback_fn)__bt_phone_name_changed_cb, NULL))
+               BT_ERR("DEVICE_NAME key changed notification registration failed");
 
-               __bt_set_local_name();
-       }
+       __bt_set_local_name();
 
        /* Get All properties */
        if (OAL_STATUS_SUCCESS != adapter_get_properties())
@@ -1469,19 +1475,10 @@ static int __bt_adapter_state_discovery_request(gboolean enable,
        case ADAPTER_DISCOVERY_STARTING: {
                BT_INFO("Adapter is currently in discovery starting state, state [%d]",
                                adapter_discovery_state);
-               if (enable) {
-                       return BLUETOOTH_ERROR_IN_PROGRESS;
-               } else {
-                       result = adapter_stop_inquiry();
-                       if (result != OAL_STATUS_SUCCESS) {
-                               BT_ERR("Discover stop failed: %d", result);
-                               result = BLUETOOTH_ERROR_INTERNAL;
-                       } else {
-                               BT_ERR("Stop Discovery Triggered successfully");
-                               __bt_adapter_update_discovery_status(ADAPTER_DISCOVERY_STOPPING);
-                               result = BLUETOOTH_ERROR_NONE;
-                       }
-               }
+
+               result = enable ?  BLUETOOTH_ERROR_IN_PROGRESS :
+                                       BLUETOOTH_ERROR_DEVICE_BUSY;
+
                break;
        }
        case ADAPTER_DISCOVERY_STOPPED: {
@@ -1511,23 +1508,10 @@ static int __bt_adapter_state_discovery_request(gboolean enable,
        case ADAPTER_DISCOVERY_STOPPING: {
                BT_INFO("Adapter is currently in discovery stopping state, state [%d]",
                                adapter_discovery_state);
-               if (!enable)
-                       return BLUETOOTH_ERROR_NOT_IN_OPERATION;
-               else {
-                       BT_DBG("max_resp: %u, duration: %u, cod: 0x%X", max_response, duration, mask);
-                       if (!is_custom)
-                               result = adapter_start_inquiry(duration);
-                       else
-                               result = adapter_start_custom_inquiry(role);
-                       if (result != OAL_STATUS_SUCCESS) {
-                               BT_ERR("Start Discovery failed: %d", result);
-                               result = BLUETOOTH_ERROR_INTERNAL;
-                       } else {
-                               BT_ERR("Start Discovery Triggered successfully");
-                       __bt_adapter_update_discovery_status(ADAPTER_DISCOVERY_STARTING);
-                               result = BLUETOOTH_ERROR_NONE;
-                       }
-               }
+
+               result = enable ?  BLUETOOTH_ERROR_DEVICE_BUSY :
+                                       BLUETOOTH_ERROR_NOT_IN_OPERATION;
+
                break;
        }
        default: