mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-30 17:01:46 +03:00
pySim.esim.es8p: Add support for encoding icon in ProfileMetadata
Change-Id: I8c6a0c628f07c2a9608174457d20b8955114731a
This commit is contained in:
@@ -79,8 +79,20 @@ class ProfileMetadata:
|
|||||||
self.iccid_bin = iccid_bin
|
self.iccid_bin = iccid_bin
|
||||||
self.spn = spn
|
self.spn = spn
|
||||||
self.profile_name = profile_name
|
self.profile_name = profile_name
|
||||||
|
self.icon = None
|
||||||
|
self.icon_type = None
|
||||||
self.notifications = []
|
self.notifications = []
|
||||||
|
|
||||||
|
def set_icon(self, is_png: bool, icon_data: bytes):
|
||||||
|
"""Set the icon that is part of the metadata."""
|
||||||
|
if len(icon_data) > 1024:
|
||||||
|
raise ValueError('Icon data must not exceed 1024 bytes')
|
||||||
|
self.icon = icon_data
|
||||||
|
if is_png:
|
||||||
|
self.icon_type = 1
|
||||||
|
else:
|
||||||
|
self.icon_type = 0
|
||||||
|
|
||||||
def add_notification(self, event: str, address: str):
|
def add_notification(self, event: str, address: str):
|
||||||
"""Add an 'other' notification to the notification configuration of the metadata"""
|
"""Add an 'other' notification to the notification configuration of the metadata"""
|
||||||
self.notifications.append((event, address))
|
self.notifications.append((event, address))
|
||||||
@@ -92,6 +104,9 @@ class ProfileMetadata:
|
|||||||
'serviceProviderName': self.spn,
|
'serviceProviderName': self.spn,
|
||||||
'profileName': self.profile_name,
|
'profileName': self.profile_name,
|
||||||
}
|
}
|
||||||
|
if self.icon:
|
||||||
|
smr['icon'] = self.icon
|
||||||
|
smr['iconType'] = self.icon_type
|
||||||
nci = []
|
nci = []
|
||||||
for n in self.notifications:
|
for n in self.notifications:
|
||||||
pmo = PMO(n[0])
|
pmo = PMO(n[0])
|
||||||
|
|||||||
Reference in New Issue
Block a user