Change visibility settings for DA devices 99/306999/1
authorSohyeon Choi <shss.choi@samsung.com>
Tue, 23 Jan 2024 09:35:00 +0000 (18:35 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Sun, 3 Mar 2024 22:58:34 +0000 (07:58 +0900)
Change-Id: I10d20fe86e2f2f6c6b27c358e4f6c08af2ffcc6a
Signed-off-by: Sohyeon Choi <shss.choi@samsung.com>
bt-service/services/adapter/bt-service-core-adapter.c

index de51753..ae91760 100644 (file)
@@ -96,8 +96,6 @@ typedef enum {
        BT_ADAPTER_A2DP_ROLE_SINK = 0x02,
 } bt_adapter_a2dp_role_e;
 
-static bt_adapter_a2dp_role_e a2dp_role_state = BT_ADAPTER_A2DP_ROLE_SOURCE;
-
 /* Forward declarations */
 static void __bt_adapter_event_handler(int event_type, gpointer event_data);
 static void __bt_post_oal_init(void);
@@ -1243,14 +1241,6 @@ static void __bt_adapter_event_handler(int event_type, gpointer event_data)
                /* In Fhub case, both role(Source|Sink, 0x03) can be delivered */
                __bt_handle_pending_a2dp_init(*a2dp_role);
 
-               if (TIZEN_FEATURE_FHUB_REFERENCE) {
-                       a2dp_role_state = *a2dp_role;
-                       if (adapter_state == BT_ACTIVATED) {
-                               BT_DBG("Set visible mode by a2dp role");
-                               __bt_set_visible_mode();
-                       }
-               }
-
                break;
        }
        case OAL_EVENT_CONTROLLER_ERROR_RECEIVED: {
@@ -1507,15 +1497,17 @@ static gboolean __bt_adapter_post_set_enabled(gpointer user_data)
 
        BT_INFO("__bt_adapter_post_set_enabled>>");
 
-       if (TIZEN_FEATURE_DA_REFERENCE) {
-               /* If non-Fhub, visible off even if headless device.
-                * If Fhub, visible on when a2dp role sink(speaker). otherwise, visible off */
-               if (TIZEN_FEATURE_FHUB_REFERENCE && a2dp_role_state & BT_ADAPTER_A2DP_ROLE_SINK) {
-                       BT_DBG("It is initial state.. Set General Discoverable Mode");
+       if (TIZEN_FEATURE_FHUB_REFERENCE) {
+               _bt_set_connectable(TRUE);
+               __bt_set_visible_mode();
+       } else if (TIZEN_FEATURE_DA_REFERENCE) {
+               if (headed_plugin_info->plugin_headed_enabled) {
+                       BT_DBG("DA Headed devices. Set General Discoverable Mode");
                        if (BLUETOOTH_ERROR_NONE != _bt_set_discoverable_mode(
                                        BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE, 0))
                                BT_ERR("Fail to set discoverable mode");
                } else {
+                       BT_DBG("DA Headless devices. Set Connectable Mode");
                        if (BLUETOOTH_ERROR_NONE != _bt_set_discoverable_mode(
                                        BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE, 0))
                                BT_ERR("Fail to set connectable mode");
@@ -1890,19 +1882,6 @@ static void __bt_set_visible_mode(void)
        if (vconf_get_int(BT_FILE_VISIBLE_TIME, &timeout) != 0)
                BT_ERR("Fail to get the timeout value");
 
-       if (TIZEN_FEATURE_FHUB_REFERENCE) {
-               BT_DBG("timeout : %d, a2dp_role : %d", timeout, a2dp_role_state);
-               if (timeout == 0 && a2dp_role_state & BT_ADAPTER_A2DP_ROLE_SINK) {
-                       BT_DBG("It is initial state.. Set General Discoverable Mode");
-                       if (_bt_set_discoverable_mode(
-                                                       BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE,
-                                                       timeout) != BLUETOOTH_ERROR_NONE) {
-                               BT_ERR("Set discoverable mode failed");
-                       }
-                       return;
-               }
-       }
-
        _bt_dpm_get_bluetooth_limited_discoverable_state(&discoverable_state);
        if (timeout == -1 || discoverable_state == DPM_RESTRICTED) {
                if (_bt_set_discoverable_mode(