blob: 7290fb73e351fde71474e4765b05cab46d704a67 [file] [log] [blame]
Jonathan Basseri9a1c9b62015-02-25 13:01:52 -08001/*
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
Jonathan Basserib731c3d2015-05-05 12:00:59 -070021import android.annotation.NonNull;
22import android.annotation.Nullable;
Jonathan Basseri9a1c9b62015-02-25 13:01:52 -080023import android.annotation.SystemApi;
24import android.content.Context;
Jonathan Basseri4f9ad1672015-05-12 10:06:32 -070025import android.os.PersistableBundle;
Jonathan Basseri9a1c9b62015-02-25 13:01:52 -080026import android.os.RemoteException;
27import android.os.ServiceManager;
28
29/**
30 * Provides access to telephony configuration values that are carrier-specific.
31 * <p>
32 * Users should obtain an instance of this class by calling
33 * {@code mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);}
34 * </p>
35 *
36 * @see Context#getSystemService
37 * @see Context#CARRIER_CONFIG_SERVICE
38 */
39public class CarrierConfigManager {
40 /**
41 * @hide
42 */
43 public CarrierConfigManager() {
44 }
45
46 /**
47 * This intent is broadcast by the system when carrier config changes.
48 */
49 public static final String
50 ACTION_CARRIER_CONFIG_CHANGED = "android.telephony.action.CARRIER_CONFIG_CHANGED";
51
52 /**
Jonathan Basseri9b56ad82015-04-27 14:14:38 -070053 * Flag indicating whether the Phone app should ignore EVENT_SIM_NETWORK_LOCKED
54 * events from the Sim.
55 * If true, this will prevent the IccNetworkDepersonalizationPanel from being shown, and
56 * effectively disable the "Sim network lock" feature.
57 */
58 public static final String
59 BOOL_IGNORE_SIM_NETWORK_LOCKED_EVENTS = "bool_ignore_sim_network_locked_events";
60
61 /**
62 * Flag indicating whether the Phone app should provide a "Dismiss" button on the SIM network
63 * unlock screen. The default value is true. If set to false, there will be *no way* to dismiss
64 * the SIM network unlock screen if you don't enter the correct unlock code. (One important
65 * consequence: there will be no way to make an Emergency Call if your SIM is network-locked and
66 * you don't know the PIN.)
67 */
68 public static final String
69 BOOL_SIM_NETWORK_UNLOCK_ALLOW_DISMISS = "bool_sim_network_unlock_allow_dismiss";
70
71 /** Flag indicating if the phone is a world phone */
72 public static final String BOOL_WORLD_PHONE = "bool_world_phone";
73
74 /**
75 * If true, enable vibration (haptic feedback) for key presses in the EmergencyDialer activity.
76 * The pattern is set on a per-platform basis using config_virtualKeyVibePattern. To be
77 * consistent with the regular Dialer, this value should agree with the corresponding values
78 * from config.xml under apps/Contacts.
79 */
80 public static final String
81 BOOL_ENABLE_DIALER_KEY_VIBRATION = "bool_enable_dialer_key_vibration";
82
83 /** Flag indicating if dtmf tone type is enabled */
84 public static final String BOOL_DTMF_TYPE_ENABLED = "bool_dtmf_type_enabled";
85
86 /** Flag indicating if auto retry is enabled */
87 public static final String BOOL_AUTO_RETRY_ENABLED = "bool_auto_retry_enabled";
88
89 /**
90 * Determine whether we want to play local DTMF tones in a call, or just let the radio/BP handle
91 * playing of the tones.
92 */
93 public static final String BOOL_ALLOW_LOCAL_DTMF_TONES = "bool_allow_local_dtmf_tones";
94
95 /**
96 * If true, show an onscreen "Dial" button in the dialer. In practice this is used on all
97 * platforms, even the ones with hard SEND/END keys, but for maximum flexibility it's controlled
98 * by a flag here (which can be overridden on a per-product basis.)
99 */
100 public static final String BOOL_SHOW_ONSCREEN_DIAL_BUTTON = "bool_show_onscreen_dial_button";
101
102 /** Determines if device implements a noise suppression device for in call audio. */
103 public static final String
104 BOOL_HAS_IN_CALL_NOISE_SUPPRESSION = "bool_has_in_call_noise_suppression";
105
106 /**
107 * Determines if the current device should allow emergency numbers to be logged in the Call Log.
108 * (Some carriers require that emergency calls *not* be logged, presumably to avoid the risk of
109 * accidental redialing from the call log UI. This is a good idea, so the default here is
110 * false.)
111 * <p>
112 * TODO: on the other hand, it might still be useful to have some record of the emergency calls
113 * you've made, or to be able to look up the exact date/time of an emergency call. So perhaps we
114 * <b>should</b> log those calls, but instead fix the call log to disable the "call" button for
115 * emergency numbers.
116 */
117 public static final String
118 BOOL_ALLOW_EMERGENCY_NUMBERS_IN_CALL_LOG = "bool_allow_emergency_numbers_in_call_log";
119
120 /** If true, removes the Voice Privacy option from Call Settings */
121 public static final String BOOL_VOICE_PRIVACY_DISABLE = "bool_voice_privacy_disable";
122
123 /** Control whether users can reach the carrier portions of Cellular Network Settings. */
124 public static final String
125 BOOL_HIDE_CARRIER_NETWORK_SETTINGS = "bool_hide_carrier_network_settings";
126
127 /** Control whether users can edit APNs in Settings. */
128 public static final String BOOL_APN_EXPAND = "bool_apn_expand";
129
130 /** Control whether users can choose a network operator. */
131 public static final String BOOL_OPERATOR_SELECTION_EXPAND = "bool_operator_selection_expand";
132
133 /** Used in Cellular Network Settings for preferred network type. */
134 public static final String BOOL_PREFER_2G = "bool_prefer_2g";
135
Junda Liucd115b72015-05-13 14:57:48 -0700136 /** Show cdma network mode choices 1x, 3G, global etc. */
137 public static final String BOOL_SHOW_CDMA_CHOICES = "bool_show_cdma_choices";
Jonathan Basseri9b56ad82015-04-27 14:14:38 -0700138
139 /** CDMA activation goes through HFA */
140 public static final String BOOL_USE_HFA_FOR_PROVISIONING = "bool_use_hfa_for_provisioning";
141
142 /**
143 * CDMA activation goes through OTASP.
144 * <p>
145 * TODO: This should be combined with config_use_hfa_for_provisioning and implemented as an enum
146 * (NONE, HFA, OTASP).
147 */
148 public static final String BOOL_USE_OTASP_FOR_PROVISIONING = "bool_use_otasp_for_provisioning";
149
150 /** Display carrier settings menu if true */
151 public static final String BOOL_CARRIER_SETTINGS_ENABLE = "bool_carrier_settings_enable";
152
153 /** Does not display additional call seting for IMS phone based on GSM Phone */
154 public static final String BOOL_ADDITIONAL_CALL_SETTING = "bool_additional_call_setting";
155
156 /** Show APN Settings for some CDMA carriers */
157 public static final String BOOL_SHOW_APN_SETTING_CDMA = "bool_show_apn_setting_cdma";
158
159 /** After a CDMA conference call is merged, the swap button should be displayed. */
160 public static final String BOOL_SUPPORT_SWAP_AFTER_MERGE = "bool_support_swap_after_merge";
161
162 /**
163 * Determine whether the voicemail notification is persistent in the notification bar. If true,
164 * the voicemail notifications cannot be dismissed from the notification bar.
165 */
166 public static final String
167 BOOL_VOICEMAIL_NOTIFICATION_PERSISTENT = "bool_voicemail_notification_persistent";
168
169 /** For IMS video over LTE calls, determines whether video pause signalling is supported. */
170 public static final String
171 BOOL_SUPPORT_PAUSE_IMS_VIDEO_CALLS = "bool_support_pause_ims_video_calls";
172
173 /**
174 * Disables dialing "*228" (OTASP provisioning) on CDMA carriers where it is not supported or is
175 * potentially harmful by locking the SIM to 3G.
176 */
177 public static final String
178 BOOL_DISABLE_CDMA_ACTIVATION_CODE = "bool_disable_cdma_activation_code";
179
180 /**
Jonathan Basseri9a1c9b62015-02-25 13:01:52 -0800181 * Flag specifying whether VoLTE should be available for carrier, independent of carrier
182 * provisioning. If false: hard disabled. If true: then depends on carrier provisioning,
183 * availability, etc.
184 */
185 public static final String BOOL_CARRIER_VOLTE_AVAILABLE = "bool_carrier_volte_available";
186
Jonathan Basseri9b56ad82015-04-27 14:14:38 -0700187 /** Flag specifying whether VoLTE availability is based on provisioning. */
Jonathan Basseri9a1c9b62015-02-25 13:01:52 -0800188 public static final String BOOL_CARRIER_VOLTE_PROVISIONED = "bool_carrier_volte_provisioned";
189
Jonathan Basseri9b56ad82015-04-27 14:14:38 -0700190 /** Flag specifying whether VoLTE TTY is supported. */
Jonathan Basseri9a1c9b62015-02-25 13:01:52 -0800191 public static final String BOOL_CARRIER_VOLTE_TTY_SUPPORTED
192 = "bool_carrier_volte_tty_supported";
193
194 /**
Jonathan Basseri9a1c9b62015-02-25 13:01:52 -0800195 * If Voice Radio Technology is RIL_RADIO_TECHNOLOGY_LTE:14 or RIL_RADIO_TECHNOLOGY_UNKNOWN:0
196 * this is the value that should be used instead. A configuration value of
197 * RIL_RADIO_TECHNOLOGY_UNKNOWN:0 means there is no replacement value and that the default
198 * assumption for phone type (GSM) should be used.
199 */
200 public static final String INT_VOLTE_REPLACEMENT_RAT = "int_volte_replacement_rat";
201
Nancy Chen5c86e922015-04-09 13:17:20 -0700202 /* The following 3 fields are related to carrier visual voicemail. */
203
204 /**
Jonathan Basseri9b56ad82015-04-27 14:14:38 -0700205 * The carrier number MO sms messages are sent to.
Nancy Chen5c86e922015-04-09 13:17:20 -0700206 *
Jonathan Basseri9b56ad82015-04-27 14:14:38 -0700207 * @hide
Nancy Chen5c86e922015-04-09 13:17:20 -0700208 */
Nancy Chen5c86e922015-04-09 13:17:20 -0700209 public static final String STRING_VVM_DESTINATION_NUMBER = "string_vvm_destination_number";
210
211 /**
212 * The port through which the MO sms messages are sent through.
213 *
214 * @hide
215 */
Yorke Lee2850d7a2015-04-17 13:55:56 -0700216 public static final String INT_VVM_PORT_NUMBER = "int_vvm_port_number";
Nancy Chen5c86e922015-04-09 13:17:20 -0700217
218 /**
Nancy Chencb43f422015-05-27 15:06:58 -0700219 * The type of visual voicemail protocol the carrier adheres to. See {@link TelephonyManager}
220 * for possible values. For example {@link TelephonyManager#VVM_TYPE_OMTP}.
Nancy Chen5c86e922015-04-09 13:17:20 -0700221 *
222 * @hide
223 */
Nancy Chen5c86e922015-04-09 13:17:20 -0700224 public static final String STRING_VVM_TYPE = "string_vvm_type";
225
226 /* Visual voicemail protocols */
227
228 /**
229 * The OMTP protocol.
230 *
231 * @hide
232 */
Nancy Chen5c86e922015-04-09 13:17:20 -0700233 public static final String VVM_TYPE_OMTP = "vvm_type_omtp";
234
Jonathan Basseri9a1c9b62015-02-25 13:01:52 -0800235 private final static String TAG = "CarrierConfigManager";
236
237 /** The default value for every variable. */
Jonathan Basseri4f9ad1672015-05-12 10:06:32 -0700238 private final static PersistableBundle sDefaults;
Jonathan Basseri9a1c9b62015-02-25 13:01:52 -0800239
240 static {
Jonathan Basseri4f9ad1672015-05-12 10:06:32 -0700241 sDefaults = new PersistableBundle();
Jonathan Basseri9b56ad82015-04-27 14:14:38 -0700242 sDefaults.putBoolean(BOOL_ADDITIONAL_CALL_SETTING, true);
243 sDefaults.putBoolean(BOOL_ALLOW_EMERGENCY_NUMBERS_IN_CALL_LOG, false);
244 sDefaults.putBoolean(BOOL_ALLOW_LOCAL_DTMF_TONES, true);
245 sDefaults.putBoolean(BOOL_APN_EXPAND, true);
246 sDefaults.putBoolean(BOOL_AUTO_RETRY_ENABLED, false);
247 sDefaults.putBoolean(BOOL_CARRIER_SETTINGS_ENABLE, false);
Jonathan Basseri9a1c9b62015-02-25 13:01:52 -0800248 sDefaults.putBoolean(BOOL_CARRIER_VOLTE_AVAILABLE, false);
249 sDefaults.putBoolean(BOOL_CARRIER_VOLTE_PROVISIONED, false);
250 sDefaults.putBoolean(BOOL_CARRIER_VOLTE_TTY_SUPPORTED, true);
Jonathan Basseri9b56ad82015-04-27 14:14:38 -0700251 sDefaults.putBoolean(BOOL_DISABLE_CDMA_ACTIVATION_CODE, false);
252 sDefaults.putBoolean(BOOL_DTMF_TYPE_ENABLED, false);
253 sDefaults.putBoolean(BOOL_ENABLE_DIALER_KEY_VIBRATION, true);
254 sDefaults.putBoolean(BOOL_HAS_IN_CALL_NOISE_SUPPRESSION, false);
255 sDefaults.putBoolean(BOOL_HIDE_CARRIER_NETWORK_SETTINGS, false);
256 sDefaults.putBoolean(BOOL_IGNORE_SIM_NETWORK_LOCKED_EVENTS, false);
257 sDefaults.putBoolean(BOOL_OPERATOR_SELECTION_EXPAND, true);
258 sDefaults.putBoolean(BOOL_PREFER_2G, true);
Jonathan Basseri9a1c9b62015-02-25 13:01:52 -0800259 sDefaults.putBoolean(BOOL_SHOW_APN_SETTING_CDMA, false);
Junda Liucd115b72015-05-13 14:57:48 -0700260 sDefaults.putBoolean(BOOL_SHOW_CDMA_CHOICES, false);
Jonathan Basseri9b56ad82015-04-27 14:14:38 -0700261 sDefaults.putBoolean(BOOL_SHOW_ONSCREEN_DIAL_BUTTON, true);
262 sDefaults.putBoolean(BOOL_SIM_NETWORK_UNLOCK_ALLOW_DISMISS, true);
263 sDefaults.putBoolean(BOOL_SUPPORT_PAUSE_IMS_VIDEO_CALLS, true);
264 sDefaults.putBoolean(BOOL_SUPPORT_SWAP_AFTER_MERGE, true);
265 sDefaults.putBoolean(BOOL_USE_HFA_FOR_PROVISIONING, false);
266 sDefaults.putBoolean(BOOL_USE_OTASP_FOR_PROVISIONING, false);
267 sDefaults.putBoolean(BOOL_VOICEMAIL_NOTIFICATION_PERSISTENT, false);
268 sDefaults.putBoolean(BOOL_VOICE_PRIVACY_DISABLE, false);
269 sDefaults.putBoolean(BOOL_WORLD_PHONE, false);
Jonathan Basseri9a1c9b62015-02-25 13:01:52 -0800270 sDefaults.putInt(INT_VOLTE_REPLACEMENT_RAT, 0);
Jonathan Basseri9b56ad82015-04-27 14:14:38 -0700271 sDefaults.putInt(INT_VVM_PORT_NUMBER, 0);
Yorke Lee2850d7a2015-04-17 13:55:56 -0700272 sDefaults.putString(STRING_VVM_DESTINATION_NUMBER, "");
273 sDefaults.putString(STRING_VVM_TYPE, "");
Jonathan Basseri9a1c9b62015-02-25 13:01:52 -0800274 }
275
276 /**
277 * Gets the configuration values for a particular subscription, which is associated with a
278 * specific SIM card. If an invalid subId is used, the returned config will contain default
279 * values.
280 *
281 * @param subId the subscription ID, normally obtained from {@link SubscriptionManager}.
Jonathan Basseri4f9ad1672015-05-12 10:06:32 -0700282 * @return A {@link PersistableBundle} containing the config for the given subId, or default
283 * values for an invalid subId.
Jonathan Basseri9a1c9b62015-02-25 13:01:52 -0800284 */
Jonathan Basserib731c3d2015-05-05 12:00:59 -0700285 @Nullable
Jonathan Basseri4f9ad1672015-05-12 10:06:32 -0700286 public PersistableBundle getConfigForSubId(int subId) {
Jonathan Basseri9a1c9b62015-02-25 13:01:52 -0800287 try {
288 return getICarrierConfigLoader().getConfigForSubId(subId);
289 } catch (RemoteException ex) {
290 Rlog.e(TAG, "Error getting config for subId " + Integer.toString(subId) + ": "
291 + ex.toString());
292 } catch (NullPointerException ex) {
293 Rlog.e(TAG, "Error getting config for subId " + Integer.toString(subId) + ": "
294 + ex.toString());
295 }
296 return null;
297 }
298
299 /**
300 * Gets the configuration values for the default subscription.
301 *
302 * @see #getConfigForSubId
303 */
Jonathan Basserib731c3d2015-05-05 12:00:59 -0700304 @Nullable
Jonathan Basseri4f9ad1672015-05-12 10:06:32 -0700305 public PersistableBundle getConfig() {
Jonathan Basseri9a1c9b62015-02-25 13:01:52 -0800306 return getConfigForSubId(SubscriptionManager.getDefaultSubId());
307 }
308
309 /**
310 * Calling this method triggers telephony services to fetch the current carrier configuration.
311 * <p>
312 * Normally this does not need to be called because the platform reloads config on its own. Call
313 * this method if your app wants to update config at an arbitrary moment.
314 * </p>
315 * <p>
316 * This method returns before the reload has completed, and
317 * {@link android.service.carrier.CarrierConfigService#onLoadConfig} will be called from an
318 * arbitrary thread.
319 * </p>
320 */
321 public void reloadCarrierConfigForSubId(int subId) {
322 try {
323 getICarrierConfigLoader().reloadCarrierConfigForSubId(subId);
324 } catch (RemoteException ex) {
325 Rlog.e(TAG, "Error reloading config for subId=" + subId + ": " + ex.toString());
326 } catch (NullPointerException ex) {
327 Rlog.e(TAG, "Error reloading config for subId=" + subId + ": " + ex.toString());
328 }
329 }
330
331 /**
332 * Request the carrier config loader to update the cofig for phoneId.
Jonathan Basseri9b56ad82015-04-27 14:14:38 -0700333 * <p>
334 * Depending on simState, the config may be cleared or loaded from config app. This is only used
335 * by SubscriptionInfoUpdater.
336 * </p>
337 *
Jonathan Basseri9a1c9b62015-02-25 13:01:52 -0800338 * @hide
339 */
340 @SystemApi
341 public void updateConfigForPhoneId(int phoneId, String simState) {
342 try {
343 getICarrierConfigLoader().updateConfigForPhoneId(phoneId, simState);
344 } catch (RemoteException ex) {
345 Rlog.e(TAG, "Error updating config for phoneId=" + phoneId + ": " + ex.toString());
346 } catch (NullPointerException ex) {
347 Rlog.e(TAG, "Error updating config for phoneId=" + phoneId + ": " + ex.toString());
348 }
349 }
350
351 /**
Jonathan Basseri98927182015-04-23 23:34:15 -0700352 * Returns a new bundle with the default value for every supported configuration variable.
Jonathan Basseri9a1c9b62015-02-25 13:01:52 -0800353 *
354 * @hide
355 */
Jonathan Basserib731c3d2015-05-05 12:00:59 -0700356 @NonNull
Jonathan Basseri9a1c9b62015-02-25 13:01:52 -0800357 @SystemApi
Jonathan Basseri4f9ad1672015-05-12 10:06:32 -0700358 public static PersistableBundle getDefaultConfig() {
359 return new PersistableBundle(sDefaults);
Jonathan Basseri9a1c9b62015-02-25 13:01:52 -0800360 }
361
362 /** @hide */
363 private ICarrierConfigLoader getICarrierConfigLoader() {
364 return ICarrierConfigLoader.Stub
365 .asInterface(ServiceManager.getService(Context.CARRIER_CONFIG_SERVICE));
366 }
367}