Ignore stale system location callbacks

This commit is contained in:
liuyunming521520-cell 2026-09-10 23:56:10 +08:00
parent 546c298efd
commit 61c9e94e46

View File

@ -376,9 +376,13 @@ internal class SystemLocationProvider(private val context: Context) : LocationPr
removeLocationUpdates(callback)
val listener = object : LocationListener {
lateinit var listener: LocationListener
listener = object : LocationListener {
override fun onLocationChanged(location: Location) {
if (hasLocationPermission()) callback(location)
val isCurrentListener = synchronized(activeListeners) {
activeListeners[callback] === listener
}
if (isCurrentListener && hasLocationPermission()) callback(location)
}
override fun onStatusChanged(provider: String?, status: Int, extras: Bundle?) = Unit