Properly drop Binder connections on death on some providers

This commit is contained in:
Adam Gastineau 2025-09-01 14:43:46 -07:00
parent 8dc079a926
commit f64f5b13c5
2 changed files with 14 additions and 0 deletions

View File

@ -1,5 +1,6 @@
package com.penumbraos.bridge_system.provider
import android.os.IBinder
import android.os.Looper
import android.util.Log
import android.view.InputChannel
@ -81,6 +82,12 @@ class HandGestureProvider(private val looper: Looper) : IHandGestureProvider.Stu
}
override fun registerCallback(callback: IHandGestureCallback) {
callback.asBinder().linkToDeath(object : IBinder.DeathRecipient {
override fun binderDied() {
deregisterCallback(callback)
}
}, 0)
callbacks.add(callback)
registerListenerIfNecessary()
}

View File

@ -1,5 +1,6 @@
package com.penumbraos.bridge_system.provider
import android.os.IBinder
import android.os.Looper
import android.util.Log
import android.view.InputChannel
@ -37,6 +38,12 @@ class TouchpadProvider(private val looper: Looper) :
}
override fun registerCallback(callback: ITouchpadCallback) {
callback.asBinder().linkToDeath(object : IBinder.DeathRecipient {
override fun binderDied() {
deregisterCallback(callback)
}
}, 0)
callbacks.add(callback)
registerListenerIfNecessary()
}