1 /* 2 * Copyright (C) 2020 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 android.telephony.ims; 18 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 import android.annotation.StringDef; 22 import android.annotation.SuppressLint; 23 import android.annotation.SystemApi; 24 import android.net.InetAddresses; 25 import android.net.Uri; 26 import android.os.Parcel; 27 import android.os.Parcelable; 28 import android.os.PersistableBundle; 29 import android.text.TextUtils; 30 31 import java.lang.annotation.Retention; 32 import java.lang.annotation.RetentionPolicy; 33 import java.net.InetSocketAddress; 34 35 /** 36 * @hide 37 * @removed Use {@link SipDelegateConfiguration} instead. 38 */ 39 @Deprecated 40 @SystemApi 41 public final class SipDelegateImsConfiguration implements Parcelable { 42 43 /** 44 * IPV4 Address type. 45 * <p> 46 * Used as a potential value for {@link #KEY_SIP_CONFIG_IPTYPE_STRING}. 47 */ 48 public static final String IPTYPE_IPV4 = "IPV4"; 49 50 /** 51 * IPV6 Address type. 52 * <p> 53 * Used as a potential value for {@link #KEY_SIP_CONFIG_IPTYPE_STRING}. 54 */ 55 public static final String IPTYPE_IPV6 = "IPV6"; 56 57 /** 58 * The SIP transport uses UDP. 59 * <p> 60 * Used as a potential value for {@link #KEY_SIP_CONFIG_TRANSPORT_TYPE_STRING}. 61 */ 62 public static final String SIP_TRANSPORT_UDP = "UDP"; 63 64 /** 65 * The SIP transport uses TCP. 66 * <p> 67 * Used as a potential value for {@link #KEY_SIP_CONFIG_TRANSPORT_TYPE_STRING}. 68 */ 69 public static final String SIP_TRANSPORT_TCP = "TCP"; 70 71 /** 72 * Flag specifying if SIP compact form is enabled 73 */ 74 public static final String KEY_SIP_CONFIG_IS_COMPACT_FORM_ENABLED_BOOL = 75 "sip_config_is_compact_form_enabled_bool"; 76 77 /** 78 * Flag specifying if SIP keepalives are enabled 79 */ 80 public static final String KEY_SIP_CONFIG_IS_KEEPALIVE_ENABLED_BOOL = 81 "sip_config_is_keepalive_enabled_bool"; 82 83 /** 84 * Maximum SIP payload to be sent on UDP. If the SIP message payload is greater than max udp 85 * payload size, then TCP must be used 86 */ 87 public static final String KEY_SIP_CONFIG_MAX_PAYLOAD_SIZE_ON_UDP_INT = 88 "sip_config_udp_max_payload_size_int"; 89 90 /** 91 * Transport protocol used for SIP signaling. 92 * Available options are: {@link #SIP_TRANSPORT_UDP }, {@link #SIP_TRANSPORT_TCP } 93 */ 94 public static final String KEY_SIP_CONFIG_TRANSPORT_TYPE_STRING = 95 "sip_config_protocol_type_string"; 96 97 /** 98 * IMS public user identifier string 99 */ 100 public static final String KEY_SIP_CONFIG_UE_PUBLIC_USER_ID_STRING = 101 "sip_config_ue_public_user_id_string"; 102 103 /** 104 * IMS private user identifier string 105 */ 106 public static final String KEY_SIP_CONFIG_UE_PRIVATE_USER_ID_STRING = 107 "sip_config_ue_private_user_id_string"; 108 109 /** 110 * IMS home domain string 111 */ 112 public static final String KEY_SIP_CONFIG_HOME_DOMAIN_STRING = "sip_config_home_domain_string"; 113 114 /** 115 * IMEI string. Application can include the Instance-ID feature tag " +sip.instance" in the 116 * Contact header with a value of the device IMEI in the form "urn:gsma:imei:<device IMEI>". 117 */ 118 public static final String KEY_SIP_CONFIG_IMEI_STRING = "sip_config_imei_string"; 119 120 /** 121 * IP address type for SIP signaling. 122 * Available options are: {@link #IPTYPE_IPV6}, {@link #IPTYPE_IPV4} 123 */ 124 public static final String KEY_SIP_CONFIG_IPTYPE_STRING = "sip_config_iptype_string"; 125 126 /** 127 * Local IPaddress used for SIP signaling. 128 */ 129 public static final String KEY_SIP_CONFIG_UE_DEFAULT_IPADDRESS_STRING = 130 "sip_config_ue_default_ipaddress_string"; 131 132 /** 133 * Local port used for sending SIP traffic 134 */ 135 public static final String KEY_SIP_CONFIG_UE_DEFAULT_PORT_INT = 136 "sip_config_ue_default_port_int"; 137 138 /** 139 * SIP server / PCSCF default ip address 140 */ 141 public static final String KEY_SIP_CONFIG_SERVER_DEFAULT_IPADDRESS_STRING = 142 "sip_config_server_default_ipaddress_string"; 143 144 /** 145 * SIP server / PCSCF port used for sending SIP traffic 146 */ 147 public static final String KEY_SIP_CONFIG_SERVER_DEFAULT_PORT_INT = 148 "sip_config_server_default_port_int"; 149 150 /** 151 * Flag specifying if Network Address Translation is enabled and UE is behind a NAT. 152 */ 153 public static final String KEY_SIP_CONFIG_IS_NAT_ENABLED_BOOL = 154 "sip_config_is_nat_enabled_bool"; 155 156 /** 157 * UE's public IPaddress when UE is behind a NAT. 158 * <p> 159 * This key will not exist if {@link #KEY_SIP_CONFIG_IS_NAT_ENABLED_BOOL} is {@code false}. 160 */ 161 public static final String KEY_SIP_CONFIG_UE_PUBLIC_IPADDRESS_WITH_NAT_STRING = 162 "sip_config_ue_public_ipaddress_with_nat_string"; 163 164 /** 165 * UE's public SIP port when UE is behind a NAT. 166 * <p> 167 * This key will not exist if {@link #KEY_SIP_CONFIG_IS_NAT_ENABLED_BOOL} is {@code false}. 168 */ 169 public static final String KEY_SIP_CONFIG_UE_PUBLIC_PORT_WITH_NAT_INT = 170 "sip_config_ue_public_port_with_nat_int"; 171 172 /** 173 * Flag specifying if Globally routable user-agent uri (GRUU) is enabled as per TS 23.808 174 */ 175 public static final String KEY_SIP_CONFIG_IS_GRUU_ENABLED_BOOL = 176 "sip_config_is_gruu_enabled_bool"; 177 178 /** 179 * UE's Globally routable user-agent uri if this feature is enabled. 180 * <p> 181 * This key will not exist if {@link #KEY_SIP_CONFIG_IS_GRUU_ENABLED_BOOL} is {@code false}. 182 */ 183 public static final String KEY_SIP_CONFIG_UE_PUBLIC_GRUU_STRING = 184 "sip_config_ue_public_gruu_string"; 185 186 /** 187 * Flag specifying if SIP over IPSec is enabled. 188 */ 189 public static final String KEY_SIP_CONFIG_IS_IPSEC_ENABLED_BOOL = 190 "sip_config_is_ipsec_enabled_bool"; 191 /** 192 * UE's SIP port used to send traffic when IPSec is enabled. 193 * <p> 194 * This key will not exist if {@link #KEY_SIP_CONFIG_IS_IPSEC_ENABLED_BOOL} is {@code false}. 195 */ 196 public static final String KEY_SIP_CONFIG_UE_IPSEC_CLIENT_PORT_INT = 197 "sip_config_ue_ipsec_client_port_int"; 198 199 /** 200 * UE's SIP port used to receive traffic when IPSec is enabled. 201 * <p> 202 * This key will not exist if {@link #KEY_SIP_CONFIG_IS_IPSEC_ENABLED_BOOL} is {@code false}. 203 */ 204 public static final String KEY_SIP_CONFIG_UE_IPSEC_SERVER_PORT_INT = 205 "sip_config_ue_ipsec_server_port_int"; 206 207 /** 208 * UE's SIP port used for the previous IPsec security association if IPSec is enabled. 209 * <p> 210 * This key will not exist if {@link #KEY_SIP_CONFIG_IS_IPSEC_ENABLED_BOOL} is {@code false}. 211 */ 212 public static final String KEY_SIP_CONFIG_UE_IPSEC_OLD_CLIENT_PORT_INT = 213 "sip_config_ue_ipsec_old_client_port_int"; 214 215 /** 216 * Port number used by the SIP server to send SIP traffic when IPSec is enabled. 217 * <p> 218 * This key will not exist if {@link #KEY_SIP_CONFIG_IS_IPSEC_ENABLED_BOOL} is {@code false}. 219 */ 220 public static final String KEY_SIP_CONFIG_SERVER_IPSEC_CLIENT_PORT_INT = 221 "sip_config_server_ipsec_client_port_int"; 222 223 /** 224 * Port number used by the SIP server to receive incoming SIP traffic when IPSec is enabled. 225 * <p> 226 * This key will not exist if {@link #KEY_SIP_CONFIG_IS_IPSEC_ENABLED_BOOL} is {@code false}. 227 */ 228 public static final String KEY_SIP_CONFIG_SERVER_IPSEC_SERVER_PORT_INT = 229 "sip_config_server_ipsec_server_port_int"; 230 231 /** 232 * Port number used by the SIP server to send SIP traffic on the previous IPSec security 233 * association when IPSec is enabled. 234 * <p> 235 * This key will not exist if {@link #KEY_SIP_CONFIG_IS_IPSEC_ENABLED_BOOL} is {@code false}. 236 */ 237 public static final String KEY_SIP_CONFIG_SERVER_IPSEC_OLD_CLIENT_PORT_INT = 238 "sip_config_server_ipsec_old_client_port_int"; 239 /** 240 * SIP Authentication header string 241 */ 242 public static final String KEY_SIP_CONFIG_AUTHENTICATION_HEADER_STRING = 243 "sip_config_auhentication_header_string"; 244 245 /** 246 * SIP Authentication nonce string 247 */ 248 public static final String KEY_SIP_CONFIG_AUTHENTICATION_NONCE_STRING = 249 "sip_config_authentication_nonce_string"; 250 251 /** 252 * SIP service route header string 253 */ 254 public static final String KEY_SIP_CONFIG_SERVICE_ROUTE_HEADER_STRING = 255 "sip_config_service_route_header_string"; 256 257 /** 258 * SIP security verify header string 259 */ 260 public static final String KEY_SIP_CONFIG_SECURITY_VERIFY_HEADER_STRING = 261 "sip_config_security_verify_header_string"; 262 263 /** 264 * SIP Path header string 265 */ 266 public static final String KEY_SIP_CONFIG_PATH_HEADER_STRING = 267 "sip_config_path_header_string"; 268 269 /** 270 * The SIP User-Agent header value used by the IMS stack during IMS registration. 271 */ 272 public static final String KEY_SIP_CONFIG_USER_AGENT_HEADER_STRING = 273 "sip_config_sip_user_agent_header_string"; 274 275 /** 276 * SIP User part string in contact header 277 */ 278 public static final String KEY_SIP_CONFIG_URI_USER_PART_STRING = 279 "sip_config_uri_user_part_string"; 280 281 /** 282 * SIP P-access-network-info header string 283 */ 284 public static final String KEY_SIP_CONFIG_P_ACCESS_NETWORK_INFO_HEADER_STRING = 285 "sip_config_p_access_network_info_header_string"; 286 287 /** 288 * The SIP P-last-access-network-info header value, populated for networks that require this 289 * information to be provided in outgoing SIP messages. 290 */ 291 public static final String KEY_SIP_CONFIG_P_LAST_ACCESS_NETWORK_INFO_HEADER_STRING = 292 "sip_config_p_last_access_network_info_header_string"; 293 294 /** 295 * The Cellular-Network-Info header value (See 3GPP 24.229, section 7.2.15), populated for 296 * networks that require this information to be provided as part of outgoing SIP messages. 297 */ 298 public static final String KEY_SIP_CONFIG_CELLULAR_NETWORK_INFO_HEADER_STRING = 299 "sip_config_cellular_network_info_header_string"; 300 301 /** 302 * SIP P-associated-uri header string 303 */ 304 public static final String KEY_SIP_CONFIG_P_ASSOCIATED_URI_HEADER_STRING = 305 "sip_config_p_associated_uri_header_string"; 306 307 /**@hide*/ 308 @StringDef(prefix = "KEY_SIP_CONFIG", suffix = "_STRING", value = { 309 KEY_SIP_CONFIG_TRANSPORT_TYPE_STRING, 310 KEY_SIP_CONFIG_UE_PUBLIC_USER_ID_STRING, 311 KEY_SIP_CONFIG_UE_PRIVATE_USER_ID_STRING, 312 KEY_SIP_CONFIG_HOME_DOMAIN_STRING, 313 KEY_SIP_CONFIG_IMEI_STRING, 314 KEY_SIP_CONFIG_IPTYPE_STRING, 315 KEY_SIP_CONFIG_UE_DEFAULT_IPADDRESS_STRING, 316 KEY_SIP_CONFIG_SERVER_DEFAULT_IPADDRESS_STRING, 317 KEY_SIP_CONFIG_UE_PUBLIC_IPADDRESS_WITH_NAT_STRING, 318 KEY_SIP_CONFIG_UE_PUBLIC_GRUU_STRING, 319 KEY_SIP_CONFIG_AUTHENTICATION_HEADER_STRING, 320 KEY_SIP_CONFIG_AUTHENTICATION_NONCE_STRING, 321 KEY_SIP_CONFIG_SERVICE_ROUTE_HEADER_STRING, 322 KEY_SIP_CONFIG_SECURITY_VERIFY_HEADER_STRING, 323 KEY_SIP_CONFIG_PATH_HEADER_STRING, 324 KEY_SIP_CONFIG_USER_AGENT_HEADER_STRING, 325 KEY_SIP_CONFIG_URI_USER_PART_STRING, 326 KEY_SIP_CONFIG_P_ACCESS_NETWORK_INFO_HEADER_STRING, 327 KEY_SIP_CONFIG_P_LAST_ACCESS_NETWORK_INFO_HEADER_STRING, 328 KEY_SIP_CONFIG_CELLULAR_NETWORK_INFO_HEADER_STRING, 329 KEY_SIP_CONFIG_P_ASSOCIATED_URI_HEADER_STRING 330 }) 331 @Retention(RetentionPolicy.SOURCE) 332 public @interface StringConfigKey {} 333 334 /**@hide*/ 335 @StringDef(prefix = "KEY_SIP_CONFIG", suffix = "_INT", value = { 336 KEY_SIP_CONFIG_MAX_PAYLOAD_SIZE_ON_UDP_INT, 337 KEY_SIP_CONFIG_UE_DEFAULT_PORT_INT, 338 KEY_SIP_CONFIG_SERVER_DEFAULT_PORT_INT, 339 KEY_SIP_CONFIG_UE_PUBLIC_PORT_WITH_NAT_INT, 340 KEY_SIP_CONFIG_UE_IPSEC_CLIENT_PORT_INT, 341 KEY_SIP_CONFIG_UE_IPSEC_SERVER_PORT_INT, 342 KEY_SIP_CONFIG_UE_IPSEC_OLD_CLIENT_PORT_INT, 343 KEY_SIP_CONFIG_SERVER_IPSEC_CLIENT_PORT_INT, 344 KEY_SIP_CONFIG_SERVER_IPSEC_SERVER_PORT_INT, 345 KEY_SIP_CONFIG_SERVER_IPSEC_OLD_CLIENT_PORT_INT 346 }) 347 @Retention(RetentionPolicy.SOURCE) 348 public @interface IntConfigKey {} 349 350 /**@hide*/ 351 @StringDef(prefix = "KEY_SIP_CONFIG", suffix = "_BOOL", value = { 352 KEY_SIP_CONFIG_IS_COMPACT_FORM_ENABLED_BOOL, 353 KEY_SIP_CONFIG_IS_KEEPALIVE_ENABLED_BOOL, 354 KEY_SIP_CONFIG_IS_NAT_ENABLED_BOOL, 355 KEY_SIP_CONFIG_IS_GRUU_ENABLED_BOOL, 356 KEY_SIP_CONFIG_IS_IPSEC_ENABLED_BOOL 357 }) 358 @Retention(RetentionPolicy.SOURCE) 359 public @interface BooleanConfigKey {} 360 361 /** 362 * Builder class to be used when constructing a new SipDelegateImsConfiguration. 363 */ 364 public static final class Builder { 365 private final long mVersion; 366 private final PersistableBundle mBundle; 367 368 /** 369 * Creates an empty implementation of SipDelegateImsConfiguration. 370 * @param version The version associated with the SipDelegateImsConfiguration being built. 371 * See {@link #getVersion} for more information. 372 */ Builder(int version)373 public Builder(int version) { 374 mVersion = version; 375 mBundle = new PersistableBundle(); 376 } 377 /** 378 * Clones an existing implementation of SipDelegateImsConfiguration to handle situations 379 * where only a small number of parameters have changed from the previous configuration. 380 * <p> 381 * Automatically increments the version of this configuration by 1. See {@link #getVersion} 382 * for more information. 383 */ Builder(@onNull SipDelegateImsConfiguration config)384 public Builder(@NonNull SipDelegateImsConfiguration config) { 385 mVersion = config.getVersion() + 1; 386 mBundle = config.copyBundle(); 387 } 388 /** 389 * Put a string value into this configuration bundle for the given key. 390 */ 391 // getString is available below. 392 @SuppressLint("MissingGetterMatchingBuilder") addString(@onNull @tringConfigKey String key, @NonNull String value)393 public @NonNull Builder addString(@NonNull @StringConfigKey String key, 394 @NonNull String value) { 395 mBundle.putString(key, value); 396 return this; 397 } 398 399 /** 400 * Replace the existing default value with a new value for a given key. 401 */ 402 // getInt is available below. 403 @SuppressLint("MissingGetterMatchingBuilder") addInt(@onNull @ntConfigKey String key, int value)404 public @NonNull Builder addInt(@NonNull @IntConfigKey String key, int value) { 405 mBundle.putInt(key, value); 406 return this; 407 } 408 409 /** 410 * Replace the existing default value with a new value for a given key. 411 */ 412 // getBoolean is available below. 413 @SuppressLint("MissingGetterMatchingBuilder") addBoolean(@onNull @ooleanConfigKey String key, boolean value)414 public @NonNull Builder addBoolean(@NonNull @BooleanConfigKey String key, boolean value) { 415 mBundle.putBoolean(key, value); 416 return this; 417 } 418 419 /** 420 * @return a new SipDelegateImsConfiguration from this Builder. 421 */ build()422 public @NonNull SipDelegateImsConfiguration build() { 423 return new SipDelegateImsConfiguration(mVersion, mBundle); 424 } 425 } 426 427 private final long mVersion; 428 private final PersistableBundle mBundle; 429 SipDelegateImsConfiguration(long version, PersistableBundle bundle)430 private SipDelegateImsConfiguration(long version, PersistableBundle bundle) { 431 mVersion = version; 432 mBundle = bundle; 433 } 434 SipDelegateImsConfiguration(Parcel source)435 private SipDelegateImsConfiguration(Parcel source) { 436 mVersion = source.readLong(); 437 mBundle = source.readPersistableBundle(); 438 } 439 440 /** 441 * @return {@code true} if this configuration object has a an entry for the key specified, 442 * {@code false} if it does not. 443 */ containsKey(@onNull String key)444 public boolean containsKey(@NonNull String key) { 445 return mBundle.containsKey(key); 446 } 447 448 /** 449 * @return the string value associated with a given key or {@code null} if it doesn't exist. 450 */ getString(@onNull String key)451 public @Nullable @StringConfigKey String getString(@NonNull String key) { 452 return mBundle.getString(key); 453 } 454 455 /** 456 * @return the integer value associated with a given key if it exists or the supplied default 457 * value if it does not. 458 */ getInt(@onNull String key, int defaultValue)459 public @IntConfigKey int getInt(@NonNull String key, int defaultValue) { 460 if (!mBundle.containsKey(key)) { 461 return defaultValue; 462 } 463 return mBundle.getInt(key); 464 } 465 466 /** 467 * @return the boolean value associated with a given key or the supplied default value if the 468 * value doesn't exist in the bundle. 469 */ getBoolean(@onNull String key, boolean defaultValue)470 public @BooleanConfigKey boolean getBoolean(@NonNull String key, boolean defaultValue) { 471 if (!mBundle.containsKey(key)) { 472 return defaultValue; 473 } 474 return mBundle.getBoolean(key); 475 } 476 477 /** 478 * @return a shallow copy of the full configuration. 479 */ copyBundle()480 public @NonNull PersistableBundle copyBundle() { 481 return new PersistableBundle(mBundle); 482 } 483 484 /** 485 * An integer representing the version number of this SipDelegateImsConfiguration. 486 * {@link SipMessage}s that are created using this configuration will also have a this 487 * version number associated with them, which will allow the IMS service to validate that the 488 * {@link SipMessage} was using the latest configuration during creation and not a stale 489 * configuration due to race conditions between the configuration being updated and the RCS 490 * application not receiving the updated configuration before generating a new message. 491 * <p> 492 * The version number should be a positive number that starts at 0 and increments sequentially 493 * as new {@link SipDelegateImsConfiguration} instances are created to update the IMS 494 * configuration state. 495 * 496 * @return the version number associated with this {@link SipDelegateImsConfiguration}. 497 */ getVersion()498 public long getVersion() { 499 return mVersion; 500 } 501 502 @Override describeContents()503 public int describeContents() { 504 return 0; 505 } 506 507 @Override writeToParcel(@onNull Parcel dest, int flags)508 public void writeToParcel(@NonNull Parcel dest, int flags) { 509 dest.writeLong(mVersion); 510 dest.writePersistableBundle(mBundle); 511 } 512 513 public static final @NonNull Creator<SipDelegateImsConfiguration> CREATOR = 514 new Creator<SipDelegateImsConfiguration>() { 515 @Override 516 public SipDelegateImsConfiguration createFromParcel(Parcel source) { 517 return new SipDelegateImsConfiguration(source); 518 } 519 520 @Override 521 public SipDelegateImsConfiguration[] newArray(int size) { 522 return new SipDelegateImsConfiguration[size]; 523 } 524 }; 525 526 /** 527 * Temporary helper to transition from old form of config to new form. 528 * @return new config 529 * @hide 530 */ toNewConfig()531 public SipDelegateConfiguration toNewConfig() { 532 // IP version is now included in call to InetSocketAddr 533 String transportTypeString = getString(KEY_SIP_CONFIG_TRANSPORT_TYPE_STRING); 534 int transportType = (transportTypeString != null 535 && transportTypeString.equals(SIP_TRANSPORT_UDP)) 536 ? SipDelegateConfiguration.SIP_TRANSPORT_UDP 537 : SipDelegateConfiguration.SIP_TRANSPORT_TCP; 538 SipDelegateConfiguration.Builder builder = new SipDelegateConfiguration.Builder(mVersion, 539 transportType, 540 getSocketAddr(getString(KEY_SIP_CONFIG_UE_DEFAULT_IPADDRESS_STRING), 541 getInt(KEY_SIP_CONFIG_UE_DEFAULT_PORT_INT, -1)), 542 getSocketAddr(getString(KEY_SIP_CONFIG_SERVER_DEFAULT_IPADDRESS_STRING), 543 getInt(KEY_SIP_CONFIG_SERVER_DEFAULT_PORT_INT, -1))); 544 builder.setSipCompactFormEnabled( 545 getBoolean(KEY_SIP_CONFIG_IS_COMPACT_FORM_ENABLED_BOOL, false)); 546 builder.setSipKeepaliveEnabled( 547 getBoolean(KEY_SIP_CONFIG_IS_KEEPALIVE_ENABLED_BOOL, false)); 548 builder.setMaxUdpPayloadSizeBytes(getInt(KEY_SIP_CONFIG_MAX_PAYLOAD_SIZE_ON_UDP_INT, -1)); 549 builder.setPublicUserIdentifier(getString(KEY_SIP_CONFIG_UE_PUBLIC_USER_ID_STRING)); 550 builder.setPrivateUserIdentifier(getString(KEY_SIP_CONFIG_UE_PRIVATE_USER_ID_STRING)); 551 builder.setHomeDomain(getString(KEY_SIP_CONFIG_HOME_DOMAIN_STRING)); 552 builder.setImei(getString(KEY_SIP_CONFIG_IMEI_STRING)); 553 builder.setSipAuthenticationHeader(getString(KEY_SIP_CONFIG_AUTHENTICATION_HEADER_STRING)); 554 builder.setSipAuthenticationNonce(getString(KEY_SIP_CONFIG_AUTHENTICATION_NONCE_STRING)); 555 builder.setSipServiceRouteHeader(getString(KEY_SIP_CONFIG_SERVICE_ROUTE_HEADER_STRING)); 556 builder.setSipPathHeader(getString(KEY_SIP_CONFIG_PATH_HEADER_STRING)); 557 builder.setSipUserAgentHeader(getString(KEY_SIP_CONFIG_USER_AGENT_HEADER_STRING)); 558 builder.setSipContactUserParameter(getString(KEY_SIP_CONFIG_URI_USER_PART_STRING)); 559 builder.setSipPaniHeader(getString(KEY_SIP_CONFIG_P_ACCESS_NETWORK_INFO_HEADER_STRING)); 560 builder.setSipPlaniHeader( 561 getString(KEY_SIP_CONFIG_P_LAST_ACCESS_NETWORK_INFO_HEADER_STRING)); 562 builder.setSipCniHeader(getString(KEY_SIP_CONFIG_CELLULAR_NETWORK_INFO_HEADER_STRING)); 563 builder.setSipAssociatedUriHeader(getString(KEY_SIP_CONFIG_P_ASSOCIATED_URI_HEADER_STRING)); 564 if (getBoolean(KEY_SIP_CONFIG_IS_GRUU_ENABLED_BOOL, false)) { 565 String uri = getString(KEY_SIP_CONFIG_UE_PUBLIC_GRUU_STRING); 566 Uri gruuUri = null; 567 if (!TextUtils.isEmpty(uri)) { 568 gruuUri = Uri.parse(uri); 569 } 570 builder.setPublicGruuUri(gruuUri); 571 } 572 if (getBoolean(KEY_SIP_CONFIG_IS_IPSEC_ENABLED_BOOL, false)) { 573 builder.setIpSecConfiguration(new SipDelegateConfiguration.IpSecConfiguration( 574 getInt(KEY_SIP_CONFIG_UE_IPSEC_CLIENT_PORT_INT, -1), 575 getInt(KEY_SIP_CONFIG_UE_IPSEC_SERVER_PORT_INT, -1), 576 getInt(KEY_SIP_CONFIG_UE_IPSEC_OLD_CLIENT_PORT_INT, -1), 577 getInt(KEY_SIP_CONFIG_SERVER_IPSEC_CLIENT_PORT_INT, -1), 578 getInt(KEY_SIP_CONFIG_SERVER_IPSEC_SERVER_PORT_INT, -1), 579 getInt(KEY_SIP_CONFIG_SERVER_IPSEC_OLD_CLIENT_PORT_INT, -1), 580 getString(KEY_SIP_CONFIG_SECURITY_VERIFY_HEADER_STRING)) 581 ); 582 } 583 if (getBoolean(KEY_SIP_CONFIG_IS_NAT_ENABLED_BOOL, false)) { 584 builder.setNatSocketAddress(getSocketAddr( 585 getString(KEY_SIP_CONFIG_UE_PUBLIC_IPADDRESS_WITH_NAT_STRING), 586 getInt(KEY_SIP_CONFIG_UE_PUBLIC_PORT_WITH_NAT_INT, -1))); 587 } 588 return builder.build(); 589 } 590 getSocketAddr(String ipAddr, int port)591 private InetSocketAddress getSocketAddr(String ipAddr, int port) { 592 return new InetSocketAddress(InetAddresses.parseNumericAddress(ipAddr), port); 593 } 594 } 595