updater: check for updates while online

This commit is contained in:
1okko
2026-09-28 20:32:27 +08:00
parent 718a417672
commit 57502cb445
2 changed files with 16 additions and 1 deletions
+1 -1
View File
@@ -153,7 +153,7 @@ procs = [
PythonProcess("hardwared", "openpilot.system.hardware.hardwared", always_run),
PythonProcess("modem", "openpilot.common.hardware.comma.modem", always_run, enabled=COMMA_HARDWARE),
PythonProcess("tombstoned", "openpilot.system.tombstoned", always_run, enabled=not PC),
PythonProcess("updated", "openpilot.system.updated.updated", only_offroad, enabled=not PC),
PythonProcess("updated", "openpilot.system.updated.updated", always_run, enabled=not PC),
PythonProcess("uploader", "openpilot.system.loggerd.uploader", uploader_ready),
PythonProcess("statsd", "openpilot.sunnypilot.system.statsd", always_run),
+15
View File
@@ -20,6 +20,7 @@ from openpilot.common.hardware import AGNOS, HARDWARE
from openpilot.common.version import get_build_metadata, SP_BRANCH_MIGRATIONS
LOCK_FILE = os.getenv("UPDATER_LOCK_FILE", "/tmp/safe_staging_overlay.lock")
ONROAD_CHECK_INTERVAL = 15 * 60
STAGING_ROOT = os.getenv("UPDATER_STAGING_ROOT", "/data/safe_staging")
OVERLAY_UPPER = os.path.join(STAGING_ROOT, "upper")
@@ -511,6 +512,7 @@ def main() -> None:
# Run the update loop
first_run = True
last_onroad_check = 0.0
while True:
wait_helper.ready_event.clear()
@@ -528,6 +530,19 @@ def main() -> None:
wait_helper.sleep(60)
continue
# While driving, only check for a remote update. Downloading and applying
# remain offroad-only so an update cannot interfere with driving.
if not params.get_bool("IsOffroad"):
now = time.monotonic()
if now - last_onroad_check >= ONROAD_CHECK_INTERVAL:
params.put("UpdaterState", "checking...", block=True)
updater.check_for_update()
updater.set_params(False, 0, None)
last_onroad_check = now
params.put("UpdaterState", "idle", block=True)
wait_helper.sleep(30)
continue
update_failed_count += 1
# check for update