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

Commit c94433a1 authored by Anju Mathapati's avatar Anju Mathapati Committed by Linux Build Service Account
Browse files

Telephony: Voice mail notification related changes.

* Separate voice mail notify from SIM/RUIM card

* For GSM store voice mail count in phone memory
irrespective of SIM write result.

* Display voice mail count for GSM

CRs-Fixed: 579524

Conflicts:
        src/java/com/android/internal/telephony/gsm/GsmInboundSmsHandler.java

Change-Id: I368bfb98c8798ed1f43bcc330e6d97e8f95f0f54
parent eaf00bb8
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ 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;
@@ -42,6 +43,7 @@ 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;
@@ -946,6 +948,24 @@ 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
                    + " subId = "+ mPhone.getSubId()
                    + " in preferences.");

        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext);
        SharedPreferences.Editor editor = sp.edit();
        editor.putInt(mPhone.VM_COUNT + mPhone.getSubId(), mwi);
        editor.putString(mPhone.VM_ID + mPhone.getSubId(), 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).
+19 −15
Original line number Diff line number Diff line
@@ -174,6 +174,11 @@ 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";

@@ -191,6 +196,7 @@ public abstract class PhoneBase extends Handler implements Phone {

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

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

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

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

    /**
@@ -1803,19 +1817,9 @@ 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) {
        IccRecords r = mIccRecords.get();
        if (r != null) {
            r.setVoiceMessageWaiting(line, countWaiting);
        }
        // This function should be overridden by class GSMPhone and CDMAPhone.
        Rlog.e(LOG_TAG, "Error! This function should never be executed, inactive Phone.");
    }

    /**
+11 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.internal.telephony;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.AsyncResult;
import android.os.Handler;
import android.os.Message;
@@ -30,6 +31,7 @@ import android.net.NetworkRequest;
import android.net.NetworkCapabilities;
import android.database.Cursor;
import android.content.Intent;
import android.preference.PreferenceManager;
import android.provider.BaseColumns;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
@@ -1673,4 +1675,13 @@ public class SubscriptionController extends ISub.Stub {
    public interface OnDemandDdsLockNotifier {
        public void notifyOnDemandDdsLockGranted(NetworkRequest n);
    }
    public void removeStaleSubPreferences(String prefKey) {
        List<SubInfoRecord> subInfoList = getAllSubInfoList();
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext);
        for (SubInfoRecord subInfo : subInfoList) {
            if (subInfo.mSlotId == -1) {
                sp.edit().remove(prefKey+subInfo.mSubId).commit();
            }
        }
    }
}
+4 −4
Original line number Diff line number Diff line
@@ -73,12 +73,12 @@ public class TelephonyCapabilities {
    }

    /**
     * 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.
     * Return true if the current phone supports voice message count.
     * and the count is available
     * Both CDMA and GSM phones support voice message count
     */
    public static boolean supportsVoiceMessageCount(Phone phone) {
        return (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA);
        return (phone.getVoiceMessageCount() != -1);
    }

    /**
+26 −43
Original line number Diff line number Diff line
@@ -95,7 +95,6 @@ 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;

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

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

    @Override
    public List<? extends MmiCode>
    getPendingMmiCodes() {
@@ -940,7 +933,7 @@ public class CDMAPhone extends PhoneBase {
    public String getVoiceMailNumber() {
        String number = null;
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext());
        number = sp.getString(VM_NUMBER_CDMA + getPhoneId(), null);
        number = sp.getString(VM_NUMBER_CDMA + getSubId(), null);
        if (TextUtils.isEmpty(number)) {
            String[] listArray = getContext().getResources()
                .getStringArray(com.android.internal.R.array.config_default_vm_number);
@@ -974,21 +967,15 @@ public class CDMAPhone extends PhoneBase {
        return number;
    }

    /* 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);
    // pending voice mail count updated after phone creation
    private void updateVoiceMail() {
        setVoiceMessageCount(getStoredVoiceMessageCount());
    }
        return voicemailCount;

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

    @Override
@@ -1283,11 +1270,6 @@ 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);
            }
@@ -1299,6 +1281,7 @@ public class CDMAPhone extends PhoneBase {
                // Notify voicemails.
                log("notifyMessageWaitingChanged");
                mNotifier.notifyMessageWaitingChanged(this);
                updateVoiceMail();
            }
            break;

@@ -1335,6 +1318,7 @@ public class CDMAPhone extends PhoneBase {
                // Notify voicemails.
                log("notifyMessageWaitingChanged");
                mNotifier.notifyMessageWaitingChanged(this);
                updateVoiceMail();
            }
            break;

@@ -1409,18 +1393,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
     *
@@ -1740,7 +1712,7 @@ public class CDMAPhone extends PhoneBase {
        // Update the preference value of voicemail number
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext());
        SharedPreferences.Editor editor = sp.edit();
        editor.putString(VM_NUMBER_CDMA + getPhoneId(), number);
        editor.putString(VM_NUMBER_CDMA + getSubId(), number);
        editor.apply();
    }

@@ -1828,7 +1800,6 @@ 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);
    }

@@ -1837,10 +1808,22 @@ 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);
Loading