Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fea4c4ab authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Telephony: Voice mail notification related changes"

parents 69a90bda 4d8fb81a
Loading
Loading
Loading
Loading
+20 −0
Original line number Original line Diff line number Diff line
@@ -27,6 +27,7 @@ import android.content.ContentUris;
import android.content.ContentValues;
import android.content.ContentValues;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.database.Cursor;
import android.database.SQLException;
import android.database.SQLException;
import android.net.Uri;
import android.net.Uri;
@@ -35,6 +36,7 @@ import android.os.Build;
import android.os.Message;
import android.os.Message;
import android.os.PowerManager;
import android.os.PowerManager;
import android.os.SystemProperties;
import android.os.SystemProperties;
import android.preference.PreferenceManager;
import android.provider.Telephony;
import android.provider.Telephony;
import android.provider.Telephony.Sms.Intents;
import android.provider.Telephony.Sms.Intents;
import android.telephony.Rlog;
import android.telephony.Rlog;
@@ -811,6 +813,24 @@ public abstract class InboundSmsHandler extends StateMachine {
        return (PHONE_TYPE_CDMA == activePhone);
        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 imsi = " + imsi
                    + " 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
     * 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).
     * logs the broadcast duration (as an error if the other receivers were especially slow).
+19 −15
Original line number Original line Diff line number Diff line
@@ -133,6 +133,11 @@ public abstract class PhoneBase extends Handler implements Phone {
    // Key used to read/write current CLIR setting
    // Key used to read/write current CLIR setting
    public static final String CLIR_KEY = "clir_key";
    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)
    // 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";
    public static final String DNS_SERVER_CHECK_DISABLED_KEY = "dns_server_check_disabled_key";


@@ -141,6 +146,7 @@ public abstract class PhoneBase extends Handler implements Phone {


    /* Instance Variables */
    /* Instance Variables */
    public CommandsInterface mCi;
    public CommandsInterface mCi;
    private int mVmCount = 0;
    boolean mDnsCheckDisabled;
    boolean mDnsCheckDisabled;
    public DcTrackerBase mDcTracker;
    public DcTrackerBase mDcTracker;
    boolean mDoesRilSendMultipleCallRing;
    boolean mDoesRilSendMultipleCallRing;
@@ -886,9 +892,9 @@ public abstract class PhoneBase extends Handler implements Phone {
    }
    }


    @Override
    @Override
    /** @return true if there are messages waiting, false otherwise. */
    public boolean getMessageWaitingIndicator() {
    public boolean getMessageWaitingIndicator() {
        IccRecords r = mIccRecords.get();
        return mVmCount != 0;
        return (r != null) ? r.getVoiceMessageWaiting() : false;
    }
    }


    @Override
    @Override
@@ -1061,9 +1067,17 @@ public abstract class PhoneBase extends Handler implements Phone {
    public abstract int getPhoneType();
    public abstract int getPhoneType();


    /** @hide */
    /** @hide */
    /** @return number of voicemails */
    @Override
    @Override
    public int getVoiceMessageCount(){
    public int getVoiceMessageCount(){
        return 0;
        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();
    }
    }


    /**
    /**
@@ -1429,19 +1443,9 @@ public abstract class PhoneBase extends Handler implements Phone {
        return mCi.getLteOnCdmaMode();
        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) {
    public void setVoiceMessageWaiting(int line, int countWaiting) {
        IccRecords r = mIccRecords.get();
        // This function should be overridden by class GSMPhone and CDMAPhone.
        if (r != null) {
        Rlog.e(LOG_TAG, "Error! This function should never be executed, inactive Phone.");
            r.setVoiceMessageWaiting(line, countWaiting);
        }
    }
    }


    /**
    /**
+4 −4
Original line number Original line Diff line number Diff line
@@ -71,12 +71,12 @@ public class TelephonyCapabilities {
    }
    }


    /**
    /**
     * Return true if the current phone can retrieve the voice message count.
     * Return true if the current phone supports voice message count.
     *
     * and the count is available
     * Currently this is assumed to be true on CDMA phones and false otherwise.
     * Both CDMA and GSM phones support voice message count
     */
     */
    public static boolean supportsVoiceMessageCount(Phone phone) {
    public static boolean supportsVoiceMessageCount(Phone phone) {
        return (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA);
        return (phone.getVoiceMessageCount() != -1);
    }
    }


    /**
    /**
+23 −42
Original line number Original line Diff line number Diff line
@@ -93,7 +93,6 @@ public class CDMAPhone extends PhoneBase {
    // Default Emergency Callback Mode exit timer
    // Default Emergency Callback Mode exit timer
    private static final int DEFAULT_ECM_EXIT_TIMER_VALUE = 300000;
    private static final int DEFAULT_ECM_EXIT_TIMER_VALUE = 300000;


    protected static final String VM_COUNT_CDMA = "vm_count_key_cdma";
    protected static final String VM_NUMBER_CDMA = "vm_number_key_cdma";
    protected static final String VM_NUMBER_CDMA = "vm_number_key_cdma";
    private String mVmNumber = null;
    private String mVmNumber = null;


@@ -223,7 +222,7 @@ public class CDMAPhone extends PhoneBase {
        updateCurrentCarrierInProvider(operatorNumeric);
        updateCurrentCarrierInProvider(operatorNumeric);


        // Notify voicemails.
        // Notify voicemails.
        notifier.notifyMessageWaitingChanged(this);
        updateVoiceMail();
    }
    }


    @Override
    @Override
@@ -387,12 +386,6 @@ public class CDMAPhone extends PhoneBase {
        throw new CallStateException("Sending UUS information NOT supported in CDMA!");
        throw new CallStateException("Sending UUS information NOT supported in CDMA!");
    }
    }


    @Override
    public boolean
    getMessageWaitingIndicator() {
        return (getVoiceMessageCount() > 0);
    }

    @Override
    @Override
    public List<? extends MmiCode>
    public List<? extends MmiCode>
    getPendingMmiCodes() {
    getPendingMmiCodes() {
@@ -874,21 +867,15 @@ public class CDMAPhone extends PhoneBase {
        return number;
        return number;
    }
    }


    /* Returns Number of Voicemails
    // pending voice mail count updated after phone creation
     * @hide
    private void updateVoiceMail() {
     */
        setVoiceMessageCount(getStoredVoiceMessageCount());
    @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, 0);
    }
    }
        return voicemailCount;

    /** gets the voice mail count from preferences */
    private int getStoredVoiceMessageCount() {
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext);
        return (sp.getInt(VM_COUNT, 0));
    }
    }


    @Override
    @Override
