diff --git a/openpilot/starpilot/navigation/navtilesd.py b/openpilot/starpilot/navigation/navtilesd.py index 1f23a820b7..b8c699f5f3 100644 --- a/openpilot/starpilot/navigation/navtilesd.py +++ b/openpilot/starpilot/navigation/navtilesd.py @@ -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) diff --git a/openpilot/starpilot/navigation/tests/test_navtilesd.py b/openpilot/starpilot/navigation/tests/test_navtilesd.py index 1a0307bfc1..225f5884ae 100644 --- a/openpilot/starpilot/navigation/tests/test_navtilesd.py +++ b/openpilot/starpilot/navigation/tests/test_navtilesd.py @@ -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() diff --git a/openpilot/starpilot/ui/onroad_map.py b/openpilot/starpilot/ui/onroad_map.py index dc45739381..a37f0e32dd 100644 --- a/openpilot/starpilot/ui/onroad_map.py +++ b/openpilot/starpilot/ui/onroad_map.py @@ -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 diff --git a/openpilot/starpilot/ui/tests/test_onroad_map.py b/openpilot/starpilot/ui/tests/test_onroad_map.py index 92f1ed8031..ca3aa85bca 100644 --- a/openpilot/starpilot/ui/tests/test_onroad_map.py +++ b/openpilot/starpilot/ui/tests/test_onroad_map.py @@ -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