Fix navigation GPS carrier subscriptions

Use GPS transport services in navtilesd and MapFeed, preserving phone GPS through starpilotNavigation. Add startup subscription regressions.

Source-only correction; no prebuilt receipt or native artifacts changed.
This commit is contained in:
Dom
2026-10-20 17:39:33 -05:00
parent b209e6a655
commit de0092349d
4 changed files with 58 additions and 4 deletions
+2 -2
View File
@@ -487,8 +487,8 @@ def main() -> None:
pass
daemon = TileDaemon()
owner = NavigationOwner()
from openpilot.starpilot.gps.source import GPS_SOURCES
sm = messaging.SubMaster(["deviceState", *GPS_SOURCES, "starpilotNavigation"])
from openpilot.starpilot.gps.source import GPS_SERVICES
sm = messaging.SubMaster(["deviceState", *GPS_SERVICES])
map_enabled, layout_checked = False, -math.inf
while True:
sm.update(0)
@@ -322,3 +322,32 @@ def test_status_reports_sizes_and_failure(tmp_path):
assert status["failure"] == "key" and status["hasKey"] and status["network"] == "wifi"
assert set(status["bytes"]) == {"saved", "driven", "cache"}
assert navtilesd.FAILURE_KEY == "key"
def test_main_subscribes_to_registered_gps_carriers(monkeypatch):
import sys
from types import SimpleNamespace
from openpilot.cereal.services import SERVICE_LIST
from openpilot.starpilot.navigation import navtilesd, owner
class SubscriptionsChecked(Exception):
pass
def submaster(services):
assert len(services) == len(set(services))
assert set(services) <= SERVICE_LIST.keys()
assert {"gpsLocationExternal", "gpsLocation", "starpilotCarState"} <= set(services)
assert "phoneGps" not in services
assert services.count("starpilotNavigation") == 1
assert "deviceState" in services
raise SubscriptionsChecked
messaging = SimpleNamespace(SubMaster=submaster)
from openpilot import cereal
monkeypatch.setattr(cereal, "messaging", messaging, raising=False)
monkeypatch.setitem(sys.modules, "openpilot.cereal.messaging", messaging)
monkeypatch.setattr(navtilesd, "TileDaemon", lambda: None)
monkeypatch.setattr(owner, "NavigationOwner", lambda: None)
monkeypatch.setattr(navtilesd.os, "nice", lambda _: None)
with pytest.raises(SubscriptionsChecked):
navtilesd.main()
+2 -2
View File
@@ -787,10 +787,10 @@ class MapFeed:
"""The same GPS choice as navigation (either receiver, then the car's own), and the active route."""
def __init__(self, sm=None, *, acquisition=None):
from openpilot.starpilot.gps.source import GPS_SOURCES
from openpilot.starpilot.gps.source import GPS_SERVICES
if sm is None:
from openpilot.cereal import messaging
sm = messaging.SubMaster(list(GPS_SOURCES))
sm = messaging.SubMaster(list(GPS_SERVICES))
self.sm = sm
self._fix: MapFix | None = None
self._route_stamp = None
@@ -583,3 +583,28 @@ def test_culled_guidance_draws_the_same_inside_the_canvas():
assert len(core) < len(full) / 3, "most of the route is off this canvas"
inside = (full[:, 1] > 0) & (full[:, 1] < 1024)
assert np.isin(full[inside].view(np.complex64), core.view(np.complex64)).all(), "the on-canvas strip is unchanged"
def test_map_feed_subscribes_to_registered_gps_carriers(monkeypatch):
import sys
from openpilot.cereal.services import SERVICE_LIST
from openpilot.starpilot.ui.onroad_map import MapFeed
subscriptions = []
def submaster(services):
assert len(services) == len(set(services))
assert set(services) <= SERVICE_LIST.keys()
assert {"gpsLocationExternal", "gpsLocation", "starpilotCarState"} <= set(services)
assert "phoneGps" not in services
assert services.count("starpilotNavigation") == 1
subscriptions.extend(services)
return NS()
messaging = NS(SubMaster=submaster)
from openpilot import cereal
monkeypatch.setattr(cereal, "messaging", messaging, raising=False)
monkeypatch.setitem(sys.modules, "openpilot.cereal.messaging", messaging)
feed = MapFeed(acquisition=NS())
assert feed.sm is not None
assert subscriptions