equip/init: read the selected EF directly, bound the startup drain
pySim's scc.read_binary/read_record call select_path(ef) first, so the ICCID, network-state, EF.ARR and EF.PBR readers - which had already made a parent-scoped selection and hold its FCP - sent a second SELECT per file and per record. _read_selected_ef() issues READ BINARY (chunked at max_cmd_len from the FCP file size) / READ RECORD (b2<rec>04<len> at the FCP record length) directly; the pySim helpers stay as the fallback when the FCP lacks the value. The startup TERMINAL PROFILE drain now breaks on the chain's idle SW instead of polling STATUS once more. Measured on the last startup: ~3.4 s traced init (netstate/ARR/PBR 271 APDUs / 1.26 s incl. 169 SELECTs; the card's own TP processing 1.58 s); the change removes ~0.7-0.8 s of the read phase without touching any data or the TP. v3.38.1; tests: tests/test_read_selected.py (direct reads, chunking, the fallback and the drain source pin) and the ARR/PBR/ICCID/netstate fakes. 1067 Python + 1075 frontend. sw cache simple-v482.
This commit is contained in:
+21
-5
@@ -23,13 +23,29 @@ class FakeFile:
|
||||
self.fid = fid
|
||||
|
||||
|
||||
class FakeScc:
|
||||
"""Serves READ RECORD for the selected fake ARR file."""
|
||||
|
||||
cla_byte = '00'
|
||||
max_cmd_len = 255
|
||||
|
||||
def __init__(self, lchan):
|
||||
self.lchan = lchan
|
||||
self.sent = []
|
||||
|
||||
def send_apdu_checksw(self, pdu):
|
||||
self.sent.append(pdu)
|
||||
return (self.lchan.files[self.lchan._cur][int(pdu[4:6], 16) - 1], '9000')
|
||||
|
||||
|
||||
class FakeLchan:
|
||||
"""One selected ARR file: read_record serves its records."""
|
||||
"""One selected ARR file: READ RECORD serves its records."""
|
||||
|
||||
def __init__(self, files):
|
||||
self.files = files # path -> [record hex]
|
||||
self._cur = None
|
||||
self.selected_file = None
|
||||
self.scc = FakeScc(self)
|
||||
|
||||
def selected_file_num_of_rec(self):
|
||||
return len(self.files.get(self._cur) or [])
|
||||
@@ -96,13 +112,13 @@ class ReadArrTests(unittest.TestCase):
|
||||
|
||||
def test_a_failing_read_skips_the_file(self):
|
||||
app, lchan = _app({'MF/2F06': ['9000'], 'ADF.USIM/6F06': ['9000']})
|
||||
orig = lchan.read_record
|
||||
orig = lchan.scc.send_apdu_checksw
|
||||
|
||||
def flaky(n):
|
||||
def flaky(pdu):
|
||||
if lchan._cur == 'MF/2F06':
|
||||
raise RuntimeError('6A82')
|
||||
return orig(n)
|
||||
lchan.read_record = flaky
|
||||
return orig(pdu)
|
||||
lchan.scc.send_apdu_checksw = flaky
|
||||
arrs = _read(app)
|
||||
self.assertEqual([a['fid'] for a in arrs], ['6F06'])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user