From 03194c08774ed5fc872a691d4cc35e4b01dfafef Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Tue, 16 Jul 2024 16:41:16 +0200 Subject: [PATCH] pySim.esim.es8p: Add support for encoding icon in ProfileMetadata Change-Id: I8c6a0c628f07c2a9608174457d20b8955114731a --- pySim/esim/es8p.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pySim/esim/es8p.py b/pySim/esim/es8p.py index a5c88f02..ba824d6c 100644 --- a/pySim/esim/es8p.py +++ b/pySim/esim/es8p.py @@ -79,8 +79,20 @@ class ProfileMetadata: self.iccid_bin = iccid_bin self.spn = spn self.profile_name = profile_name + self.icon = None + self.icon_type = None 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): """Add an 'other' notification to the notification configuration of the metadata""" self.notifications.append((event, address)) @@ -92,6 +104,9 @@ class ProfileMetadata: 'serviceProviderName': self.spn, 'profileName': self.profile_name, } + if self.icon: + smr['icon'] = self.icon + smr['iconType'] = self.icon_type nci = [] for n in self.notifications: pmo = PMO(n[0])