From 345b7b905113f67c9f666a3c4363c293b3a24d23 Mon Sep 17 00:00:00 2001 From: Kavish Devar Date: Mon, 24 Nov 2025 14:59:01 +0530 Subject: [PATCH] android(fix): set HSP/HFP policy to allow when connecting to audio (#318) * android: use setConnectionProfile instead of (dis)connect on BluetoothProfile this prevents android from trying to reconnect to audio itself after we disconnect. this is essentially the same as toggling the 'Media Audio' and 'Phone Calls' settings in the android settings * android(fix): set HSP/HFP policy to allow when connecting to audio forgot to change it --- .../me/kavishdevar/librepods/services/AirPodsService.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/android/app/src/main/java/me/kavishdevar/librepods/services/AirPodsService.kt b/android/app/src/main/java/me/kavishdevar/librepods/services/AirPodsService.kt index effe90b..d890e88 100644 --- a/android/app/src/main/java/me/kavishdevar/librepods/services/AirPodsService.kt +++ b/android/app/src/main/java/me/kavishdevar/librepods/services/AirPodsService.kt @@ -2708,9 +2708,11 @@ class AirPodsService : Service(), SharedPreferences.OnSharedPreferenceChangeList override fun onServiceConnected(profile: Int, proxy: BluetoothProfile) { if (profile == BluetoothProfile.HEADSET) { try { - val method = + val policyMethod = proxy.javaClass.getMethod("setConnectionPolicy", BluetoothDevice::class.java, Int::class.java) + policyMethod.invoke(proxy, device, 100) + val connectMethod = proxy.javaClass.getMethod("connect", BluetoothDevice::class.java) - method.invoke(proxy, device) + connectMethod.invoke(proxy, device) } catch (e: Exception) { e.printStackTrace() } finally {