@@ -144,6 +144,25 @@ public final class SIMRecords extends IccRecords {
144144 private static final int EVENT_GET_CFIS_DONE = 32 ;
145145 private static final int EVENT_GET_CSP_CPHS_DONE = 33 ;
146146
147+ // Lookup table for carriers known to produce SIMs which incorrectly indicate MNC length.
148+
149+ private static final String [] MCCMNC_CODES_HAVING_3DIGITS_MNC = {
150+ "405025" , "405026" , "405027" , "405028" , "405029" , "405030" , "405031" , "405032" ,
151+ "405033" , "405034" , "405035" , "405036" , "405037" , "405038" , "405039" , "405040" ,
152+ "405041" , "405042" , "405043" , "405044" , "405045" , "405046" , "405047" , "405750" ,
153+ "405751" , "405752" , "405753" , "405754" , "405755" , "405756" , "405799" , "405800" ,
154+ "405801" , "405802" , "405803" , "405804" , "405805" , "405806" , "405807" , "405808" ,
155+ "405809" , "405810" , "405811" , "405812" , "405813" , "405814" , "405815" , "405816" ,
156+ "405817" , "405818" , "405819" , "405820" , "405821" , "405822" , "405823" , "405824" ,
157+ "405825" , "405826" , "405827" , "405828" , "405829" , "405830" , "405831" , "405832" ,
158+ "405833" , "405834" , "405835" , "405836" , "405837" , "405838" , "405839" , "405840" ,
159+ "405841" , "405842" , "405843" , "405844" , "405845" , "405846" , "405847" , "405848" ,
160+ "405849" , "405850" , "405851" , "405852" , "405853" , "405875" , "405876" , "405877" ,
161+ "405878" , "405879" , "405880" , "405881" , "405882" , "405883" , "405884" , "405885" ,
162+ "405886" , "405908" , "405909" , "405910" , "405911" , "405925" , "405926" , "405927" ,
163+ "405928" , "405929" , "405932"
164+ };
165+
147166 // ***** Constructor
148167
149168 SIMRecords (GSMPhone p ) {
@@ -501,6 +520,17 @@ public void handleMessage(Message msg) {
501520
502521 Log .d (LOG_TAG , "IMSI: " + imsi .substring (0 , 6 ) + "xxxxxxx" );
503522
523+ if (((mncLength == UNKNOWN ) || (mncLength == 2 )) &&
524+ ((imsi != null ) && (imsi .length () >= 6 ))) {
525+ String mccmncCode = imsi .substring (0 , 6 );
526+ for (String mccmnc : MCCMNC_CODES_HAVING_3DIGITS_MNC ) {
527+ if (mccmnc .equals (mccmncCode )) {
528+ mncLength = 3 ;
529+ break ;
530+ }
531+ }
532+ }
533+
504534 if (mncLength == UNKNOWN ) {
505535 // the SIM has told us all it knows, but it didn't know the mnc length.
506536 // guess using the mcc
@@ -752,6 +782,17 @@ public void handleMessage(Message msg) {
752782 mncLength = UNKNOWN ;
753783 }
754784 } finally {
785+ if (((mncLength == UNINITIALIZED ) || (mncLength == UNKNOWN ) ||
786+ (mncLength == 2 )) && ((imsi != null ) && (imsi .length () >= 6 ))) {
787+ String mccmncCode = imsi .substring (0 , 6 );
788+ for (String mccmnc : MCCMNC_CODES_HAVING_3DIGITS_MNC ) {
789+ if (mccmnc .equals (mccmncCode )) {
790+ mncLength = 3 ;
791+ break ;
792+ }
793+ }
794+ }
795+
755796 if (mncLength == UNKNOWN || mncLength == UNINITIALIZED ) {
756797 if (imsi != null ) {
757798 try {
0 commit comments