Remove duplicated logic
[platform/core/connectivity/bluetooth-frwk.git] / bt-service-adaptation / services / adapter / bt-service-core-adapter.c
index 0e5e357..98c5ec4 100644 (file)
@@ -507,7 +507,7 @@ int _bt_set_discoverable_mode(int discoverable_mode, int timeout)
        _bt_dpm_get_bluetooth_limited_discoverable_state(&discoverable_state);
        if (discoverable_mode != BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE &&
                 discoverable_state == DPM_RESTRICTED) {
-               if (headed_plugin_info->plugin_headed_enabled) // TODO: There is no definition headed_plugin_info
+               if (headed_plugin_info->plugin_headed_enabled)
                        headed_plugin_info->headed_plugin->bt_launch_dpmpopup("DPM_POLICY_DISABLE_BT_HANDSFREE");
                return BLUETOOTH_ERROR_ACCESS_DENIED;
        }
@@ -548,15 +548,21 @@ int _bt_set_discoverable_mode(int discoverable_mode, int timeout)
 
        if (discoverable_mode == BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE) {
                ret = _bt_stop_visibility_timer();
+               if (BLUETOOTH_ERROR_NONE != ret)
+                       BT_ERR("_bt_stop_visibility_timer failed");
                if (!TIZEN_PROFILE_WEARABLE) {
                        if (vconf_set_int(BT_FILE_VISIBLE_TIME, -1) != 0)
                                 BT_ERR("Set vconf failed");
                }
        } else if (discoverable_mode == BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE) {
                ret = _bt_start_visibility_timer(timeout);
+               if (BLUETOOTH_ERROR_NONE != ret)
+                       BT_ERR("_bt_start_visibility_timer failed");
 
        } else {
                ret = _bt_stop_visibility_timer();
+               if (BLUETOOTH_ERROR_NONE != ret)
+                       BT_ERR("_bt_stop_visibility_timer failed");
        }
 
        BT_DBG("-");
@@ -1169,11 +1175,7 @@ static gboolean __bt_adapter_post_set_enabled(gpointer user_data)
 {
        BT_INFO("__bt_adapter_post_set_enabled>>");
 
-       if (TIZEN_PROFILE_TV || !headed_plugin_info->plugin_headed_enabled) {
-               if (BLUETOOTH_ERROR_NONE != _bt_set_discoverable_mode(
-                               BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE, 0))
-                       BT_ERR("Fail to set discoverable mode");
-       } else {
+       if (!TIZEN_PROFILE_TV) {
                __bt_set_visible_mode();
 
                /* add the vconf noti handler */
@@ -1182,6 +1184,10 @@ static gboolean __bt_adapter_post_set_enabled(gpointer user_data)
                        BT_ERR("DEVICE_NAME key changed notification registration failed");
 
                __bt_set_local_name();
+       } else {
+               if (BLUETOOTH_ERROR_NONE != _bt_set_discoverable_mode(
+                               BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE, 0))
+                       BT_ERR("Fail to set discoverable mode");
        }
 
        /* Get All properties */
@@ -1662,7 +1668,6 @@ void _bt_set_disabled(int result)
        if (vconf_set_int(VCONFKEY_BT_DEVICE, VCONFKEY_BT_DEVICE_NONE) != 0)
                BT_ERR("Set vconf failed\n");
 
-       _bt_cancel_queued_transfers();
        _bt_adapter_set_status(BT_DEACTIVATED);
        __bt_adapter_update_discovery_status(ADAPTER_DISCOVERY_STOPPED);