Add DA logic so that A2DP connection is only possible for one device 16/304816/1 accepted/tizen/7.0/unified/20240125.012453
authorWootak Jung <wootak.jung@samsung.com>
Wed, 24 Jan 2024 03:56:37 +0000 (12:56 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Wed, 24 Jan 2024 03:59:44 +0000 (12:59 +0900)
A2DP and HFP can only be connected to the same device.

Change-Id: I600ffc9d7dd753f6bd9a070f8616d893b832d4bb
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
bt-service/services/audio/a2dp_src/bt-service-a2dp-src.c
bt-service/services/audio/bt-service-audio.c

index 56410b9..ef66f2d 100644 (file)
@@ -359,6 +359,11 @@ void _bt_a2dp_src_handle_incoming_authorization(char *address, int service_id)
        case A2DP_SERVICE_ID:
                connected = _bt_is_headset_type_connected(BT_AUDIO_A2DP, connected_address);
 
+               if (TIZEN_FEATURE_DA_REFERENCE) {
+                       if (!connected)
+                               connected = _bt_is_headset_type_connected(BT_AUDIO_A2DP_SOURCE, connected_address);
+               }
+
                if (connected) {
                        BT_INFO("A2DP is already connected..check which device..");
                        if (g_strcmp0(connected_address, address) != 0) {
@@ -370,6 +375,24 @@ void _bt_a2dp_src_handle_incoming_authorization(char *address, int service_id)
                                return;
                        }
                } else {
+                       if (TIZEN_FEATURE_DA_REFERENCE) {
+                               char hfp_connected_address[BT_ADDRESS_STRING_SIZE + 1];
+                               gboolean hfp_connected = FALSE;
+
+                               hfp_connected = _bt_is_headset_type_connected(BT_AUDIO_AG, hfp_connected_address);
+
+                               if (hfp_connected) {
+                                       if (g_strcmp0(hfp_connected_address, address) != 0) {
+                                               BT_INFO("Different device is HF connected[%s] reject current [%s] device authorization request",
+                                                       hfp_connected_address, address);
+                                               res = device_reply_auth_request((bt_address_t*)&device_address, service_id, FALSE, FALSE);
+                                               if (res != OAL_STATUS_SUCCESS)
+                                                       BT_ERR("authorize_response: %d", res);
+                                               return;
+                                       }
+                               }
+                       }
+
                        res = device_reply_auth_request((bt_address_t*)&device_address, service_id, TRUE, FALSE);
                        if (res != OAL_STATUS_SUCCESS)
                                BT_ERR("authorize_response: %d", res);
index d26f414..3f7d50a 100644 (file)
@@ -1399,6 +1399,37 @@ void _bt_audio_handle_incoming_authorization(char *address, int service_id)
                return;
        }
 
+       if (TIZEN_FEATURE_DA_REFERENCE) {
+               char a2dp_connected_address[BT_ADDRESS_STRING_SIZE + 1];
+               gboolean a2dp_connected = FALSE;
+
+               a2dp_connected = _bt_is_headset_type_connected(BT_AUDIO_A2DP_SOURCE, a2dp_connected_address);
+
+               if (a2dp_connected) {
+                       if (g_strcmp0(a2dp_connected_address, address) != 0) {
+                               BT_INFO("Different device is A2DP Source connected[%s] reject current [%s] device authorization request",
+                                       a2dp_connected_address, address);
+                               res = device_reply_auth_request((bt_address_t*)&device_address, service_id, FALSE, FALSE);
+                               if (res != OAL_STATUS_SUCCESS)
+                                       BT_ERR("authorize_response: %d", res);
+                               return;
+                       }
+               }
+
+               a2dp_connected = _bt_is_headset_type_connected(BT_AUDIO_A2DP, a2dp_connected_address);
+
+               if (a2dp_connected) {
+                       if (g_strcmp0(a2dp_connected_address, address) != 0) {
+                               BT_INFO("Different device is A2DP Sink connected[%s] reject current [%s] device authorization request",
+                                       a2dp_connected_address, address);
+                               res = device_reply_auth_request((bt_address_t*)&device_address, service_id, FALSE, FALSE);
+                               if (res != OAL_STATUS_SUCCESS)
+                                       BT_ERR("authorize_response: %d", res);
+                               return;
+                       }
+               }
+       }
+
        if (connected) {
                BT_INFO("[%d] device is already connected..check which device..", service_id);
                if (g_strcmp0(connected_address, address) != 0) {