*gtdZddlmZmZddlTddlmZmZddlm Z ddl m Z ddl m Z mZGdd ZGd d eZGd d eZdedeefdZdS)z! pySim: Card programmation logic )OptionalTuple)*)EF_DIRCardProfileUICC)DF_GSM)SwHexstr)PathSimCardCommandsceZdZdZdefdZdeefdZdededdfd Z de eeffd Z d Z d e defd ZdeefdZdS)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'usimc^i}d|d<d|d<|}||vr||SdS)Na0000000871002roa0000000871004isim)lower)adfaid_maps r_get_aidzUiccCardBase._get_aid}s>**iikk '>>3< traidct|rI|jD]A}t|t|kr||dt|kr|cSBdS)z.find the complete version of an ADF.U/ISIM AIDrN)is_hexrrf)rrx aid_knowns r _complete_aidzUiccCardBase._complete_aidse #;; %!Z % % y>>SXX--#1SXX:9N2N2N$$$$trrucf||}|r||}|rdSdS)zVCheck if the AID of the specified ADF is present in EF.DIR (call read_aids before use)TF)rwr|)rrurxaid_fulls r adf_presentzUiccCardBase.adf_presents@mmC    ))#..H turNc|p|j}t|r|}n||}|rA||}|r||S||SdS)z0Select ADF.U/ISIM in the Card using its full AID)NN)rrzrwr| select_adf)rrurrxr~s rselect_adf_by_aidzUiccCardBase.select_adf_by_aidsTY #;; %CC--$$C  '))#..H 0~~h///>>#&& &|r)ro)roN)r:r;r<rMr rr?rLr@r>r9 staticmethodrrwr|rjrrr rrNrOs@rrQrQ\s^ D!O!!!!!!,t,,,, 4<$ 0\HV,<sS8Q]bcklrcsu}GvHdH^IrrQrrct|}|r|St|}|r|SdSr)rQrLrB)ruiccsims r card_detectrsM   D zz||  c  C yy{{ 4rN)r=typingrr osmocom.utilspySim.ts_102_221rrpySim.ts_51_011r pySim.utilsr pySim.commandsr r r rBrQrr8rrrs@,#"""""""44444444"""""" 00000000))))))))X , , , , ,( , , ,LLLLL;LLL\ _ ();      r