mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-11-12 15:33:45 +08:00
StarPort: Try experimental fixes is the only switch, off by default
This commit is contained in:
@@ -22,12 +22,9 @@ STARPORT_NEW_SETUP_DESCRIPTION = ("Guided StarPort setup with a live checklist o
|
||||
STARPORT_HEVC_KEY = "StarPortAllowHevc"
|
||||
STARPORT_HEVC_DESCRIPTION = ("Experimental. Only for a car that offers H.265 and no H.264 video. Cars that offer H.264 are not " +
|
||||
"affected. Applies from the next StarPort connection.")
|
||||
STARPORT_FIXES_KEY = "StarPortHeadUnitFixes"
|
||||
STARPORT_FIXES_DESCRIPTION = ("Lets StarPort adjust how it talks to head units it has learned about. Turn off to use the standard " +
|
||||
"connection for every car. Applies from the next StarPort connection.")
|
||||
STARPORT_EXPERIMENTS_KEY = "StarPortHeadUnitExperiments"
|
||||
STARPORT_EXPERIMENTS_DESCRIPTION = ("Shows experimental fixes for specific cars and dongles. Each one still needs its own switch, and the " +
|
||||
"car-specific fixes setting must be on. Applies from the next StarPort connection.")
|
||||
STARPORT_EXPERIMENTS_DESCRIPTION = ("Shows experimental fixes for specific cars and dongles, each with its own switch. Turn off to use the " +
|
||||
"standard connection for every car. Applies from the next StarPort connection.")
|
||||
STARPORT_EXPERIMENT_PREFIX = "StarPortExperiment:"
|
||||
DRIVER_MONITORING_RESET = "reset_driver_monitoring"
|
||||
DRIVER_MONITORING_RESET_DESCRIPTION = "Clear saved wheel-side detection. Automatic detection restarts on the next drive."
|
||||
@@ -64,10 +61,8 @@ class DeveloperSettingsOwner:
|
||||
("Off", "On"), available=parked, reason=STARPORT_WIFI_DESCRIPTION if parked else held, default_value="On"))
|
||||
rows.append(FeatureRow(STARPORT_HEVC_KEY, "Allow H.265 video", "On" if hevc else "Off", b"1" if hevc else b"0",
|
||||
("Off", "On"), available=parked, reason=STARPORT_HEVC_DESCRIPTION if parked else held, default_value="Off"))
|
||||
fixes, experiments = bool(status.get("head_unit_fixes", True)), bool(status.get("head_unit_experiments"))
|
||||
experiments = bool(status.get("head_unit_experiments"))
|
||||
chosen = set(status.get("head_unit_experiment_rules") or ())
|
||||
rows.append(FeatureRow(STARPORT_FIXES_KEY, "Car-specific fixes", "On" if fixes else "Off", b"1" if fixes else b"0",
|
||||
("Off", "On"), available=parked, reason=STARPORT_FIXES_DESCRIPTION if parked else held, default_value="On"))
|
||||
rows.append(FeatureRow(STARPORT_EXPERIMENTS_KEY, "Try experimental fixes", "On" if experiments else "Off",
|
||||
b"1" if experiments else b"0", ("Off", "On"), available=parked,
|
||||
reason=STARPORT_EXPERIMENTS_DESCRIPTION if parked else held, default_value="Off"))
|
||||
@@ -139,8 +134,6 @@ class DeveloperSettingsOwner:
|
||||
return self._apply_starport(request, "dedicated_wifi_interface", "set_dedicated_wifi")
|
||||
if request.key == STARPORT_HEVC_KEY:
|
||||
return self._apply_starport(request, "allow_hevc", "set_allow_hevc")
|
||||
if request.key == STARPORT_FIXES_KEY:
|
||||
return self._apply_starport(request, "head_unit_fixes", "set_head_unit_fixes")
|
||||
if request.key == STARPORT_EXPERIMENTS_KEY:
|
||||
return self._apply_starport(request, "head_unit_experiments", "set_head_unit_experiments")
|
||||
if request.key.startswith(STARPORT_EXPERIMENT_PREFIX):
|
||||
|
||||
@@ -93,8 +93,7 @@ DESCRIPTIONS = {
|
||||
'heading:starport': 'Settings for connecting Android Auto to the car through StarPort.',
|
||||
'StarPortNewSetup': 'Shows the guided StarPort setup with a live checklist instead of the classic setup screens.',
|
||||
'StarPortAllowHevc': 'Lets a car that offers only H.265 video receive H.265; a car with an H.264 mode keeps H.264.',
|
||||
'StarPortHeadUnitFixes': 'Lets StarPort adjust how it talks to head units it has learned about. Turn off to use the standard connection for every car.',
|
||||
'StarPortHeadUnitExperiments': 'Shows experimental fixes for specific cars and dongles. Each one still needs its own switch.',
|
||||
'StarPortHeadUnitExperiments': 'Shows experimental fixes for specific cars and dongles, each with its own switch. Off is the standard connection.',
|
||||
'StarPortDedicatedWifi': "Joins the car's Wi-Fi on a second interface so the comma stays on its home Wi-Fi or phone hotspot.",
|
||||
'TeslaWakeOnCAN': 'Wakes comma when the Tesla wakes up, before you press the brake.',
|
||||
'RadarRecoveryAlert': 'Play a chime and show a brief message when a radar fault clears. You must re-engage manually.',
|
||||
@@ -166,7 +165,6 @@ DESCRIPTIONS = {
|
||||
INITIALIZATION = {
|
||||
'StarPortNewSetup': 'Applies the next time the setup screen opens.',
|
||||
'StarPortAllowHevc': 'Applies from the next StarPort connection.',
|
||||
'StarPortHeadUnitFixes': 'Applies from the next StarPort connection.',
|
||||
'StarPortHeadUnitExperiments': 'Applies from the next StarPort connection.',
|
||||
'StarPortDedicatedWifi': 'Applies from the next StarPort connection.',
|
||||
'LateralControllerSelection': ('Applies when driving processes next start: the controller class, vehicle policy and ' +
|
||||
|
||||
@@ -102,7 +102,6 @@
|
||||
"StarPortAllowHevc",
|
||||
"StarPortDedicatedWifi",
|
||||
"StarPortHeadUnitExperiments",
|
||||
"StarPortHeadUnitFixes",
|
||||
"StarPortNewSetup",
|
||||
"SteerFriction",
|
||||
"SteerLatAccel",
|
||||
|
||||
@@ -11,7 +11,7 @@ from unittest.mock import patch
|
||||
|
||||
from openpilot.starpilot.galaxy.developer_settings import (CALIBRATION_RESET, DRIVER_MONITORING_RESET, STARPORT_EXPERIMENT_PREFIX,
|
||||
STARPORT_EXPERIMENTS_KEY,
|
||||
STARPORT_FIXES_KEY, STARPORT_HEADING_KEY, STARPORT_HEVC_KEY,
|
||||
STARPORT_HEADING_KEY, STARPORT_HEVC_KEY,
|
||||
STARPORT_NEW_SETUP_KEY, STARPORT_WIFI_KEY, DeveloperSettingsOwner)
|
||||
from openpilot.starpilot.galaxy.settings import AuthorityContext, ContextSource, SettingsChanged, SettingsGateway
|
||||
from openpilot.starpilot.longitudinal.voacc import KEY, selected
|
||||
@@ -46,7 +46,7 @@ class FileParams:
|
||||
class FakeStarPort:
|
||||
def __init__(self, enabled=False, running=True):
|
||||
self.enabled, self.running, self.hevc = enabled, running, False
|
||||
self.fixes, self.experiments, self.rules = True, False, []
|
||||
self.experiments, self.rules = False, []
|
||||
|
||||
def call(self, command, **payload):
|
||||
if not self.running:
|
||||
@@ -57,16 +57,13 @@ class FakeStarPort:
|
||||
if command == "set_allow_hevc":
|
||||
self.hevc = payload["enabled"]
|
||||
return {"ok": True}
|
||||
if command == "set_head_unit_fixes":
|
||||
self.fixes = payload["enabled"]
|
||||
return {"ok": True}
|
||||
if command == "set_head_unit_experiments":
|
||||
self.experiments = payload["enabled"]
|
||||
return {"ok": True}
|
||||
if command == "set_head_unit_experiment_rule":
|
||||
self.rules = sorted(set(self.rules) | {payload["rule"]} if payload["enabled"] else set(self.rules) - {payload["rule"]})
|
||||
return {"ok": True, "changed": True}
|
||||
return {"ok": True, "status": {"dedicated_wifi_interface": self.enabled, "allow_hevc": self.hevc, "head_unit_fixes": self.fixes,
|
||||
return {"ok": True, "status": {"dedicated_wifi_interface": self.enabled, "allow_hevc": self.hevc,
|
||||
"head_unit_experiments": self.experiments, "head_unit_experiment_rules": self.rules}}
|
||||
|
||||
|
||||
@@ -244,17 +241,17 @@ class DeveloperSettingsTest(unittest.TestCase):
|
||||
service.running = False
|
||||
self.assertFalse(owner.apply(FeatureSettingsRequest(STARPORT_HEVC_KEY, b"1", "Off")))
|
||||
|
||||
def test_car_specific_fixes_default_on_and_experiments_default_off(self):
|
||||
def test_try_experimental_fixes_defaults_off_and_is_the_only_master_switch(self):
|
||||
service = FakeStarPort()
|
||||
owner = DeveloperSettingsOwner(self.params, lambda: self.parked, starport=lambda: service)
|
||||
rows = {row.key: row for row in owner.snapshot().rows}
|
||||
self.assertEqual((rows[STARPORT_FIXES_KEY].value, rows[STARPORT_FIXES_KEY].default_value), ("On", "On"))
|
||||
self.assertEqual((rows[STARPORT_EXPERIMENTS_KEY].value, rows[STARPORT_EXPERIMENTS_KEY].default_value), ("Off", "Off"))
|
||||
self.assertTrue(owner.apply(FeatureSettingsRequest(STARPORT_FIXES_KEY, b"1", "Off")))
|
||||
self.assertFalse(service.fixes)
|
||||
self.assertFalse(owner.apply(FeatureSettingsRequest(STARPORT_FIXES_KEY, b"1", "Off"))) # stale view
|
||||
self.assertNotIn("StarPortHeadUnitFixes", rows)
|
||||
self.assertTrue(owner.apply(FeatureSettingsRequest(STARPORT_EXPERIMENTS_KEY, b"0", "On")))
|
||||
self.assertTrue(service.experiments)
|
||||
self.assertFalse(owner.apply(FeatureSettingsRequest(STARPORT_EXPERIMENTS_KEY, b"0", "On"))) # stale view
|
||||
self.assertTrue(owner.apply(FeatureSettingsRequest(STARPORT_EXPERIMENTS_KEY, b"1", "Off")))
|
||||
self.assertFalse(service.experiments)
|
||||
|
||||
def test_experiment_toggles_appear_only_under_try_experimental_fixes(self):
|
||||
service = FakeStarPort()
|
||||
@@ -289,7 +286,7 @@ class DeveloperSettingsTest(unittest.TestCase):
|
||||
|
||||
def test_experiment_rows_are_hidden_when_the_service_is_off(self):
|
||||
keys = [row.key for row in self.owner.snapshot().rows]
|
||||
self.assertNotIn(STARPORT_FIXES_KEY, keys)
|
||||
self.assertNotIn(STARPORT_EXPERIMENTS_KEY, keys)
|
||||
self.assertNotIn(STARPORT_EXPERIMENTS_KEY, keys)
|
||||
|
||||
|
||||
|
||||
@@ -120,8 +120,6 @@ def handle(supervisor: Supervisor, request: dict[str, Any], verifier: StarPortSo
|
||||
supervisor.set_dedicated_wifi(request.get("enabled") is True)
|
||||
elif command == "set_allow_hevc":
|
||||
supervisor.set_allow_hevc(request.get("enabled") is True)
|
||||
elif command == "set_head_unit_fixes":
|
||||
supervisor.set_head_unit_fixes(request.get("enabled") is True)
|
||||
elif command == "set_head_unit_experiments":
|
||||
supervisor.set_head_unit_experiments(request.get("enabled") is True)
|
||||
elif command == "set_head_unit_experiment_rule":
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
A rule names the build it was seen on, the failure it targets and an ordered ladder of actions. A trial runs one more action
|
||||
per level (see quirk_state), so the smallest change that helps is the one that stays. Rules are either
|
||||
``experimental`` (they run only when the owner switches them on) or ``validated`` (a tested sequence, applied automatically
|
||||
to the matching build). The global "Car-specific fixes" switch turns every rule off, whatever has been learned.
|
||||
to the matching build). "Try experimental fixes" is the master switch: off, no rule runs, whatever has been learned.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -28,7 +28,7 @@ SDR_LABELS = {"2": "car_make", "3": "car_model", "4": "car_year", "7": "head_uni
|
||||
"9": "head_unit_software_build", "10": "head_unit_software_version"}
|
||||
MATCH_FIELDS = ("car_make", "car_model", "car_year", "head_unit_make", "head_unit_model", "head_unit_software_version")
|
||||
|
||||
# Automatic experiments (an experimental rule that starts without being switched on) are not enabled in this release.
|
||||
# Automatic experiments (an experimental rule that starts without its own toggle) are not enabled in this release.
|
||||
AUTO_EXPERIMENTS = False
|
||||
WIRELESS, WIRED = "wireless", "wired"
|
||||
|
||||
@@ -51,7 +51,7 @@ class Rule:
|
||||
ladder: tuple[str, ...] # one action per level, cumulative
|
||||
validated_level: int = 0 # for a validated rule: how many ladder steps the tested sequence uses
|
||||
summary: str = "" # one sentence for the setup suggestion
|
||||
setting_path: str = "Settings → Developer → StarPort → Specific car experiments"
|
||||
setting_path: str = "Settings → Developer → StarPort → Try experimental fixes"
|
||||
|
||||
|
||||
RULES: tuple[Rule, ...] = (
|
||||
@@ -99,7 +99,7 @@ def experimental_entries() -> list[dict]:
|
||||
|
||||
def bootstrap_experiment(config: dict) -> str:
|
||||
"""The Wi-Fi setup experiment to add, or "". Needs the master switch, the experiments switch and its own toggle."""
|
||||
if not (config.get("head_unit_fixes", True) and config.get("head_unit_experiments")):
|
||||
if not config.get("head_unit_experiments"):
|
||||
return ""
|
||||
chosen = config.get("head_unit_experiment_rules") or []
|
||||
return next((fix.experiment for fix in BOOTSTRAP_FIXES if fix.id in chosen), "")
|
||||
@@ -160,24 +160,21 @@ class Selection:
|
||||
|
||||
|
||||
def _enabled(config: dict, rule: Rule) -> bool:
|
||||
if not config.get("head_unit_fixes", True):
|
||||
"""Try experimental fixes is the master switch: off, no rule of either status runs, whatever has been learned."""
|
||||
if not config.get("head_unit_experiments"):
|
||||
return False
|
||||
if rule.status == VALIDATED:
|
||||
return True
|
||||
if AUTO_EXPERIMENTS:
|
||||
return True
|
||||
return bool(config.get("head_unit_experiments")) and rule.id in (config.get("head_unit_experiment_rules") or [])
|
||||
return rule.status == VALIDATED or AUTO_EXPERIMENTS or rule.id in (config.get("head_unit_experiment_rules") or [])
|
||||
|
||||
|
||||
def eligible(config: dict, car_type: str, profile: str) -> bool:
|
||||
def eligible(car_type: str, profile: str) -> bool:
|
||||
"""A rule never applies behind an adapter, or on top of a car profile the owner or the fingerprint picked."""
|
||||
return config.get("head_unit_fixes", True) and car_type != "adapter" and profile == "default"
|
||||
return car_type != "adapter" and profile == "default"
|
||||
|
||||
|
||||
def select(config: dict, labels: dict[str, str], transport: str, quirks: QuirkState, key: str, *, car_type: str,
|
||||
profile: str) -> Selection | None:
|
||||
"""The fix to run for this session, or None. Starts a trial the first time a rule applies to a car."""
|
||||
if not eligible(config, car_type, profile):
|
||||
if not eligible(car_type, profile):
|
||||
return None
|
||||
for rule in RULES:
|
||||
if not matches(rule, labels) or transport not in rule.transports or not _enabled(config, rule):
|
||||
@@ -197,7 +194,7 @@ def select(config: dict, labels: dict[str, str], transport: str, quirks: QuirkSt
|
||||
def suggestion(config: dict, labels: dict[str, str], transport: str, quirks: QuirkState, key: str, *, car_type: str,
|
||||
profile: str) -> dict | None:
|
||||
"""Advice for the setup screen: a fix made for this exact build exists and this car has shown the failure. Advice only."""
|
||||
if not eligible(config, car_type, profile) or not key:
|
||||
if not eligible(car_type, profile) or not key:
|
||||
return None
|
||||
for rule in RULES:
|
||||
if rule.status != EXPERIMENTAL or not matches(rule, labels) or transport not in rule.transports:
|
||||
@@ -210,5 +207,5 @@ def suggestion(config: dict, labels: dict[str, str], transport: str, quirks: Qui
|
||||
if quirks.early_shutdowns(key) < 2:
|
||||
continue
|
||||
return {"rule": rule.id, "title": rule.summary, "label": rule.label, "path": rule.setting_path,
|
||||
"detail": f"{rule.summary} A setting made for this exact car might help: {rule.setting_path} → {rule.label}. It's experimental."}
|
||||
"detail": f"{rule.summary} A setting made for this exact car might help: {rule.setting_path}, then {rule.label}. It's experimental."}
|
||||
return None
|
||||
|
||||
@@ -159,8 +159,7 @@ DEFAULT_CONFIG = {
|
||||
"car_type": "", # wireless setup shown in Galaxy: "builtin" or "adapter"; "" = work it out from the saved companion car
|
||||
"car_profile_override": "", # "" = pick by fingerprint (a wireless adapter must choose); "default" = standard; otherwise a car_profiles id
|
||||
"car_fingerprint": {}, # what the chosen car's head unit reported last time, used to pick a profile before it connects
|
||||
"head_unit_fixes": True, # master switch for car-specific fixes (Galaxy Developer > StarPort); off = the standard connection for every car
|
||||
"head_unit_experiments": False, # allow experimental fixes at all (Galaxy Developer > StarPort > Specific car experiments)
|
||||
"head_unit_experiments": False, # master switch for car and dongle fixes (Galaxy: Try experimental fixes); off = standard connection
|
||||
"head_unit_experiment_rules": [], # ids of the experimental fixes switched on for this comma's car
|
||||
}
|
||||
|
||||
@@ -202,7 +201,6 @@ def load_config(path: Path | None = None) -> dict:
|
||||
config["usb_mode"] = "auto"
|
||||
config["bitrate_kbps"] = max(1000, min(12000, int(config["bitrate_kbps"])))
|
||||
config["allow_hevc"] = config["allow_hevc"] is True
|
||||
config["head_unit_fixes"] = config["head_unit_fixes"] is not False
|
||||
config["head_unit_experiments"] = config["head_unit_experiments"] is True
|
||||
config["head_unit_experiment_rules"] = sorted({str(rule)[:64] for rule in config["head_unit_experiment_rules"]
|
||||
if isinstance(rule, str)})[:16]
|
||||
|
||||
@@ -78,7 +78,7 @@ RADIO_CHECK_INTERVAL = 0.5 # how often the comma's own Wi-Fi is checked for a
|
||||
RADIO_CHANGE_WINDOW = 15.0 # a join or roam this recent can still stall the car (11-02: stall came 7.5 s after a roam)
|
||||
REPORTED_SETTINGS = ("connection", "usb_mode", "view", "encoder", "fps", "bitrate_kbps", "rate_control", "gpu_nv12",
|
||||
"async_readback", "wifi_interface", "dedicated_wifi_interface", "verify_head_unit", "version_status",
|
||||
"rfcomm_channel", "phone_class", "auto_connect", "allow_hevc", "head_unit_fixes", "head_unit_experiments",
|
||||
"rfcomm_channel", "phone_class", "auto_connect", "allow_hevc", "head_unit_experiments",
|
||||
"head_unit_experiment_rules")
|
||||
|
||||
|
||||
@@ -515,7 +515,6 @@ class Supervisor:
|
||||
status["auto_connect"] = bool(self.config["auto_connect"])
|
||||
status["dedicated_wifi_interface"] = bool(self.config["dedicated_wifi_interface"])
|
||||
status["allow_hevc"] = bool(self.config["allow_hevc"])
|
||||
status["head_unit_fixes"] = bool(self.config["head_unit_fixes"])
|
||||
status["head_unit_experiments"] = bool(self.config["head_unit_experiments"])
|
||||
status["head_unit_experiment_rules"] = list(self.config["head_unit_experiment_rules"])
|
||||
status["experimental_fixes"] = head_unit_fixes.experimental_entries()
|
||||
@@ -558,14 +557,8 @@ class Supervisor:
|
||||
identity_store.save_config(self.config)
|
||||
self.log("allow_hevc_selected", enabled=bool(enabled))
|
||||
|
||||
def set_head_unit_fixes(self, enabled: bool) -> None:
|
||||
"""The master switch for car-specific fixes; off gives the standard connection to every car from the next session."""
|
||||
with self._lock:
|
||||
self.config["head_unit_fixes"] = bool(enabled)
|
||||
identity_store.save_config(self.config)
|
||||
self.log("head_unit_fixes_selected", enabled=bool(enabled))
|
||||
|
||||
def set_head_unit_experiments(self, enabled: bool) -> None:
|
||||
"""The master switch for car and dongle fixes; off gives the standard connection to every car from the next session."""
|
||||
with self._lock:
|
||||
self.config["head_unit_experiments"] = bool(enabled)
|
||||
identity_store.save_config(self.config)
|
||||
@@ -2108,7 +2101,7 @@ class Supervisor:
|
||||
else quirk_state.QuirkState.wired_key(labels))
|
||||
profile = car_profiles.resolve(config)[0]
|
||||
car_type = self.car_type()
|
||||
if head_unit_fixes.eligible(config, car_type, profile):
|
||||
if head_unit_fixes.eligible(car_type, profile):
|
||||
for rule in head_unit_fixes.RULES:
|
||||
if head_unit_fixes.near_miss(rule, labels):
|
||||
self.log("head_unit_rule_near_miss", rule=rule.id, build=labels.get("head_unit_software_version", ""))
|
||||
|
||||
@@ -7,7 +7,7 @@ from openpilot.starpilot.system.starport.quirk_state import QuirkState, SessionO
|
||||
|
||||
RULE = hf.RULES[0]
|
||||
BOLT = dict(RULE.match)
|
||||
CFG_ON = {"head_unit_fixes": True, "head_unit_experiments": True, "head_unit_experiment_rules": [RULE.id]}
|
||||
CFG_ON = {"head_unit_experiments": True, "head_unit_experiment_rules": [RULE.id]}
|
||||
|
||||
|
||||
def pick(config, labels=BOLT, transport="wireless", q=None, key="bt:AA", car_type="builtin", profile="default"):
|
||||
@@ -57,18 +57,18 @@ def test_match_is_case_insensitive_exact():
|
||||
|
||||
|
||||
def test_experimental_rule_needs_both_opt_ins_and_the_rule_toggle():
|
||||
assert pick({"head_unit_fixes": True}) is None
|
||||
assert pick({"head_unit_fixes": True, "head_unit_experiments": True}) is None
|
||||
assert pick({"head_unit_fixes": True, "head_unit_experiments": False, "head_unit_experiment_rules": [RULE.id]}) is None
|
||||
assert pick({}) is None
|
||||
assert pick({"head_unit_experiments": True}) is None
|
||||
assert pick({"head_unit_experiments": False, "head_unit_experiment_rules": [RULE.id]}) is None
|
||||
sel = pick(CFG_ON)
|
||||
assert sel and sel.level == 1 and sel.actions == (hf.OPEN_BLUETOOTH,)
|
||||
|
||||
|
||||
def test_kill_switch_beats_populated_state(tmp_path):
|
||||
def test_experiments_off_beats_populated_state(tmp_path):
|
||||
q = QuirkState(tmp_path / "q.json")
|
||||
q.begin("bt:AA", BOLT, RULE.id)
|
||||
assert pick(CFG_ON, q=q) is not None
|
||||
assert pick({**CFG_ON, "head_unit_fixes": False}, q=q) is None
|
||||
assert pick({**CFG_ON, "head_unit_experiments": False}, q=q) is None
|
||||
|
||||
|
||||
@pytest.mark.parametrize("kwargs", [{"car_type": "adapter"}, {"profile": "aawireless"}, {"profile": "unofficial"}, {"key": ""},
|
||||
@@ -89,7 +89,7 @@ def test_reverted_trial_stays_off(tmp_path):
|
||||
|
||||
def test_suggestion_conditions(tmp_path):
|
||||
q = QuirkState(tmp_path / "q.json")
|
||||
cfg = {"head_unit_fixes": True}
|
||||
cfg = {}
|
||||
early = SessionOutcome(video_seen=True, streamed_s=20, ended_by_car=True)
|
||||
assert hf.suggestion(cfg, BOLT, "wireless", q, "bt:AA", car_type="builtin", profile="default") is None
|
||||
q.record("bt:AA", BOLT, early, now=1)
|
||||
@@ -97,7 +97,7 @@ def test_suggestion_conditions(tmp_path):
|
||||
q.record("bt:AA", BOLT, early, now=2)
|
||||
s = hf.suggestion(cfg, BOLT, "wireless", q, "bt:AA", car_type="builtin", profile="default")
|
||||
assert s and s["rule"] == RULE.id
|
||||
assert hf.suggestion({"head_unit_fixes": False}, BOLT, "wireless", q, "bt:AA", car_type="builtin", profile="default") is None
|
||||
assert hf.suggestion({"head_unit_experiments": True}, BOLT, "wireless", q, "bt:AA", car_type="builtin", profile="default") is not None
|
||||
assert hf.suggestion(cfg, BOLT, "wireless", q, "bt:AA", car_type="adapter", profile="default") is None
|
||||
assert hf.suggestion(cfg, BOLT, "wireless", q, "bt:AA", car_type="builtin", profile="aawireless") is None
|
||||
assert hf.suggestion(CFG_ON, BOLT, "wireless", q, "bt:AA", car_type="builtin", profile="default") is None
|
||||
|
||||
@@ -10,7 +10,7 @@ from openpilot.starpilot.system.starport.tests.test_starport import connect, del
|
||||
from openpilot.starpilot.system.starport.wire import field
|
||||
|
||||
RULE = hf.RULES[0]
|
||||
ON = {"head_unit_fixes": True, "head_unit_experiments": True, "head_unit_experiment_rules": [RULE.id]}
|
||||
ON = {"head_unit_experiments": True, "head_unit_experiment_rules": [RULE.id]}
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
@@ -48,13 +48,13 @@ def test_discovery_labels_identify_the_bolt_build(identity, tmp_path):
|
||||
|
||||
|
||||
def test_without_opt_in_the_bolt_gets_the_default_session(identity, tmp_path):
|
||||
hu, _ = run(identity, tmp_path, {"head_unit_fixes": True})
|
||||
hu, _ = run(identity, tmp_path, {})
|
||||
assert sorted(hu.opened) == [1, 3] and hu.pairing_requests == []
|
||||
assert hu.focus_request_bodies == [field(2, 1) + field(3, 4)]
|
||||
|
||||
|
||||
def test_kill_switch_off_gives_default_session(identity, tmp_path):
|
||||
hu, _ = run(identity, tmp_path, {**ON, "head_unit_fixes": False})
|
||||
def test_experiments_off_gives_default_session(identity, tmp_path):
|
||||
hu, _ = run(identity, tmp_path, {**ON, "head_unit_experiments": False})
|
||||
assert sorted(hu.opened) == [1, 3]
|
||||
|
||||
|
||||
@@ -102,5 +102,5 @@ def bolt_hangs_up(identity, tmp_path, config):
|
||||
|
||||
|
||||
def test_fix_stops_the_bolt_hang_up(identity, tmp_path):
|
||||
assert bolt_hangs_up(identity, tmp_path, {"head_unit_fixes": True}) is True
|
||||
assert bolt_hangs_up(identity, tmp_path, {}) is True
|
||||
assert bolt_hangs_up(identity, tmp_path, ON) is False
|
||||
|
||||
@@ -38,9 +38,8 @@ def test_unofficial_dongle_profile_and_last_rung_do_not_ping():
|
||||
|
||||
def test_phone_ping_needs_every_switch():
|
||||
from openpilot.starpilot.system.starport import head_unit_fixes as hf
|
||||
on = {"head_unit_fixes": True, "head_unit_experiments": True, "head_unit_experiment_rules": ["phone_ping"]}
|
||||
on = {"head_unit_experiments": True, "head_unit_experiment_rules": ["phone_ping"]}
|
||||
assert hf.bootstrap_experiment(on) == "phone_ping"
|
||||
assert hf.bootstrap_experiment({**on, "head_unit_fixes": False}) == ""
|
||||
assert hf.bootstrap_experiment({**on, "head_unit_experiments": False}) == ""
|
||||
assert hf.bootstrap_experiment({**on, "head_unit_experiment_rules": []}) == ""
|
||||
assert hf.bootstrap_experiment({"head_unit_fixes": True}) == ""
|
||||
assert hf.bootstrap_experiment({}) == ""
|
||||
|
||||
Reference in New Issue
Block a user