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.content.Context; 20 import android.os.RemoteException; 21 import android.telephony.Rlog; 22 23 import com.android.ims.ImsConfigListener; 24 import com.android.ims.ImsReasonInfo; 25 import com.android.ims.internal.IImsConfig; 26 /** 27 * Provides APIs to get/set the IMS service feature/capability/parameters. 28 * The config items include: 29 * 1) Items provisioned by the operator. 30 * 2) Items configured by user. Mainly service feature class. 31 * 32 * @hide 33 */ 34 public class ImsConfig { 35 private static final String TAG = "ImsConfig"; 36 private boolean DBG = true; 37 private final IImsConfig miConfig; 38 private Context mContext; 39 40 /** 41 * Defines IMS service/capability feature constants. 42 */ 43 public static class FeatureConstants { 44 public static final int FEATURE_TYPE_UNKNOWN = -1; 45 46 /** 47 * FEATURE_TYPE_VOLTE supports features defined in 3GPP and 48 * GSMA IR.92 over LTE. 49 */ 50 public static final int FEATURE_TYPE_VOICE_OVER_LTE = 0; 51 52 /** 53 * FEATURE_TYPE_LVC supports features defined in 3GPP and 54 * GSMA IR.94 over LTE. 55 */ 56 public static final int FEATURE_TYPE_VIDEO_OVER_LTE = 1; 57 58 /** 59 * FEATURE_TYPE_VOICE_OVER_WIFI supports features defined in 3GPP and 60 * GSMA IR.92 over WiFi. 61 */ 62 public static final int FEATURE_TYPE_VOICE_OVER_WIFI = 2; 63 64 /** 65 * FEATURE_TYPE_VIDEO_OVER_WIFI supports features defined in 3GPP and 66 * GSMA IR.94 over WiFi. 67 */ 68 public static final int FEATURE_TYPE_VIDEO_OVER_WIFI = 3; 69 } 70 71 /** 72 * Defines IMS service/capability parameters. 73 */ 74 public static class ConfigConstants { 75 76 // Define IMS config items 77 public static final int CONFIG_START = 0; 78 79 // Define operator provisioned config items 80 public static final int PROVISIONED_CONFIG_START = CONFIG_START; 81 82 /** 83 * AMR CODEC Mode Value set, 0-7 in comma separated sequence. 84 * Value is in String format. 85 */ 86 public static final int VOCODER_AMRMODESET = CONFIG_START; 87 88 /** 89 * Wide Band AMR CODEC Mode Value set,0-7 in comma separated sequence. 90 * Value is in String format. 91 */ 92 public static final int VOCODER_AMRWBMODESET = 1; 93 94 /** 95 * SIP Session Timer value (seconds). 96 * Value is in Integer format. 97 */ 98 public static final int SIP_SESSION_TIMER = 2; 99 100 /** 101 * Minimum SIP Session Expiration Timer in (seconds). 102 * Value is in Integer format. 103 */ 104 public static final int MIN_SE = 3; 105 106 /** 107 * SIP_INVITE cancellation time out value (in milliseconds). Integer format. 108 * Value is in Integer format. 109 */ 110 public static final int CANCELLATION_TIMER = 4; 111 112 /** 113 * Delay time when an iRAT transition from eHRPD/HRPD/1xRTT to LTE. 114 * Value is in Integer format. 115 */ 116 public static final int TDELAY = 5; 117 118 /** 119 * Silent redial status of Enabled (True), or Disabled (False). 120 * Value is in Integer format. 121 */ 122 public static final int SILENT_REDIAL_ENABLE = 6; 123 124 /** 125 * SIP T1 timer value in milliseconds. See RFC 3261 for define. 126 * Value is in Integer format. 127 */ 128 public static final int SIP_T1_TIMER = 7; 129 130 /** 131 * SIP T2 timer value in milliseconds. See RFC 3261 for define. 132 * Value is in Integer format. 133 */ 134 public static final int SIP_T2_TIMER = 8; 135 136 /** 137 * SIP TF timer value in milliseconds. See RFC 3261 for define. 138 * Value is in Integer format. 139 */ 140 public static final int SIP_TF_TIMER = 9; 141 142 /** 143 * VoLTE status for VLT/s status of Enabled (1), or Disabled (0). 144 * Value is in Integer format. 145 */ 146 public static final int VLT_SETTING_ENABLED = 10; 147 148 /** 149 * VoLTE status for LVC/s status of Enabled (1), or Disabled (0). 150 * Value is in Integer format. 151 */ 152 public static final int LVC_SETTING_ENABLED = 11; 153 /** 154 * Domain Name for the device to populate the request URI for REGISTRATION. 155 * Value is in String format. 156 */ 157 public static final int DOMAIN_NAME = 12; 158 /** 159 * Device Outgoing SMS based on either 3GPP or 3GPP2 standards. 160 * Value is in Integer format. 3GPP2(0), 3GPP(1) 161 */ 162 public static final int SMS_FORMAT = 13; 163 /** 164 * Turns IMS ON/OFF on the device. 165 * Value is in Integer format. ON (1), OFF(0). 166 */ 167 public static final int SMS_OVER_IP = 14; 168 /** 169 * Requested expiration for Published Online availability. 170 * Value is in Integer format. 171 */ 172 public static final int PUBLISH_TIMER = 15; 173 /** 174 * Requested expiration for Published Offline availability. 175 * Value is in Integer format. 176 */ 177 public static final int PUBLISH_TIMER_EXTENDED = 16; 178 /** 179 * Period of time the capability information of the contact is cached on handset. 180 * Value is in Integer format. 181 */ 182 public static final int CAPABILITIES_CACHE_EXPIRATION = 17; 183 /** 184 * Peiod of time the availability information of a contact is cached on device. 185 * Value is in Integer format. 186 */ 187 public static final int AVAILABILITY_CACHE_EXPIRATION = 18; 188 /** 189 * Interval between successive capabilities polling. 190 * Value is in Integer format. 191 */ 192 public static final int CAPABILITIES_POLL_INTERVAL = 19; 193 /** 194 * Minimum time between two published messages from the device. 195 * Value is in Integer format. 196 */ 197 public static final int SOURCE_THROTTLE_PUBLISH = 20; 198 /** 199 * The Maximum number of MDNs contained in one Request Contained List. 200 * Value is in Integer format. 201 */ 202 public static final int MAX_NUMENTRIES_IN_RCL = 21; 203 /** 204 * Expiration timer for subscription of a Request Contained List, used in capability polling. 205 * Value is in Integer format. 206 */ 207 public static final int CAPAB_POLL_LIST_SUB_EXP = 22; 208 /** 209 * Applies compression to LIST Subscription. 210 * Value is in Integer format. Enable (1), Disable(0). 211 */ 212 public static final int GZIP_FLAG = 23; 213 /** 214 * VOLTE Status for EAB/s status of Enabled (1), or Disabled (0). 215 * Value is in Integer format. 216 */ 217 public static final int EAB_SETTING_ENABLED = 24; 218 /** 219 * Wi-Fi calling roaming status. 220 * Value is in Integer format. ON (1), OFF(0). 221 */ 222 public static final int VOICE_OVER_WIFI_ROAMING = 25; 223 /** 224 * Wi-Fi calling modem - WfcModeFeatureValueConstants. 225 * Value is in Integer format. 226 */ 227 public static final int VOICE_OVER_WIFI_MODE = 26; 228 229 // Expand the operator config items as needed here, need to change 230 // PROVISIONED_CONFIG_END after that. 231 public static final int PROVISIONED_CONFIG_END = VOICE_OVER_WIFI_MODE; 232 233 // Expand the operator config items as needed here. 234 } 235 236 /** 237 * Defines IMS set operation status. 238 */ 239 public static class OperationStatusConstants { 240 public static final int UNKNOWN = -1; 241 public static final int SUCCESS = 0; 242 public static final int FAILED = 1; 243 public static final int UNSUPPORTED_CAUSE_NONE = 2; 244 public static final int UNSUPPORTED_CAUSE_RAT = 3; 245 public static final int UNSUPPORTED_CAUSE_DISABLED = 4; 246 } 247 248 /** 249 * Defines IMS get operation values. 250 */ 251 public static class OperationValuesConstants { 252 /** 253 * Values related to Video Quality 254 */ 255 public static final int VIDEO_QUALITY_UNKNOWN = -1; 256 public static final int VIDEO_QUALITY_LOW = 0; 257 public static final int VIDEO_QUALITY_HIGH = 1; 258 } 259 260 /** 261 * Defines IMS feature value. 262 */ 263 public static class FeatureValueConstants { 264 public static final int OFF = 0; 265 public static final int ON = 1; 266 } 267 268 /** 269 * Defines IMS feature value. 270 */ 271 public static class WfcModeFeatureValueConstants { 272 public static final int WIFI_ONLY = 0; 273 public static final int CELLULAR_PREFERRED = 1; 274 public static final int WIFI_PREFERRED = 2; 275 } 276 ImsConfig(IImsConfig iconfig, Context context)277 public ImsConfig(IImsConfig iconfig, Context context) { 278 if (DBG) Rlog.d(TAG, "ImsConfig creates"); 279 miConfig = iconfig; 280 mContext = context; 281 } 282 283 /** 284 * Gets the provisioned value for IMS service/capabilities parameters used by IMS stack. 285 * This function should not be called from the mainthread as it could block the 286 * mainthread. 287 * 288 * @param item, as defined in com.android.ims.ImsConfig#ConfigConstants. 289 * @return the value in Integer format. 290 * 291 * @throws ImsException if calling the IMS service results in an error. 292 */ getProvisionedValue(int item)293 public int getProvisionedValue(int item) throws ImsException { 294 int ret = 0; 295 try { 296 ret = miConfig.getProvisionedValue(item); 297 } catch (RemoteException e) { 298 throw new ImsException("getValue()", e, 299 ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE); 300 } 301 if (DBG) Rlog.d(TAG, "getProvisionedValue(): item = " + item + ", ret =" + ret); 302 303 return ret; 304 } 305 306 /** 307 * Gets the provisioned value for IMS service/capabilities parameters used by IMS stack. 308 * This function should not be called from the mainthread as it could block the 309 * mainthread. 310 * 311 * @param item, as defined in com.android.ims.ImsConfig#ConfigConstants. 312 * @return value in String format. 313 * 314 * @throws ImsException if calling the IMS service results in an error. 315 */ getProvisionedStringValue(int item)316 public String getProvisionedStringValue(int item) throws ImsException { 317 String ret = "Unknown"; 318 try { 319 ret = miConfig.getProvisionedStringValue(item); 320 } catch (RemoteException e) { 321 throw new ImsException("getProvisionedStringValue()", e, 322 ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE); 323 } 324 if (DBG) Rlog.d(TAG, "getProvisionedStringValue(): item = " + item + ", ret =" + ret); 325 326 return ret; 327 } 328 329 /** 330 * Sets the value for IMS service/capabilities parameters by 331 * the operator device management entity. 332 * This function should not be called from main thread as it could block 333 * mainthread. 334 * 335 * @param item, as defined in com.android.ims.ImsConfig#ConfigConstants. 336 * @param value in Integer format. 337 * @return as defined in com.android.ims.ImsConfig#OperationStatusConstants 338 * 339 * @throws ImsException if calling the IMS service results in an error. 340 */ setProvisionedValue(int item, int value)341 public int setProvisionedValue(int item, int value) 342 throws ImsException { 343 int ret = ImsConfig.OperationStatusConstants.UNKNOWN; 344 if (DBG) { 345 Rlog.d(TAG, "setProvisionedValue(): item = " + item + 346 "value = " + value); 347 } 348 try { 349 ret = miConfig.setProvisionedValue(item, value); 350 } catch (RemoteException e) { 351 throw new ImsException("setProvisionedValue()", e, 352 ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE); 353 } 354 if (DBG) { 355 Rlog.d(TAG, "setProvisionedValue(): item = " + item + 356 " value = " + value + " ret = " + ret); 357 } 358 return ret; 359 } 360 361 /** 362 * Sets the value for IMS service/capabilities parameters by 363 * the operator device management entity. 364 * This function should not be called from main thread as it could block 365 * mainthread. 366 * 367 * @param item, as defined in com.android.ims.ImsConfig#ConfigConstants. 368 * @param value in String format. 369 * @return as defined in com.android.ims.ImsConfig#OperationStatusConstants 370 * 371 * @throws ImsException if calling the IMS service results in an error. 372 */ setProvisionedStringValue(int item, String value)373 public int setProvisionedStringValue(int item, String value) 374 throws ImsException { 375 int ret = ImsConfig.OperationStatusConstants.UNKNOWN; 376 try { 377 ret = miConfig.setProvisionedStringValue(item, value); 378 } catch (RemoteException e) { 379 throw new ImsException("setProvisionedStringValue()", e, 380 ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE); 381 } 382 if (DBG) { 383 Rlog.d(TAG, "setProvisionedStringValue(): item = " + item + 384 ", value =" + value); 385 } 386 return ret; 387 } 388 389 /** 390 * Gets the value for IMS feature item for specified network type. 391 * 392 * @param feature, defined as in FeatureConstants. 393 * @param network, defined as in android.telephony.TelephonyManager#NETWORK_TYPE_XXX. 394 * @param listener, provided to be notified for the feature on/off status. 395 * @return void 396 * 397 * @throws ImsException if calling the IMS service results in an error. 398 */ getFeatureValue(int feature, int network, ImsConfigListener listener)399 public void getFeatureValue(int feature, int network, 400 ImsConfigListener listener) throws ImsException { 401 if (DBG) { 402 Rlog.d(TAG, "getFeatureValue: feature = " + feature + ", network =" + network + 403 ", listener =" + listener); 404 } 405 try { 406 miConfig.getFeatureValue(feature, network, listener); 407 } catch (RemoteException e) { 408 throw new ImsException("getFeatureValue()", e, 409 ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE); 410 } 411 } 412 413 /** 414 * Sets the value for IMS feature item for specified network type. 415 * 416 * @param feature, as defined in FeatureConstants. 417 * @param network, as defined in android.telephony.TelephonyManager#NETWORK_TYPE_XXX. 418 * @param value, as defined in FeatureValueConstants. 419 * @param listener, provided if caller needs to be notified for set result. 420 * @return void 421 * 422 * @throws ImsException if calling the IMS service results in an error. 423 */ setFeatureValue(int feature, int network, int value, ImsConfigListener listener)424 public void setFeatureValue(int feature, int network, int value, 425 ImsConfigListener listener) throws ImsException { 426 if (DBG) { 427 Rlog.d(TAG, "setFeatureValue: feature = " + feature + ", network =" + network + 428 ", value =" + value + ", listener =" + listener); 429 } 430 try { 431 miConfig.setFeatureValue(feature, network, value, listener); 432 } catch (RemoteException e) { 433 throw new ImsException("setFeatureValue()", e, 434 ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE); 435 } 436 } 437 438 /** 439 * Gets the value for IMS Volte provisioned. 440 * It should be the same as operator provisioned value if applies. 441 * 442 * @return boolean 443 * 444 * @throws ImsException if calling the IMS service results in an error. 445 */ getVolteProvisioned()446 public boolean getVolteProvisioned() throws ImsException { 447 try { 448 return miConfig.getVolteProvisioned(); 449 } catch (RemoteException e) { 450 throw new ImsException("getVolteProvisioned()", e, 451 ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE); 452 } 453 } 454 455 /** 456 * Gets the value for IMS feature item for video call quality. 457 * 458 * @param listener, provided if caller needs to be notified for set result. 459 * @return void 460 * 461 * @throws ImsException if calling the IMS service results in an error. 462 */ getVideoQuality(ImsConfigListener listener)463 public void getVideoQuality(ImsConfigListener listener) throws ImsException { 464 try { 465 miConfig.getVideoQuality(listener); 466 } catch (RemoteException e) { 467 throw new ImsException("getVideoQuality()", e, 468 ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE); 469 } 470 } 471 472 /** 473 * Sets the value for IMS feature item video quality. 474 * 475 * @param quality, defines the value of video quality. 476 * @param listener, provided if caller needs to be notified for set result. 477 * @return void 478 * 479 * @throws ImsException if calling the IMS service results in an error. 480 */ setVideoQuality(int quality, ImsConfigListener listener)481 public void setVideoQuality(int quality, ImsConfigListener listener) throws ImsException { 482 try { 483 miConfig.setVideoQuality(quality, listener); 484 } catch (RemoteException e) { 485 throw new ImsException("setVideoQuality()", e, 486 ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE); 487 } 488 } 489 } 490