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

Commit 1fdab8a0 authored by Nancy Chen's avatar Nancy Chen
Browse files

Use TelecomManager to call TelephonyManager#getVoicemailNumber (2/2)

Since we don't want the phone app to call TelephonyManager methods
directly, create a method in TelecomManager to mimic the behavior. The
reason we don't return the voicemail number directly is because once
TelecomManager becomes public, we don't want any old app to be able to
get the SIM's voicemail number.

Bug: 18233678

Change-Id: I7eb9a60ab65aababeef7da7bce3b035dcaa1ad1d
parent d5c2fcf3
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -37,7 +37,10 @@ import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.telephony.PhoneNumberUtils;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;


// TODO: Needed for move to system service: import com.android.internal.R;
import com.android.internal.telecom.ITelecomService;
@@ -353,6 +356,24 @@ public class TelecomServiceImpl extends ITelecomService.Stub {
        }
    }

    /**
     * @see android.telecom.TelecomManager#hasVoiceMailNumber
     */
    @Override
    public boolean hasVoiceMailNumber(PhoneAccountHandle accountHandle) {
        enforceReadPermissionOrDefaultDialer();
        try {
            int subId = SubscriptionManager.getDefaultVoiceSubId();
            if (accountHandle != null) {
                subId = mPhoneAccountRegistrar.getSubscriptionIdForPhoneAccount(accountHandle);
            }
            return !TextUtils.isEmpty(getTelephonyManager().getVoiceMailNumber(subId));
        } catch (Exception e) {
            Log.e(this, e, "getSubscriptionIdForPhoneAccount");
            throw e;
        }
    }

    /**
     * @see android.telecom.TelecomManager#silenceRinger
     */