Files
firestar5683 a82935f326 User interfaces and Android Auto
Integrate onroad views, configurable widgets, local settings, steering-profile contracts, Bluetooth and Android Auto with their device and runtime services.

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
Co-authored-by: Daniel Koepping <elkoled@gmail.com>
Co-authored-by: Danny <dannyirwin31@yahoo.com>
Co-authored-by: DimitriChrysafis <Dimitri.chrysafis@gmail.com>
Co-authored-by: Dom <168790843+firestar5683@users.noreply.github.com>
Co-authored-by: Harald Schäfer <harald.the.engineer@gmail.com>
Co-authored-by: Prabhaav Pillai <prabhaav@msu.edu>
Co-authored-by: Shane Smiskol <shane@smiskol.com>
Co-authored-by: dirwin31 <83434411+dirwin31@users.noreply.github.com>
Co-authored-by: firestarsdog <229254897+firestarsdog@users.noreply.github.com>
Co-authored-by: stef <19478336+stefpi@users.noreply.github.com>
Co-authored-by: whoisdomi <dcantu83@gmail.com>

Co-authored-by: Intelli <contact@intelli.software>
Co-authored-by: pharmacomaniac <blittle65@gmail.com>

Co-authored-by: prabhaavp <prabhaav@msu.edu>
2026-10-14 20:02:39 -05:00

67 lines
2.0 KiB
Python

import threading
import time
from openpilot.starpilot.galaxy.software_operations import SoftwareOperations
class NativeSoftwareUpdate:
def __init__(self, permitted):
self.permitted = permitted
self.owner = SoftwareOperations()
self.status = None
self.error = ""
self.busy = False
self.refreshing = False
self.lock = threading.Lock()
self.next_refresh = 0.0
def refresh(self):
if self.busy or self.refreshing or time.monotonic() < self.next_refresh:
return
self.next_refresh = time.monotonic() + 1.0
self.refreshing = True
self._start(None)
def submit(self, action):
if self.busy or not self.permitted():
return False
self.busy = True
self.error = ""
self._start(action)
return True
def _start(self, action):
def work():
try:
with self.lock:
if action is not None:
status = self.owner.status.snapshot()
status["operations"] = self.owner.snapshot()
branch = status["installed"]["branch"] if action == "rollback" else status["operations"]["selectedTarget"] or status["installed"]["branch"]
self.owner.action(action, {"action": action, "branch": branch}, authorized=self.permitted)
status = self.owner.status.snapshot()
status["operations"] = self.owner.snapshot()
self.status = status
self.error = ""
except Exception as error:
self.error = str(error)
finally:
if action is None:
self.refreshing = False
else:
self.busy = False
threading.Thread(target=work, daemon=True).start()
def available(self, action):
key = "canRollback" if action == "rollback" else "canFastUpdate"
return self.permitted() and not self.busy and self.status is not None and self.status["operations"].get(key) is True
def detail(self):
if self.error:
return self.error
if self.status is None:
return ""
fast = self.status["updater"].get("fast")
return fast["detail"] if fast is not None else ""