Change to show correct number of unheard voicemail in notification.
Amit Mahajan [Fri, 26 Sep 2014 21:53:54 +0000 (14:53 -0700)]
Bug: 17299884
Change-Id: Ie26a61cbfc2254f95686b8031a0988b9cd58609d

src/java/com/android/internal/telephony/gsm/GsmInboundSmsHandler.java
src/java/com/android/internal/telephony/gsm/SmsMessage.java

index 7e48cc2..a22b0aa 100644 (file)
@@ -107,7 +107,7 @@ public class GsmInboundSmsHandler extends InboundSmsHandler {
 
         boolean handled = false;
         if (sms.isMWISetMessage()) {
-            mPhone.setVoiceMessageWaiting(1, -1);  // line 1: unknown number of msgs waiting
+            mPhone.setVoiceMessageWaiting(1, sms.getNumOfVoicemails());
             handled = sms.isMwiDontStore();
             if (DBG) log("Received voice mail indicator set SMS shouldStore=" + !handled);
         } else if (sms.isMWIClearMessage()) {
index d213641..236c3b1 100644 (file)
@@ -1356,4 +1356,27 @@ public class SmsMessage extends SmsMessageBase {
         return messageClass == MessageClass.CLASS_2 &&
                 (mProtocolIdentifier == 0x7f || mProtocolIdentifier == 0x7c);
     }
+
+    public int getNumOfVoicemails() {
+        /*
+         * Order of priority if multiple indications are present is 1.UDH,
+         *      2.DCS, 3.CPHS.
+         * Voice mail count if voice mail present indication is
+         * received
+         *  1. UDH (or both UDH & DCS): mVoiceMailCount = 0 to 0xff. Ref[TS 23. 040]
+         *  2. DCS only: count is unknown mVoiceMailCount= -1
+         *  3. CPHS only: count is unknown mVoiceMailCount = 0xff. Ref[GSM-BTR-1-4700]
+         * Voice mail clear, mVoiceMailCount = 0.
+         */
+        if ((!mIsMwi) && isCphsMwiMessage()) {
+            if (mOriginatingAddress != null
+                    && ((GsmSmsAddress) mOriginatingAddress).isCphsVoiceMessageSet()) {
+                mVoiceMailCount = 0xff;
+            } else {
+                mVoiceMailCount = 0;
+            }
+            Rlog.v(LOG_TAG, "CPHS voice mail message");
+        }
+        return mVoiceMailCount;
+    }
 }