diff options
| author | 2018-03-08 23:21:16 +0000 | |
|---|---|---|
| committer | 2018-03-08 23:21:16 +0000 | |
| commit | fdcdaee2d1435c2354d381827ecfffc5fed7aec1 (patch) | |
| tree | d5dc5758e25f34e4a5365b0dc80fab026536acfb | |
| parent | 7ac5deaf38e0949ae5f6c5b5e9565152ba5a0e29 (diff) | |
| parent | 99ca124212514e488a976b0c1bf69c12e285ebb8 (diff) | |
Merge "Support enhanced call blocking function"
| -rw-r--r-- | core/java/android/provider/BlockedNumberContract.java | 116 | ||||
| -rw-r--r-- | telephony/java/android/telephony/CarrierConfigManager.java | 30 |
2 files changed, 136 insertions, 10 deletions
diff --git a/core/java/android/provider/BlockedNumberContract.java b/core/java/android/provider/BlockedNumberContract.java index fb11d00cec46..8aef012daa41 100644 --- a/core/java/android/provider/BlockedNumberContract.java +++ b/core/java/android/provider/BlockedNumberContract.java @@ -228,6 +228,25 @@ public class BlockedNumberContract { /** @hide */ public static final String RES_CAN_BLOCK_NUMBERS = "can_block"; + /** @hide */ + public static final String RES_ENHANCED_SETTING_IS_ENABLED = "enhanced_setting_enabled"; + + /** @hide */ + public static final String RES_SHOW_EMERGENCY_CALL_NOTIFICATION = + "show_emergency_call_notification"; + + /** @hide */ + public static final String EXTRA_ENHANCED_SETTING_KEY = "extra_enhanced_setting_key"; + + /** @hide */ + public static final String EXTRA_ENHANCED_SETTING_VALUE = "extra_enhanced_setting_value"; + + /** @hide */ + public static final String EXTRA_CONTACT_EXIST = "extra_contact_exist"; + + /** @hide */ + public static final String EXTRA_CALL_PRESENTATION = "extra_call_presentation"; + /** * Returns whether a given number is in the blocked list. * @@ -314,11 +333,33 @@ public class BlockedNumberContract { public static final String METHOD_GET_BLOCK_SUPPRESSION_STATUS = "get_block_suppression_status"; + public static final String METHOD_SHOULD_SHOW_EMERGENCY_CALL_NOTIFICATION = + "should_show_emergency_call_notification"; + public static final String RES_IS_BLOCKING_SUPPRESSED = "blocking_suppressed"; public static final String RES_BLOCKING_SUPPRESSED_UNTIL_TIMESTAMP = "blocking_suppressed_until_timestamp"; + public static final String METHOD_GET_ENHANCED_BLOCK_SETTING = "get_enhanced_block_setting"; + public static final String METHOD_SET_ENHANCED_BLOCK_SETTING = "set_enhanced_block_setting"; + + /* Preference key of block numbers not in contacts setting. */ + public static final String ENHANCED_SETTING_KEY_BLOCK_UNREGISTERED = + "block_numbers_not_in_contacts_setting"; + /* Preference key of block private number calls setting. */ + public static final String ENHANCED_SETTING_KEY_BLOCK_PRIVATE = + "block_private_number_calls_setting"; + /* Preference key of block payphone calls setting. */ + public static final String ENHANCED_SETTING_KEY_BLOCK_PAYPHONE = + "block_payphone_calls_setting"; + /* Preference key of block unknown calls setting. */ + public static final String ENHANCED_SETTING_KEY_BLOCK_UNKNOWN = + "block_unknown_calls_setting"; + /* Preference key for whether should show an emergency call notification. */ + public static final String ENHANCED_SETTING_KEY_SHOW_EMERGENCY_CALL_NOTIFICATION = + "show_emergency_call_notification"; + /** * Notifies the provider that emergency services were contacted by the user. * <p> This results in {@link #shouldSystemBlockNumber} returning {@code false} independent @@ -342,13 +383,19 @@ public class BlockedNumberContract { /** * Returns {@code true} if {@code phoneNumber} is blocked taking - * {@link #notifyEmergencyContact(Context)} into consideration. If emergency services have - * not been contacted recently, this method is equivalent to - * {@link #isBlocked(Context, String)}. + * {@link #notifyEmergencyContact(Context)} into consideration. If emergency services + * have not been contacted recently and enhanced call blocking not been enabled, this + * method is equivalent to {@link #isBlocked(Context, String)}. + * + * @param context the context of the caller. + * @param phoneNumber the number to check. + * @param extras the extra attribute of the number. + * @return {@code true} if should block the number. {@code false} otherwise. */ - public static boolean shouldSystemBlockNumber(Context context, String phoneNumber) { + public static boolean shouldSystemBlockNumber(Context context, String phoneNumber, + Bundle extras) { final Bundle res = context.getContentResolver().call( - AUTHORITY_URI, METHOD_SHOULD_SYSTEM_BLOCK_NUMBER, phoneNumber, null); + AUTHORITY_URI, METHOD_SHOULD_SYSTEM_BLOCK_NUMBER, phoneNumber, extras); return res != null && res.getBoolean(RES_NUMBER_IS_BLOCKED, false); } @@ -363,9 +410,62 @@ public class BlockedNumberContract { } /** - * Represents the current status of {@link #shouldSystemBlockNumber(Context, String)}. If - * emergency services have been contacted recently, {@link #isSuppressed} is {@code true}, - * and blocking is disabled until the timestamp {@link #untilTimestampMillis}. + * Check whether should show the emergency call notification. + * + * @param context the context of the caller. + * @return {@code true} if should show emergency call notification. {@code false} otherwise. + */ + public static boolean shouldShowEmergencyCallNotification(Context context) { + final Bundle res = context.getContentResolver().call( + AUTHORITY_URI, METHOD_SHOULD_SHOW_EMERGENCY_CALL_NOTIFICATION, null, null); + return res != null && res.getBoolean(RES_SHOW_EMERGENCY_CALL_NOTIFICATION, false); + } + + /** + * Check whether the enhanced block setting is enabled. + * + * @param context the context of the caller. + * @param key the key of the setting to check, can be + * {@link #ENHANCED_SETTING_KEY_BLOCK_UNREGISTERED} + * {@link #ENHANCED_SETTING_KEY_BLOCK_PRIVATE} + * {@link #ENHANCED_SETTING_KEY_BLOCK_PAYPHONE} + * {@link #ENHANCED_SETTING_KEY_BLOCK_UNKNOWN} + * {@link #ENHANCED_SETTING_KEY_EMERGENCY_CALL_NOTIFICATION_SHOWING} + * @return {@code true} if the setting is enabled. {@code false} otherwise. + */ + public static boolean getEnhancedBlockSetting(Context context, String key) { + Bundle extras = new Bundle(); + extras.putString(EXTRA_ENHANCED_SETTING_KEY, key); + final Bundle res = context.getContentResolver().call( + AUTHORITY_URI, METHOD_GET_ENHANCED_BLOCK_SETTING, null, extras); + return res != null && res.getBoolean(RES_ENHANCED_SETTING_IS_ENABLED, false); + } + + /** + * Set the enhanced block setting enabled status. + * + * @param context the context of the caller. + * @param key the key of the setting to set, can be + * {@link #ENHANCED_SETTING_KEY_BLOCK_UNREGISTERED} + * {@link #ENHANCED_SETTING_KEY_BLOCK_PRIVATE} + * {@link #ENHANCED_SETTING_KEY_BLOCK_PAYPHONE} + * {@link #ENHANCED_SETTING_KEY_BLOCK_UNKNOWN} + * {@link #ENHANCED_SETTING_KEY_EMERGENCY_CALL_NOTIFICATION_SHOWING} + * @param value the enabled statue of the setting to set. + */ + public static void setEnhancedBlockSetting(Context context, String key, boolean value) { + Bundle extras = new Bundle(); + extras.putString(EXTRA_ENHANCED_SETTING_KEY, key); + extras.putBoolean(EXTRA_ENHANCED_SETTING_VALUE, value); + context.getContentResolver().call(AUTHORITY_URI, METHOD_SET_ENHANCED_BLOCK_SETTING, + null, extras); + } + + /** + * Represents the current status of + * {@link #shouldSystemBlockNumber(Context, String, Bundle)}. If emergency services + * have been contacted recently, {@link #isSuppressed} is {@code true}, and blocking + * is disabled until the timestamp {@link #untilTimestampMillis}. */ public static class BlockSuppressionStatus { public final boolean isSuppressed; diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java index 8202d565c390..fa0777782f3b 100644 --- a/telephony/java/android/telephony/CarrierConfigManager.java +++ b/telephony/java/android/telephony/CarrierConfigManager.java @@ -1276,13 +1276,38 @@ public class CarrierConfigManager { /** * The duration in seconds that platform call and message blocking is disabled after the user - * contacts emergency services. Platform considers values in the range 0 to 604800 (one week) as - * valid. See {@link android.provider.BlockedNumberContract#isBlocked(Context, String)}). + * contacts emergency services. Platform considers values for below cases: + * 1) 0 <= VALUE <= 604800(one week): the value will be used as the duration directly. + * 2) VALUE > 604800(one week): will use the default value as duration instead. + * 3) VALUE < 0: block will be disabled forever until user re-eanble block manually, + * the suggested value to disable forever is -1. + * See {@code android.provider.BlockedNumberContract#notifyEmergencyContact(Context)} + * See {@code android.provider.BlockedNumberContract#isBlocked(Context, String)}. */ public static final String KEY_DURATION_BLOCKING_DISABLED_AFTER_EMERGENCY_INT = "duration_blocking_disabled_after_emergency_int"; /** + * Determines whether to enable enhanced call blocking feature on the device. + * @see SystemContract#ENHANCED_SETTING_KEY_BLOCK_UNREGISTERED + * @see SystemContract#ENHANCED_SETTING_KEY_BLOCK_PRIVATE + * @see SystemContract#ENHANCED_SETTING_KEY_BLOCK_PAYPHONE + * @see SystemContract#ENHANCED_SETTING_KEY_BLOCK_UNKNOWN + * + * <p> + * 1. For Single SIM(SS) device, it can be customized in both carrier_config_mccmnc.xml + * and vendor.xml. + * <p> + * 2. For Dual SIM(DS) device, it should be customized in vendor.xml, since call blocking + * function is used regardless of SIM. + * <p> + * If {@code true} enable enhanced call blocking feature on the device, {@code false} otherwise. + * @hide + */ + public static final String KEY_SUPPORT_ENHANCED_CALL_BLOCKING_BOOL = + "support_enhanced_call_blocking_bool"; + + /** * For carriers which require an empty flash to be sent before sending the normal 3-way calling * flash, the duration in milliseconds of the empty flash to send. When {@code 0}, no empty * flash is sent. @@ -2036,6 +2061,7 @@ public class CarrierConfigManager { sDefaults.putBoolean(KEY_SUPPORT_DIRECT_FDN_DIALING_BOOL, false); sDefaults.putBoolean(KEY_CARRIER_DEFAULT_DATA_ROAMING_ENABLED_BOOL, false); sDefaults.putBoolean(KEY_SKIP_CF_FAIL_TO_DISABLE_DIALOG_BOOL, false); + sDefaults.putBoolean(KEY_SUPPORT_ENHANCED_CALL_BLOCKING_BOOL, false); // MMS defaults sDefaults.putBoolean(KEY_MMS_ALIAS_ENABLED_BOOL, false); |