Fix the logic to set visible mode by a2dp role 83/291683/3 accepted/tizen/7.0/unified/20230424.135833
authorWootak Jung <wootak.jung@samsung.com>
Thu, 20 Apr 2023 07:28:35 +0000 (16:28 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Fri, 21 Apr 2023 01:20:07 +0000 (10:20 +0900)
add the logic to set visible mode in da case

Change-Id: I2ecfd35ad7ffad1ddad8cc197d12a5dd84f5fa1e
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
bt-service/services/adapter/bt-service-core-adapter.c

index 3538516..57c9773 100644 (file)
@@ -1239,9 +1239,13 @@ static void __bt_adapter_event_handler(int event_type, gpointer event_data)
 
                __bt_handle_pending_a2dp_init(*a2dp_role);
 
-               if (TIZEN_FEATURE_FHUB_REFERENCE)
-                       if (a2dp_role != NULL)
-                               a2dp_role_state = *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;
        }
@@ -1499,7 +1503,20 @@ static gboolean __bt_adapter_post_set_enabled(gpointer user_data)
 
        BT_INFO("__bt_adapter_post_set_enabled>>");
 
-       if (TIZEN_PROFILE_TV || TIZEN_FEATURE_ROBOT_REFERENCE ||
+       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 (BLUETOOTH_ERROR_NONE != _bt_set_discoverable_mode(
+                                       BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE, 0))
+                               BT_ERR("Fail to set discoverable mode");
+               } else {
+                       if (BLUETOOTH_ERROR_NONE != _bt_set_discoverable_mode(
+                                       BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE, 0))
+                               BT_ERR("Fail to set connectable mode");
+               }
+       } else if (TIZEN_PROFILE_TV || TIZEN_FEATURE_ROBOT_REFERENCE ||
                         !headed_plugin_info->plugin_headed_enabled) {
                if (BLUETOOTH_ERROR_NONE != _bt_set_discoverable_mode(
                                BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE, 0))
@@ -1508,7 +1525,7 @@ static gboolean __bt_adapter_post_set_enabled(gpointer user_data)
                /* Tizen IOT Speaker - The default visible mode is off */
                if (BLUETOOTH_ERROR_NONE != _bt_set_discoverable_mode(
                                BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE, 0))
-                       BT_ERR("Fail to set discoverable mode");
+                       BT_ERR("Fail to set connectable mode");
        } else {
                __bt_set_visible_mode();
        }
@@ -1870,7 +1887,7 @@ static void __bt_set_visible_mode(void)
                        if (_bt_set_discoverable_mode(
                                                        BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE,
                                                        timeout) != BLUETOOTH_ERROR_NONE) {
-                               BT_ERR("Set connectable mode failed");
+                               BT_ERR("Set discoverable mode failed");
                        }
                        return;
                }