1 /* 2 * Copyright (c) 2014 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 17 package com.android.ims; 18 19 import android.os.RemoteException; 20 import android.telephony.Rlog; 21 22 import com.android.ims.ImsConfigListener; 23 import com.android.ims.ImsReasonInfo; 24 import com.android.ims.internal.IImsConfig; 25 /** 26 * Provides APIs to get/set the IMS service feature/capability/parameters. 27 * The config items include: 28 * 1) Items provisioned by the operator. 29 * 2) Items configured by user. Mainly service feature class. 30 * 31 * @hide 32 */ 33 public class ImsConfig { 34 private static final String TAG = "ImsConfig"; 35 private boolean DBG = true; 36 private final IImsConfig miConfig; 37 38 /** 39 * Defines IMS service/capability feature constants. 40 */ 41 public static class FeatureConstants { 42 public static final int FEATURE_TYPE_UNKNOWN = -1; 43 44 /** 45 * FEATURE_TYPE_VOLTE supports features defined in 3GPP and 46 * GSMA IR.92 over LTE. 47 */ 48 public static final int FEATURE_TYPE_VOICE_OVER_LTE = 0; 49 50 /** 51 * FEATURE_TYPE_LVC supports features defined in 3GPP and 52 * GSMA IR.94 over LTE. 53 */ 54 public static final int FEATURE_TYPE_VIDEO_OVER_LTE = 1; 55 56 /** 57 * FEATURE_TYPE_VOICE_OVER_WIFI supports features defined in 3GPP and 58 * GSMA IR.92 over WiFi. 59 */ 60 public static final int FEATURE_TYPE_VOICE_OVER_WIFI = 2; 61 62 /** 63 * FEATURE_TYPE_VIDEO_OVER_WIFI supports features defined in 3GPP and 64 * GSMA IR.94 over WiFi. 65 */ 66 public static final int FEATURE_TYPE_VIDEO_OVER_WIFI = 3; 67 } 68 69 /** 70 * Defines IMS service/capability parameters. 71 */ 72 public static class ConfigConstants { 73 74 // Define IMS config items 75 public static final int CONFIG_START = 0; 76 77 // Define operator provisioned config items 78 public static final int PROVISIONED_CONFIG_START = CONFIG_START; 79 80 /** 81 * AMR CODEC Mode Value set, 0-7 in comma separated sequence. 82 * Value is in String format. 83 */ 84 public static final int VOCODER_AMRMODESET = CONFIG_START; 85 86 /** 87 * Wide Band AMR CODEC Mode Value set,0-7 in comma separated sequence. 88 * Value is in String format. 89 */ 90 public static final int VOCODER_AMRWBMODESET = 1; 91 92 /** 93 * SIP Session Timer value (seconds). 94 * Value is in Integer format. 95 */ 96 public static final int SIP_SESSION_TIMER = 2; 97 98 /** 99 * Minimum SIP Session Expiration Timer in (seconds). 100 * Value is in Integer format. 101 */ 102 public static final int MIN_SE = 3; 103 104 /** 105 * SIP_INVITE cancellation time out value. Integer format. 106 * Value is in Integer format. 107 */ 108 public static final int CANCELLATION_TIMER = 4; 109 110 /** 111 * Delay time when an iRAT transition from eHRPD/HRPD/1xRTT to LTE. 112 * Value is in Integer format. 113 */ 114 public static final int TDELAY = 5; 115 116 /** 117 * Silent redial status of Enabled (True), or Disabled (False). 118 * Value is in Integer format. 119 */ 120 public static final int SILENT_REDIAL_ENABLE = 6; 121 122 /** 123 * SIP T1 timer value in seconds. See RFC 3261 for define. 124 * Value is in Integer format. 125 */ 126 public static final int SIP_T1_TIMER = 7; 127 128 /** 129 * SIP T2 timer value in seconds. See RFC 3261 for define. 130 * Value is in Integer format. 131 */ 132 public static final int SIP_T2_TIMER = 8; 133 134 /** 135 * SIP TF timer value in seconds. See RFC 3261 for define. 136 * Value is in Integer format. 137 */ 138 public static final int SIP_TF_TIMER = 9; 139 140 /** 141 * VoLTE status for VLT/s status of Enabled (1), or Disabled (0). 142 * Value is in Integer format. 143 */ 144 public static final int VLT_SETTING_ENABLED = 10; 145 146 /** 147 * VoLTE status for LVC/s status of Enabled (1), or Disabled (0). 148 * Value is in Integer format. 149 */ 150 public static final int LVC_SETTING_ENABLED = 11; 151 152 // Expand the operator config items as needed here, need to change 153 // PROVISIONED_CONFIG_END after that. 154 public static final int PROVISIONED_CONFIG_END = LVC_SETTING_ENABLED; 155 156 // Expand the operator config items as needed here. 157 } 158 159 /** 160 * Defines IMS set operation status. 161 */ 162 public static class OperationStatusConstants { 163 public static final int UNKNOWN = -1; 164 public static final int SUCCESS = 0; 165 public static final int FAILED = 1; 166 public static final int UNSUPPORTED_CAUSE_NONE = 2; 167 public static final int UNSUPPORTED_CAUSE_RAT = 3; 168 public static final int UNSUPPORTED_CAUSE_DISABLED = 4; 169 } 170 171 /** 172 * Defines IMS feature value. 173 */ 174 public static class FeatureValueConstants { 175 public static final int OFF = 0; 176 public static final int ON = 1; 177 } 178 179 public ImsConfig(IImsConfig iconfig) { 180 if (DBG) Rlog.d(TAG, "ImsConfig creates"); 181 miConfig = iconfig; 182 } 183 184 /** 185 * Gets the value for IMS service/capabilities parameters used by IMS stack. 186 * This function should not be called from the mainthread as it could block the 187 * mainthread to cause ANR. 188 * 189 * @param item, as defined in com.android.ims.ImsConfig#ConfigConstants. 190 * @return the value in Integer format. 191 * 192 * @throws ImsException if calling the IMS service results in an error. 193 */ 194 public int getMasterValue(int item) throws ImsException { 195 int ret = 0; 196 try { 197 ret = miConfig.getMasterValue(item); 198 } catch (RemoteException e) { 199 throw new ImsException("getValue()", e, 200 ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE); 201 } 202 if (DBG) Rlog.d(TAG, "getMasterValue(): item = " + item + ", ret =" + ret); 203 204 return ret; 205 } 206 207 /** 208 * Gets the value for IMS service/capabilities parameters used by IMS stack. 209 * This function should not be called from the mainthread as it could block the 210 * mainthread to cause ANR. 211 * 212 * @param item, as defined in com.android.ims.ImsConfig#ConfigConstants. 213 * @return value in String format. 214 * 215 * @throws ImsException if calling the IMS service results in an error. 216 */ 217 public String getMasterStringValue(int item) throws ImsException { 218 String ret = "Unknown"; 219 try { 220 ret = miConfig.getMasterStringValue(item); 221 } catch (RemoteException e) { 222 throw new ImsException("getStringValue()", e, 223 ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE); 224 } 225 if (DBG) Rlog.d(TAG, "getMasterStringValue(): item = " + item + ", ret =" + ret); 226 227 return ret; 228 } 229 230 /** 231 * Sets the value for IMS service/capabilities parameters by 232 * the operator device management entity. 233 * This function should not be called from main thread as it could block 234 * mainthread to cause ANR. 235 * 236 * @param item, as defined in com.android.ims.ImsConfig#ConfigConstants. 237 * @param value in Integer format. 238 * @return void 239 * 240 * @throws ImsException if calling the IMS service results in an error. 241 */ 242 public void setProvisionedValue(int item, int value) 243 throws ImsException { 244 // TODO: ADD PERMISSION CHECK 245 if (DBG) { 246 Rlog.d(TAG, "setProvisionedValue(): item = " + item + 247 "value = " + value); 248 } 249 try { 250 miConfig.setProvisionedValue(item, value); 251 } catch (RemoteException e) { 252 throw new ImsException("setProvisionedValue()", e, 253 ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE); 254 } 255 } 256 257 /** 258 * Sets the value for IMS service/capabilities parameters by 259 * the operator device management entity. 260 * 261 * @param item, as defined in com.android.ims.ImsConfig#ConfigConstants. 262 * @param value in String format. 263 * @return void. 264 * 265 * @throws ImsException if calling the IMS service results in an error. 266 */ 267 public void setProvisionedStringValue(int item, String value) 268 throws ImsException { 269 // TODO: ADD PERMISSION CHECK 270 if (DBG) { 271 Rlog.d(TAG, "setProvisionedStringValue(): item = " + item + 272 ", value =" + value); 273 } 274 try { 275 miConfig.setProvisionedStringValue(item, value); 276 } catch (RemoteException e) { 277 throw new ImsException("setProvisionedStringValue()", e, 278 ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE); 279 } 280 } 281 282 /** 283 * Gets the value for IMS feature item for specified network type. 284 * 285 * @param feature, defined as in FeatureConstants. 286 * @param network, defined as in android.telephony.TelephonyManager#NETWORK_TYPE_XXX. 287 * @param listener, provided to be notified for the feature on/off status. 288 * @return void 289 * 290 * @throws ImsException if calling the IMS service results in an error. 291 */ 292 public void getFeatureValue(int feature, int network, 293 ImsConfigListener listener) throws ImsException { 294 if (DBG) { 295 Rlog.d(TAG, "getFeatureValue: feature = " + feature + ", network =" + network + 296 ", listener =" + listener); 297 } 298 try { 299 miConfig.getFeatureValue(feature, network, listener); 300 } catch (RemoteException e) { 301 throw new ImsException("getFeatureValue()", e, 302 ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE); 303 } 304 } 305 306 /** 307 * Sets the value for IMS feature item for specified network type. 308 * 309 * @param feature, as defined in FeatureConstants. 310 * @param network, as defined in android.telephony.TelephonyManager#NETWORK_TYPE_XXX. 311 * @param value, as defined in FeatureValueConstants. 312 * @param listener, provided if caller needs to be notified for set result. 313 * @return void 314 * 315 * @throws ImsException if calling the IMS service results in an error. 316 */ 317 public void setFeatureValue(int feature, int network, int value, 318 ImsConfigListener listener) throws ImsException { 319 // TODO: ADD PERMISSION CHECK (should there be permission, same as provisioning?) 320 if (DBG) { 321 Rlog.d(TAG, "setFeatureValue: feature = " + feature + ", network =" + network + 322 ", value =" + value + ", listener =" + listener); 323 } 324 try { 325 miConfig.setFeatureValue(feature, network, value, listener); 326 } catch (RemoteException e) { 327 throw new ImsException("setFeatureValue()", e, 328 ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE); 329 } 330 } 331 } 332