diff options
author | arunvoddu <arunvoddu@google.com> | 2022-03-10 04:59:49 +0000 |
---|---|---|
committer | arunvoddu <arunvoddu@google.com> | 2022-08-26 04:46:45 +0000 |
commit | 559e5b704d9d5a37862d5a612b72f9dbf79765d6 (patch) | |
tree | 0fc874b7efc0ca15c7c8ee9eaf7e28448266cea8 /src/java/com/android/internal/telephony/uicc | |
parent | 34c143fb44db35ed89067256262367c75dfbfe8d (diff) | |
download | telephony-559e5b704d9d5a37862d5a612b72f9dbf79765d6.tar.gz |
saving null alphaTag if exceeds the uicc allowed limit in
voicemailAlphatag case
Bug: 143508861
Test: aTest verification passed,Manually verified with testapp
Change-Id: Ia28e65337dc341d177996a2f5123f5571979212b
Diffstat (limited to 'src/java/com/android/internal/telephony/uicc')
-rw-r--r-- | src/java/com/android/internal/telephony/uicc/AdnRecordLoader.java | 40 | ||||
-rw-r--r-- | src/java/com/android/internal/telephony/uicc/SIMRecords.java | 35 |
2 files changed, 63 insertions, 12 deletions
diff --git a/src/java/com/android/internal/telephony/uicc/AdnRecordLoader.java b/src/java/com/android/internal/telephony/uicc/AdnRecordLoader.java index a688c6e5d7..5b0a6a3612 100644 --- a/src/java/com/android/internal/telephony/uicc/AdnRecordLoader.java +++ b/src/java/com/android/internal/telephony/uicc/AdnRecordLoader.java @@ -59,6 +59,7 @@ public class AdnRecordLoader extends Handler { static final int EVENT_EF_LINEAR_RECORD_SIZE_DONE = 4; static final int EVENT_UPDATE_RECORD_DONE = 5; + static final int VOICEMAIL_ALPHATAG_ARG = 1; //***** Constructor @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) @@ -177,14 +178,34 @@ public class AdnRecordLoader extends Handler { data = adn.buildAdnString(recordSize[0]); if(data == null) { - throw new RuntimeException("wrong ADN format", - ar.exception); + /** + * The voicemail number saving to the SIM is in name(alphaTag) and number + * format. {@link recordSize[0]} indicates the SIM EF memory size that the + * sim can have to save both voicemail name and number. 14 byte of memory + * is reserved to save the voicemail number and remaining memory is reserved + * for the alphaTag. In case if we receive the alphaTag which is more than + * the reserved memory size then SIM will throw the exception and it don't + * save both the voicemail number and alphaTag. To avoid this problem, in + * case alphaTag length is more we nullify the alphaTag and save the same. + */ + if (mUserResponse.arg1 == VOICEMAIL_ALPHATAG_ARG) { + adn.mAlphaTag = null; + data = adn.buildAdnString(recordSize[0]); + } + if (data == null) { + throw new RuntimeException("wrong ADN format", + ar.exception); + } } - - mFh.updateEFLinearFixed(mEf, getEFPath(mEf), mRecordNumber, - data, mPin2, obtainMessage(EVENT_UPDATE_RECORD_DONE)); - + // Send adn record to caller to track the changes made to alphaTag + if (mUserResponse.arg1 == VOICEMAIL_ALPHATAG_ARG) { + mFh.updateEFLinearFixed(mEf, getEFPath(mEf), mRecordNumber, + data, mPin2, obtainMessage(EVENT_UPDATE_RECORD_DONE, adn)); + } else { + mFh.updateEFLinearFixed(mEf, getEFPath(mEf), mRecordNumber, + data, mPin2, obtainMessage(EVENT_UPDATE_RECORD_DONE)); + } mPendingExtLoads = 1; break; @@ -195,7 +216,12 @@ public class AdnRecordLoader extends Handler { ar.exception); } mPendingExtLoads = 0; - mResult = null; + // send the adn record back to caller through the result of AsyncResult + if (mUserResponse.arg1 == VOICEMAIL_ALPHATAG_ARG) { + mResult = ar.userObj; + } else { + mResult = null; + } break; case EVENT_ADN_LOAD_DONE: ar = (AsyncResult)(msg.obj); diff --git a/src/java/com/android/internal/telephony/uicc/SIMRecords.java b/src/java/com/android/internal/telephony/uicc/SIMRecords.java index 39336c6c0c..77b83ccf48 100644 --- a/src/java/com/android/internal/telephony/uicc/SIMRecords.java +++ b/src/java/com/android/internal/telephony/uicc/SIMRecords.java @@ -34,6 +34,7 @@ import android.text.TextUtils; import android.util.Log; import android.util.Pair; +import com.android.internal.annotations.VisibleForTesting; import com.android.internal.telephony.CommandsInterface; import com.android.internal.telephony.MccTable; import com.android.internal.telephony.SmsConstants; @@ -397,18 +398,20 @@ public class SIMRecords extends IccRecords { mNewVoiceMailTag = alphaTag; AdnRecord adn = new AdnRecord(mNewVoiceMailTag, mNewVoiceMailNum); - if (mMailboxIndex != 0 && mMailboxIndex != 0xff) { new AdnRecordLoader(mFh).updateEF(adn, EF_MBDN, EF_EXT6, mMailboxIndex, null, - obtainMessage(EVENT_SET_MBDN_DONE, onComplete)); + obtainMessage(EVENT_SET_MBDN_DONE, AdnRecordLoader.VOICEMAIL_ALPHATAG_ARG, + 0 /* ignored arg2 */, onComplete)); } else if (isCphsMailboxEnabled()) { new AdnRecordLoader(mFh).updateEF(adn, EF_MAILBOX_CPHS, EF_EXT1, 1, null, - obtainMessage(EVENT_SET_CPHS_MAILBOX_DONE, onComplete)); + obtainMessage(EVENT_SET_CPHS_MAILBOX_DONE, + AdnRecordLoader.VOICEMAIL_ALPHATAG_ARG, + 0 /* ignored arg2 */, onComplete)); } else { AsyncResult.forMessage((onComplete)).exception = @@ -1031,10 +1034,20 @@ public class SIMRecords extends IccRecords { if (DBG) log("EVENT_SET_MBDN_DONE ex:" + ar.exception); if (ar.exception == null) { + /** + * Check for any changes made to voicemail alphaTag while saving to SIM. + * if voicemail alphaTag length is more than allowed limit of SIM EF then + * null alphaTag will be saved to SIM {@code AdnRecordLoader}. + */ + if (ar.result != null) { + AdnRecord adnRecord = (AdnRecord) (ar.result); + if (adnRecord != null) { + mNewVoiceMailTag = adnRecord.mAlphaTag; + } + } mVoiceMailNum = mNewVoiceMailNum; mVoiceMailTag = mNewVoiceMailTag; } - if (isCphsMailboxEnabled()) { adn = new AdnRecord(mVoiceMailTag, mVoiceMailNum); Message onCphsCompleted = (Message) ar.userObj; @@ -1058,7 +1071,8 @@ public class SIMRecords extends IccRecords { new AdnRecordLoader(mFh) .updateEF(adn, EF_MAILBOX_CPHS, EF_EXT1, 1, null, obtainMessage(EVENT_SET_CPHS_MAILBOX_DONE, - onCphsCompleted)); + AdnRecordLoader.VOICEMAIL_ALPHATAG_ARG, + 0 /* ignored arg2 */, onCphsCompleted)); } else { if (ar.userObj != null) { CarrierConfigManager configManager = (CarrierConfigManager) @@ -1090,6 +1104,12 @@ public class SIMRecords extends IccRecords { isRecordLoadResponse = false; ar = (AsyncResult) msg.obj; if (ar.exception == null) { + if (ar.result != null) { + AdnRecord adnRecord = (AdnRecord) (ar.result); + if (adnRecord != null) { + mNewVoiceMailTag = adnRecord.mAlphaTag; + } + } mVoiceMailNum = mNewVoiceMailNum; mVoiceMailTag = mNewVoiceMailTag; } else { @@ -2163,6 +2183,11 @@ public class SIMRecords extends IccRecords { log("[CSP] Value Added Service Group (0xC0), not found!"); } + @VisibleForTesting + public void setMailboxIndex(int mailboxIndex) { + mMailboxIndex = mailboxIndex; + } + @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { pw.println("SIMRecords: " + this); |