mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-04-02 00:19:31 +03:00
esim.saip: Fix parsing/generating fillPattern + repeatPattern
So far we only thought of default filling coming from a template. However, filling can happen from the Fcp, and we need to properly parse and [re-]encode that information. Change-Id: Iff339cbe841112a01c9c617f43b0e69df2521b51 Related: OS#6643
This commit is contained in:
@@ -116,6 +116,8 @@ class File:
|
|||||||
self.high_update: bool = False
|
self.high_update: bool = False
|
||||||
self.shareable: bool = True
|
self.shareable: bool = True
|
||||||
self.df_name = None
|
self.df_name = None
|
||||||
|
self.fill_pattern = None
|
||||||
|
self.fill_pattern_repeat = False
|
||||||
# apply some defaults from profile
|
# apply some defaults from profile
|
||||||
if self.template:
|
if self.template:
|
||||||
self.from_template(self.template)
|
self.from_template(self.template)
|
||||||
@@ -174,8 +176,6 @@ class File:
|
|||||||
self.fid = template.fid
|
self.fid = template.fid
|
||||||
self.sfi = template.sfi
|
self.sfi = template.sfi
|
||||||
self.arr = template.arr
|
self.arr = template.arr
|
||||||
#self.default_val = template.default_val
|
|
||||||
#self.default_val_repeat = template.default_val_repeat
|
|
||||||
if hasattr(template, 'rec_len'):
|
if hasattr(template, 'rec_len'):
|
||||||
self.rec_len = template.rec_len
|
self.rec_len = template.rec_len
|
||||||
else:
|
else:
|
||||||
@@ -234,14 +234,11 @@ class File:
|
|||||||
fileDescriptor['fileDescriptor'] = build_construct(FileDescriptor._construct, fd_dict)
|
fileDescriptor['fileDescriptor'] = build_construct(FileDescriptor._construct, fd_dict)
|
||||||
if self.high_update:
|
if self.high_update:
|
||||||
pefi['specialFileInformation'] = b'\x80' # TS 102 222 Table 5
|
pefi['specialFileInformation'] = b'\x80' # TS 102 222 Table 5
|
||||||
try:
|
if self.fill_pattern:
|
||||||
if self.template and self.template.default_val_repeat:
|
if not self.fill_pattern_repeat:
|
||||||
pefi['repeatPattern'] = self.template.expand_default_value_pattern()
|
pefi['fillPattern'] = self.fill_pattern
|
||||||
elif self.template and self.template.default_val:
|
else:
|
||||||
pefi['fillPattern'] = self.template.expand_default_value_pattern()
|
pefi['repeatPattern'] = self.fill_pattern
|
||||||
except ValueError:
|
|
||||||
# ignore this here as without a file or record length we cannot do this
|
|
||||||
pass
|
|
||||||
if len(pefi.keys()):
|
if len(pefi.keys()):
|
||||||
# TODO: When overwriting the default "proprietaryEFInfo" for a template EF for which a
|
# TODO: When overwriting the default "proprietaryEFInfo" for a template EF for which a
|
||||||
# default fill or repeat pattern is defined; it is hence recommended to provide the
|
# default fill or repeat pattern is defined; it is hence recommended to provide the
|
||||||
@@ -292,11 +289,13 @@ class File:
|
|||||||
specialFileInformation = pefi.get('specialFileInformation', None)
|
specialFileInformation = pefi.get('specialFileInformation', None)
|
||||||
if specialFileInformation:
|
if specialFileInformation:
|
||||||
if specialFileInformation[0] & 0x80:
|
if specialFileInformation[0] & 0x80:
|
||||||
self.hihgi_update = True
|
self.high_update = True
|
||||||
if 'repeatPattern' in pefi:
|
if 'repeatPattern' in pefi:
|
||||||
self.repeat_pattern = pefi['repeatPattern']
|
self.fill_pattern = pefi['repeatPattern']
|
||||||
if 'defaultPattern' in pefi:
|
self.fill_pattern_repeat = True
|
||||||
self.repeat_pattern = pefi['defaultPattern']
|
if 'fillPattern' in pefi:
|
||||||
|
self.fill_pattern = pefi['fillPattern']
|
||||||
|
self.fill_pattern_repeat = False
|
||||||
elif fdb_dec['file_type'] == 'df':
|
elif fdb_dec['file_type'] == 'df':
|
||||||
# only set it, if an earlier call to from_template() didn't alrady set it, as
|
# only set it, if an earlier call to from_template() didn't alrady set it, as
|
||||||
# the template can differentiate between MF, DF and ADF (unlike FDB)
|
# the template can differentiate between MF, DF and ADF (unlike FDB)
|
||||||
|
|||||||
Reference in New Issue
Block a user