mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-10-28 00:03:45 +08:00
9b585d58f5
* force metered on comma prime webbing sim * rearrange --------- Co-authored-by: Daniel Koepping <elkoled@gmail.com>
65 lines
1.2 KiB
Python
65 lines
1.2 KiB
Python
from abc import ABC, abstractmethod
|
|
from dataclasses import dataclass
|
|
|
|
WEBBING_ICCID_PREFIX = "8985235"
|
|
|
|
|
|
class LPAError(RuntimeError):
|
|
pass
|
|
|
|
|
|
class LPAProfileNotFoundError(LPAError):
|
|
pass
|
|
|
|
|
|
@dataclass
|
|
class Profile:
|
|
iccid: str
|
|
nickname: str
|
|
enabled: bool
|
|
provider: str
|
|
|
|
@property
|
|
def is_comma(self) -> bool:
|
|
return self.provider == 'Webbing' and self.iccid.startswith(WEBBING_ICCID_PREFIX)
|
|
|
|
@property
|
|
def display_name(self) -> str:
|
|
if self.is_comma:
|
|
return "comma prime"
|
|
name = self.nickname or self.provider or "<unnamed>"
|
|
return f"{name} (...{self.iccid[-4:]})"
|
|
|
|
|
|
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
|
|
|
|
def process_notifications(self) -> None:
|
|
pass
|
|
|
|
@abstractmethod
|
|
def is_euicc(self) -> bool:
|
|
pass
|