From be45b8c5a53a8f11a09cbe457d929a102fcf6891 Mon Sep 17 00:00:00 2001 From: Jordan Liu Date: Wed, 9 Nov 2016 13:23:42 -0800 Subject: [PATCH] Treat the mdn as an additional voicemail number Use carrier config to specify whether the carrier treats the mdn as an additonal voicemail number. Change-Id: I7192a3505da87d6b50a100e041d2b502cf37e113 Fix: 29145323 Test: build and flash on device --- api/current.txt | 1 + api/system-current.txt | 1 + api/test-current.txt | 1 + .../telephony/CarrierConfigManager.java | 10 +++++ .../android/telephony/PhoneNumberUtils.java | 40 ++++++++++++++++--- .../telephony/CallerInfoAsyncQuery.java | 2 +- 6 files changed, 49 insertions(+), 6 deletions(-) diff --git a/api/current.txt b/api/current.txt index 3bf4954638154..6bb580d018d8f 100644 --- a/api/current.txt +++ b/api/current.txt @@ -37075,6 +37075,7 @@ package android.telephony { field public static final java.lang.String KEY_HIDE_SIM_LOCK_SETTINGS_BOOL = "hide_sim_lock_settings_bool"; field public static final java.lang.String KEY_IGNORE_SIM_NETWORK_LOCKED_EVENTS_BOOL = "ignore_sim_network_locked_events_bool"; field public static final java.lang.String KEY_IMS_DTMF_TONE_DELAY_INT = "ims_dtmf_tone_delay_int"; + field public static final java.lang.String KEY_MDN_IS_ADDITIONAL_VOICEMAIL_NUMBER_BOOL = "mdn_is_additional_voicemail_number_bool"; field public static final java.lang.String KEY_MMS_ALIAS_ENABLED_BOOL = "aliasEnabled"; field public static final java.lang.String KEY_MMS_ALIAS_MAX_CHARS_INT = "aliasMaxChars"; field public static final java.lang.String KEY_MMS_ALIAS_MIN_CHARS_INT = "aliasMinChars"; diff --git a/api/system-current.txt b/api/system-current.txt index 26a2f61a26dc9..a5fc8b2007585 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -40153,6 +40153,7 @@ package android.telephony { field public static final java.lang.String KEY_HIDE_SIM_LOCK_SETTINGS_BOOL = "hide_sim_lock_settings_bool"; field public static final java.lang.String KEY_IGNORE_SIM_NETWORK_LOCKED_EVENTS_BOOL = "ignore_sim_network_locked_events_bool"; field public static final java.lang.String KEY_IMS_DTMF_TONE_DELAY_INT = "ims_dtmf_tone_delay_int"; + field public static final java.lang.String KEY_MDN_IS_ADDITIONAL_VOICEMAIL_NUMBER_BOOL = "mdn_is_additional_voicemail_number_bool"; field public static final java.lang.String KEY_MMS_ALIAS_ENABLED_BOOL = "aliasEnabled"; field public static final java.lang.String KEY_MMS_ALIAS_MAX_CHARS_INT = "aliasMaxChars"; field public static final java.lang.String KEY_MMS_ALIAS_MIN_CHARS_INT = "aliasMinChars"; diff --git a/api/test-current.txt b/api/test-current.txt index 29990433a281a..5a8d5610d2e6a 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -37165,6 +37165,7 @@ package android.telephony { field public static final java.lang.String KEY_HIDE_SIM_LOCK_SETTINGS_BOOL = "hide_sim_lock_settings_bool"; field public static final java.lang.String KEY_IGNORE_SIM_NETWORK_LOCKED_EVENTS_BOOL = "ignore_sim_network_locked_events_bool"; field public static final java.lang.String KEY_IMS_DTMF_TONE_DELAY_INT = "ims_dtmf_tone_delay_int"; + field public static final java.lang.String KEY_MDN_IS_ADDITIONAL_VOICEMAIL_NUMBER_BOOL = "mdn_is_additional_voicemail_number_bool"; field public static final java.lang.String KEY_MMS_ALIAS_ENABLED_BOOL = "aliasEnabled"; field public static final java.lang.String KEY_MMS_ALIAS_MAX_CHARS_INT = "aliasMaxChars"; field public static final java.lang.String KEY_MMS_ALIAS_MIN_CHARS_INT = "aliasMinChars"; diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java index 1f06283304ca7..500b4fd75dfc1 100644 --- a/telephony/java/android/telephony/CarrierConfigManager.java +++ b/telephony/java/android/telephony/CarrierConfigManager.java @@ -72,6 +72,15 @@ public class CarrierConfigManager { public static final String KEY_IGNORE_SIM_NETWORK_LOCKED_EVENTS_BOOL = "ignore_sim_network_locked_events_bool"; + /** + * When checking if a given number is the voicemail number, if this flag is true + * then in addition to comparing the given number to the voicemail number, we also compare it + * to the mdn. If this flag is false, the given number is only compared to the voicemail number. + * By default this value is false. + */ + public static final String KEY_MDN_IS_ADDITIONAL_VOICEMAIL_NUMBER_BOOL = + "mdn_is_additional_voicemail_number_bool"; + /** * Flag indicating whether the Phone app should provide a "Dismiss" button on the SIM network * unlock screen. The default value is true. If set to false, there will be *no way* to dismiss @@ -1143,6 +1152,7 @@ public class CarrierConfigManager { sDefaults.putBoolean(KEY_CARRIER_VOLTE_PROVISIONED_BOOL, false); sDefaults.putBoolean(KEY_IGNORE_SIM_NETWORK_LOCKED_EVENTS_BOOL, false); + sDefaults.putBoolean(KEY_MDN_IS_ADDITIONAL_VOICEMAIL_NUMBER_BOOL, false); sDefaults.putBoolean(KEY_OPERATOR_SELECTION_EXPAND_BOOL, true); sDefaults.putBoolean(KEY_PREFER_2G_BOOL, true); sDefaults.putBoolean(KEY_SHOW_APN_SETTING_CDMA_BOOL, false); diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java index 152b8685027ef..6f51c6e3e461c 100644 --- a/telephony/java/android/telephony/PhoneNumberUtils.java +++ b/telephony/java/android/telephony/PhoneNumberUtils.java @@ -29,6 +29,7 @@ import android.database.Cursor; import android.location.CountryDetector; import android.net.Uri; import android.os.SystemProperties; +import android.os.PersistableBundle; import android.provider.Contacts; import android.provider.ContactsContract; import android.telecom.PhoneAccount; @@ -2106,7 +2107,7 @@ public class PhoneNumberUtils * 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 context {@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 @@ -2115,25 +2116,54 @@ public class PhoneNumberUtils * @hide */ public static boolean isVoiceMailNumber(Context context, int subId, String number) { - String vmNumber; + String vmNumber, mdn; try { final TelephonyManager tm; if (context == null) { tm = TelephonyManager.getDefault(); + if (DBG) log("isVoiceMailNumber: default tm"); } else { tm = TelephonyManager.from(context); + if (DBG) log("isVoiceMailNumber: tm from context"); } vmNumber = tm.getVoiceMailNumber(subId); + mdn = tm.getLine1Number(subId); + if (DBG) log("isVoiceMailNumber: mdn=" + mdn + ", vmNumber=" + vmNumber + + ", number=" + number); } catch (SecurityException ex) { + if (DBG) log("isVoiceMailNumber: SecurityExcpetion caught"); return false; } // Strip the separators from the number before comparing it // to the list. number = extractNetworkPortionAlt(number); + if (TextUtils.isEmpty(number)) { + if (DBG) log("isVoiceMailNumber: number is empty after stripping"); + return false; + } - // compare tolerates null so we need to make sure that we - // don't return true when both are null. - return !TextUtils.isEmpty(number) && compare(number, vmNumber); + // check if the carrier considers MDN to be an additional voicemail number + boolean compareWithMdn = false; + if (context != null) { + CarrierConfigManager configManager = (CarrierConfigManager) + context.getSystemService(Context.CARRIER_CONFIG_SERVICE); + if (configManager != null) { + PersistableBundle b = configManager.getConfigForSubId(subId); + if (b != null) { + compareWithMdn = b.getBoolean(CarrierConfigManager. + KEY_MDN_IS_ADDITIONAL_VOICEMAIL_NUMBER_BOOL); + if (DBG) log("isVoiceMailNumber: compareWithMdn=" + compareWithMdn); + } + } + } + + if (compareWithMdn) { + if (DBG) log("isVoiceMailNumber: treating mdn as additional vm number"); + return compare(number, vmNumber) || compare(number, mdn); + } else { + if (DBG) log("isVoiceMailNumber: returning regular compare"); + return compare(number, vmNumber); + } } /** diff --git a/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java b/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java index d4104bd34db38..20c303e9550b6 100644 --- a/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java +++ b/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java @@ -438,7 +438,7 @@ public class CallerInfoAsyncQuery { // check to see if these are recognized numbers, and use shortcuts if we can. if (PhoneNumberUtils.isLocalEmergencyNumber(context, number)) { cw.event = EVENT_EMERGENCY_NUMBER; - } else if (PhoneNumberUtils.isVoiceMailNumber(subId, number)) { + } else if (PhoneNumberUtils.isVoiceMailNumber(context, subId, number)) { cw.event = EVENT_VOICEMAIL_NUMBER; } else { cw.event = EVENT_NEW_QUERY;