diff options
author | Yorke Lee <yorkelee@google.com> | 2015-06-30 10:07:40 -0700 |
---|---|---|
committer | Yorke Lee <yorkelee@google.com> | 2015-06-30 10:15:40 -0700 |
commit | 1249bdbe90102172f6e678993516203bb3a493bf (patch) | |
tree | 41d26e634d44c81cbfd96ca86fce4daf41599639 /telephony/java | |
parent | 82b3f67711246ad5beaf7702ce16e9d433406d1e (diff) | |
download | frameworks_base-1249bdbe90102172f6e678993516203bb3a493bf.zip frameworks_base-1249bdbe90102172f6e678993516203bb3a493bf.tar.gz frameworks_base-1249bdbe90102172f6e678993516203bb3a493bf.tar.bz2 |
Fix TelecomManager.isVoicemailNumber
Provide an overload of PhoneNumberUtil.isVoiceMailNumber that
takes a context to prevent an NPE.
This does not fix PhoneNumberUtil.isVoicemailNumber(String number),
that will require a follow up CL.
Bug: 22184528
Change-Id: I300b70948e5ff7230989bb887ad17e222c61685d
Diffstat (limited to 'telephony/java')
-rw-r--r-- | telephony/java/android/telephony/PhoneNumberUtils.java | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java index 3fcd7d9..d18b86a 100644 --- a/telephony/java/android/telephony/PhoneNumberUtils.java +++ b/telephony/java/android/telephony/PhoneNumberUtils.java @@ -2080,14 +2080,35 @@ public class PhoneNumberUtils * @hide */ public static boolean isVoiceMailNumber(int subId, String number) { - String vmNumber; + return isVoiceMailNumber(null, subId, number); + } + /** + * isVoiceMailNumber: checks a given number against the voicemail + * number provided by the RIL and SIM card. The caller must have + * the READ_PHONE_STATE credential. + * + * @param context a non-null {@link Context}. + * @param subId the subscription id of the SIM. + * @param number the number to look up. + * @return true if the number is in the list of voicemail. False + * otherwise, including if the caller does not have the permission + * to read the VM number. + * @hide + */ + public static boolean isVoiceMailNumber(Context context, int subId, String number) { + String vmNumber; try { - vmNumber = TelephonyManager.getDefault().getVoiceMailNumber(subId); + final TelephonyManager tm; + if (context == null) { + tm = TelephonyManager.getDefault(); + } else { + tm = TelephonyManager.from(context); + } + vmNumber = tm.getVoiceMailNumber(subId); } catch (SecurityException ex) { return false; } - // Strip the separators from the number before comparing it // to the list. number = extractNetworkPortionAlt(number); |