mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-12-02 05:43:40 +08:00
Restore Galaxy driving toggles to Developer
This commit is contained in:
@@ -30,7 +30,7 @@ from openpilot.starpilot.ui.feature_settings_state import (
|
||||
FeatureRow, FeatureSettingsRequest, FEATURE_CONFIRM_ACTIONS, is_heading, is_long_confirm_action, row_change, row_default,
|
||||
)
|
||||
from openpilot.starpilot.saved_source import read_saved
|
||||
from openpilot.starpilot.galaxy.device_settings import CALIBRATION_RESET, DRIVER_MONITORING_RESET, DeviceSettingsOwner
|
||||
from openpilot.starpilot.galaxy.device_settings import CALIBRATION_RESET, DRIVER_MONITORING_RESET, KEY as VOACC_KEY, HOLD_KEY, DeviceSettingsOwner
|
||||
from openpilot.starpilot.speed_limits.vision_gate import diagnostic_choice_enabled
|
||||
from openpilot.starpilot.parked_evidence import ParkedEvidence, RESUME_SKEW_NS, fresh_offroad, host_parked
|
||||
from openpilot.starpilot.ui.pip_owner import EDITOR as PIP_EDITOR, FORMAT_PREFIX as PIP_FORMAT_PREFIX, RESET as PIP_RESET, PiPOwner, validated_editor_draft
|
||||
@@ -39,7 +39,7 @@ from openpilot.starpilot.ui.sentry_owner import RESET as SENTRY_RESET, SentryOwn
|
||||
from openpilot.starpilot.ui.vasm_owner import ANNOTATION as VASM_ANNOTATION, RESET as VASM_RESET, VASMOwner, validated_annotation
|
||||
|
||||
|
||||
PAGES = frozenset(("hub", "developer", "localization", "starport_options", "driving_options", "resets", "vehicle",
|
||||
PAGES = frozenset(("hub", "developer", "localization", "starport_options", "resets", "vehicle",
|
||||
"slc", "lane", "lane_change", "profiles", "personalities",
|
||||
"traffic", "aggressive", "standard", "relaxed",
|
||||
"curve", "torque", "torque/developer", "tuning", "torque/bluepilot", "aol", "wheel", "appearance", "display",
|
||||
@@ -56,7 +56,7 @@ TTL = 60.0
|
||||
CAR_CONTROL_SECTIONS = (
|
||||
("lateral", "Lateral (Steering)", ("aol", "lane_change", "lane", "torque", "torque/developer")),
|
||||
("longitudinal", "Longitudinal (Speed & Following)",
|
||||
("driving_options", "profiles", "conditional", "curve", "slc", "aggressive", "standard", "relaxed", "traffic")),
|
||||
("profiles", "conditional", "curve", "slc", "aggressive", "standard", "relaxed", "traffic")),
|
||||
("wheel", "Wheel Controls", ("wheel",)),
|
||||
("visual", "Visual (Display & UI)", ("display", "appearance", "pip")),
|
||||
("sounds", "Sounds & Alerts", ("sounds",)),
|
||||
@@ -147,8 +147,8 @@ def _onroad_preference(page: str, key: str) -> bool:
|
||||
# Regular saved choices are consumed by their runtime owners. Only explicit
|
||||
# multi-key reset/repair operations need the offroad transaction boundary;
|
||||
# their owners independently recheck that requirement at commit time.
|
||||
return bool(page not in ("starport_options", "driving_options", "resets", "power") and key and key != SETUP_ACTION and key not in (
|
||||
"IsRhdDetected", "AlphaLongitudinalEnabled", "reset_profiles", "curve_reset", "slc_reset",
|
||||
return bool(page not in ("starport_options", "resets", "power") and key and key != SETUP_ACTION and key not in (
|
||||
VOACC_KEY, HOLD_KEY, "IsRhdDetected", "AlphaLongitudinalEnabled", "reset_profiles", "curve_reset", "slc_reset",
|
||||
"conditional:reset", "conditional:manual_reset",
|
||||
) and not is_long_confirm_action(key) and not key.startswith("torque_repair:"))
|
||||
|
||||
@@ -649,10 +649,12 @@ class SettingsGateway:
|
||||
def _state(self, page: str, ctx: AuthorityContext):
|
||||
if page == "localization":
|
||||
return self._localization_owner(ctx).snapshot()
|
||||
if page in ("starport_options", "driving_options", "resets"):
|
||||
if page in ("starport_options", "resets"):
|
||||
return self._device_settings_owner(ctx).snapshot(page)
|
||||
if page == "developer":
|
||||
return self._appearance_owner(ctx).developer_snapshot()
|
||||
state = self._appearance_owner(ctx).developer_snapshot()
|
||||
driving = self._device_settings_owner(ctx).snapshot("driving_options")
|
||||
return replace(state, subtitle="Advanced driving and display settings.", rows=driving.rows + state.rows)
|
||||
if page == "appearance":
|
||||
return self._appearance_owner(ctx).snapshot(Profile.COMPACT, include_large=True)
|
||||
if page == "sounds":
|
||||
@@ -683,8 +685,7 @@ class SettingsGateway:
|
||||
state = replace(state, title="Data & Connections")
|
||||
if page == "hub":
|
||||
state = replace(state, rows=state.rows + (
|
||||
FeatureRow("", "Developer", "Advanced display calibration", page="developer", available=True),
|
||||
FeatureRow("", "Longitudinal options", "Vision-only cruise control and Enhanced Stops", page="driving_options", available=True),
|
||||
FeatureRow("", "Developer", "Advanced driving and display settings", page="developer", available=True),
|
||||
))
|
||||
if page in ("torque", "torque/developer"):
|
||||
state = replace(state, rows=tuple(row for row in state.rows if row.key not in ("torque:factor:reset", "torque:friction:reset")))
|
||||
@@ -887,6 +888,8 @@ class SettingsGateway:
|
||||
raise SettingsChanged("Default or saved settings changed")
|
||||
if intent.page == "pip":
|
||||
return self._pip_owner(ctx, live=True, session_valid=session_valid).apply(intent.request)
|
||||
if intent.page == "developer" and intent.request.key in (VOACC_KEY, HOLD_KEY):
|
||||
return self._device_settings_owner(ctx, live=True, session_valid=session_valid).apply(intent.request)
|
||||
if intent.page in ("appearance", "developer"):
|
||||
return self._appearance_owner(ctx, live=True, session_valid=session_valid).apply(intent.request)
|
||||
if intent.page == "sounds":
|
||||
@@ -901,7 +904,7 @@ class SettingsGateway:
|
||||
return self._vasm_owner(ctx, live=True, session_valid=session_valid).apply(intent.request)
|
||||
if intent.page == "localization":
|
||||
return self._localization_owner(ctx, live=True, session_valid=session_valid).apply(intent.request)
|
||||
if intent.page in ("starport_options", "driving_options", "resets"):
|
||||
if intent.page in ("starport_options", "resets"):
|
||||
return self._device_settings_owner(ctx, live=True, session_valid=session_valid).apply(intent.request)
|
||||
owner = self._owner(ctx, live=True, session_valid=session_valid)
|
||||
return owner.apply(intent.request, reset_default=True) if intent.recovery_default else owner.apply(intent.request)
|
||||
|
||||
@@ -6,7 +6,7 @@ const assert = require('node:assert/strict')
|
||||
try {
|
||||
const page = await browser.newPage({ viewport: { width: 390, height: 844 } })
|
||||
const errors = [], writes = [], requests = []
|
||||
let parked = true, enabled = false
|
||||
let parked = true, enabled = false, hold = false, pendingRow = 0
|
||||
page.on('pageerror', error => errors.push(error.message))
|
||||
await page.route('**/device-settings-test', route => route.fulfill({ contentType: 'text/html', body:
|
||||
'<meta name="viewport" content="width=device-width,initial-scale=1"><link rel="stylesheet" href="css/galaxy.css"><link rel="stylesheet" href="css/setup.css"><link rel="stylesheet" href="css/settings.css"><main class="gx-content"><div id="test"></div></main>' }))
|
||||
@@ -18,17 +18,17 @@ const assert = require('node:assert/strict')
|
||||
canSelect: parked, providers: [{ id: 'comma', label: 'comma', url: 'https://connect.comma.ai' }] }
|
||||
else if (path.endsWith('/connect/proxy')) data = { enabled: false, address: '', origin: '', revision: 'proxy', canEdit: parked, passwordConfigured: true }
|
||||
else if (path.endsWith('/pages/hub')) data = { page: 'hub', title: 'Driving Controls', view: 'hub', parked,
|
||||
rows: [{ page: 'driving_options', label: 'Longitudinal options', available: true }, { page: 'profiles', label: 'Long Planner', available: true }] }
|
||||
rows: [{ page: 'developer', label: 'Developer', available: true }, { page: 'profiles', label: 'Long Planner', available: true }] }
|
||||
else if (path.endsWith('/pages/display')) data = { page: 'display', title: 'Display', view: 'display', parked, rows: [{label:'Screen Brightness',value:'Auto',available:true}] }
|
||||
else if (path.endsWith('/pages/data')) data = { page: 'data', title: 'Data & Connections', view: 'data', parked, rows: [{label:'Always Allow Uploads',value:'Off',choices:['Off','On'],available:parked}] }
|
||||
else if (path.endsWith('/pages/starport_options')) data = { page: 'starport_options', title: 'StarPort', view: 'starport', parked, rows: [{label:'Stay on Wi-Fi',value:'On',choices:['Off','On'],available:parked}] }
|
||||
else if (path.endsWith('/pages/localization')) data = { page: 'localization', title: 'Localization', view: 'localization', parked, rows: [{label:'Language',value:'English',available:true}] }
|
||||
else if (path.endsWith('/pages/driving_options')) data = { page: 'driving_options', title: 'Longitudinal options', view: 'driving', parked,
|
||||
rows: [{ label: 'Use VOACC', value: enabled ? 'On' : 'Off', choices: ['Off', 'On'], available: parked, action: true, reason: 'Applies next drive.' }] }
|
||||
else if (path.endsWith('/pages/developer')) data = { page: 'developer', title: 'Developer', view: 'driving', parked,
|
||||
rows: [{ label: 'Use VOACC', value: enabled ? 'On' : 'Off', choices: ['Off', 'On'], available: parked, action: true, reason: 'Applies next drive.' }, { label: 'Always Hold Enhanced Stops', value: hold ? 'On' : 'Off', choices: ['Off', 'On'], available: parked, action: true, reason: 'Applies next drive.' }] }
|
||||
else if (path.endsWith('/pages/resets')) data = { page: 'resets', title: 'Device resets', view: 'resets', parked,
|
||||
rows: ['Reset Driver Monitoring', 'Reset Calibration'].map(label => ({ label, value: 'Ready', confirm: true, available: parked, action: true })) }
|
||||
else if (path.endsWith('/preview')) { writes.push(route.request().postDataJSON()); data = { intent: 'voacc', proposed: 'On', question: 'Set Use VOACC to On?' } }
|
||||
else if (path.endsWith('/confirm')) { enabled = true; data = { saved: true } }
|
||||
else if (path.endsWith('/preview')) { writes.push(route.request().postDataJSON()); pendingRow = writes.at(-1).row; data = { intent: 'voacc', proposed: 'On', question: 'Set Use VOACC to On?' } }
|
||||
else if (path.endsWith('/confirm')) { if (pendingRow === 1) hold = true; else enabled = true; data = { saved: true } }
|
||||
else return route.fulfill({ status: 404, json: { error: 'Unexpected endpoint' } })
|
||||
return route.fulfill({ json: data })
|
||||
})
|
||||
@@ -80,15 +80,22 @@ const assert = require('node:assert/strict')
|
||||
await page.getByText('Language',{exact:true}).waitFor()
|
||||
await page.evaluate(()=>vm.back())
|
||||
await page.getByRole('button', { name: 'Longitudinal (Speed & Following)', exact: true }).click()
|
||||
await page.locator('.gx-row').filter({has:page.getByText('Longitudinal options', {exact:true})}).getByRole('button', {name:'Manage'}).click()
|
||||
assert.equal(await page.getByText('Longitudinal options', {exact:true}).count(), 0)
|
||||
assert.equal(await page.getByRole('switch', {name:'Use VOACC',exact:true}).count(), 0)
|
||||
await page.evaluate(() => mount({ initialPage: 'developer', title: 'Developer' }))
|
||||
const toggle = page.getByRole('switch', { name: 'Use VOACC', exact: true })
|
||||
await toggle.waitFor()
|
||||
await toggle.click()
|
||||
await page.waitForFunction(() => vm.state.data?.rows[0]?.value === 'On')
|
||||
assert.equal(writes[0].value, 'On')
|
||||
const holdToggle = page.getByRole('switch', { name: 'Always Hold Enhanced Stops', exact: true })
|
||||
await holdToggle.click()
|
||||
await page.waitForFunction(() => vm.state.data?.rows[1]?.value === 'On')
|
||||
assert.equal(writes[1].value, 'On')
|
||||
parked = false
|
||||
await page.evaluate(() => vm.feed.load('driving_options'))
|
||||
await page.evaluate(() => vm.feed.load('developer'))
|
||||
assert.equal(await toggle.isDisabled(), true)
|
||||
assert.equal(await holdToggle.isDisabled(), true)
|
||||
await page.evaluate(() => mount({ initialPage: 'resets', title: 'Device resets' }))
|
||||
await page.getByText('Reset Driver Monitoring', { exact: true }).waitFor()
|
||||
await page.getByText('Reset Calibration', { exact: true }).waitFor()
|
||||
|
||||
@@ -178,7 +178,7 @@ class DeviceSettingsTest(unittest.TestCase):
|
||||
token, generation = "session", b"generation"
|
||||
|
||||
def preview(value):
|
||||
page = gateway.page("driving_options", token, generation)
|
||||
page = gateway.page("developer", token, generation)
|
||||
self.assertEqual(page["rows"][0]["label"], "Use VOACC")
|
||||
self.assertEqual(page["rows"][0]["defaultValue"], "Off")
|
||||
self.assertIn("next drive", page["rows"][0]["reason"])
|
||||
@@ -193,7 +193,7 @@ class DeviceSettingsTest(unittest.TestCase):
|
||||
gateway.confirm(intent, token, generation)
|
||||
self.assertEqual(self.path.read_bytes(), b"1")
|
||||
context.value = replace(context.value, parked=True)
|
||||
page = gateway.page("driving_options", token, generation)
|
||||
page = gateway.page("developer", token, generation)
|
||||
intent = gateway.preview(page["view"], 0, 0, token, generation, reset_default=True)
|
||||
self.assertTrue(gateway.confirm(intent["intent"], token, generation))
|
||||
self.assertEqual(self.path.read_bytes(), b"0")
|
||||
@@ -201,6 +201,39 @@ class DeviceSettingsTest(unittest.TestCase):
|
||||
with self.assertRaises(SettingsChanged):
|
||||
gateway.confirm(intent, token, generation, session_valid=lambda: False)
|
||||
|
||||
def test_developer_driving_rows_keep_owner_and_parked_guards(self):
|
||||
from openpilot.starpilot.longitudinal.enhanced_stop_hold import KEY as HOLD_KEY
|
||||
from openpilot.starpilot.galaxy.settings import SettingsUnavailable, _onroad_preference
|
||||
context = SimpleNamespace(value=AuthorityContext(True, None, None))
|
||||
context.sample = lambda: context.value
|
||||
gateway = SettingsGateway(self.params, cast(ContextSource, context), clock=lambda: 10.)
|
||||
token, generation = "session", b"generation"
|
||||
with self.assertRaises(SettingsUnavailable):
|
||||
gateway.page("driving_options", token, generation)
|
||||
for index, key in enumerate((KEY, HOLD_KEY)):
|
||||
with self.subTest(key=key):
|
||||
self.assertFalse(_onroad_preference("developer", key))
|
||||
page = gateway.page("developer", token, generation)
|
||||
row = page["rows"][index]
|
||||
self.assertEqual(row["defaultValue"], "Off")
|
||||
intent = gateway.preview(page["view"], index, 0, token, generation, value="On")["intent"]
|
||||
self.assertTrue(gateway.confirm(intent, token, generation))
|
||||
self.assertEqual(Path(self.params.get_param_path(key)).read_bytes(), b"1")
|
||||
page = gateway.page("developer", token, generation)
|
||||
intent = gateway.preview(page["view"], index, 0, token, generation, value="Off")["intent"]
|
||||
context.value = replace(context.value, parked=False)
|
||||
with self.assertRaises(SettingsChanged):
|
||||
gateway.confirm(intent, token, generation)
|
||||
self.assertFalse(gateway.page("developer", token, generation)["rows"][index]["available"])
|
||||
context.value = replace(context.value, parked=True, editing_saved_vehicle=True)
|
||||
self.assertFalse(gateway.page("developer", token, generation)["rows"][index]["available"])
|
||||
context.value = replace(context.value, editing_saved_vehicle=False)
|
||||
page = gateway.page("developer", token, generation)
|
||||
intent = gateway.preview(page["view"], index, 0, token, generation, reset_default=True)["intent"]
|
||||
self.assertTrue(gateway.confirm(intent, token, generation))
|
||||
self.assertEqual(Path(self.params.get_param_path(key)).read_bytes(), b"0")
|
||||
self.assertEqual(gateway.page("developer", token, generation)["rows"][2]["label"], "Speed display adjustment")
|
||||
|
||||
def test_starport_stay_on_wifi_toggle(self):
|
||||
self.assertNotIn(STARPORT_WIFI_KEY, [row.key for row in self.owner.snapshot("starport_options").rows])
|
||||
service = FakeStarPort()
|
||||
|
||||
@@ -56,12 +56,12 @@ class TestOffroadConfigurationPages(unittest.TestCase):
|
||||
with self.subTest(page=name):
|
||||
current = self.editable_inventory(self.page(name))
|
||||
expected = saved[name]
|
||||
if name == 'driving_options':
|
||||
if name == 'developer':
|
||||
# gated by Park, not by the vehicle
|
||||
self.assertEqual([row[0] for row in expected], ['Use VOACC', 'Always Hold Enhanced Stops'])
|
||||
self.assertEqual([row[1] for row in expected], [False, False])
|
||||
self.assertEqual([row[1] for row in current], [True, True])
|
||||
expected = [(row[0], True, *row[2:]) for row in expected]
|
||||
self.assertEqual([row[0] for row in expected[:2]], ['Use VOACC', 'Always Hold Enhanced Stops'])
|
||||
self.assertEqual([row[1] for row in expected[:2]], [False, False])
|
||||
self.assertEqual([row[1] for row in current[:2]], [True, True])
|
||||
expected = [(row[0], True, *row[2:]) for row in expected[:2]] + expected[2:]
|
||||
if name == 'profiles':
|
||||
# Saved configuration uses the native catalog; this preference is Galaxy-only.
|
||||
label = 'Disengage on Accelerator Pedal'
|
||||
|
||||
@@ -427,7 +427,7 @@ assert.equal(sections.at(-2).label, 'Device & System')
|
||||
assert(!sections.some(section => section.id === 'localization'))
|
||||
assert(sections.find(section => section.id === 'device').pages.includes('localization'))
|
||||
assert(sections.find(section => section.id === 'device').pages.includes('starport_options'))
|
||||
assert(sections.find(section => section.id === 'longitudinal').pages.includes('driving_options'))
|
||||
assert(!sections.find(section => section.id === 'longitudinal').pages.includes('driving_options'))
|
||||
assert.match(SettingsPage.template, /state.data\?\.page === 'data'/)
|
||||
|
||||
for (const subtitle of ["Off: Motion monitoring is disabled.", "Not armed: Battery is low or its charge cannot be checked.", "Not armed: The car is on or the device is shutting down."]) {
|
||||
|
||||
@@ -262,7 +262,7 @@ class SettingsGatewayTest(unittest.TestCase):
|
||||
self.assertEqual(next(page for page in lateral["pages"] if page["id"] == "aol")["title"], self.page("aol")["title"])
|
||||
self.assertEqual([row["page"] for row in hub["rows"]],
|
||||
["aol", "lane_change", "lane", "torque", "torque/developer", "curve", "slc", "profiles", "conditional", "wheel",
|
||||
"vehicle", "personalities", "developer", "driving_options"])
|
||||
"vehicle", "personalities", "developer"])
|
||||
self.assertEqual([row["page"] for row in self.page("personalities")["rows"]],
|
||||
["aggressive", "standard", "relaxed", "traffic"])
|
||||
for page in ("slc", "lane", "lane_change", "profiles", "conditional", "conditional/cem",
|
||||
|
||||
@@ -24,7 +24,7 @@ const post = (fetcher, path, body, signal) => fetcher(path, {
|
||||
|
||||
export const SETTINGS_SECTIONS = Object.freeze([
|
||||
{ id: "lateral", label: "Lateral (Steering)", icon: "bi-arrows-move", pages: ["aol", "lane_change", "lane", "torque", "torque/developer"] },
|
||||
{ id: "longitudinal", label: "Longitudinal (Speed & Following)", icon: "bi-speedometer2", pages: ["driving_options", "profiles", "conditional", "curve", "slc", "personalities", "aggressive", "standard", "relaxed", "traffic"] },
|
||||
{ id: "longitudinal", label: "Longitudinal (Speed & Following)", icon: "bi-speedometer2", pages: ["profiles", "conditional", "curve", "slc", "personalities", "aggressive", "standard", "relaxed", "traffic"] },
|
||||
{ id: "wheel", label: "Wheel Controls", icon: "bi-controller", pages: ["wheel"] },
|
||||
{ id: "visual", label: "Visual (Display & UI)", icon: "bi-eye", pages: ["display", "appearance", "ui_layout", "favorites", "pip"] },
|
||||
{ id: "sounds", label: "Sounds & Alerts", icon: "bi-volume-up", pages: ["sounds"] },
|
||||
|
||||
@@ -34,7 +34,6 @@ export const SETTINGS_WIKI_LINKS = Object.freeze({
|
||||
hub: settings,
|
||||
lateral: settings + '#steering',
|
||||
longitudinal: settings + '#driving-controls',
|
||||
driving_options: settings + '#driving-controls',
|
||||
personalities: settings + '#customize-driving-personalities',
|
||||
starport_options: starport,
|
||||
aol: settings + '#always-on-lateral',
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"protected_inventory_sha256": "946e55cd9ec6abdcec53773d7343faed6b3115af978cf87a246262a5824dddb1", "schema_version": 1}
|
||||
{"protected_inventory_sha256": "37a514391bb45b7864a68918439d9498f419a894e75a89abd1616a44c0f1aba9", "schema_version": 1}
|
||||
|
||||
Reference in New Issue
Block a user