mirror of
https://github.com/kavishdevar/librepods.git
synced 2026-05-30 21:09:20 +00:00
android: fix crash on some devices not properly closing socket
This commit is contained in:
@@ -2768,6 +2768,7 @@ class AirPodsService : Service(), SharedPreferences.OnSharedPreferenceChangeList
|
||||
|
||||
while (socket.isConnected) {
|
||||
socket.let { it ->
|
||||
try {
|
||||
val buffer = ByteArray(1024)
|
||||
val bytesRead = it.inputStream.read(buffer)
|
||||
var data: ByteArray
|
||||
@@ -2801,6 +2802,15 @@ class AirPodsService : Service(), SharedPreferences.OnSharedPreferenceChangeList
|
||||
aacpManager.disconnected()
|
||||
return@launch
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Error reading data, we have probably disconnected.")
|
||||
e.printStackTrace()
|
||||
sendBroadcast(Intent(AirPodsNotifications.AIRPODS_DISCONNECTED).apply {
|
||||
setPackage(packageName)
|
||||
})
|
||||
aacpManager.disconnected()
|
||||
return@launch
|
||||
}
|
||||
}
|
||||
}
|
||||
Log.d("AirPods Service", "Socket closed")
|
||||
|
||||
Reference in New Issue
Block a user