@@ -1144,11 +1131,6 @@ public class CDMAPhone extends PhoneBase {
            }
            }
            break;
            break;


            case EVENT_ICC_RECORD_EVENTS:
                ar = (AsyncResult)msg.obj;
                processIccRecordEvents((Integer)ar.result);
                break;

            case  EVENT_EXIT_EMERGENCY_CALLBACK_RESPONSE:{
            case  EVENT_EXIT_EMERGENCY_CALLBACK_RESPONSE:{
                handleExitEmergencyCallbackMode(msg);
                handleExitEmergencyCallbackMode(msg);
            }
            }
@@ -1264,18 +1246,6 @@ 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
     * Handles the call to get the subscription source
     *
     *
@@ -1673,7 +1643,6 @@ public class CDMAPhone extends PhoneBase {
        if (r == null) {
        if (r == null) {
            return;
            return;
        }
        }
        r.registerForRecordsEvents(this, EVENT_ICC_RECORD_EVENTS, null);
        r.registerForRecordsLoaded(this, EVENT_RUIM_RECORDS_LOADED, null);
        r.registerForRecordsLoaded(this, EVENT_RUIM_RECORDS_LOADED, null);
    }
    }


@@ -1682,10 +1651,22 @@ public class CDMAPhone extends PhoneBase {
        if (r == null) {
        if (r == null) {
            return;
            return;
        }
        }
        r.unregisterForRecordsEvents(this);
        r.unregisterForRecordsLoaded(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) {
    protected void log(String s) {
        if (DBG)
        if (DBG)
            Rlog.d(LOG_TAG, s);
            Rlog.d(LOG_TAG, s);
+12 −8
Original line number Original line Diff line number Diff line
@@ -20,11 +20,9 @@ package com.android.internal.telephony.cdma;


import android.app.Activity;
import android.app.Activity;
import android.content.Context;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.content.res.Resources;
import android.os.Message;
import android.os.Message;
import android.os.SystemProperties;
import android.os.SystemProperties;
import android.preference.PreferenceManager;
import android.provider.Telephony.Sms.Intents;
import android.provider.Telephony.Sms.Intents;
import android.telephony.SmsCbMessage;
import android.telephony.SmsCbMessage;


@@ -272,12 +270,18 @@ public class CdmaInboundSmsHandler extends InboundSmsHandler {
        int voicemailCount = sms.getNumOfVoicemails();
        int voicemailCount = sms.getNumOfVoicemails();
        if (DBG) log("Voicemail count=" + voicemailCount);
        if (DBG) log("Voicemail count=" + voicemailCount);


        // Store the voicemail count in preferences.
        // range check
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext);
        if (voicemailCount < 0) {
        SharedPreferences.Editor editor = sp.edit();
            voicemailCount = -1;
        editor.putInt(CDMAPhone.VM_COUNT_CDMA, voicemailCount);
        } else if (voicemailCount > 99) {
        editor.apply();
            // C.S0015-B v2, 4.5.12
        mPhone.setVoiceMessageWaiting(1, voicemailCount);
            // range: 0-99
            voicemailCount = 99;
        }
        // update voice mail count in phone
        mPhone.setVoiceMessageCount(voicemailCount);
        // store voice mail count in preferences
        storeVoiceMailCount();
    }
    }


    /**
    /**
Loading