Skip to content

Commit b1a1fea

Browse files
teng-linclaude
andcommitted
fix(android): use AACP connected devices for socket liveness check
inputStream.available() returns 0 on dead sockets instead of throwing, so it can't detect stale connections. Use aacpManager.connectedDevices which is cleared on disconnect and only populated after successful AACP handshake - a reliable indicator of actual socket health. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent aadcaf1 commit b1a1fea

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

android/app/src/main/java/me/kavishdevar/librepods/services/AirPodsService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2428,7 +2428,7 @@ class AirPodsService : Service(), SharedPreferences.OnSharedPreferenceChangeList
24282428
HiddenApiBypass.addHiddenApiExemptions("Landroid/bluetooth/BluetoothSocket;")
24292429
val uuid: ParcelUuid = ParcelUuid.fromString("74ec2172-0bad-4d01-8f77-997b2be0722a")
24302430
val socketActuallyAlive = isConnectedLocally && this::socket.isInitialized &&
2431-
try { socket.inputStream.available(); true } catch (_: Exception) { false }
2431+
socket.isConnected && aacpManager.connectedDevices.isNotEmpty()
24322432
if (!socketActuallyAlive) {
24332433
if (isConnectedLocally) {
24342434
Log.d(TAG, "isConnectedLocally was true but socket is dead, resetting")

0 commit comments

Comments
 (0)