@@ -141,6 +141,25 @@ public final class SIMRecords extends IccRecords {
141141 private static final int EVENT_SIM_REFRESH = 31 ;
142142 private static final int EVENT_GET_CFIS_DONE = 32 ;
143143
144+ // Lookup table for carriers known to produce SIMs which incorrectly indicate MNC length.
145+
146+ private static final String [] MCCMNC_CODES_HAVING_3DIGITS_MNC = {
147+ "405025" , "405026" , "405027" , "405028" , "405029" , "405030" , "405031" , "405032" ,
148+ "405033" , "405034" , "405035" , "405036" , "405037" , "405038" , "405039" , "405040" ,
149+ "405041" , "405042" , "405043" , "405044" , "405045" , "405046" , "405047" , "405750" ,
150+ "405751" , "405752" , "405753" , "405754" , "405755" , "405756" , "405799" , "405800" ,
151+ "405801" , "405802" , "405803" , "405804" , "405805" , "405806" , "405807" , "405808" ,
152+ "405809" , "405810" , "405811" , "405812" , "405813" , "405814" , "405815" , "405816" ,
153+ "405817" , "405818" , "405819" , "405820" , "405821" , "405822" , "405823" , "405824" ,
154+ "405825" , "405826" , "405827" , "405828" , "405829" , "405830" , "405831" , "405832" ,
155+ "405833" , "405834" , "405835" , "405836" , "405837" , "405838" , "405839" , "405840" ,
156+ "405841" , "405842" , "405843" , "405844" , "405845" , "405846" , "405847" , "405848" ,
157+ "405849" , "405850" , "405851" , "405852" , "405853" , "405875" , "405876" , "405877" ,
158+ "405878" , "405879" , "405880" , "405881" , "405882" , "405883" , "405884" , "405885" ,
159+ "405886" , "405908" , "405909" , "405910" , "405911" , "405925" , "405926" , "405927" ,
160+ "405928" , "405929" , "405932"
161+ };
162+
144163 // ***** Constructor
145164
146165 SIMRecords (GSMPhone p ) {
@@ -498,6 +517,17 @@ public void handleMessage(Message msg) {
498517
499518 Log .d (LOG_TAG , "IMSI: " + imsi .substring (0 , 6 ) + "xxxxxxx" );
500519
520+ if (((mncLength == UNKNOWN ) || (mncLength == 2 )) &&
521+ ((imsi != null ) && (imsi .length () >= 6 ))) {
522+ String mccmncCode = imsi .substring (0 , 6 );
523+ for (String mccmnc : MCCMNC_CODES_HAVING_3DIGITS_MNC ) {
524+ if (mccmnc .equals (mccmncCode )) {
525+ mncLength = 3 ;
526+ break ;
527+ }
528+ }
529+ }
530+
501531 if (mncLength == UNKNOWN ) {
502532 // the SIM has told us all it knows, but it didn't know the mnc length.
503533 // guess using the mcc
@@ -742,6 +772,17 @@ public void handleMessage(Message msg) {
742772 mncLength = UNKNOWN ;
743773 }
744774 } finally {
775+ if (((mncLength == UNINITIALIZED ) || (mncLength == UNKNOWN ) ||
776+ (mncLength == 2 )) && ((imsi != null ) && (imsi .length () >= 6 ))) {
777+ String mccmncCode = imsi .substring (0 , 6 );
778+ for (String mccmnc : MCCMNC_CODES_HAVING_3DIGITS_MNC ) {
779+ if (mccmnc .equals (mccmncCode )) {
780+ mncLength = 3 ;
781+ break ;
782+ }
783+ }
784+ }
785+
745786 if (mncLength == UNKNOWN || mncLength == UNINITIALIZED ) {
746787 if (imsi != null ) {
747788 try {
0 commit comments