mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-05 21:18:30 -04:00
location: add missing subscribe fan-out for location events (#2914)
handleSubscribe forwards every service except location, so neither subscribe-all connections nor explicit location subscriptions ever receive location events, and the shell's only source of coordinates is a single getState pull that races the geoclue TimeThreshold and loses. Wire location into the fan-out like loginctl/sysupdate: initial state on subscribe, then manager pushes.
This commit is contained in:
@@ -1183,6 +1183,38 @@ func handleSubscribe(conn *models.Conn, req models.Request) {
|
||||
}()
|
||||
}
|
||||
|
||||
if shouldSubscribe("location") && locationManager != nil {
|
||||
wg.Add(1)
|
||||
locationChan := locationManager.Subscribe(clientID + "-location")
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
defer locationManager.Unsubscribe(clientID + "-location")
|
||||
|
||||
initialState := locationManager.GetState()
|
||||
select {
|
||||
case eventChan <- ServiceEvent{Service: "location", Data: initialState}:
|
||||
case <-stopChan:
|
||||
return
|
||||
}
|
||||
|
||||
for {
|
||||
select {
|
||||
case state, ok := <-locationChan:
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
select {
|
||||
case eventChan <- ServiceEvent{Service: "location", Data: state}:
|
||||
case <-stopChan:
|
||||
return
|
||||
}
|
||||
case <-stopChan:
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
if shouldSubscribe("sysupdate") && sysUpdateManager != nil {
|
||||
wg.Add(1)
|
||||
sysupdateChan := sysUpdateManager.Subscribe(clientID + "-sysupdate")
|
||||
|
||||
Reference in New Issue
Block a user