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

Commit 7efd41c8 authored by Amit Mahajan's avatar Amit Mahajan Committed by Android Partner Code Review
Browse files

Merge changes Ic8e5b8c9,I08edb714 into mm-wireless-dev

* changes:
  Unit tests for CallForwardingOption in GsmCdmaPhone
  Support for storing voicemail count for multi-sim.
parents 3981c31c 2d6df73e
Loading
Loading
Loading
Loading
+2 −14
Original line number Diff line number Diff line
@@ -464,8 +464,8 @@ public class GsmCdmaPhone extends Phone {
        return mCT;
    }

    // pending voice mail count updated after phone creation
    private void updateVoiceMail() {
    @Override
    public void updateVoiceMail() {
        if (isPhoneTypeGsm()) {
            int countVoiceMessages = 0;
            IccRecords r = mIccRecords.get();
@@ -2003,10 +2003,6 @@ public class GsmCdmaPhone extends Phone {
            case EVENT_RUIM_RECORDS_LOADED:
                logd("Event EVENT_RUIM_RECORDS_LOADED Received");
                updateCurrentCarrierInProvider();
                // Notify voicemails.
                logd("notifyMessageWaitingChanged");
                mNotifier.notifyMessageWaitingChanged(this);
                updateVoiceMail();
                break;

            case EVENT_RADIO_ON:
@@ -2087,10 +2083,6 @@ public class GsmCdmaPhone extends Phone {
            case EVENT_NV_READY:
                logd("Event EVENT_NV_READY Received");
                prepareEri();
                // Notify voicemails.
                logd("notifyMessageWaitingChanged");
                mNotifier.notifyMessageWaitingChanged(this);
                updateVoiceMail();
                break;

            case EVENT_SIM_RECORDS_LOADED:
@@ -2108,10 +2100,6 @@ public class GsmCdmaPhone extends Phone {
                }

                mSimRecordsLoadedRegistrants.notifyRegistrants();

                if (isPhoneTypeGsm()) {
                    updateVoiceMail();
                }
                break;

            case EVENT_GET_BASEBAND_VERSION_DONE:
+0 −17
Original line number Diff line number Diff line
@@ -1039,23 +1039,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 = " + mPhone.VM_COUNT
                    + " vmId = " + 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).
+42 −11
Original line number Diff line number Diff line
@@ -191,9 +191,9 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    public static final String CLIR_KEY = "clir_key";

    // Key used for storing voice mail count
    public static final String VM_COUNT = "vm_count_key";
    private 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";
    private static final String VM_ID = "vm_id_key";

    // Key used for storing call forwarding status
    public static final String CF_STATUS = "cf_status_key";
@@ -1521,6 +1521,13 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        return null;
    }

    /**
     * Update voice mail count related fields and notify listeners
     */
    public void updateVoiceMail() {
        Rlog.e(LOG_TAG, "updateVoiceMail() should be overridden");
    }

    public AppType getCurrentUiccAppType() {
        UiccCardApplication currentApp = mUiccApplication.get();
        if (currentApp != null) {
@@ -2069,6 +2076,15 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    /** sets the voice mail count of the phone and notifies listeners. */
    public void setVoiceMessageCount(int countWaiting) {
        mVmCount = countWaiting;

        Rlog.d(LOG_TAG, "setVoiceMessageCount: Storing Voice Mail Count = " + countWaiting +
                " for mVmCountKey = " + VM_COUNT + getSubId() + " in preferences.");

        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext);
        SharedPreferences.Editor editor = sp.edit();
        editor.putInt(VM_COUNT + getSubId(), countWaiting);
        editor.apply();

        // notify listeners of voice mail
        notifyMessageWaitingIndicator();
    }
@@ -2076,8 +2092,16 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    /** gets the voice mail count from preferences */
    protected int getStoredVoiceMessageCount() {
        int countVoiceMessages = 0;
        int invalidCount = -2;  //-1 is not really invalid. It is used for unknown number of vm
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext);
        int countFromSP = sp.getInt(VM_COUNT + getSubId(), invalidCount);
        if (countFromSP != invalidCount) {
            countVoiceMessages = countFromSP;
        } else {
            // Check for old preference if count not found for current subId. This part of the code
            // is needed only when upgrading from M to N.
            String subscriberId = sp.getString(VM_ID, null);
            if (subscriberId != null) {
                String currentSubscriberId = getSubscriberId();

                if (currentSubscriberId != null && currentSubscriberId.equals(subscriberId)) {
@@ -2089,6 +2113,13 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
                            "subscriberId not found");

                }
                // get rid of old preferences.
                SharedPreferences.Editor editor = sp.edit();
                editor.remove(VM_ID);
                editor.remove(VM_COUNT);
                editor.apply();
            }
        }
        return countVoiceMessages;
    }

+5 −1
Original line number Diff line number Diff line
@@ -287,12 +287,16 @@ public class ServiceStateTracker extends Handler {

                    mPhone.notifyCallForwardingIndicator();

                    // update voicemail count and notify message waiting changed
                    mPhone.updateVoiceMail();

                    boolean restoreSelection = !context.getResources().getBoolean(
                            com.android.internal.R.bool.skip_restoring_network_selection);
                    mPhone.sendSubscriptionSettings(restoreSelection);

                    mPhone.setSystemProperty(TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE,
                            ServiceState.rilRadioTechnologyToString(mSS.getRilDataRadioTechnology()));
                            ServiceState.rilRadioTechnologyToString(
                                    mSS.getRilDataRadioTechnology()));

                    if (mSpnUpdatePending) {
                        mSubscriptionController.setPlmnSpn(mPhone.getPhoneId(), mCurShowPlmn,
+0 −2
Original line number Diff line number Diff line
@@ -243,8 +243,6 @@ public class CdmaInboundSmsHandler extends InboundSmsHandler {
        }
        // update voice mail count in phone
        mPhone.setVoiceMessageCount(voicemailCount);
        // store voice mail count in preferences
        storeVoiceMailCount();
    }

    /**
Loading