refactor: LPA interface, CLI location (#35328)

* refactor: LPABase, simpler switch() interface

* leave this since LPABase hides

* hw-agnostic esim.py

* newline

* use latest
This commit is contained in:
Trey Moen
2025-05-25 08:54:07 -07:00
committed by GitHub
parent 840ced5005
commit 993b1b4d88
7 changed files with 117 additions and 90 deletions
+42
View File
@@ -6,6 +6,19 @@ from cereal import log
NetworkType = log.DeviceState.NetworkType
class LPAError(RuntimeError):
pass
class LPAProfileNotFoundError(LPAError):
pass
@dataclass
class Profile:
iccid: str
nickname: str
enabled: bool
provider: str
@dataclass
class ThermalZone:
# a zone from /sys/class/thermal/thermal_zone*
@@ -51,6 +64,31 @@ class ThermalConfig:
ret[f.name + "TempC"] = v.read()
return ret
class LPABase(ABC):
@abstractmethod
def list_profiles(self) -> list[Profile]:
pass
@abstractmethod
def get_active_profile(self) -> Profile | None:
pass
@abstractmethod
def delete_profile(self, iccid: str) -> None:
pass
@abstractmethod
def download_profile(self, qr: str, nickname: str | None = None) -> None:
pass
@abstractmethod
def nickname_profile(self, iccid: str, nickname: str) -> None:
pass
@abstractmethod
def switch_profile(self, iccid: str) -> None:
pass
class HardwareBase(ABC):
@staticmethod
def get_cmdline() -> dict[str, str]:
@@ -105,6 +143,10 @@ class HardwareBase(ABC):
def get_sim_info(self):
pass
@abstractmethod
def get_sim_lpa(self) -> LPABase:
pass
@abstractmethod
def get_network_strength(self, network_type):
pass