Skip to contentSkip to conversation

policy: fix HSP/HFP reconnection

PATCH Applied Yao Wei (魏銘廷) 3 participants 4 messages Apr 1, 2025 – Apr 9, 2025 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

cover policy: fix HSP/HFP reconnection

This patch was regarding to https://github.com/bluez/bluez/issues/1069.

The previous patch did not fix the issue, as I was testing it with Apple AirPods Pro 2 and it automatically reconnects HSP/HFP after A2DP is connected for about 25 seconds, and I assume the patch worked for me. Some other devices I tested did not exhibit such behavior (Jabra Speak2 55 UC). This patch was tested against both these devices, and both cases with NVIDIA GPU enabled and disabled.

By removing the code checking whether A2DP service is initiator for directly starting HSP/HFP service, it will now only check whether HSP/HFP is connected, and start the service if not.

The previous patch also has an oversight of not falling back to get HSP service if HFP is not available. This patch fixed the issue.

Yao Wei (魏銘廷) (1):
policy: fix HSP/HFP reconnection

 plugins/policy.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
Signature · 1 line
2.49.0
#1 lore raw

PATCH 1/1 policy: fix HSP/HFP reconnection

This patch removes checking whether A2DP service initiates the connection starting HSP/HFP connection, instead just start timer when HSP/HFP is not connected, also move order so that setting HSP/HFP connection timer is not blocked by AVRCP connection.

The previous patch also did not get HSP service if HFP is not available. This patch adds it in.

---
 plugins/policy.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
plugins/policy.c +8 -10
index 360d1359f..0e533ba1f 100644
@@ -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;
Signature · 1 line
2.49.0
#2 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=948733

---Test result---

Test Summary:

CheckPatch                    PENDING   0.33 seconds
GitLint                       PENDING   0.40 seconds
BuildEll                      PASS      20.84 seconds
BluezMake                     PASS      1562.68 seconds
MakeCheck                     PASS      12.91 seconds
MakeDistcheck                 PASS      161.21 seconds
CheckValgrind                 PASS      217.39 seconds
CheckSmatch                   PASS      289.96 seconds
bluezmakeextell               PASS      100.81 seconds
IncrementalBuild              PENDING   0.36 seconds
ScanBuild                     PASS      893.38 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:

---
Regards,
Linux Bluetooth

#3 lore raw
In reply to Yao Wei (魏銘廷)
This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 10 lines · On Tue, 1 Apr 2025 10:02:20 +0800 you wrote:

This patch was regarding to https://github.com/bluez/bluez/issues/1069.

The previous patch did not fix the issue, as I was testing it with Apple AirPods Pro 2 and it automatically reconnects HSP/HFP after A2DP is connected for about 25 seconds, and I assume the patch worked for me. Some other devices I tested did not exhibit such behavior (Jabra Speak2 55 UC). This patch was tested against both these devices, and both cases with NVIDIA GPU enabled and disabled.

[...]

Here is the summary with links:
- [BlueZ,1/1] policy: fix HSP/HFP reconnection

    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=0b3d49f4e030

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html