diff options
11 files changed, 157 insertions, 219 deletions
diff --git a/src/java/com/android/internal/telephony/InboundSmsHandler.java b/src/java/com/android/internal/telephony/InboundSmsHandler.java index 525f875c88..328780fcc5 100644 --- a/src/java/com/android/internal/telephony/InboundSmsHandler.java +++ b/src/java/com/android/internal/telephony/InboundSmsHandler.java @@ -29,7 +29,6 @@ import android.content.ContentValues; import android.content.Context; import android.content.Intent; import android.content.pm.UserInfo; -import android.content.SharedPreferences; import android.database.Cursor; import android.database.SQLException; import android.net.Uri; @@ -43,7 +42,6 @@ import android.os.RemoteException; import android.os.SystemProperties; import android.os.UserHandle; import android.os.UserManager; -import android.preference.PreferenceManager; import android.provider.Telephony; import android.provider.Telephony.Sms.Intents; import android.telephony.Rlog; @@ -941,23 +939,6 @@ public abstract class InboundSmsHandler extends StateMachine { return (PHONE_TYPE_CDMA == activePhone); } - protected void storeVoiceMailCount() { - // Store the voice mail count in persistent memory. - String imsi = mPhone.getSubscriberId(); - int mwi = mPhone.getVoiceMessageCount(); - - log("Storing Voice Mail Count = " + mwi - + " for mVmCountKey = " + ((PhoneBase)mPhone).VM_COUNT - + " vmId = " + ((PhoneBase)mPhone).VM_ID - + " in preferences."); - - SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext); - SharedPreferences.Editor editor = sp.edit(); - editor.putInt(mPhone.VM_COUNT, mwi); - editor.putString(mPhone.VM_ID, imsi); - editor.commit(); - } - /** * Handler for an {@link InboundSmsTracker} broadcast. Deletes PDUs from the raw table and * logs the broadcast duration (as an error if the other receivers were especially slow). diff --git a/src/java/com/android/internal/telephony/PhoneBase.java b/src/java/com/android/internal/telephony/PhoneBase.java index e0753a4f3b..3c7c9afaa9 100644 --- a/src/java/com/android/internal/telephony/PhoneBase.java +++ b/src/java/com/android/internal/telephony/PhoneBase.java @@ -157,11 +157,6 @@ public abstract class PhoneBase extends Handler implements Phone { // Key used to read/write current CLIR setting public static final String CLIR_KEY = "clir_key"; - // Key used for storing voice mail count - public static final String VM_COUNT = "vm_count_key"; - // Key used to read/write the ID for storing the voice mail - public static final String VM_ID = "vm_id_key"; - // Key used to read/write "disable DNS server check" pref (used for testing) public static final String DNS_SERVER_CHECK_DISABLED_KEY = "dns_server_check_disabled_key"; @@ -179,7 +174,6 @@ public abstract class PhoneBase extends Handler implements Phone { /* Instance Variables */ public CommandsInterface mCi; - private int mVmCount = 0; boolean mDnsCheckDisabled; public DcTrackerBase mDcTracker; boolean mDoesRilSendMultipleCallRing; @@ -1175,9 +1169,9 @@ public abstract class PhoneBase extends Handler implements Phone { } @Override - /** @return true if there are messages waiting, false otherwise. */ public boolean getMessageWaitingIndicator() { - return mVmCount != 0; + IccRecords r = mIccRecords.get(); + return (r != null) ? r.getVoiceMessageWaiting() : false; } @Override @@ -1378,36 +1372,9 @@ public abstract class PhoneBase extends Handler implements Phone { public abstract int getPhoneType(); /** @hide */ - /** @return number of voicemails */ @Override public int getVoiceMessageCount(){ - return mVmCount; - } - - /** sets the voice mail count of the phone and notifies listeners. */ - public void setVoiceMessageCount(int countWaiting) { - mVmCount = countWaiting; - // notify listeners of voice mail - notifyMessageWaitingIndicator(); - } - - /** gets the voice mail count from preferences */ - protected int getStoredVoiceMessageCount() { - int countVoiceMessages = 0; - SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext); - String subscriberId = sp.getString(VM_ID, null); - String currentSubscriberId = getSubscriberId(); - - Rlog.d(LOG_TAG, "Voicemail count retrieval for subscriberId = " + subscriberId + - " current subscriberId = " + currentSubscriberId); - - if ((subscriberId != null) && (currentSubscriberId != null) - && (currentSubscriberId.equals(subscriberId))) { - // get voice mail count from preferences - countVoiceMessages = sp.getInt(VM_COUNT, 0); - Rlog.d(LOG_TAG, "Voice Mail Count from preference = " + countVoiceMessages); - } - return countVoiceMessages; + return 0; } /** @@ -1757,9 +1724,19 @@ public abstract class PhoneBase extends Handler implements Phone { return mCi.getLteOnCdmaMode(); } + /** + * Sets the SIM voice message waiting indicator records. + * @param line GSM Subscriber Profile Number, one-based. Only '1' is supported + * @param countWaiting The number of messages waiting, if known. Use + * -1 to indicate that an unknown number of + * messages are waiting + */ + @Override public void setVoiceMessageWaiting(int line, int countWaiting) { - // This function should be overridden by class GSMPhone and CDMAPhone. - Rlog.e(LOG_TAG, "Error! This function should never be executed, inactive Phone."); + IccRecords r = mIccRecords.get(); + if (r != null) { + r.setVoiceMessageWaiting(line, countWaiting); + } } /** diff --git a/src/java/com/android/internal/telephony/TelephonyCapabilities.java b/src/java/com/android/internal/telephony/TelephonyCapabilities.java index b7c68a32a8..2494b2e631 100644 --- a/src/java/com/android/internal/telephony/TelephonyCapabilities.java +++ b/src/java/com/android/internal/telephony/TelephonyCapabilities.java @@ -73,12 +73,12 @@ public class TelephonyCapabilities { } /** - * Return true if the current phone supports voice message count. - * and the count is available - * Both CDMA and GSM phones support voice message count + * Return true if the current phone can retrieve the voice message count. + * + * Currently this is assumed to be true on CDMA phones and false otherwise. */ public static boolean supportsVoiceMessageCount(Phone phone) { - return (phone.getVoiceMessageCount() != -1); + return (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA); } /** diff --git a/src/java/com/android/internal/telephony/cdma/CDMAPhone.java b/src/java/com/android/internal/telephony/cdma/CDMAPhone.java index 7e7574e0cd..2a4e694d3d 100644 --- a/src/java/com/android/internal/telephony/cdma/CDMAPhone.java +++ b/src/java/com/android/internal/telephony/cdma/CDMAPhone.java @@ -94,6 +94,7 @@ public class CDMAPhone extends PhoneBase { // Default Emergency Callback Mode exit timer private static final int DEFAULT_ECM_EXIT_TIMER_VALUE = 300000; + static final String VM_COUNT_CDMA = "vm_count_key_cdma"; private static final String VM_NUMBER_CDMA = "vm_number_key_cdma"; private String mVmNumber = null; @@ -456,6 +457,12 @@ public class CDMAPhone extends PhoneBase { } @Override + public boolean + getMessageWaitingIndicator() { + return (getVoiceMessageCount() > 0); + } + + @Override public List<? extends MmiCode> getPendingMmiCodes() { return mPendingMmis; @@ -933,9 +940,21 @@ public class CDMAPhone extends PhoneBase { return number; } - // pending voice mail count updated after phone creation - private void updateVoiceMail() { - setVoiceMessageCount(getStoredVoiceMessageCount()); + /* Returns Number of Voicemails + * @hide + */ + @Override + public int getVoiceMessageCount() { + IccRecords r = mIccRecords.get(); + int voicemailCount = (r != null) ? r.getVoiceMessageCount() : 0; + // If mRuimRecords.getVoiceMessageCount returns zero, then there is possibility + // that phone was power cycled and would have lost the voicemail count. + // So get the count from preferences. + if (voicemailCount == 0) { + SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext()); + voicemailCount = sp.getInt(VM_COUNT_CDMA + getPhoneId(), 0); + } + return voicemailCount; } @Override @@ -1197,6 +1216,11 @@ public class CDMAPhone extends PhoneBase { } break; + case EVENT_ICC_RECORD_EVENTS: + ar = (AsyncResult)msg.obj; + processIccRecordEvents((Integer)ar.result); + break; + case EVENT_EXIT_EMERGENCY_CALLBACK_RESPONSE:{ handleExitEmergencyCallbackMode(msg); } @@ -1208,7 +1232,6 @@ public class CDMAPhone extends PhoneBase { // Notify voicemails. log("notifyMessageWaitingChanged"); mNotifier.notifyMessageWaitingChanged(this); - updateVoiceMail(); } break; @@ -1249,7 +1272,6 @@ public class CDMAPhone extends PhoneBase { // Notify voicemails. log("notifyMessageWaitingChanged"); mNotifier.notifyMessageWaitingChanged(this); - updateVoiceMail(); } break; @@ -1310,6 +1332,18 @@ public class CDMAPhone extends PhoneBase { } } + private void processIccRecordEvents(int eventCode) { + switch (eventCode) { + case RuimRecords.EVENT_MWI: + notifyMessageWaitingIndicator(); + break; + + default: + Rlog.e(LOG_TAG,"Unknown icc records event code " + eventCode); + break; + } + } + /** * Handles the call to get the subscription source * @@ -1717,6 +1751,7 @@ public class CDMAPhone extends PhoneBase { if (r == null) { return; } + r.registerForRecordsEvents(this, EVENT_ICC_RECORD_EVENTS, null); r.registerForRecordsLoaded(this, EVENT_RUIM_RECORDS_LOADED, null); } @@ -1725,22 +1760,10 @@ public class CDMAPhone extends PhoneBase { if (r == null) { return; } + r.unregisterForRecordsEvents(this); r.unregisterForRecordsLoaded(this); } - /** - * Sets the SIM voice message count - * @param line Subscriber Profile Number, one-based. Only '1' is supported - * @param countWaiting The number of messages waiting, if known. Use - * -1 to indicate that an unknown number of - * messages are waiting - * This is a wrapper function for setVoiceMessageCount - */ - @Override - public void setVoiceMessageWaiting(int line, int countWaiting) { - setVoiceMessageCount(countWaiting); - } - protected void log(String s) { if (DBG) Rlog.d(LOG_TAG, s); diff --git a/src/java/com/android/internal/telephony/cdma/CdmaInboundSmsHandler.java b/src/java/com/android/internal/telephony/cdma/CdmaInboundSmsHandler.java index 37db94e5d6..c20e2ac906 100644 --- a/src/java/com/android/internal/telephony/cdma/CdmaInboundSmsHandler.java +++ b/src/java/com/android/internal/telephony/cdma/CdmaInboundSmsHandler.java @@ -18,9 +18,11 @@ package com.android.internal.telephony.cdma; import android.app.Activity; import android.content.Context; +import android.content.SharedPreferences; import android.content.res.Resources; import android.os.Message; import android.os.SystemProperties; +import android.preference.PreferenceManager; import android.provider.Telephony.Sms.Intents; import android.telephony.SmsCbMessage; @@ -250,18 +252,12 @@ public class CdmaInboundSmsHandler extends InboundSmsHandler { int voicemailCount = sms.getNumOfVoicemails(); if (DBG) log("Voicemail count=" + voicemailCount); - // range check - if (voicemailCount < 0) { - voicemailCount = -1; - } else if (voicemailCount > 99) { - // C.S0015-B v2, 4.5.12 - // range: 0-99 - voicemailCount = 99; - } - // update voice mail count in phone - mPhone.setVoiceMessageCount(voicemailCount); - // store voice mail count in preferences - storeVoiceMailCount(); + // Store the voicemail count in preferences. + SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext); + SharedPreferences.Editor editor = sp.edit(); + editor.putInt(CDMAPhone.VM_COUNT_CDMA + mPhone.getPhoneId(), voicemailCount); + editor.apply(); + mPhone.setVoiceMessageWaiting(1, voicemailCount); } /** diff --git a/src/java/com/android/internal/telephony/gsm/GSMPhone.java b/src/java/com/android/internal/telephony/gsm/GSMPhone.java index 8bdfb0a875..211d397583 100644 --- a/src/java/com/android/internal/telephony/gsm/GSMPhone.java +++ b/src/java/com/android/internal/telephony/gsm/GSMPhone.java @@ -33,7 +33,6 @@ import android.telecom.VideoProfile; import android.telephony.CellLocation; import android.telephony.PhoneNumberUtils; import android.telephony.ServiceState; -import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import com.android.ims.ImsManager; @@ -69,6 +68,7 @@ import com.android.internal.telephony.PhoneNotifier; import com.android.internal.telephony.PhoneProxy; import com.android.internal.telephony.PhoneSubInfo; +import android.telephony.SubscriptionManager; import com.android.internal.telephony.TelephonyProperties; import com.android.internal.telephony.UUSInfo; import com.android.internal.telephony.imsphone.ImsPhone; @@ -330,23 +330,6 @@ public class GSMPhone extends PhoneBase { return mCT; } - // pending voice mail count updated after phone creation - private void updateVoiceMail() { - int countVoiceMessages = 0; - IccRecords r = mIccRecords.get(); - if (r != null) { - // get voice mail count from SIM - countVoiceMessages = r.getVoiceMessageCount(); - } - int countVoiceMessagesStored = getStoredVoiceMessageCount(); - if (countVoiceMessages == -1 && countVoiceMessagesStored != 0) { - countVoiceMessages = countVoiceMessagesStored; - } - Rlog.d(LOG_TAG, "updateVoiceMail countVoiceMessages = " + countVoiceMessages - +" subId "+getSubId()); - setVoiceMessageCount(countVoiceMessages); - } - @Override public List<? extends MmiCode> getPendingMmiCodes() { @@ -1432,7 +1415,6 @@ public class GSMPhone extends PhoneBase { } mSimRecordsLoadedRegistrants.notifyRegistrants(); - updateVoiceMail(); break; case EVENT_GET_BASEBAND_VERSION_DONE: @@ -1636,10 +1618,13 @@ public class GSMPhone extends PhoneBase { case IccRecords.EVENT_CFI: notifyCallForwardingIndicator(); break; + case IccRecords.EVENT_MWI: + notifyMessageWaitingIndicator(); + break; } } - /** + /** * Sets the "current" field in the telephony provider according to the SIM's operator * * @return true for success; false otherwise. @@ -1880,23 +1865,6 @@ public class GSMPhone extends PhoneBase { public void resetSubSpecifics() { } - /** - * Sets the SIM voice message waiting indicator records. - * @param line GSM Subscriber Profile Number, one-based. Only '1' is supported - * @param countWaiting The number of messages waiting, if known. Use - * -1 to indicate that an unknown number of - * messages are waiting - */ - @Override - public void setVoiceMessageWaiting(int line, int countWaiting) { - IccRecords r = mIccRecords.get(); - if (r != null) { - r.setVoiceMessageWaiting(line, countWaiting); - } else { - log("SIM Records not found, MWI not updated"); - } - } - protected void log(String s) { Rlog.d(LOG_TAG, "[GSMPhone] " + s); } diff --git a/src/java/com/android/internal/telephony/gsm/GsmInboundSmsHandler.java b/src/java/com/android/internal/telephony/gsm/GsmInboundSmsHandler.java index 0db251d3b6..a22b0aa66e 100644 --- a/src/java/com/android/internal/telephony/gsm/GsmInboundSmsHandler.java +++ b/src/java/com/android/internal/telephony/gsm/GsmInboundSmsHandler.java @@ -27,8 +27,6 @@ import com.android.internal.telephony.PhoneBase; import com.android.internal.telephony.SmsConstants; import com.android.internal.telephony.SmsMessageBase; import com.android.internal.telephony.SmsStorageMonitor; -import com.android.internal.telephony.uicc.IccRecords; -import com.android.internal.telephony.uicc.UiccController; import com.android.internal.telephony.uicc.UsimServiceTable; /** @@ -109,11 +107,11 @@ public class GsmInboundSmsHandler extends InboundSmsHandler { boolean handled = false; if (sms.isMWISetMessage()) { - updateMessageWaitingIndicator(sms.getNumOfVoicemails()); + mPhone.setVoiceMessageWaiting(1, sms.getNumOfVoicemails()); handled = sms.isMwiDontStore(); if (DBG) log("Received voice mail indicator set SMS shouldStore=" + !handled); } else if (sms.isMWIClearMessage()) { - updateMessageWaitingIndicator(0); + mPhone.setVoiceMessageWaiting(1, 0); // line 1: no msgs waiting handled = sms.isMwiDontStore(); if (DBG) log("Received voice mail indicator clear SMS shouldStore=" + !handled); } @@ -131,29 +129,6 @@ public class GsmInboundSmsHandler extends InboundSmsHandler { return dispatchNormalMessage(smsb); } - /* package */ void updateMessageWaitingIndicator(int voicemailCount) { - // range check - if (voicemailCount < 0) { - voicemailCount = -1; - } else if (voicemailCount > 0xff) { - // TS 23.040 9.2.3.24.2 - // "The value 255 shall be taken to mean 255 or greater" - voicemailCount = 0xff; - } - // update voice mail count in GsmPhone - mPhone.setVoiceMessageCount(voicemailCount); - // store voice mail count in SIM & shared preferences - IccRecords records = UiccController.getInstance().getIccRecords( - mPhone.getPhoneId(), UiccController.APP_FAM_3GPP); - if (records != null) { - log("updateMessageWaitingIndicator: updating SIM Records"); - records.setVoiceMessageWaiting(1, voicemailCount); - } else { - log("updateMessageWaitingIndicator: SIM Records not found"); - } - storeVoiceMailCount(); - } - /** * Send an acknowledge message. * @param success indicates that last message was successfully received. diff --git a/src/java/com/android/internal/telephony/uicc/IccRecords.java b/src/java/com/android/internal/telephony/uicc/IccRecords.java index 1831f4e513..369743089a 100644 --- a/src/java/com/android/internal/telephony/uicc/IccRecords.java +++ b/src/java/com/android/internal/telephony/uicc/IccRecords.java @@ -65,6 +65,7 @@ public abstract class IccRecords extends Handler implements IccConstants { protected String mNewVoiceMailNum = null; protected String mNewVoiceMailTag = null; protected boolean mIsVoiceMailFixed = false; + protected int mCountVoiceMessages = 0; protected String mImsi; private IccIoResult auth_rsp; @@ -121,6 +122,7 @@ public abstract class IccRecords extends Handler implements IccConstants { + " newVoiceMailNum=" + mNewVoiceMailNum + " newVoiceMailTag=" + mNewVoiceMailTag + " isVoiceMailFixed=" + mIsVoiceMailFixed + + " countVoiceMessages=" + mCountVoiceMessages + " mImsi=" + mImsi + " mncLength=" + mMncLength + " mailboxIndex=" + mMailboxIndex @@ -381,10 +383,19 @@ public abstract class IccRecords extends Handler implements IccConstants { */ public abstract void setVoiceMessageWaiting(int line, int countWaiting); + /** @return true if there are messages waiting, false otherwise. */ + public boolean getVoiceMessageWaiting() { + return mCountVoiceMessages != 0; + } + /** - * Called by GsmPhone to update VoiceMail count + * Returns number of voice messages waiting, if available + * If not available (eg, on an older CPHS SIM) -1 is returned if + * getVoiceMessageWaiting() is true */ - public abstract int getVoiceMessageCount(); + public int getVoiceMessageCount() { + return mCountVoiceMessages; + } /** * Called by STK Service when REFRESH is received. @@ -647,6 +658,7 @@ public abstract class IccRecords extends Handler implements IccConstants { pw.println(" mNewVoiceMailNum=" + mNewVoiceMailNum); pw.println(" mNewVoiceMailTag=" + mNewVoiceMailTag); pw.println(" mIsVoiceMailFixed=" + mIsVoiceMailFixed); + pw.println(" mCountVoiceMessages=" + mCountVoiceMessages); pw.println(" mImsi=" + mImsi); pw.println(" mMncLength=" + mMncLength); pw.println(" mMailboxIndex=" + mMailboxIndex); diff --git a/src/java/com/android/internal/telephony/uicc/IsimUiccRecords.java b/src/java/com/android/internal/telephony/uicc/IsimUiccRecords.java index c7c1c8fb99..9bf45875a7 100644 --- a/src/java/com/android/internal/telephony/uicc/IsimUiccRecords.java +++ b/src/java/com/android/internal/telephony/uicc/IsimUiccRecords.java @@ -517,10 +517,4 @@ public final class IsimUiccRecords extends IccRecords implements IsimRecords { pw.println(" mIsimPcscf"+mIsimPcscf); pw.flush(); } - - @Override - public int getVoiceMessageCount() { - return 0; // Not applicable to Isim - } - } diff --git a/src/java/com/android/internal/telephony/uicc/RuimRecords.java b/src/java/com/android/internal/telephony/uicc/RuimRecords.java index d296f78e1f..1a591c697d 100644 --- a/src/java/com/android/internal/telephony/uicc/RuimRecords.java +++ b/src/java/com/android/internal/telephony/uicc/RuimRecords.java @@ -134,6 +134,7 @@ public final class RuimRecords extends IccRecords { } protected void resetRecords() { + mCountVoiceMessages = 0; mMncLength = UNINITIALIZED; log("setting0 mMncLength" + mMncLength); mIccId = null; @@ -794,17 +795,22 @@ public final class RuimRecords extends IccRecords { @Override public void setVoiceMessageWaiting(int line, int countWaiting) { - // Will be used in future to store voice mail count in UIM - // C.S0023-D_v1.0 does not have a file id in UIM for MWI - log("RuimRecords:setVoiceMessageWaiting - NOP for CDMA"); - } + if (line != 1) { + // only profile 1 is supported + return; + } - @Override - public int getVoiceMessageCount() { - // Will be used in future to retrieve voice mail count for UIM - // C.S0023-D_v1.0 does not have a file id in UIM for MWI - log("RuimRecords:getVoiceMessageCount - NOP for CDMA"); - return 0; + // range check + if (countWaiting < 0) { + countWaiting = -1; + } else if (countWaiting > 0xff) { + // C.S0015-B v2, 4.5.12 + // range: 0-99 + countWaiting = 0xff; + } + mCountVoiceMessages = countWaiting; + + mRecordsEventsRegistrants.notifyResult(EVENT_MWI); } private void handleRuimRefresh(IccRefreshResponse refreshResponse) { diff --git a/src/java/com/android/internal/telephony/uicc/SIMRecords.java b/src/java/com/android/internal/telephony/uicc/SIMRecords.java index 4ca8f085a0..f3cf197612 100644 --- a/src/java/com/android/internal/telephony/uicc/SIMRecords.java +++ b/src/java/com/android/internal/telephony/uicc/SIMRecords.java @@ -236,6 +236,7 @@ public class SIMRecords extends IccRecords { mImsi = null; mMsisdn = null; mVoiceMailNum = null; + mCountVoiceMessages = 0; mMncLength = UNINITIALIZED; log("setting0 mMncLength" + mMncLength); mIccId = null; @@ -407,13 +408,26 @@ public class SIMRecords extends IccRecords { return; } + // range check + if (countWaiting < 0) { + countWaiting = -1; + } else if (countWaiting > 0xff) { + // TS 23.040 9.2.3.24.2 + // "The value 255 shall be taken to mean 255 or greater" + countWaiting = 0xff; + } + + mCountVoiceMessages = countWaiting; + + mRecordsEventsRegistrants.notifyResult(EVENT_MWI); + try { if (mEfMWIS != null) { // TS 51.011 10.3.45 // lsb of byte 0 is 'voicemail' status mEfMWIS[0] = (byte)((mEfMWIS[0] & 0xfe) - | (countWaiting == 0 ? 0 : 1)); + | (mCountVoiceMessages == 0 ? 0 : 1)); // byte 1 is the number of voice messages waiting if (countWaiting < 0) { @@ -426,13 +440,14 @@ public class SIMRecords extends IccRecords { mFh.updateEFLinearFixed( EF_MWIS, 1, mEfMWIS, null, - obtainMessage (EVENT_UPDATE_DONE, EF_MWIS, 0)); + obtainMessage (EVENT_UPDATE_DONE, EF_MWIS)); } if (mEfCPHS_MWI != null) { // Refer CPHS4_2.WW6 B4.2.3 mEfCPHS_MWI[0] = (byte)((mEfCPHS_MWI[0] & 0xf0) - | (countWaiting == 0 ? 0x5 : 0xa)); + | (mCountVoiceMessages == 0 ? 0x5 : 0xa)); + mFh.updateEFTransparent( EF_VOICE_MAIL_INDICATOR_CPHS, mEfCPHS_MWI, obtainMessage (EVENT_UPDATE_DONE, EF_VOICE_MAIL_INDICATOR_CPHS)); @@ -448,37 +463,6 @@ public class SIMRecords extends IccRecords { return ((data != null) && (data[0] >= 1) && (data[0] <= 4)); } - public int getVoiceMessageCount() { - boolean voiceMailWaiting = false; - int countVoiceMessages = -1; - if (mEfMWIS != null) { - // Use this data if the EF[MWIS] exists and - // has been loaded - // Refer TS 51.011 Section 10.3.45 for the content description - voiceMailWaiting = ((mEfMWIS[0] & 0x01) != 0); - countVoiceMessages = mEfMWIS[1] & 0xff; - - if (voiceMailWaiting && countVoiceMessages == 0) { - // Unknown count = -1 - countVoiceMessages = -1; - } - if(DBG) log(" VoiceMessageCount from SIM MWIS = " + countVoiceMessages); - } else if (mEfCPHS_MWI != null) { - // use voice mail count from CPHS - int indicator = (int) (mEfCPHS_MWI[0] & 0xf); - - // Refer CPHS4_2.WW6 B4.2.3 - if (indicator == 0xA) { - // Unknown count = -1 - countVoiceMessages = -1; - } else if (indicator == 0x5) { - countVoiceMessages = 0; - } - if(DBG) log(" VoiceMessageCount from SIM CPHS = " + countVoiceMessages); - } - return countVoiceMessages; - } - /** * {@inheritDoc} */ @@ -795,21 +779,30 @@ public class SIMRecords extends IccRecords { ar = (AsyncResult)msg.obj; data = (byte[])ar.result; - if(DBG) log("EF_MWIS : " + IccUtils.bytesToHexString(data)); - if (ar.exception != null) { - if(DBG) log("EVENT_GET_MWIS_DONE exception = " - + ar.exception); break; } + log("EF_MWIS: " + IccUtils.bytesToHexString(data)); + + mEfMWIS = data; + if ((data[0] & 0xff) == 0xff) { - if(DBG) log("SIMRecords: Uninitialized record MWIS"); + log("Uninitialized record MWIS"); break; } - mEfMWIS = data; - break; + // Refer TS 51.011 Section 10.3.45 for the content description + boolean voiceMailWaiting = ((data[0] & 0x01) != 0); + mCountVoiceMessages = data[1] & 0xff; + + if (voiceMailWaiting && mCountVoiceMessages == 0) { + // Unknown count = -1 + mCountVoiceMessages = -1; + } + + mRecordsEventsRegistrants.notifyResult(EVENT_MWI); + break; case EVENT_GET_VOICE_MAIL_INDICATOR_CPHS_DONE: isRecordLoadResponse = true; @@ -817,16 +810,29 @@ public class SIMRecords extends IccRecords { ar = (AsyncResult)msg.obj; data = (byte[])ar.result; - if(DBG) log("EF_CPHS_MWI: " + IccUtils.bytesToHexString(data)); - if (ar.exception != null) { - if(DBG) log("EVENT_GET_VOICE_MAIL_INDICATOR_CPHS_DONE exception = " - + ar.exception); break; } mEfCPHS_MWI = data; - break; + + // Use this data if the EF[MWIS] exists and + // has been loaded + + if (mEfMWIS == null) { + int indicator = data[0] & 0xf; + + // Refer CPHS4_2.WW6 B4.2.3 + if (indicator == 0xA) { + // Unknown count = -1 + mCountVoiceMessages = -1; + } else if (indicator == 0x5) { + mCountVoiceMessages = 0; + } + + mRecordsEventsRegistrants.notifyResult(EVENT_MWI); + } + break; case EVENT_GET_ICCID_DONE: isRecordLoadResponse = true; |