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

Commit e0cba130 authored by Maanasa Gopal's avatar Maanasa Gopal
Browse files

MSIM: Add voice mail subscription prompt for MSIM

When prompt option is enabled in MultiSIM settings,
check for the voicemail number on all subs and allow
voice mail request if at least one sub has voice mail
number associated with it. Based on this check, prompt
is displayed in the dialer.

Change-Id: I590ea6b4779c8452364b8565be9819d352b7af1f
parent b7502017
Loading
Loading
Loading
Loading
+33 −11
Original line number Diff line number Diff line
@@ -1724,11 +1724,15 @@ public class DialpadFragment extends Fragment
     * @see MSimTelephonyManager#getVoiceMailNumber()
     */
    private boolean isVoicemailAvailable() {
        boolean promptEnabled = Settings.Global.getInt(getActivity().getContentResolver(),
                Settings.Global.MULTI_SIM_VOICE_PROMPT, 0) == 1;
        Log.d(TAG, "prompt enabled :  "+ promptEnabled);
        if (promptEnabled) {
            return hasVMNumber();
        } else {
            try {
            if (MSimTelephonyManager.getDefault().isMultiSimEnabled()) {
                mSubscription = MSimTelephonyManager.getDefault().getPreferredVoiceSubscription();
                Log.d(TAG, "Voicemail preferred sub id = "+ mSubscription);

                if (MSimTelephonyManager.getDefault().isMultiSimEnabled()) {
                    return (MSimTelephonyManager.getDefault().
                            getVoiceMailNumber(mSubscription) != null);
                } else {
@@ -1738,9 +1742,27 @@ public class DialpadFragment extends Fragment
                // Possibly no READ_PHONE_STATE privilege.
                Log.e(TAG, "SecurityException is thrown. Maybe privilege isn't sufficient.");
            }
        }
        return false;
    }

    private boolean hasVMNumber() {
        boolean hasVMNum = false;
        int phoneCount = MSimTelephonyManager.getDefault().getPhoneCount();
        for (int i = 0; i < phoneCount; i++) {
            try {
                hasVMNum = MSimTelephonyManager.getDefault().getVoiceMailNumber(i) != null;
            } catch (SecurityException se) {
                // Possibly no READ_PHONE_STATE privilege.
                Log.e(TAG, "SecurityException is thrown. Maybe privilege isn't sufficient.");
            }
            if (hasVMNum) {
                break;
            }
        }
        return hasVMNum;
    }

    /**
     * Returns true of the newDigit parameter can be added at the current selection
     * point, otherwise returns false.