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

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

Merge "MSIM: Add voice mail subscription prompt for MSIM"

parents b7502017 e0cba130
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.