diff --git a/system/hardware/base.py b/system/hardware/base.py index 0f578dffa4..5bcf886ae8 100644 --- a/system/hardware/base.py +++ b/system/hardware/base.py @@ -20,6 +20,10 @@ class Profile: enabled: bool provider: str + @property + def is_comma(self) -> bool: + return self.provider == 'Webbing' and self.iccid.startswith('8985235') + @dataclass class ThermalZone: # a zone from /sys/class/thermal/thermal_zone* @@ -98,9 +102,6 @@ class LPABase(ABC): def is_euicc(self) -> bool: pass - def is_comma_profile(self, iccid: str) -> bool: - return any(iccid.startswith(prefix) for prefix in ('8985235',)) - class HardwareBase(ABC): @staticmethod def get_cmdline() -> dict[str, str]: diff --git a/system/hardware/tici/lpa.py b/system/hardware/tici/lpa.py index 1a52915325..3b8a6c6a84 100644 --- a/system/hardware/tici/lpa.py +++ b/system/hardware/tici/lpa.py @@ -19,7 +19,7 @@ from typing import Any from pathlib import Path from openpilot.common.time_helpers import system_time_valid -from openpilot.system.hardware.base import LPABase, LPAError, Profile +from openpilot.system.hardware.base import LPABase, LPAError, LPAProfileNotFoundError, Profile GSMA_CI_BUNDLE = str(Path(__file__).parent / "gsma_ci_bundle.pem") @@ -735,7 +735,10 @@ class TiciLPA(LPABase): process_notifications(self._client) def delete_profile(self, iccid: str) -> None: - if self.is_comma_profile(iccid): + profile = next((p for p in self.list_profiles() if p.iccid == iccid), None) + if profile is None: + raise LPAProfileNotFoundError(f"profile not found: {iccid}") + if profile.is_comma: raise LPAError("refusing to delete a comma profile") with self._acquire_channel(): request = encode_tlv(TAG_DELETE_PROFILE, encode_tlv(TAG_ICCID, string_to_tbcd(iccid)))