CarrierConfigManager.java revision abfdaead4c3a11b2a9997bf3ebe252ed975d2b28
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.Bundle; 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 /** 40 * This intent is broadcast by the system when carrier config changes. 41 */ 42 public static final String 43 ACTION_CARRIER_CONFIG_CHANGED = "android.intent.action.carrier_config_changed"; 44 45 /** 46 * Flag specifying whether VoLTE should be available for carrier, independent of carrier 47 * provisioning. If false: hard disabled. If true: then depends on carrier provisioning, 48 * availability, etc. 49 */ 50 public static final String BOOL_CARRIER_VOLTE_AVAILABLE = "bool_carrier_volte_available"; 51 52 /** 53 * Flag specifying whether VoLTE availability is based on provisioning. 54 */ 55 public static final String BOOL_CARRIER_VOLTE_PROVISIONED = "bool_carrier_volte_provisioned"; 56 57 /** 58 * Flag specifying whether VoLTE TTY is supported. 59 */ 60 public static final String BOOL_CARRIER_VOLTE_TTY_SUPPORTED 61 = "bool_carrier_volte_tty_supported"; 62 63 /** 64 * Show APN Settings for some CDMA carriers. 65 */ 66 public static final String BOOL_SHOW_APN_SETTING_CDMA = "bool_show_apn_setting_cdma"; 67 68 /** 69 * If Voice Radio Technology is RIL_RADIO_TECHNOLOGY_LTE:14 or RIL_RADIO_TECHNOLOGY_UNKNOWN:0 70 * this is the value that should be used instead. A configuration value of 71 * RIL_RADIO_TECHNOLOGY_UNKNOWN:0 means there is no replacement value and that the default 72 * assumption for phone type (GSM) should be used. 73 */ 74 public static final String INT_VOLTE_REPLACEMENT_RAT = "int_volte_replacement_rat"; 75 76 /* The following 3 fields are related to carrier visual voicemail. */ 77 78 /** 79 * The carrier number MO sms messages are sent to. 80 * 81 * @hide 82 */ 83 @SystemApi 84 public static final String STRING_VVM_DESTINATION_NUMBER = "string_vvm_destination_number"; 85 86 /** 87 * The port through which the MO sms messages are sent through. 88 * 89 * @hide 90 */ 91 @SystemApi 92 public static final String SHORT_VVM_PORT_NUMBER = "string_vvm_port_number"; 93 94 /** 95 * The type of visual voicemail protocol the carrier adheres to (see below). 96 * 97 * @hide 98 */ 99 @SystemApi 100 public static final String STRING_VVM_TYPE = "string_vvm_type"; 101 102 /* Visual voicemail protocols */ 103 104 /** 105 * The OMTP protocol. 106 * 107 * @hide 108 */ 109 @SystemApi 110 public static final String VVM_TYPE_OMTP = "vvm_type_omtp"; 111 112 /** 113 * Flag indicating whether to allow carrier video calls to emergency numbers. 114 * When {@code true}, video calls to emergency numbers will be allowed. When {@code false}, 115 * video calls to emergency numbers will be initiated as audio-only calls instead. 116 * 117 * @hide 118 */ 119 @SystemApi 120 public static final String BOOL_ALLOW_EMERGENCY_VIDEO_CALLS = 121 "bool_allow_emergency_video_calls"; 122 123 /** 124 * Flag indicating whether the carrier supports video pause signaling. When {@code true}, the 125 * carrier supports use of the {@link android.telecom.VideoProfile#STATE_PAUSED} video state 126 * to pause transmission of video when the In-Call app is sent to the background. 127 * When {@code false}, video pause signaling is not supported. {@code True} by default unless 128 * a carrier configuration overrides the default. 129 * 130 * @hide 131 */ 132 @SystemApi 133 public static final String BOOL_ALLOW_VIDEO_PAUSE = 134 "bool_allow_video_pause"; 135 136 private final static String TAG = "CarrierConfigManager"; 137 138 /** The default value for every variable. */ 139 private final static Bundle sDefaults; 140 141 static { 142 sDefaults = new Bundle(); 143 sDefaults.putBoolean(BOOL_CARRIER_VOLTE_AVAILABLE, false); 144 sDefaults.putBoolean(BOOL_CARRIER_VOLTE_PROVISIONED, false); 145 sDefaults.putBoolean(BOOL_CARRIER_VOLTE_TTY_SUPPORTED, true); 146 sDefaults.putBoolean(BOOL_SHOW_APN_SETTING_CDMA, false); 147 sDefaults.putBoolean(BOOL_ALLOW_EMERGENCY_VIDEO_CALLS, false); 148 sDefaults.putBoolean(BOOL_ALLOW_VIDEO_PAUSE, true); 149 150 sDefaults.putInt(INT_VOLTE_REPLACEMENT_RAT, 0); 151 } 152 153 /** 154 * Gets the configuration values for a particular subscription, which is associated with a 155 * specific SIM card. If an invalid subId is used, the returned config will contain default 156 * values. 157 * 158 * @param subId the subscription ID, normally obtained from {@link SubscriptionManager}. 159 * @return A {@link Bundle} containing the config for the given subId, or default values for an 160 * invalid subId. 161 */ 162 public Bundle getConfigForSubId(int subId) { 163 try { 164 return getICarrierConfigLoader().getConfigForSubId(subId); 165 } catch (RemoteException ex) { 166 Rlog.e(TAG, "Error getting config for subId " + Integer.toString(subId) + ": " 167 + ex.toString()); 168 } catch (NullPointerException ex) { 169 Rlog.e(TAG, "Error getting config for subId " + Integer.toString(subId) + ": " 170 + ex.toString()); 171 } 172 return null; 173 } 174 175 /** 176 * Gets the configuration values for the default subscription. 177 * 178 * @see #getConfigForSubId 179 */ 180 public Bundle getConfig() { 181 return getConfigForSubId(SubscriptionManager.getDefaultSubId()); 182 } 183 184 /** 185 * Calling this method triggers telephony services to fetch the current carrier configuration. 186 * <p> 187 * Normally this does not need to be called because the platform reloads config on its own. Call 188 * this method if your app wants to update config at an arbitrary moment. 189 * </p> 190 * <p> 191 * This method returns before the reload has completed, and 192 * {@link android.service.carrier.CarrierConfigService#onLoadConfig} will be called from an 193 * arbitrary thread. 194 * </p> 195 */ 196 public void reloadCarrierConfigForSubId(int subId) { 197 try { 198 getICarrierConfigLoader().reloadCarrierConfigForSubId(subId); 199 } catch (RemoteException ex) { 200 Rlog.e(TAG, "Error reloading config for subId=" + subId + ": " + ex.toString()); 201 } catch (NullPointerException ex) { 202 Rlog.e(TAG, "Error reloading config for subId=" + subId + ": " + ex.toString()); 203 } 204 } 205 206 /** 207 * Request the carrier config loader to update the cofig for phoneId. 208 * 209 * Depending on simState, the config may be cleared or loaded from config app. 210 * This is only used by SubscriptionInfoUpdater. 211 * 212 * @hide 213 */ 214 @SystemApi 215 public void updateConfigForPhoneId(int phoneId, String simState) { 216 try { 217 getICarrierConfigLoader().updateConfigForPhoneId(phoneId, simState); 218 } catch (RemoteException ex) { 219 Rlog.e(TAG, "Error updating config for phoneId=" + phoneId + ": " + ex.toString()); 220 } catch (NullPointerException ex) { 221 Rlog.e(TAG, "Error updating config for phoneId=" + phoneId + ": " + ex.toString()); 222 } 223 } 224 225 /** 226 * Returns a bundle with the default value for every supported configuration variable. 227 * 228 * @hide 229 */ 230 @SystemApi 231 public static Bundle getDefaultConfig() { 232 return sDefaults; 233 } 234 235 /** @hide */ 236 private ICarrierConfigLoader getICarrierConfigLoader() { 237 return ICarrierConfigLoader.Stub 238 .asInterface(ServiceManager.getService(Context.CARRIER_CONFIG_SERVICE)); 239 } 240} 241