diff --git a/openpilot/starpilot/ui/feature_settings_owner.py b/openpilot/starpilot/ui/feature_settings_owner.py index 6040e85258..f97ad460ee 100644 --- a/openpilot/starpilot/ui/feature_settings_owner.py +++ b/openpilot/starpilot/ui/feature_settings_owner.py @@ -84,7 +84,7 @@ from openpilot.starpilot.controllers.toyota_cruise import capability as toyota_c GLOBAL_BOOL_PREFERENCES = frozenset((LEAD_APPROACH_KEY, LEAD_TAKEOFF_KEY, NUDGE_KEY, "DisengageOnAccelerator")) BOOL_DEFAULTS = { - "GMPedalLongitudinal": False, "ForceStops": False, "AlwaysAllowUploads": False, "TurnAssist": True, + "GMPedalLongitudinal": False, "ForceStops": True, "AlwaysAllowUploads": False, "TurnAssist": True, "SubaruAvhStartup": False, "SubaruStopStartOff": False, "SubaruSNG": False, diff --git a/openpilot/system/manager/manager.py b/openpilot/system/manager/manager.py index b5629d6536..6fdcc593f9 100755 --- a/openpilot/system/manager/manager.py +++ b/openpilot/system/manager/manager.py @@ -78,7 +78,7 @@ def manager_init() -> None: for k in params.all_keys(): if k == b"LKASButtonControl": continue # Card enrolls the vehicle-specific default after identification. - default_value = not os.path.lexists(params.get_param_path("Version")) if k == b"LaneCentering" else params.get_default_value(k) + default_value = not os.path.lexists(params.get_param_path("Version")) if k in (b"LaneCentering", b"ForceStops") else params.get_default_value(k) if default_value is not None and not os.path.lexists(params.get_param_path(k)): params.put(k, default_value, block=True) diff --git a/openpilot/system/manager/test/test_enhanced_stops_defaults.py b/openpilot/system/manager/test/test_enhanced_stops_defaults.py new file mode 100644 index 0000000000..cac7c90db6 --- /dev/null +++ b/openpilot/system/manager/test/test_enhanced_stops_defaults.py @@ -0,0 +1,27 @@ +import ast +import os +from pathlib import Path +import tempfile +import unittest + +from openpilot.common.params import Params + + +class TestEnhancedStopsDefaults(unittest.TestCase): + def test_typed_enrollment_preserves_existing_choices(self): + source = Path(__file__).resolve().parents[1] / "manager.py" + tree = ast.parse(source.read_text()) + loop = next(node for node in ast.walk(tree) if isinstance(node, ast.For) and + ast.unparse(node.iter) == "params.all_keys()") + code = compile(ast.fix_missing_locations(ast.Module(body=[loop], type_ignores=[])), str(source), "exec") + for upgrade in (False, True): + for saved in (None, b"0", b"1", b"malformed"): + with self.subTest(upgrade=upgrade, saved=saved), tempfile.TemporaryDirectory() as root: + params = Params(root) + if upgrade: + params.put("Version", "7.0", block=True) + path = Path(params.get_param_path("ForceStops")) + if saved is not None: + path.write_bytes(saved) + exec(code, {"params": params, "os": os}) + self.assertEqual(path.read_bytes(), saved if saved is not None else b"0" if upgrade else b"1") diff --git a/prebuilt.json b/prebuilt.json index 6736796985..be62478134 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "26ffbe8157fb1f59f9cdf5141380ff040e251450435acd02ac0dfe08c5bffe4f", "schema_version": 1} +{"protected_inventory_sha256": "29623ab48d26c161d75502f9ddeeb5cf416cc2f4e5bdafa8243660fadf9c4e96", "schema_version": 1}