am c2042f5e: Merge change 24029 into eclair

Merge commit 'c2042f5e4910c4f7c5b812787ad2b025d93da497' into eclair-plus-aosp

* commit 'c2042f5e4910c4f7c5b812787ad2b025d93da497':
  Fix mncLength in cases with a malformed AD_DONE msg from SIM
This commit is contained in:
Robert Greenwalt
2009-09-04 16:00:08 -07:00
committed by Android Git Automerger

View File

@@ -713,52 +713,58 @@ public final class SIMRecords extends IccRecords {
case EVENT_GET_AD_DONE:
isRecordLoadResponse = true;
try {
isRecordLoadResponse = true;
ar = (AsyncResult)msg.obj;
data = (byte[])ar.result;
ar = (AsyncResult)msg.obj;
data = (byte[])ar.result;
if (ar.exception != null) {
break;
}
if (ar.exception != null) {
break;
}
Log.d(LOG_TAG, "EF_AD: " +
IccUtils.bytesToHexString(data));
Log.d(LOG_TAG, "EF_AD: " +
IccUtils.bytesToHexString(data));
if (data.length < 3) {
Log.d(LOG_TAG, "SIMRecords: Corrupt AD data on SIM");
break;
}
if (data.length == 3) {
Log.d(LOG_TAG, "SIMRecords: MNC length not present in EF_AD");
break;
}
mncLength = (int)data[3] & 0xf;
if (mncLength == 0xf) {
if (imsi != null) {
try {
int mcc = Integer.parseInt(imsi.substring(0,3));
mncLength = MccTable.smallestDigitsMccForMnc(mcc);
} catch (NumberFormatException e) {
mncLength = UNKNOWN;
Log.e(LOG_TAG, "SIMRecords: Corrupt IMSI!");
}
} else {
// Indicate we got this info, but it didn't contain the length.
mncLength = UNKNOWN;
if (data.length < 3) {
Log.d(LOG_TAG, "SIMRecords: Corrupt AD data on SIM");
break;
}
if (data.length == 3) {
Log.d(LOG_TAG, "SIMRecords: MNC length not present in EF_AD");
break;
}
mncLength = (int)data[3] & 0xf;
if (mncLength == 0xf) {
mncLength = UNKNOWN;
}
} finally {
if (mncLength == UNKNOWN || mncLength == UNINITIALIZED) {
if (imsi != null) {
try {
int mcc = Integer.parseInt(imsi.substring(0,3));
mncLength = MccTable.smallestDigitsMccForMnc(mcc);
} catch (NumberFormatException e) {
mncLength = UNKNOWN;
Log.e(LOG_TAG, "SIMRecords: Corrupt IMSI!");
}
} else {
// Indicate we got this info, but it didn't contain the length.
mncLength = UNKNOWN;
Log.d(LOG_TAG, "SIMRecords: MNC length not present in EF_AD");
}
}
if (imsi != null && mncLength != UNKNOWN) {
// finally have both imsi and the length of the mnc and can parse
// the imsi properly
MccTable.updateMccMncConfiguration(phone, imsi.substring(0, 3 + mncLength));
}
}
if (imsi != null && mncLength != UNKNOWN) {
// finally have both imsi and the length of the mnc and can parse it properly
MccTable.updateMccMncConfiguration(phone, imsi.substring(0, 3 + mncLength));
}
break;
case EVENT_GET_SPN_DONE: