)gdZddlmZmZddlTddlmZmZddlm Z ddl m Z ddl m Z mZGdd ZGd d eZGd d eZdedeefdZdS)z! pySim: Card programmation logic )OptionalTuple)*)EF_DIRCardProfileUICC)DF_GSM)SwHexstr)PathSimCardCommandsc eZdZdZdefdZdeefdZdededdfd Z de eeffd Z d Z d e defd ZdeefdZddedefdZddedeede eeeeffdZdS)CardBasez>F1Q3KQ!-==#c!f++PRBRBRF1QSVAaC[")=)=)A%A#AB$*TTJ%%c!fQq3s1vac{B3G3G!3K/K-K&LMMM  N     Ec!fff> ? ? ?DJJJJJJ zsD#D-- E'7&E""E'r:c^i}d|d<d|d<|}||vr||SdS)Na0000000871002r:a0000000871004isim)lower)r;aid_maps r_get_aidzUiccCardBase._get_aids>**iikk '>>3< traidct|rI|jD]A}t|t|kr||dt|kr|cSBdS)z.find the complete version of an ADF.U/ISIM AIDrN)is_hexrrp)rr aid_knowns r _complete_aidzUiccCardBase._complete_aidse #;; %!Z % % y>>SXX--#1SXX:9N2N2N$$$$trr;cf||}|r||}|rdSdS)zVCheck if the AID of the specified ADF is present in EF.DIR (call read_aids before use)TF)r~r)rr;raid_fulls rr=zUiccCardBase.adf_presents@mmC    ))#..H turNc|p|j}t|r|}n||}|rA||}|r||S||SdS)z0Select ADF.U/ISIM in the Card using its full AIDr?)rrr~r select_adf)rr;rrrs rr@zUiccCardBase.select_adf_by_aidsTY #;; %CC--$$C  '))#..H 0~~h///>>#&& &|rrArB)rCrDrErWr rrHrVrIrGr9 staticmethodrr~rrJr=rr r@rXrYs@rr[r[fs^ D!O!!!!!!,t,,,, 4<$ 0\HV,<sS8Q]bcklrcsu}GvHdH^Irr[rrct|}|r|St|}|r|SdSr)r[rVrL)ruiccsims r card_detectrsM   D zz||  c  C yy{{ 4rN)rFtypingrr osmocom.utilspySim.ts_102_221rrpySim.ts_51_011r pySim.utilsr pySim.commandsr r r rLr[rr8rrrs@,#"""""""44444444"""""" 0000000033333333l , , , , ,( , , ,LLLLL;LLL\ _ ();      r