[bt-audio] Fix dbus method reply for audio connect 47/139447/1
authorAnurag Biradar <biradar.a@samsung.com>
Wed, 19 Jul 2017 04:10:50 +0000 (09:40 +0530)
committerAnurag Biradar <biradar.a@samsung.com>
Wed, 19 Jul 2017 04:10:50 +0000 (09:40 +0530)
Application is showing as Connecting and never came back to
Disconnected or Connected state(Application didn't got dbus
reply for audio connect method call)

We were overwriting the global data which stores request id to which
we need to reply. Because of which bt-service will not able to reply
to dbus request. For Ex. Already Headset A is connected, Applications
sends connection request for Headset B, than bt-service initiates
disconnection for Headset A and Stores Headset B in global wait data.
And When Headset A's HFP profile is connected, Application sends
connection request for Headset C, than bt-service initiates disconnection
for Headset B and overwrite the global wait data with that of Headset C.

Measure: Before checking if any device is connected or not check first
if any device is in connecting state with type. If any device is in
connecting state than return IN_PROGRESS error no need to handle.

Change-Id: I1e721f2e2660274ecef2c3cf551377572e557b3b

bt-service/bt-service-audio.c

index fcc6302..68994b4 100644 (file)
@@ -821,6 +821,12 @@ int _bt_audio_connect(int request_id, int type,
                goto fail;
        }
        BT_INFO("Connecting to service %s", uuid);
+       /* First Check if device is in connecting state if it than return error */
+       value = __bt_is_headset_connecting(type);
+       if (value != BLUETOOTH_ERROR_NONE) {
+               result = BLUETOOTH_ERROR_IN_PROGRESS;
+               goto fail;
+       }
 
        value = __bt_is_headset_connected(type, request_id, address);
 
@@ -828,11 +834,6 @@ int _bt_audio_connect(int request_id, int type,
                result = BLUETOOTH_ERROR_ALREADY_CONNECT;
                goto fail;
        } else if (value == BLUETOOTH_ERROR_NOT_CONNECTED) {
-               value = __bt_is_headset_connecting(type);
-               if (value != BLUETOOTH_ERROR_NONE) {
-                       result = BLUETOOTH_ERROR_IN_PROGRESS;
-                       goto fail;
-               }
                _bt_headset_set_local_connection(TRUE);
                ret = _bt_connect_profile(address, uuid,
                                __bt_audio_request_cb, func_data);