diff --git a/system/athena/athenad.py b/system/athena/athenad.py index 94ca0be618..426f1ebad3 100755 --- a/system/athena/athenad.py +++ b/system/athena/athenad.py @@ -561,8 +561,14 @@ def getNetworks(): @dispatcher.add_method -def getEsimProfiles(): - return [asdict(p) for p in HARDWARE.get_sim_lpa().list_profiles()] +def getEsim(): + lpa = HARDWARE.get_sim_lpa() + profiles = [asdict(p) for p in lpa.list_profiles()] + is_bootstrapped = lpa.is_bootstrapped() + return { + "profiles": profiles, + "is_bootstrapped": is_bootstrapped + } @dispatcher.add_method diff --git a/system/hardware/base.py b/system/hardware/base.py index 269c4022a9..4910d1cfb3 100644 --- a/system/hardware/base.py +++ b/system/hardware/base.py @@ -65,6 +65,9 @@ class ThermalConfig: class LPABase(ABC): @abstractmethod def bootstrap(self) -> None: + + @abstractmethod + def is_bootstrapped(self) -> bool: pass @abstractmethod diff --git a/system/hardware/tici/esim.py b/system/hardware/tici/esim.py index 4203a35456..ebbf4ae459 100644 --- a/system/hardware/tici/esim.py +++ b/system/hardware/tici/esim.py @@ -87,16 +87,16 @@ class TiciLPA(LPABase): self._disable_profile(p.iccid) self.delete_profile(p.iccid) + def is_bootstrapped(self) -> bool: + """ check if any comma provisioned profiles are on the eUICC """ + return not any(self.is_comma_profile(iccid) for iccid in (p.iccid for p in self.list_profiles())) + def _disable_profile(self, iccid: str) -> None: self._validate_successful(self._invoke('profile', 'disable', iccid)) self._process_notifications() def _check_bootstrapped(self) -> None: - assert self._is_bootstrapped(), 'eUICC is not bootstrapped, please bootstrap before performing this operation' - - def _is_bootstrapped(self) -> bool: - """ check if any comma provisioned profiles are on the eUICC """ - return not any(self.is_comma_profile(iccid) for iccid in (p.iccid for p in self.list_profiles())) + assert self.is_bootstrapped(), 'eUICC is not bootstrapped, please bootstrap before performing this operation' def _invoke(self, *cmd: str): proc = subprocess.Popen(['sudo', '-E', 'lpac'] + list(cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=self.env)