diff options
| -rw-r--r-- | api/current.txt | 1 | ||||
| -rw-r--r-- | core/java/android/provider/BlockedNumberContract.java | 116 | ||||
| -rw-r--r-- | media/java/android/media/AudioManager.java | 15 | ||||
| -rw-r--r-- | services/core/java/com/android/server/audio/AudioService.java | 9 | ||||
| -rw-r--r-- | telephony/java/android/telephony/CarrierConfigManager.java | 30 |
5 files changed, 158 insertions, 13 deletions
diff --git a/api/current.txt b/api/current.txt index 65dcae2d4683..2250379b94cd 100644 --- a/api/current.txt +++ b/api/current.txt @@ -21435,6 +21435,7 @@ package android.media { field public static final java.lang.String ACTION_AUDIO_BECOMING_NOISY = "android.media.AUDIO_BECOMING_NOISY"; field public static final java.lang.String ACTION_HDMI_AUDIO_PLUG = "android.media.action.HDMI_AUDIO_PLUG"; field public static final java.lang.String ACTION_HEADSET_PLUG = "android.intent.action.HEADSET_PLUG"; + field public static final java.lang.String ACTION_MICROPHONE_MUTE_CHANGED = "android.media.action.MICROPHONE_MUTE_CHANGED"; field public static final deprecated java.lang.String ACTION_SCO_AUDIO_STATE_CHANGED = "android.media.SCO_AUDIO_STATE_CHANGED"; field public static final java.lang.String ACTION_SCO_AUDIO_STATE_UPDATED = "android.media.ACTION_SCO_AUDIO_STATE_UPDATED"; field public static final int ADJUST_LOWER = -1; // 0xffffffff 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/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java index ede172c225ef..a80c74197de2 100644 --- a/media/java/android/media/AudioManager.java +++ b/media/java/android/media/AudioManager.java @@ -1552,6 +1552,21 @@ public class AudioManager { } /** + * Broadcast Action: microphone muting state changed. + * + * You <em>cannot</em> receive this through components declared + * in manifests, only by explicitly registering for it with + * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) + * Context.registerReceiver()}. + * + * <p>The intent has no extra values, use {@link #isMicrophoneMute} to check whether the + * microphone is muted. + */ + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String ACTION_MICROPHONE_MUTE_CHANGED = + "android.media.action.MICROPHONE_MUTE_CHANGED"; + + /** * Sets the audio mode. * <p> * The audio mode encompasses audio routing AND the behavior of diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java index cb96bacac914..9e37c78017e5 100644 --- a/services/core/java/com/android/server/audio/AudioService.java +++ b/services/core/java/com/android/server/audio/AudioService.java @@ -2240,12 +2240,15 @@ public class AudioService extends IAudioService.Stub if (DEBUG_VOL) { Log.d(TAG, String.format("Mic mute %s, user=%d", on, userId)); } - // If mute is for current user actually mute, else just persist the setting - // which will be loaded on user switch. + // only mute for the current user if (getCurrentUserId() == userId) { + final boolean currentMute = AudioSystem.isMicrophoneMuted(); AudioSystem.muteMicrophone(on); + if (on != currentMute) { + mContext.sendBroadcast(new Intent(AudioManager.ACTION_MICROPHONE_MUTE_CHANGED) + .setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY)); + } } - // Post a persist microphone msg. } @Override 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); |