diff options
author | Robert Greenwalt <robdroid@android.com> | 2009-09-04 15:08:37 -0700 |
---|---|---|
committer | Robert Greenwalt <robdroid@android.com> | 2009-09-04 15:08:37 -0700 |
commit | bf87c9e7d4a11dd6e237222190d6b92b25bf8ac9 (patch) | |
tree | 4f5735f3d2c085dfab2369b6952128ade4ecb5d8 /telephony | |
parent | 3c32474f0e0df419135f1966796d277aba9ee7cb (diff) | |
download | frameworks_base-bf87c9e7d4a11dd6e237222190d6b92b25bf8ac9.zip frameworks_base-bf87c9e7d4a11dd6e237222190d6b92b25bf8ac9.tar.gz frameworks_base-bf87c9e7d4a11dd6e237222190d6b92b25bf8ac9.tar.bz2 |
Fix mncLength in cases with a malformed AD_DONE msg from SIM
Several cases error out and skip our guessing of the mcnLength. This
results in no operator_numeric being set and no APN's matching.
bug: 2101770
Diffstat (limited to 'telephony')
-rw-r--r-- | telephony/java/com/android/internal/telephony/gsm/SIMRecords.java | 76 |
1 files changed, 41 insertions, 35 deletions
diff --git a/telephony/java/com/android/internal/telephony/gsm/SIMRecords.java b/telephony/java/com/android/internal/telephony/gsm/SIMRecords.java index 7f7855a..d711a80 100644 --- a/telephony/java/com/android/internal/telephony/gsm/SIMRecords.java +++ b/telephony/java/com/android/internal/telephony/gsm/SIMRecords.java @@ -713,52 +713,58 @@ public final class SIMRecords extends IccRecords { case EVENT_GET_AD_DONE: - isRecordLoadResponse = true; - - ar = (AsyncResult)msg.obj; - data = (byte[])ar.result; + try { + isRecordLoadResponse = true; - if (ar.exception != null) { - break; - } + ar = (AsyncResult)msg.obj; + data = (byte[])ar.result; - Log.d(LOG_TAG, "EF_AD: " + - IccUtils.bytesToHexString(data)); + if (ar.exception != null) { + break; + } - if (data.length < 3) { - Log.d(LOG_TAG, "SIMRecords: Corrupt AD data on SIM"); - break; - } + Log.d(LOG_TAG, "EF_AD: " + + IccUtils.bytesToHexString(data)); - if (data.length == 3) { - Log.d(LOG_TAG, "SIMRecords: MNC length not present in EF_AD"); - break; - } + if (data.length < 3) { + Log.d(LOG_TAG, "SIMRecords: Corrupt AD data on SIM"); + break; + } - mncLength = (int)data[3] & 0xf; + if (data.length == 3) { + Log.d(LOG_TAG, "SIMRecords: MNC length not present in EF_AD"); + break; + } - if (mncLength == 0xf) { - if (imsi != null) { - try { - int mcc = Integer.parseInt(imsi.substring(0,3)); + mncLength = (int)data[3] & 0xf; - 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. + 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"); + 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: |