From 57f65eedfcc2d301bb0b7137ec9fc2efcba65529 Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Mon, 18 Oct 2021 14:09:02 +0200 Subject: [PATCH] ts_31_10x: add a class for CardApplicationXSIM In change Id410489841bb9020ddbf74de9114d808b1d5adb6, the RuntimeState class automatically adds additional files to the CardApplications for ISIM and USIM. This works only once. The second time an exception will be thrown because the added files are already in the CardApplication. Currently there is no way generate new card applications during initialization because the card applications are just objects that are created once in ts_31_10x.py. Lets turn them into classes and create the objects during initialization. This way we get fresh objects when we re-initialize. Change-Id: Ibb4f6242e7a92af84a905daa727b1b87016e7819 --- pySim-shell.py | 4 ++-- pySim/ts_31_102.py | 4 +++- pySim/ts_31_103.py | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pySim-shell.py b/pySim-shell.py index d24a881f..594ad974 100755 --- a/pySim-shell.py +++ b/pySim-shell.py @@ -82,8 +82,8 @@ def init_card(sl): # Create runtime state with card profile profile = CardProfileUICC() - profile.add_application(CardApplicationUSIM) - profile.add_application(CardApplicationISIM) + profile.add_application(CardApplicationUSIM()) + profile.add_application(CardApplicationISIM()) rs = RuntimeState(card, profile) # FIXME: do this dynamically diff --git a/pySim/ts_31_102.py b/pySim/ts_31_102.py index faf0f38d..14d7ec1e 100644 --- a/pySim/ts_31_102.py +++ b/pySim/ts_31_102.py @@ -1115,4 +1115,6 @@ sw_usim = { } } -CardApplicationUSIM = CardApplication('USIM', adf=ADF_USIM(), sw=sw_usim) +class CardApplicationUSIM(CardApplication): + def __init__(self): + super().__init__('USIM', adf=ADF_USIM(), sw=sw_usim) diff --git a/pySim/ts_31_103.py b/pySim/ts_31_103.py index e1f552fb..63ef99ea 100644 --- a/pySim/ts_31_103.py +++ b/pySim/ts_31_103.py @@ -223,4 +223,6 @@ sw_isim = { } } -CardApplicationISIM = CardApplication('ISIM', adf=ADF_ISIM(), sw=sw_isim) +class CardApplicationISIM(CardApplication): + def __init__(self): + super().__init__('ISIM', adf=ADF_ISIM(), sw=sw_isim)