CarrierConfigManager.java revision cd115b738c3ead973425b64c19e3f78052979261
1/* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.telephony; 18 19import com.android.internal.telephony.ICarrierConfigLoader; 20 21import android.annotation.SystemApi; 22import android.content.Context; 23import android.os.PersistableBundle; 24import android.os.RemoteException; 25import android.os.ServiceManager; 26 27/** 28 * Provides access to telephony configuration values that are carrier-specific. 29 * <p> 30 * Users should obtain an instance of this class by calling 31 * {@code mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);} 32 * </p> 33 * 34 * @see Context#getSystemService 35 * @see Context#CARRIER_CONFIG_SERVICE 36 */ 37public class CarrierConfigManager { 38 /** 39 * @hide 40 */ 41 public CarrierConfigManager() { 42 } 43 44 /** 45 * This intent is broadcast by the system when carrier config changes. 46 */ 47 public static final String 48 ACTION_CARRIER_CONFIG_CHANGED = "android.telephony.action.CARRIER_CONFIG_CHANGED"; 49 50 /** 51 * Flag indicating whether the Phone app should ignore EVENT_SIM_NETWORK_LOCKED 52 * events from the Sim. 53 * If true, this will prevent the IccNetworkDepersonalizationPanel from being shown, and 54 * effectively disable the "Sim network lock" feature. 55 */ 56 public static final String 57 BOOL_IGNORE_SIM_NETWORK_LOCKED_EVENTS = "bool_ignore_sim_network_locked_events"; 58 59 /** 60 * Flag indicating whether the Phone app should provide a "Dismiss" button on the SIM network 61 * unlock screen. The default value is true. If set to false, there will be *no way* to dismiss 62 * the SIM network unlock screen if you don't enter the correct unlock code. (One important 63 * consequence: there will be no way to make an Emergency Call if your SIM is network-locked and 64 * you don't know the PIN.) 65 */ 66 public static final String 67 BOOL_SIM_NETWORK_UNLOCK_ALLOW_DISMISS = "bool_sim_network_unlock_allow_dismiss"; 68 69 /** Flag indicating if the phone is a world phone */ 70 public static final String BOOL_WORLD_PHONE = "bool_world_phone"; 71 72 /** 73 * If true, enable vibration (haptic feedback) for key presses in the EmergencyDialer activity. 74 * The pattern is set on a per-platform basis using config_virtualKeyVibePattern. To be 75 * consistent with the regular Dialer, this value should agree with the corresponding values 76 * from config.xml under apps/Contacts. 77 */ 78 public static final String 79 BOOL_ENABLE_DIALER_KEY_VIBRATION = "bool_enable_dialer_key_vibration"; 80 81 /** Flag indicating if dtmf tone type is enabled */ 82 public static final String BOOL_DTMF_TYPE_ENABLED = "bool_dtmf_type_enabled"; 83 84 /** Flag indicating if auto retry is enabled */ 85 public static final String BOOL_AUTO_RETRY_ENABLED = "bool_auto_retry_enabled"; 86 87 /** 88 * Determine whether we want to play local DTMF tones in a call, or just let the radio/BP handle 89 * playing of the tones. 90 */ 91 public static final String BOOL_ALLOW_LOCAL_DTMF_TONES = "bool_allow_local_dtmf_tones"; 92 93 /** 94 * If true, show an onscreen "Dial" button in the dialer. In practice this is used on all 95 * platforms, even the ones with hard SEND/END keys, but for maximum flexibility it's controlled 96 * by a flag here (which can be overridden on a per-product basis.) 97 */ 98 public static final String BOOL_SHOW_ONSCREEN_DIAL_BUTTON = "bool_show_onscreen_dial_button"; 99 100 /** Determines if device implements a noise suppression device for in call audio. */ 101 public static final String 102 BOOL_HAS_IN_CALL_NOISE_SUPPRESSION = "bool_has_in_call_noise_suppression"; 103 104 /** 105 * Determines if the current device should allow emergency numbers to be logged in the Call Log. 106 * (Some carriers require that emergency calls *not* be logged, presumably to avoid the risk of 107 * accidental redialing from the call log UI. This is a good idea, so the default here is 108 * false.) 109 * <p> 110 * TODO: on the other hand, it might still be useful to have some record of the emergency calls 111 * you've made, or to be able to look up the exact date/time of an emergency call. So perhaps we 112 * <b>should</b> log those calls, but instead fix the call log to disable the "call" button for 113 * emergency numbers. 114 */ 115 public static final String 116 BOOL_ALLOW_EMERGENCY_NUMBERS_IN_CALL_LOG = "bool_allow_emergency_numbers_in_call_log"; 117 118 /** If true, removes the Voice Privacy option from Call Settings */ 119 public static final String BOOL_VOICE_PRIVACY_DISABLE = "bool_voice_privacy_disable"; 120 121 /** Control whether users can reach the carrier portions of Cellular Network Settings. */ 122 public static final String 123 BOOL_HIDE_CARRIER_NETWORK_SETTINGS = "bool_hide_carrier_network_settings"; 124 125 /** Control whether users can edit APNs in Settings. */ 126 public static final String BOOL_APN_EXPAND = "bool_apn_expand"; 127 128 /** Control whether users can choose a network operator. */ 129 public static final String BOOL_OPERATOR_SELECTION_EXPAND = "bool_operator_selection_expand"; 130 131 /** Used in Cellular Network Settings for preferred network type. */ 132 public static final String BOOL_PREFER_2G = "bool_prefer_2g"; 133 134 /** Show cdma network mode choices 1x, 3G, global etc. */ 135 public static final String BOOL_SHOW_CDMA_CHOICES = "bool_show_cdma_choices"; 136 137 /** CDMA activation goes through HFA */ 138 public static final String BOOL_USE_HFA_FOR_PROVISIONING = "bool_use_hfa_for_provisioning"; 139 140 /** 141 * CDMA activation goes through OTASP. 142 * <p> 143 * TODO: This should be combined with config_use_hfa_for_provisioning and implemented as an enum 144 * (NONE, HFA, OTASP). 145 */ 146 public static final String BOOL_USE_OTASP_FOR_PROVISIONING = "bool_use_otasp_for_provisioning"; 147 148 /** Display carrier settings menu if true */ 149 public static final String BOOL_CARRIER_SETTINGS_ENABLE = "bool_carrier_settings_enable"; 150 151 /** Does not display additional call seting for IMS phone based on GSM Phone */ 152 public static final String BOOL_ADDITIONAL_CALL_SETTING = "bool_additional_call_setting"; 153 154 /** Show APN Settings for some CDMA carriers */ 155 public static final String BOOL_SHOW_APN_SETTING_CDMA = "bool_show_apn_setting_cdma"; 156 157 /** After a CDMA conference call is merged, the swap button should be displayed. */ 158 public static final String BOOL_SUPPORT_SWAP_AFTER_MERGE = "bool_support_swap_after_merge"; 159 160 /** 161 * Determine whether the voicemail notification is persistent in the notification bar. If true, 162 * the voicemail notifications cannot be dismissed from the notification bar. 163 */ 164 public static final String 165 BOOL_VOICEMAIL_NOTIFICATION_PERSISTENT = "bool_voicemail_notification_persistent"; 166 167 /** For IMS video over LTE calls, determines whether video pause signalling is supported. */ 168 public static final String 169 BOOL_SUPPORT_PAUSE_IMS_VIDEO_CALLS = "bool_support_pause_ims_video_calls"; 170 171 /** 172 * Disables dialing "*228" (OTASP provisioning) on CDMA carriers where it is not supported or is 173 * potentially harmful by locking the SIM to 3G. 174 */ 175 public static final String 176 BOOL_DISABLE_CDMA_ACTIVATION_CODE = "bool_disable_cdma_activation_code"; 177 178 /** 179 * Flag specifying whether VoLTE should be available for carrier, independent of carrier 180 * provisioning. If false: hard disabled. If true: then depends on carrier provisioning, 181 * availability, etc. 182 */ 183 public static final String BOOL_CARRIER_VOLTE_AVAILABLE = "bool_carrier_volte_available"; 184 185 /** Flag specifying whether VoLTE availability is based on provisioning. */ 186 public static final String BOOL_CARRIER_VOLTE_PROVISIONED = "bool_carrier_volte_provisioned"; 187 188 /** Flag specifying whether VoLTE TTY is supported. */ 189 public static final String BOOL_CARRIER_VOLTE_TTY_SUPPORTED 190 = "bool_carrier_volte_tty_supported"; 191 192 /** 193 * If Voice Radio Technology is RIL_RADIO_TECHNOLOGY_LTE:14 or RIL_RADIO_TECHNOLOGY_UNKNOWN:0 194 * this is the value that should be used instead. A configuration value of 195 * RIL_RADIO_TECHNOLOGY_UNKNOWN:0 means there is no replacement value and that the default 196 * assumption for phone type (GSM) should be used. 197 */ 198 public static final String INT_VOLTE_REPLACEMENT_RAT = "int_volte_replacement_rat"; 199 200 /* The following 3 fields are related to carrier visual voicemail. */ 201 202 /** 203 * The carrier number MO sms messages are sent to. 204 * 205 * @hide 206 */ 207 public static final String STRING_VVM_DESTINATION_NUMBER = "string_vvm_destination_number"; 208 209 /** 210 * The port through which the MO sms messages are sent through. 211 * 212 * @hide 213 */ 214 public static final String INT_VVM_PORT_NUMBER = "int_vvm_port_number"; 215 216 /** 217 * The type of visual voicemail protocol the carrier adheres to (see below). 218 * 219 * @hide 220 */ 221 public static final String STRING_VVM_TYPE = "string_vvm_type"; 222 223 /* Visual voicemail protocols */ 224 225 /** 226 * The OMTP protocol. 227 * 228 * @hide 229 */ 230 public static final String VVM_TYPE_OMTP = "vvm_type_omtp"; 231 232 private final static String TAG = "CarrierConfigManager"; 233 234 /** The default value for every variable. */ 235 private final static PersistableBundle sDefaults; 236 237 static { 238 sDefaults = new PersistableBundle(); 239 sDefaults.putBoolean(BOOL_ADDITIONAL_CALL_SETTING, true); 240 sDefaults.putBoolean(BOOL_ALLOW_EMERGENCY_NUMBERS_IN_CALL_LOG, false); 241 sDefaults.putBoolean(BOOL_ALLOW_LOCAL_DTMF_TONES, true); 242 sDefaults.putBoolean(BOOL_APN_EXPAND, true); 243 sDefaults.putBoolean(BOOL_AUTO_RETRY_ENABLED, false); 244 sDefaults.putBoolean(BOOL_CARRIER_SETTINGS_ENABLE, false); 245 sDefaults.putBoolean(BOOL_CARRIER_VOLTE_AVAILABLE, false); 246 sDefaults.putBoolean(BOOL_CARRIER_VOLTE_PROVISIONED, false); 247 sDefaults.putBoolean(BOOL_CARRIER_VOLTE_TTY_SUPPORTED, true); 248 sDefaults.putBoolean(BOOL_DISABLE_CDMA_ACTIVATION_CODE, false); 249 sDefaults.putBoolean(BOOL_DTMF_TYPE_ENABLED, false); 250 sDefaults.putBoolean(BOOL_ENABLE_DIALER_KEY_VIBRATION, true); 251 sDefaults.putBoolean(BOOL_HAS_IN_CALL_NOISE_SUPPRESSION, false); 252 sDefaults.putBoolean(BOOL_HIDE_CARRIER_NETWORK_SETTINGS, false); 253 sDefaults.putBoolean(BOOL_IGNORE_SIM_NETWORK_LOCKED_EVENTS, false); 254 sDefaults.putBoolean(BOOL_OPERATOR_SELECTION_EXPAND, true); 255 sDefaults.putBoolean(BOOL_PREFER_2G, true); 256 sDefaults.putBoolean(BOOL_SHOW_APN_SETTING_CDMA, false); 257 sDefaults.putBoolean(BOOL_SHOW_CDMA_CHOICES, false); 258 sDefaults.putBoolean(BOOL_SHOW_ONSCREEN_DIAL_BUTTON, true); 259 sDefaults.putBoolean(BOOL_SIM_NETWORK_UNLOCK_ALLOW_DISMISS, true); 260 sDefaults.putBoolean(BOOL_SUPPORT_PAUSE_IMS_VIDEO_CALLS, true); 261 sDefaults.putBoolean(BOOL_SUPPORT_SWAP_AFTER_MERGE, true); 262 sDefaults.putBoolean(BOOL_USE_HFA_FOR_PROVISIONING, false); 263 sDefaults.putBoolean(BOOL_USE_OTASP_FOR_PROVISIONING, false); 264 sDefaults.putBoolean(BOOL_VOICEMAIL_NOTIFICATION_PERSISTENT, false); 265 sDefaults.putBoolean(BOOL_VOICE_PRIVACY_DISABLE, false); 266 sDefaults.putBoolean(BOOL_WORLD_PHONE, false); 267 sDefaults.putInt(INT_VOLTE_REPLACEMENT_RAT, 0); 268 sDefaults.putInt(INT_VVM_PORT_NUMBER, 0); 269 sDefaults.putString(STRING_VVM_DESTINATION_NUMBER, ""); 270 sDefaults.putString(STRING_VVM_TYPE, ""); 271 } 272 273 /** 274 * Gets the configuration values for a particular subscription, which is associated with a 275 * specific SIM card. If an invalid subId is used, the returned config will contain default 276 * values. 277 * 278 * @param subId the subscription ID, normally obtained from {@link SubscriptionManager}. 279 * @return A {@link PersistableBundle} containing the config for the given subId, or default 280 * values for an invalid subId. 281 */ 282 public PersistableBundle getConfigForSubId(int subId) { 283 try { 284 return getICarrierConfigLoader().getConfigForSubId(subId); 285 } catch (RemoteException ex) { 286 Rlog.e(TAG, "Error getting config for subId " + Integer.toString(subId) + ": " 287 + ex.toString()); 288 } catch (NullPointerException ex) { 289 Rlog.e(TAG, "Error getting config for subId " + Integer.toString(subId) + ": " 290 + ex.toString()); 291 } 292 return null; 293 } 294 295 /** 296 * Gets the configuration values for the default subscription. 297 * 298 * @see #getConfigForSubId 299 */ 300 public PersistableBundle getConfig() { 301 return getConfigForSubId(SubscriptionManager.getDefaultSubId()); 302 } 303 304 /** 305 * Calling this method triggers telephony services to fetch the current carrier configuration. 306 * <p> 307 * Normally this does not need to be called because the platform reloads config on its own. Call 308 * this method if your app wants to update config at an arbitrary moment. 309 * </p> 310 * <p> 311 * This method returns before the reload has completed, and 312 * {@link android.service.carrier.CarrierConfigService#onLoadConfig} will be called from an 313 * arbitrary thread. 314 * </p> 315 */ 316 public void reloadCarrierConfigForSubId(int subId) { 317 try { 318 getICarrierConfigLoader().reloadCarrierConfigForSubId(subId); 319 } catch (RemoteException ex) { 320 Rlog.e(TAG, "Error reloading config for subId=" + subId + ": " + ex.toString()); 321 } catch (NullPointerException ex) { 322 Rlog.e(TAG, "Error reloading config for subId=" + subId + ": " + ex.toString()); 323 } 324 } 325 326 /** 327 * Request the carrier config loader to update the cofig for phoneId. 328 * <p> 329 * Depending on simState, the config may be cleared or loaded from config app. This is only used 330 * by SubscriptionInfoUpdater. 331 * </p> 332 * 333 * @hide 334 */ 335 @SystemApi 336 public void updateConfigForPhoneId(int phoneId, String simState) { 337 try { 338 getICarrierConfigLoader().updateConfigForPhoneId(phoneId, simState); 339 } catch (RemoteException ex) { 340 Rlog.e(TAG, "Error updating config for phoneId=" + phoneId + ": " + ex.toString()); 341 } catch (NullPointerException ex) { 342 Rlog.e(TAG, "Error updating config for phoneId=" + phoneId + ": " + ex.toString()); 343 } 344 } 345 346 /** 347 * Returns a new bundle with the default value for every supported configuration variable. 348 * 349 * @hide 350 */ 351 @SystemApi 352 public static PersistableBundle getDefaultConfig() { 353 return new PersistableBundle(sDefaults); 354 } 355 356 /** @hide */ 357 private ICarrierConfigLoader getICarrierConfigLoader() { 358 return ICarrierConfigLoader.Stub 359 .asInterface(ServiceManager.getService(Context.CARRIER_CONFIG_SERVICE)); 360 } 361} 362