Diff between 1288facd554823b302024d7f0589a68a58fa2ac8 and 0b3d49f4e03014a911c421896ae727bba9e09ba1

Changed Files

File Additions Deletions Status
plugins/policy.c +8 -10 modified

Full Patch

diff --git a/plugins/policy.c b/plugins/policy.c
index 360d135..0e533ba 100644
--- a/plugins/policy.c
+++ b/plugins/policy.c
@@ -312,6 +312,14 @@ static void sink_cb(struct btd_service *service, btd_service_state_t old_state,
 			data->sink_timer = 0;
 		}
 
+		/* Try connecting HSP/HFP if it is not connected */
+		hs = btd_device_get_service(dev, HFP_HS_UUID);
+		if (hs == NULL)
+			hs = btd_device_get_service(data->dev, HSP_HS_UUID);
+		if (hs && btd_service_get_state(hs) !=
+						BTD_SERVICE_STATE_CONNECTED)
+			policy_set_hs_timer(data);
+
 		/* Check if service initiate the connection then proceed
 		 * immediatelly otherwise set timer
 		 */
@@ -321,16 +329,6 @@ static void sink_cb(struct btd_service *service, btd_service_state_t old_state,
 						BTD_SERVICE_STATE_CONNECTED)
 			policy_set_ct_timer(data, CONTROL_CONNECT_TIMEOUT);
 
-		/* Also try connecting HSP/HFP if it is not connected */
-		hs = btd_device_get_service(dev, HFP_HS_UUID);
-		if (hs) {
-			if (btd_service_is_initiator(service))
-				policy_connect(data, hs);
-			else if (btd_service_get_state(hs) !=
-						BTD_SERVICE_STATE_CONNECTED)
-				policy_set_hs_timer(data);
-		}
-
 		break;
 	case BTD_SERVICE_STATE_DISCONNECTING:
 		break;