fhub: reject A2DP sink/HF/AVRCP CT profile connect request when local a2dp role is... 01/281701/1
authorAyush Garg <ayush.garg@samsung.com>
Tue, 20 Sep 2022 07:29:21 +0000 (12:59 +0530)
committerAyush Garg <ayush.garg@samsung.com>
Wed, 21 Sep 2022 02:29:41 +0000 (07:59 +0530)
Change-Id: I83a0c8c132945971acd4dde3e840f8b43c91e14b
Signed-off-by: shss-choi <shss.choi@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
bt-service/services/audio/a2dp_src/bt-service-a2dp-src.c
bt-service/services/audio/bt-service-audio.c
bt-service/services/include/bt-service-audio-common.h

index e122e6a..3bc7f63 100644 (file)
@@ -357,9 +357,18 @@ void _bt_a2dp_src_handle_incoming_authorization(char *address, int service_id)
 
        switch (service_id) {
        case A2DP_SERVICE_ID:
-               if (TIZEN_FEATURE_FHUB_REFERENCE)
+               if (TIZEN_FEATURE_FHUB_REFERENCE) {
+                       if (_bt_audio_get_current_role() == BLUETOOTH_A2DP_SOURCE) {
+                               BT_INFO("Current local A2DP role is Source.. reject [%s] device authorization request with [%d]",
+                                                       address, service_id);
+                               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;
+                       }
+
                        connected = _bt_is_headset_type_connected(BT_AUDIO_A2DP_SOURCE, connected_address);
-               else
+               else
                        connected = _bt_is_headset_type_connected(BT_AUDIO_A2DP, connected_address);
 
                if (connected) {
index 1e84b6d..58ea05c 100644 (file)
@@ -1348,6 +1348,11 @@ int _bt_hf_connect(bluetooth_device_address_t *device_address)
        return result;
 }
 
+int _bt_audio_get_current_role(void)
+{
+       return curr_audio_role;
+}
+
 int _bt_hf_disconnect(bluetooth_device_address_t *device_address)
 {
        int result = BLUETOOTH_ERROR_NONE;
@@ -1392,6 +1397,19 @@ void _bt_audio_handle_incoming_authorization(char *address, int service_id)
                return;
        }
 
+       if (TIZEN_FEATURE_FHUB_REFERENCE) {
+               if (service_id == HFP_HS_SERVICE_ID || service_id == AVRCP_SERVICE_ID) {
+                       if (curr_audio_role != BLUETOOTH_A2DP_SINK) {
+                               BT_INFO("Current local A2DP role is Source.. reject [%s] device authorization request with [%d]",
+                                               address, service_id);
+                               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) {
index f8a7fbe..86da48c 100644 (file)
@@ -132,6 +132,8 @@ int _bt_audio_select_role(bluetooth_audio_role_t role);
 
 void _bt_audio_set_current_role(bluetooth_audio_role_t role);
 
+int _bt_audio_get_current_role(void);
+
 void _bt_audio_handle_incoming_authorization(char *address, int service_id);
 
 typedef enum {