mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-08-05 13:25:40 +08:00
lpa: move comma-profile check to Profile.is_comma (#37965)
This commit is contained in:
@@ -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]:
|
||||
|
||||
@@ -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)))
|
||||
|
||||
Reference in New Issue
Block a user