1 /* 2 * Copyright (C) 2018 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.IntDef; 20 import android.annotation.NonNull; 21 import android.annotation.Nullable; 22 import android.annotation.SystemApi; 23 import android.annotation.TestApi; 24 import android.compat.annotation.UnsupportedAppUsage; 25 import android.os.Build; 26 import android.os.Bundle; 27 import android.os.Parcel; 28 import android.os.Parcelable; 29 import android.telecom.VideoProfile; 30 import android.telephony.emergency.EmergencyNumber; 31 import android.telephony.emergency.EmergencyNumber.EmergencyCallRouting; 32 import android.telephony.emergency.EmergencyNumber.EmergencyServiceCategories; 33 import android.telephony.ims.feature.MmTelFeature; 34 import android.util.ArraySet; 35 import android.util.Log; 36 37 import com.android.internal.annotations.VisibleForTesting; 38 import com.android.internal.telephony.PhoneConstants; 39 import com.android.internal.telephony.util.TelephonyUtils; 40 41 import java.lang.annotation.Retention; 42 import java.lang.annotation.RetentionPolicy; 43 import java.util.ArrayList; 44 import java.util.Arrays; 45 import java.util.List; 46 import java.util.Set; 47 import java.util.stream.Collectors; 48 49 /** 50 * A Parcelable object to handle the IMS call profile, which provides the service, call type, and 51 * additional information related to the call. 52 * <p> 53 * See the following specifications for more information about this class: GSMA IR.92/IR.94, 54 * 3GPP TS 24.229/TS 26.114/TS26.111. 55 * @hide 56 */ 57 @SystemApi 58 public final class ImsCallProfile implements Parcelable { 59 private static final String TAG = "ImsCallProfile"; 60 61 /** 62 * Service types 63 */ 64 /** 65 * It is for a special case. It helps that the application can make a call 66 * without IMS connection (not registered). 67 * In the moment of the call initiation, the device try to connect to the IMS network 68 * and initiates the call. 69 */ 70 public static final int SERVICE_TYPE_NONE = 0; 71 /** 72 * It is a default type and can be selected when the device is connected to the IMS network. 73 */ 74 public static final int SERVICE_TYPE_NORMAL = 1; 75 /** 76 * It is for an emergency call. 77 */ 78 public static final int SERVICE_TYPE_EMERGENCY = 2; 79 80 /** 81 * Call types 82 */ 83 /** 84 * IMSPhone to support IR.92 & IR.94 (voice + video upgrade/downgrade) 85 */ 86 public static final int CALL_TYPE_VOICE_N_VIDEO = 1; 87 /** 88 * IR.92 (Voice only) 89 */ 90 public static final int CALL_TYPE_VOICE = 2; 91 /** 92 * VT to support IR.92 & IR.94 (voice + video upgrade/downgrade) 93 */ 94 public static final int CALL_TYPE_VIDEO_N_VOICE = 3; 95 /** 96 * Video Telephony (audio / video two way) 97 */ 98 public static final int CALL_TYPE_VT = 4; 99 /** 100 * Video Telephony (audio two way / video TX one way) 101 */ 102 public static final int CALL_TYPE_VT_TX = 5; 103 /** 104 * Video Telephony (audio two way / video RX one way) 105 */ 106 public static final int CALL_TYPE_VT_RX = 6; 107 /** 108 * Video Telephony (audio two way / video inactive) 109 */ 110 public static final int CALL_TYPE_VT_NODIR = 7; 111 /** 112 * VideoShare (video two way) 113 */ 114 public static final int CALL_TYPE_VS = 8; 115 /** 116 * VideoShare (video TX one way) 117 */ 118 public static final int CALL_TYPE_VS_TX = 9; 119 /** 120 * VideoShare (video RX one way) 121 */ 122 public static final int CALL_TYPE_VS_RX = 10; 123 124 /** 125 * Extra properties for IMS call. 126 */ 127 /** 128 * Boolean extra properties - "true" / "false" 129 * conference : Indicates if the session is for the conference call or not. 130 * e_call : Indicates if the session is for the emergency call or not. 131 * vms : Indicates if the session is connected to the voice mail system or not. 132 * call_mode_changeable : Indicates if the session is able to upgrade/downgrade 133 * the video during voice call. 134 * conference_avail : Indicates if the session can be extended to the conference. 135 */ 136 137 /** 138 * Indicates if the session is for a conference call or not. If not defined, should be 139 * considered {@code false}. 140 * Boolean extra properties - {@code true} / {@code false}. 141 * 142 * This extra is set on an instance of {@link ImsCallProfile} via {@link #setCallExtraBoolean}. 143 * @hide 144 */ 145 @SystemApi 146 public static final String EXTRA_CONFERENCE = "android.telephony.ims.extra.CONFERENCE"; 147 148 /** 149 * The previous string of EXTRA_CONFERENCE. Use EXTRA_CONFERENCE whenever possible. 150 * For external app or vendor code backward compatibility, we should always set value for both 151 * EXTRA_CONFERENCE_DEPRECATED and EXTRA_CONFERENCE. 152 * 153 * @deprecated Remove when not needed anymore. 154 * 155 * @hide 156 */ 157 public static final String EXTRA_CONFERENCE_DEPRECATED = "conference"; 158 159 /** 160 * Boolean extra property set on an {@link ImsCallProfile} to indicate that this call is an 161 * emergency call. The {@link ImsService} sets this on a call to indicate that the network has 162 * identified the call as an emergency call. 163 */ 164 public static final String EXTRA_EMERGENCY_CALL = "e_call"; 165 166 /** 167 * @hide 168 */ 169 public static final String EXTRA_VMS = "vms"; 170 /** 171 * @hide 172 */ 173 public static final String EXTRA_CALL_MODE_CHANGEABLE = "call_mode_changeable"; 174 175 /** 176 * Indicates if the session can be extended to a conference call. If not defined, should be 177 * considered {@code false}. 178 * Boolean extra properties - {@code true} / {@code false}. 179 * 180 * This extra is set on an instance of {@link ImsCallProfile} via {@link #setCallExtraBoolean}. 181 * @hide 182 */ 183 @SystemApi 184 public static final String EXTRA_EXTENDING_TO_CONFERENCE_SUPPORTED = 185 "android.telephony.ims.extra.EXTENDING_TO_CONFERENCE_SUPPORTED"; 186 187 /** 188 * The previous string of EXTRA_EXTENDING_TO_CONFERENCE_SUPPORTED. 189 * Use EXTRA_EXTENDING_TO_CONFERENCE_SUPPORTED whenever possible. 190 * For backward compatibility, we should always set value for both 191 * EXTRA_EXTENDING_TO_CONFERENCE_SUPPORTED and EXTRA_CONFERENCE_AVAIL. 192 * 193 * @deprecated Remove when not needed anymore. 194 * 195 * @hide 196 */ 197 public static final String EXTRA_CONFERENCE_AVAIL = "conference_avail"; 198 199 /** 200 * Extra key used to store a Bundle containing proprietary extras to send to the ImsService. 201 * Use {@link #getProprietaryCallExtras()} instead. 202 * @hide 203 */ 204 @TestApi 205 public static final String EXTRA_OEM_EXTRAS = "android.telephony.ims.extra.OEM_EXTRAS"; 206 207 /** 208 * Rule for originating identity (number) presentation, MO/MT. 209 * {@link ImsCallProfile#OIR_DEFAULT} 210 * {@link ImsCallProfile#OIR_PRESENTATION_RESTRICTED} 211 * {@link ImsCallProfile#OIR_PRESENTATION_NOT_RESTRICTED} 212 */ 213 public static final String EXTRA_OIR = "oir"; 214 /** 215 * Rule for calling name presentation 216 * {@link ImsCallProfile#OIR_DEFAULT} 217 * {@link ImsCallProfile#OIR_PRESENTATION_RESTRICTED} 218 * {@link ImsCallProfile#OIR_PRESENTATION_NOT_RESTRICTED} 219 */ 220 public static final String EXTRA_CNAP = "cnap"; 221 /** 222 * To identify the Ims call type, MO 223 * {@link ImsCallProfile#DIALSTRING_NORMAL} 224 * {@link ImsCallProfile#DIALSTRING_SS_CONF} 225 * {@link ImsCallProfile#DIALSTRING_USSD} 226 */ 227 public static final String EXTRA_DIALSTRING = "dialstring"; 228 /** 229 * This extra holds call fail cause because of which redial is attempted. 230 * see {@link android.telephony.ims.ImsReasonInfo} {@code CODE_*} 231 * for possible values this extra can hold. 232 * 233 * @hide 234 */ 235 public static final String EXTRA_RETRY_CALL_FAIL_REASON = 236 "android.telephony.ims.extra.RETRY_CALL_FAIL_REASON"; 237 /** 238 * This extra holds call network type on which lower layers 239 * may try attempting redial. 240 * See {@link TelephonyManager} {@code NETWORK_TYPE_*} 241 * for possible values this extra can hold. 242 * 243 * @hide 244 */ 245 public static final String EXTRA_RETRY_CALL_FAIL_NETWORKTYPE = 246 "android.telephony.ims.extra.RETRY_CALL_FAIL_NETWORKTYPE"; 247 248 /** 249 * Extra for the call composer call priority, either {@link ImsCallProfile#PRIORITY_NORMAL} or 250 * {@link ImsCallProfile#PRIORITY_URGENT}. It can be set via 251 * {@link #setCallExtraInt(String, int)}. 252 * 253 * Reference: RCC.20 Section 2.4.4.2 254 */ 255 public static final String EXTRA_PRIORITY = "android.telephony.ims.extra.PRIORITY"; 256 257 // TODO(hallliu) remove the reference to the maximum length and update it later. 258 /** 259 * Extra for the call composer call subject, a string of maximum length 60 characters. 260 * It can be set via {@link #setCallExtra(String, String)}. 261 * 262 * Reference: RCC.20 Section 2.4.3.2 263 */ 264 public static final String EXTRA_CALL_SUBJECT = "android.telephony.ims.extra.CALL_SUBJECT"; 265 266 /** 267 * Extra for the call composer call location, an {@Link android.location.Location} parcelable 268 * class to represent the geolocation as a latitude and longitude pair. It can be set via 269 * {@link #setCallExtraParcelable(String, Parcelable)}. 270 * 271 * Reference: RCC.20 Section 2.4.3.2 272 */ 273 public static final String EXTRA_LOCATION = "android.telephony.ims.extra.LOCATION"; 274 275 /** 276 * Extra for the call composer picture URL, a String that indicates the URL on the carrier’s 277 * server infrastructure to get the picture. It can be set via 278 * {@link #setCallExtra(String, String)}. 279 * 280 * Note that this URL is not intended to be parsed by the IMS stack -- it should be sent 281 * directly to the network for consumption by the called party or forwarded directly from the 282 * network to the platform for caching and download. 283 * 284 * Reference: RCC.20 Section 2.4.3.2 285 */ 286 public static final String EXTRA_PICTURE_URL = "android.telephony.ims.extra.PICTURE_URL"; 287 288 /** 289 * Boolean extra indicating whether the call is a business call. 290 * 291 * This extra will be set to {@code true} if and only if the SIP INVITE headers contain the 292 * "Organization" header. 293 */ 294 public static final String EXTRA_IS_BUSINESS_CALL = 295 "android.telephony.ims.extra.IS_BUSINESS_CALL"; 296 297 /** 298 * Values for EXTRA_OIR / EXTRA_CNAP 299 */ 300 /** 301 * Default presentation for Originating Identity. 302 */ 303 public static final int OIR_DEFAULT = 0; // "user subscription default value" 304 /** 305 * Restricted presentation for Originating Identity. 306 */ 307 public static final int OIR_PRESENTATION_RESTRICTED = 1; 308 /** 309 * Not restricted presentation for Originating Identity. 310 */ 311 public static final int OIR_PRESENTATION_NOT_RESTRICTED = 2; 312 /** 313 * Presentation unknown for Originating Identity. 314 */ 315 public static final int OIR_PRESENTATION_UNKNOWN = 3; 316 /** 317 * Payphone presentation for Originating Identity. 318 */ 319 public static final int OIR_PRESENTATION_PAYPHONE = 4; 320 /** 321 * Unavailable presentation for Originating Identity. 322 */ 323 public static final int OIR_PRESENTATION_UNAVAILABLE = 5; 324 325 //Values for EXTRA_DIALSTRING 326 /** 327 * A default or normal normal call. 328 */ 329 public static final int DIALSTRING_NORMAL = 0; 330 /** 331 * Call for SIP-based user configuration 332 */ 333 public static final int DIALSTRING_SS_CONF = 1; 334 /** 335 * Call for USSD message 336 */ 337 public static final int DIALSTRING_USSD = 2; 338 339 // Values for EXTRA_PRIORITY 340 /** 341 * Indicates the call composer call priority is normal. 342 * 343 * Reference: RCC.20 Section 2.4.4.2 344 */ 345 public static final int PRIORITY_NORMAL = 0; 346 347 /** 348 * Indicates the call composer call priority is urgent. 349 * 350 * Reference: RCC.20 Section 2.4.4.2 351 */ 352 public static final int PRIORITY_URGENT = 1; 353 354 /** 355 * Call is not restricted on peer side and High Definition media is supported 356 */ 357 public static final int CALL_RESTRICT_CAUSE_NONE = 0; 358 359 /** 360 * High Definition media is not supported on the peer side due to the Radio Access Technology 361 * (RAT) it is are connected to. 362 */ 363 public static final int CALL_RESTRICT_CAUSE_RAT = 1; 364 365 /** 366 * The service has been disabled on the peer side. 367 */ 368 public static final int CALL_RESTRICT_CAUSE_DISABLED = 2; 369 370 /** 371 * High definition media is not currently supported. 372 */ 373 public static final int CALL_RESTRICT_CAUSE_HD = 3; 374 375 /**@hide*/ 376 @Retention(RetentionPolicy.SOURCE) 377 @IntDef(prefix = "CALL_RESTRICT_CAUSE_", value = { 378 CALL_RESTRICT_CAUSE_NONE, 379 CALL_RESTRICT_CAUSE_RAT, 380 CALL_RESTRICT_CAUSE_DISABLED, 381 CALL_RESTRICT_CAUSE_HD 382 }) 383 public @interface CallRestrictCause {} 384 385 /** 386 * String extra properties 387 * oi : Originating identity (number), MT only 388 * cna : Calling name 389 * ussd : For network-initiated USSD, MT only 390 * remote_uri : Connected user identity (it can be used for the conference) 391 * ChildNum: Child number info. 392 * Codec: Codec info. 393 * DisplayText: Display text for the call. 394 * AdditionalCallInfo: Additional call info. 395 * CallPull: Boolean value specifying if the call is a pulled call. 396 */ 397 public static final String EXTRA_OI = "oi"; 398 public static final String EXTRA_CNA = "cna"; 399 public static final String EXTRA_USSD = "ussd"; 400 public static final String EXTRA_REMOTE_URI = "remote_uri"; 401 public static final String EXTRA_CHILD_NUMBER = "ChildNum"; 402 public static final String EXTRA_CODEC = "Codec"; 403 public static final String EXTRA_DISPLAY_TEXT = "DisplayText"; 404 public static final String EXTRA_ADDITIONAL_CALL_INFO = "AdditionalCallInfo"; 405 public static final String EXTRA_IS_CALL_PULL = "CallPull"; 406 407 /** 408 * String extra property 409 * Containing fields from the SIP INVITE message for an IMS call 410 */ 411 public static final String EXTRA_ADDITIONAL_SIP_INVITE_FIELDS = 412 "android.telephony.ims.extra.ADDITIONAL_SIP_INVITE_FIELDS"; 413 414 /** 415 * CallDisconnectCause: Specify call disconnect cause. This extra should be a code 416 * corresponding to ImsReasonInfo and should only be populated in the case that the 417 * call has already been missed 418 */ 419 public static final String EXTRA_CALL_DISCONNECT_CAUSE = 420 "android.telephony.ims.extra.CALL_DISCONNECT_CAUSE"; 421 422 /** 423 * Extra key which the RIL can use to indicate the radio technology used for a call. 424 * Valid values are: 425 * {@link android.telephony.ServiceState#RIL_RADIO_TECHNOLOGY_LTE}, 426 * {@link android.telephony.ServiceState#RIL_RADIO_TECHNOLOGY_IWLAN}, and the other defined 427 * {@code RIL_RADIO_TECHNOLOGY_*} constants. 428 * Note: Despite the fact the {@link android.telephony.ServiceState} values are integer 429 * constants, the values passed for the {@link #EXTRA_CALL_RAT_TYPE} should be strings (e.g. 430 * "14" vs (int) 14). 431 * Note: This is used by {@link com.android.internal.telephony.imsphone.ImsPhoneConnection# 432 * updateImsCallRatFromExtras(Bundle)} to determine whether to set the 433 * {@link android.telecom.TelecomManager#EXTRA_CALL_NETWORK_TYPE} extra value and 434 * {@link android.telecom.Connection#PROPERTY_WIFI} property on a connection. 435 * @deprecated the constants associated with this extra are hidden, instead use 436 * {@link #EXTRA_CALL_NETWORK_TYPE}. 437 */ 438 @Deprecated 439 public static final String EXTRA_CALL_RAT_TYPE = "CallRadioTech"; 440 441 /** 442 * Extra key with an {@code int} value which can be set in {@link #setCallExtraInt(String, int)} 443 * to indicate the network type used for a call. 444 * <p> 445 * Valid values are defined by {@code TelephonyManager.NETWORK_TYPE_*} constants. An example may 446 * be {@link android.telephony.TelephonyManager#NETWORK_TYPE_LTE}. 447 */ 448 public static final String EXTRA_CALL_NETWORK_TYPE = 449 "android.telephony.ims.extra.CALL_NETWORK_TYPE"; 450 451 /** 452 * Similar to {@link #EXTRA_CALL_RAT_TYPE}, except with a lowercase 'c'. Used to ensure 453 * compatibility with modems that are non-compliant with the {@link #EXTRA_CALL_RAT_TYPE} 454 * extra key. Should be removed when the non-compliant modems are fixed. 455 * @hide 456 * @deprecated Use {@link #EXTRA_CALL_NETWORK_TYPE} instead. 457 */ 458 @Deprecated 459 public static final String EXTRA_CALL_RAT_TYPE_ALT = "callRadioTech"; 460 461 /** 462 * String extra property containing forwarded numbers associated with the current connection 463 * for an IMS call. The value is string array, and it can include multiple numbers, and 464 * the array values are expected E164 (e.g. +1 (650) 253-0000) format. 465 */ 466 public static final String EXTRA_FORWARDED_NUMBER = 467 "android.telephony.ims.extra.FORWARDED_NUMBER"; 468 469 /** 470 * Extra key with an {@code boolean} value which can be set in 471 * {@link #setCallExtraBoolean(String, boolean)} to indicate whether call is a cross sim call. 472 * <p> 473 * Valid values are true if call is cross sim call else false. 474 */ 475 public static final String EXTRA_IS_CROSS_SIM_CALL = 476 "android.telephony.ims.extra.IS_CROSS_SIM_CALL"; 477 478 /** @hide */ 479 public int mServiceType; 480 /** @hide */ 481 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 482 public int mCallType; 483 /** @hide */ 484 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 485 public @CallRestrictCause int mRestrictCause = CALL_RESTRICT_CAUSE_NONE; 486 487 /** 488 * The VERSTAT for an incoming call's phone number. 489 */ 490 private @VerificationStatus int mCallerNumberVerificationStatus; 491 492 /** 493 * Indicates that the network could not perform verification. 494 */ 495 public static final int VERIFICATION_STATUS_NOT_VERIFIED = 0; 496 497 /** 498 * Indicates that verification by the network passed. This indicates there is a high likelihood 499 * that the call originated from a valid source. 500 */ 501 public static final int VERIFICATION_STATUS_PASSED = 1; 502 503 /** 504 * Indicates that verification by the network failed. This indicates there is a high likelihood 505 * that the call did not originate from a valid source. 506 */ 507 public static final int VERIFICATION_STATUS_FAILED = 2; 508 509 /**@hide*/ 510 @Retention(RetentionPolicy.SOURCE) 511 @IntDef(prefix = "VERIFICATION_STATUS_", value = { 512 VERIFICATION_STATUS_NOT_VERIFIED, 513 VERIFICATION_STATUS_PASSED, 514 VERIFICATION_STATUS_FAILED 515 }) 516 public @interface VerificationStatus {} 517 518 /** 519 * The emergency service categories, only valid if {@link #getServiceType} returns 520 * {@link #SERVICE_TYPE_EMERGENCY} 521 * 522 * If valid, the value is the bitwise-OR combination of the following constants: 523 * <ol> 524 * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_UNSPECIFIED} </li> 525 * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_POLICE} </li> 526 * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_AMBULANCE} </li> 527 * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_FIRE_BRIGADE} </li> 528 * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_MARINE_GUARD} </li> 529 * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_MOUNTAIN_RESCUE} </li> 530 * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_MIEC} </li> 531 * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_AIEC} </li> 532 * </ol> 533 * 534 * Reference: 3gpp 23.167, Section 6 - Functional description; 535 * 3gpp 22.101, Section 10 - Emergency Calls. 536 */ 537 private @EmergencyServiceCategories int mEmergencyServiceCategories = 538 EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_UNSPECIFIED; 539 540 /** 541 * The emergency Uniform Resource Names (URN), only valid if {@link #getServiceType} returns 542 * {@link #SERVICE_TYPE_EMERGENCY}. 543 * 544 * Reference: 3gpp 24.503, Section 5.1.6.8.1 - General; 545 * 3gpp 22.101, Section 10 - Emergency Calls. 546 */ 547 private List<String> mEmergencyUrns = new ArrayList<>(); 548 549 /** 550 * The emergency call routing, only valid if {@link #getServiceType} returns 551 * {@link #SERVICE_TYPE_EMERGENCY} 552 * 553 * If valid, the value is any of the following constants: 554 * <ol> 555 * <li>{@link EmergencyNumber#EMERGENCY_CALL_ROUTING_UNKNOWN} </li> 556 * <li>{@link EmergencyNumber#EMERGENCY_CALL_ROUTING_NORMAL} </li> 557 * <li>{@link EmergencyNumber#EMERGENCY_CALL_ROUTING_EMERGENCY} </li> 558 * </ol> 559 */ 560 private @EmergencyCallRouting int mEmergencyCallRouting = 561 EmergencyNumber.EMERGENCY_CALL_ROUTING_UNKNOWN; 562 563 /** Indicates if the call is for testing purpose */ 564 private boolean mEmergencyCallTesting = false; 565 566 /** Indicates if we have known the intent of the user for the call is emergency */ 567 private boolean mHasKnownUserIntentEmergency = false; 568 569 private Set<RtpHeaderExtensionType> mAcceptedRtpHeaderExtensionTypes = new ArraySet<>(); 570 571 /** 572 * Extras associated with this {@link ImsCallProfile}. 573 * <p> 574 * Valid data types include: 575 * <ul> 576 * <li>{@link Integer} (and int)</li> 577 * <li>{@link Long} (and long)</li> 578 * <li>{@link Double} (and double)</li> 579 * <li>{@link String}</li> 580 * <li>{@code int[]}</li> 581 * <li>{@code long[]}</li> 582 * <li>{@code double[]}</li> 583 * <li>{@code String[]}</li> 584 * <li>{@link android.os.PersistableBundle}</li> 585 * <li>{@link Boolean} (and boolean)</li> 586 * <li>{@code boolean[]}</li> 587 * <li>Other {@link Parcelable} classes in the {@code android.*} namespace.</li> 588 * </ul> 589 * <p> 590 * Invalid types will be removed when the {@link ImsCallProfile} is parceled for transmit across 591 * a {@link android.os.Binder}. 592 */ 593 /** @hide */ 594 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 595 public Bundle mCallExtras; 596 /** @hide */ 597 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 598 public ImsStreamMediaProfile mMediaProfile; 599 600 /** @hide */ ImsCallProfile(Parcel in)601 public ImsCallProfile(Parcel in) { 602 readFromParcel(in); 603 } 604 605 /** 606 * Default Constructor that initializes the call profile with service type 607 * {@link #SERVICE_TYPE_NORMAL} and call type {@link #CALL_TYPE_VIDEO_N_VOICE} 608 */ ImsCallProfile()609 public ImsCallProfile() { 610 mServiceType = SERVICE_TYPE_NORMAL; 611 mCallType = CALL_TYPE_VOICE_N_VIDEO; 612 mCallExtras = new Bundle(); 613 mMediaProfile = new ImsStreamMediaProfile(); 614 } 615 616 /** 617 * Constructor. 618 * 619 * @param serviceType the service type for the call. Can be one of the following: 620 * {@link #SERVICE_TYPE_NONE}, 621 * {@link #SERVICE_TYPE_NORMAL}, 622 * {@link #SERVICE_TYPE_EMERGENCY} 623 * @param callType the call type. Can be one of the following: 624 * {@link #CALL_TYPE_VOICE_N_VIDEO}, 625 * {@link #CALL_TYPE_VOICE}, 626 * {@link #CALL_TYPE_VIDEO_N_VOICE}, 627 * {@link #CALL_TYPE_VT}, 628 * {@link #CALL_TYPE_VT_TX}, 629 * {@link #CALL_TYPE_VT_RX}, 630 * {@link #CALL_TYPE_VT_NODIR}, 631 * {@link #CALL_TYPE_VS}, 632 * {@link #CALL_TYPE_VS_TX}, 633 * {@link #CALL_TYPE_VS_RX} 634 */ ImsCallProfile(int serviceType, int callType)635 public ImsCallProfile(int serviceType, int callType) { 636 mServiceType = serviceType; 637 mCallType = callType; 638 mCallExtras = new Bundle(); 639 mMediaProfile = new ImsStreamMediaProfile(); 640 } 641 642 /** 643 * Constructor. 644 * 645 * @param serviceType the service type for the call. Can be one of the following: 646 * {@link #SERVICE_TYPE_NONE}, 647 * {@link #SERVICE_TYPE_NORMAL}, 648 * {@link #SERVICE_TYPE_EMERGENCY} 649 * @param callType the call type. Can be one of the following: 650 * {@link #CALL_TYPE_VOICE_N_VIDEO}, 651 * {@link #CALL_TYPE_VOICE}, 652 * {@link #CALL_TYPE_VIDEO_N_VOICE}, 653 * {@link #CALL_TYPE_VT}, 654 * {@link #CALL_TYPE_VT_TX}, 655 * {@link #CALL_TYPE_VT_RX}, 656 * {@link #CALL_TYPE_VT_NODIR}, 657 * {@link #CALL_TYPE_VS}, 658 * {@link #CALL_TYPE_VS_TX}, 659 * {@link #CALL_TYPE_VS_RX} 660 * @param callExtras A bundle with the call extras. 661 * @param mediaProfile The IMS stream media profile. 662 */ ImsCallProfile(int serviceType, int callType, Bundle callExtras, ImsStreamMediaProfile mediaProfile)663 public ImsCallProfile(int serviceType, int callType, Bundle callExtras, 664 ImsStreamMediaProfile mediaProfile) { 665 mServiceType = serviceType; 666 mCallType = callType; 667 mCallExtras = callExtras; 668 mMediaProfile = mediaProfile; 669 } 670 getCallExtra(String name)671 public String getCallExtra(String name) { 672 return getCallExtra(name, ""); 673 } 674 getCallExtra(String name, String defaultValue)675 public String getCallExtra(String name, String defaultValue) { 676 if (mCallExtras == null) { 677 return defaultValue; 678 } 679 680 return mCallExtras.getString(name, defaultValue); 681 } 682 getCallExtraBoolean(String name)683 public boolean getCallExtraBoolean(String name) { 684 return getCallExtraBoolean(name, false); 685 } 686 getCallExtraBoolean(String name, boolean defaultValue)687 public boolean getCallExtraBoolean(String name, boolean defaultValue) { 688 if (mCallExtras == null) { 689 return defaultValue; 690 } 691 692 return mCallExtras.getBoolean(name, defaultValue); 693 } 694 getCallExtraInt(String name)695 public int getCallExtraInt(String name) { 696 return getCallExtraInt(name, -1); 697 } 698 getCallExtraInt(String name, int defaultValue)699 public int getCallExtraInt(String name, int defaultValue) { 700 if (mCallExtras == null) { 701 return defaultValue; 702 } 703 704 return mCallExtras.getInt(name, defaultValue); 705 } 706 707 /** 708 * Get the call extras (Parcelable), given the extra name. 709 * @param name call extra name 710 * @return the corresponding call extra Parcelable or null if not applicable 711 */ 712 @Nullable getCallExtraParcelable(@ullable String name)713 public <T extends Parcelable> T getCallExtraParcelable(@Nullable String name) { 714 if (mCallExtras != null) { 715 return mCallExtras.getParcelable(name); 716 } 717 return null; 718 } 719 setCallExtra(String name, String value)720 public void setCallExtra(String name, String value) { 721 if (mCallExtras != null) { 722 mCallExtras.putString(name, value); 723 } 724 } 725 setCallExtraBoolean(String name, boolean value)726 public void setCallExtraBoolean(String name, boolean value) { 727 if (mCallExtras != null) { 728 mCallExtras.putBoolean(name, value); 729 } 730 } 731 setCallExtraInt(String name, int value)732 public void setCallExtraInt(String name, int value) { 733 if (mCallExtras != null) { 734 mCallExtras.putInt(name, value); 735 } 736 } 737 738 /** 739 * Set the call extra value (Parcelable), given the call extra name. 740 * 741 * Note that the {@link Parcelable} provided must be a class defined in the Android API surface, 742 * as opposed to a class defined by your app. 743 * 744 * @param name call extra name 745 * @param parcelable call extra value 746 */ setCallExtraParcelable(@onNull String name, @NonNull Parcelable parcelable)747 public void setCallExtraParcelable(@NonNull String name, @NonNull Parcelable parcelable) { 748 if (mCallExtras != null) { 749 mCallExtras.putParcelable(name, parcelable); 750 } 751 } 752 753 /** 754 * Set the call restrict cause, which provides the reason why a call has been restricted from 755 * using High Definition media. 756 */ setCallRestrictCause(@allRestrictCause int cause)757 public void setCallRestrictCause(@CallRestrictCause int cause) { 758 mRestrictCause = cause; 759 } 760 updateCallType(ImsCallProfile profile)761 public void updateCallType(ImsCallProfile profile) { 762 mCallType = profile.mCallType; 763 } 764 updateCallExtras(ImsCallProfile profile)765 public void updateCallExtras(ImsCallProfile profile) { 766 mCallExtras.clear(); 767 mCallExtras = (Bundle) profile.mCallExtras.clone(); 768 } 769 770 /** 771 * Updates the media profile for the call. 772 * 773 * @param profile Call profile with new media profile. 774 */ updateMediaProfile(ImsCallProfile profile)775 public void updateMediaProfile(ImsCallProfile profile) { 776 mMediaProfile = profile.mMediaProfile; 777 } 778 779 /** 780 * Sets the verification status for the phone number of an incoming call as identified in 781 * ATIS-1000082. 782 * <p> 783 * The ImsService should parse the verstat information from the SIP INVITE headers for the call 784 * to determine this information. It is typically found in the P-Asserted-Identity OR From 785 * header fields. 786 * @param callerNumberVerificationStatus the new verification status. 787 */ setCallerNumberVerificationStatus( @erificationStatus int callerNumberVerificationStatus)788 public void setCallerNumberVerificationStatus( 789 @VerificationStatus int callerNumberVerificationStatus) { 790 mCallerNumberVerificationStatus = callerNumberVerificationStatus; 791 } 792 793 /** 794 * Gets the verification status for the phone number of an incoming call as identified in 795 * ATIS-1000082. 796 * @return the verification status. 797 */ getCallerNumberVerificationStatus()798 public @VerificationStatus int getCallerNumberVerificationStatus() { 799 return mCallerNumberVerificationStatus; 800 } 801 802 @NonNull 803 @Override toString()804 public String toString() { 805 return "{ serviceType=" + mServiceType 806 + ", callType=" + mCallType 807 + ", restrictCause=" + mRestrictCause 808 + ", mediaProfile=" + (mMediaProfile != null ? mMediaProfile.toString() : "null") 809 + ", emergencyServiceCategories=" + mEmergencyServiceCategories 810 + ", emergencyUrns=" + mEmergencyUrns 811 + ", emergencyCallRouting=" + mEmergencyCallRouting 812 + ", emergencyCallTesting=" + mEmergencyCallTesting 813 + ", hasKnownUserIntentEmergency=" + mHasKnownUserIntentEmergency 814 + ", mRestrictCause=" + mRestrictCause 815 + ", mCallerNumberVerstat= " + mCallerNumberVerificationStatus 816 + ", mAcceptedRtpHeaderExtensions= " + mAcceptedRtpHeaderExtensionTypes 817 + " }"; 818 } 819 820 @Override describeContents()821 public int describeContents() { 822 return 0; 823 } 824 825 @Override writeToParcel(Parcel out, int flags)826 public void writeToParcel(Parcel out, int flags) { 827 Bundle filteredExtras = maybeCleanseExtras(mCallExtras); 828 out.writeInt(mServiceType); 829 out.writeInt(mCallType); 830 out.writeBundle(filteredExtras); 831 out.writeParcelable(mMediaProfile, 0); 832 out.writeInt(mEmergencyServiceCategories); 833 out.writeStringList(mEmergencyUrns); 834 out.writeInt(mEmergencyCallRouting); 835 out.writeBoolean(mEmergencyCallTesting); 836 out.writeBoolean(mHasKnownUserIntentEmergency); 837 out.writeInt(mRestrictCause); 838 out.writeInt(mCallerNumberVerificationStatus); 839 out.writeArray(mAcceptedRtpHeaderExtensionTypes.toArray()); 840 } 841 readFromParcel(Parcel in)842 private void readFromParcel(Parcel in) { 843 mServiceType = in.readInt(); 844 mCallType = in.readInt(); 845 mCallExtras = in.readBundle(); 846 mMediaProfile = in.readParcelable(ImsStreamMediaProfile.class.getClassLoader(), android.telephony.ims.ImsStreamMediaProfile.class); 847 mEmergencyServiceCategories = in.readInt(); 848 mEmergencyUrns = in.createStringArrayList(); 849 mEmergencyCallRouting = in.readInt(); 850 mEmergencyCallTesting = in.readBoolean(); 851 mHasKnownUserIntentEmergency = in.readBoolean(); 852 mRestrictCause = in.readInt(); 853 mCallerNumberVerificationStatus = in.readInt(); 854 Object[] accepted = in.readArray(RtpHeaderExtensionType.class.getClassLoader(), 855 RtpHeaderExtensionType.class); 856 mAcceptedRtpHeaderExtensionTypes = Arrays.stream(accepted) 857 .map(o -> (RtpHeaderExtensionType) o).collect(Collectors.toSet()); 858 } 859 860 public static final @android.annotation.NonNull Creator<ImsCallProfile> CREATOR = 861 new Creator<ImsCallProfile>() { 862 @Override 863 public ImsCallProfile createFromParcel(Parcel in) { 864 return new ImsCallProfile(in); 865 } 866 867 @Override 868 public ImsCallProfile[] newArray(int size) { 869 return new ImsCallProfile[size]; 870 } 871 }; 872 getServiceType()873 public int getServiceType() { 874 return mServiceType; 875 } 876 getCallType()877 public int getCallType() { 878 return mCallType; 879 } 880 881 /** 882 * @return The call restrict cause, which provides the reason why a call has been restricted 883 * from using High Definition media. 884 */ getRestrictCause()885 public @CallRestrictCause int getRestrictCause() { 886 return mRestrictCause; 887 } 888 getCallExtras()889 public Bundle getCallExtras() { 890 return mCallExtras; 891 } 892 893 /** 894 * Get the proprietary extras set for this ImsCallProfile. 895 * @return A {@link Bundle} containing proprietary call extras that were not set by the 896 * platform. 897 */ getProprietaryCallExtras()898 public @NonNull Bundle getProprietaryCallExtras() { 899 if (mCallExtras == null) { 900 return new Bundle(); 901 } 902 Bundle proprietaryExtras = mCallExtras.getBundle(EXTRA_OEM_EXTRAS); 903 if (proprietaryExtras == null) { 904 return new Bundle(); 905 } 906 // Make a copy so users do not accidentally change this copy of the extras. 907 return new Bundle(proprietaryExtras); 908 } 909 getMediaProfile()910 public ImsStreamMediaProfile getMediaProfile() { 911 return mMediaProfile; 912 } 913 914 /** 915 * Converts from the call types defined in {@link ImsCallProfile} to the 916 * video state values defined in {@link VideoProfile}. 917 * 918 * @param callProfile The call profile. 919 * @return The video state. 920 */ getVideoStateFromImsCallProfile(ImsCallProfile callProfile)921 public static int getVideoStateFromImsCallProfile(ImsCallProfile callProfile) { 922 int videostate = getVideoStateFromCallType(callProfile.mCallType); 923 if (callProfile.isVideoPaused() && !VideoProfile.isAudioOnly(videostate)) { 924 videostate |= VideoProfile.STATE_PAUSED; 925 } else { 926 videostate &= ~VideoProfile.STATE_PAUSED; 927 } 928 return videostate; 929 } 930 931 /** 932 * Translates a {@link ImsCallProfile} {@code CALL_TYPE_*} constant into a video state. 933 * @param callType The call type. 934 * @return The video state. 935 */ getVideoStateFromCallType(int callType)936 public static int getVideoStateFromCallType(int callType) { 937 int videostate = VideoProfile.STATE_AUDIO_ONLY; 938 switch (callType) { 939 case CALL_TYPE_VT_TX: 940 videostate = VideoProfile.STATE_TX_ENABLED; 941 break; 942 case CALL_TYPE_VT_RX: 943 videostate = VideoProfile.STATE_RX_ENABLED; 944 break; 945 case CALL_TYPE_VT: 946 videostate = VideoProfile.STATE_BIDIRECTIONAL; 947 break; 948 case CALL_TYPE_VOICE: 949 videostate = VideoProfile.STATE_AUDIO_ONLY; 950 break; 951 default: 952 videostate = VideoProfile.STATE_AUDIO_ONLY; 953 break; 954 } 955 return videostate; 956 } 957 958 /** 959 * Converts from the video state values defined in {@link VideoProfile} 960 * to the call types defined in {@link ImsCallProfile}. 961 * 962 * @param videoState The video state. 963 * @return The call type. 964 */ getCallTypeFromVideoState(int videoState)965 public static int getCallTypeFromVideoState(int videoState) { 966 boolean videoTx = isVideoStateSet(videoState, VideoProfile.STATE_TX_ENABLED); 967 boolean videoRx = isVideoStateSet(videoState, VideoProfile.STATE_RX_ENABLED); 968 boolean isPaused = isVideoStateSet(videoState, VideoProfile.STATE_PAUSED); 969 if (isPaused) { 970 return ImsCallProfile.CALL_TYPE_VT_NODIR; 971 } else if (videoTx && !videoRx) { 972 return ImsCallProfile.CALL_TYPE_VT_TX; 973 } else if (!videoTx && videoRx) { 974 return ImsCallProfile.CALL_TYPE_VT_RX; 975 } else if (videoTx && videoRx) { 976 return ImsCallProfile.CALL_TYPE_VT; 977 } 978 return ImsCallProfile.CALL_TYPE_VOICE; 979 } 980 981 /** 982 * Badly named old method, kept for compatibility. 983 * See {@link #presentationToOir(int)}. 984 * @hide 985 */ 986 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) presentationToOIR(int presentation)987 public static int presentationToOIR(int presentation) { 988 switch (presentation) { 989 case PhoneConstants.PRESENTATION_RESTRICTED: 990 return ImsCallProfile.OIR_PRESENTATION_RESTRICTED; 991 case PhoneConstants.PRESENTATION_ALLOWED: 992 return ImsCallProfile.OIR_PRESENTATION_NOT_RESTRICTED; 993 case PhoneConstants.PRESENTATION_PAYPHONE: 994 return ImsCallProfile.OIR_PRESENTATION_PAYPHONE; 995 case PhoneConstants.PRESENTATION_UNKNOWN: 996 return ImsCallProfile.OIR_PRESENTATION_UNKNOWN; 997 case PhoneConstants.PRESENTATION_UNAVAILABLE: 998 return ImsCallProfile.OIR_PRESENTATION_UNAVAILABLE; 999 default: 1000 return ImsCallProfile.OIR_DEFAULT; 1001 } 1002 } 1003 1004 /** 1005 * Translate presentation value to OIR value 1006 * @param presentation 1007 * @return OIR values 1008 */ presentationToOir(int presentation)1009 public static int presentationToOir(int presentation) { 1010 return presentationToOIR(presentation); 1011 } 1012 1013 /** 1014 * Translate OIR value to presentation value 1015 * @param oir value 1016 * @return presentation value 1017 * @hide 1018 */ OIRToPresentation(int oir)1019 public static int OIRToPresentation(int oir) { 1020 switch(oir) { 1021 case ImsCallProfile.OIR_PRESENTATION_RESTRICTED: 1022 return PhoneConstants.PRESENTATION_RESTRICTED; 1023 case ImsCallProfile.OIR_PRESENTATION_NOT_RESTRICTED: 1024 return PhoneConstants.PRESENTATION_ALLOWED; 1025 case ImsCallProfile.OIR_PRESENTATION_PAYPHONE: 1026 return PhoneConstants.PRESENTATION_PAYPHONE; 1027 case ImsCallProfile.OIR_PRESENTATION_UNAVAILABLE: 1028 return PhoneConstants.PRESENTATION_UNAVAILABLE; 1029 case ImsCallProfile.OIR_PRESENTATION_UNKNOWN: 1030 return PhoneConstants.PRESENTATION_UNKNOWN; 1031 default: 1032 return PhoneConstants.PRESENTATION_UNKNOWN; 1033 } 1034 } 1035 1036 /** 1037 * Checks if video call is paused 1038 * @return true if call is video paused 1039 */ isVideoPaused()1040 public boolean isVideoPaused() { 1041 return mMediaProfile.mVideoDirection == ImsStreamMediaProfile.DIRECTION_INACTIVE; 1042 } 1043 1044 /** 1045 * Determines if the {@link ImsCallProfile} represents a video call. 1046 * 1047 * @return {@code true} if the profile is for a video call, {@code false} otherwise. 1048 */ isVideoCall()1049 public boolean isVideoCall() { 1050 return VideoProfile.isVideo(getVideoStateFromCallType(mCallType)); 1051 } 1052 1053 /** 1054 * Cleanses a {@link Bundle} to ensure that it contains only data of type: 1055 * 1. Primitive data types (e.g. int, bool, and other values determined by 1056 * {@link android.os.PersistableBundle#isValidType(Object)}). 1057 * 2. Other Bundles. 1058 * 3. {@link Parcelable} objects in the {@code android.*} namespace. 1059 * @param extras the source {@link Bundle} 1060 * @return where all elements are valid types the source {@link Bundle} is returned unmodified, 1061 * otherwise a copy of the {@link Bundle} with the invalid elements is returned. 1062 */ maybeCleanseExtras(Bundle extras)1063 private Bundle maybeCleanseExtras(Bundle extras) { 1064 if (extras == null) { 1065 return null; 1066 } 1067 1068 int startSize = extras.size(); 1069 Bundle filtered = TelephonyUtils.filterValues(extras); 1070 int endSize = filtered.size(); 1071 if (startSize != endSize) { 1072 Log.i(TAG, "maybeCleanseExtras: " + (startSize - endSize) + " extra values were " 1073 + "removed - only primitive types and system parcelables are permitted."); 1074 } 1075 return filtered; 1076 } 1077 1078 /** 1079 * Determines if a video state is set in a video state bit-mask. 1080 * 1081 * @param videoState The video state bit mask. 1082 * @param videoStateToCheck The particular video state to check. 1083 * @return True if the video state is set in the bit-mask. 1084 */ isVideoStateSet(int videoState, int videoStateToCheck)1085 private static boolean isVideoStateSet(int videoState, int videoStateToCheck) { 1086 return (videoState & videoStateToCheck) == videoStateToCheck; 1087 } 1088 1089 /** 1090 * Set the emergency number information. The set value is valid 1091 * only if {@link #getServiceType} returns {@link #SERVICE_TYPE_EMERGENCY} 1092 * 1093 * Reference: 3gpp 23.167, Section 6 - Functional description; 1094 * 3gpp 24.503, Section 5.1.6.8.1 - General; 1095 * 3gpp 22.101, Section 10 - Emergency Calls. 1096 * 1097 * @hide 1098 */ setEmergencyCallInfo(EmergencyNumber num, boolean hasKnownUserIntentEmergency)1099 public void setEmergencyCallInfo(EmergencyNumber num, boolean hasKnownUserIntentEmergency) { 1100 setEmergencyServiceCategories(num.getEmergencyServiceCategoryBitmaskInternalDial()); 1101 setEmergencyUrns(num.getEmergencyUrns()); 1102 setEmergencyCallRouting(num.getEmergencyCallRouting()); 1103 setEmergencyCallTesting(num.getEmergencyNumberSourceBitmask() 1104 == EmergencyNumber.EMERGENCY_NUMBER_SOURCE_TEST); 1105 setHasKnownUserIntentEmergency(hasKnownUserIntentEmergency); 1106 } 1107 1108 /** 1109 * Set the emergency service categories. The set value is valid only if 1110 * {@link #getServiceType} returns {@link #SERVICE_TYPE_EMERGENCY} 1111 * 1112 * If valid, the value is the bitwise-OR combination of the following constants: 1113 * <ol> 1114 * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_UNSPECIFIED} </li> 1115 * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_POLICE} </li> 1116 * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_AMBULANCE} </li> 1117 * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_FIRE_BRIGADE} </li> 1118 * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_MARINE_GUARD} </li> 1119 * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_MOUNTAIN_RESCUE} </li> 1120 * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_MIEC} </li> 1121 * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_AIEC} </li> 1122 * </ol> 1123 * 1124 * Reference: 3gpp 23.167, Section 6 - Functional description; 1125 * 3gpp 22.101, Section 10 - Emergency Calls. 1126 */ 1127 @VisibleForTesting setEmergencyServiceCategories( @mergencyServiceCategories int emergencyServiceCategories)1128 public void setEmergencyServiceCategories( 1129 @EmergencyServiceCategories int emergencyServiceCategories) { 1130 mEmergencyServiceCategories = emergencyServiceCategories; 1131 } 1132 1133 /** 1134 * Set the emergency Uniform Resource Names (URN), only valid if {@link #getServiceType} 1135 * returns {@link #SERVICE_TYPE_EMERGENCY}. 1136 * 1137 * Reference: 3gpp 24.503, Section 5.1.6.8.1 - General; 1138 * 3gpp 22.101, Section 10 - Emergency Calls. 1139 */ 1140 @VisibleForTesting setEmergencyUrns(@onNull List<String> emergencyUrns)1141 public void setEmergencyUrns(@NonNull List<String> emergencyUrns) { 1142 mEmergencyUrns = emergencyUrns; 1143 } 1144 1145 /** 1146 * Set the emergency call routing, only valid if {@link #getServiceType} returns 1147 * {@link #SERVICE_TYPE_EMERGENCY} 1148 * 1149 * If valid, the value is any of the following constants: 1150 * <ol> 1151 * <li>{@link EmergencyNumber#EMERGENCY_CALL_ROUTING_UNKNOWN} </li> 1152 * <li>{@link EmergencyNumber#EMERGENCY_CALL_ROUTING_NORMAL} </li> 1153 * <li>{@link EmergencyNumber#EMERGENCY_CALL_ROUTING_EMERGENCY} </li> 1154 * </ol> 1155 */ 1156 @VisibleForTesting setEmergencyCallRouting(@mergencyCallRouting int emergencyCallRouting)1157 public void setEmergencyCallRouting(@EmergencyCallRouting int emergencyCallRouting) { 1158 mEmergencyCallRouting = emergencyCallRouting; 1159 } 1160 1161 /** 1162 * Set if this is for testing emergency call, only valid if {@link #getServiceType} returns 1163 * {@link #SERVICE_TYPE_EMERGENCY}. 1164 */ 1165 @VisibleForTesting setEmergencyCallTesting(boolean isTesting)1166 public void setEmergencyCallTesting(boolean isTesting) { 1167 mEmergencyCallTesting = isTesting; 1168 } 1169 1170 /** 1171 * Set if we have known the user intent of the call is emergency. 1172 * 1173 * This is only used to specify when the dialed number is ambiguous when it can be identified 1174 * as both emergency number and any other non-emergency number; e.g. in some situation, 611 1175 * could be both an emergency number in a country and a non-emergency number of a carrier's 1176 * customer service hotline. 1177 */ 1178 @VisibleForTesting setHasKnownUserIntentEmergency(boolean hasKnownUserIntentEmergency)1179 public void setHasKnownUserIntentEmergency(boolean hasKnownUserIntentEmergency) { 1180 mHasKnownUserIntentEmergency = hasKnownUserIntentEmergency; 1181 } 1182 1183 /** 1184 * Get the emergency service categories, only valid if {@link #getServiceType} returns 1185 * {@link #SERVICE_TYPE_EMERGENCY} 1186 * 1187 * @return the emergency service categories, 1188 * 1189 * If valid, the value is the bitwise-OR combination of the following constants: 1190 * <ol> 1191 * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_UNSPECIFIED} </li> 1192 * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_POLICE} </li> 1193 * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_AMBULANCE} </li> 1194 * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_FIRE_BRIGADE} </li> 1195 * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_MARINE_GUARD} </li> 1196 * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_MOUNTAIN_RESCUE} </li> 1197 * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_MIEC} </li> 1198 * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_AIEC} </li> 1199 * </ol> 1200 * 1201 * Reference: 3gpp 23.167, Section 6 - Functional description; 1202 * 3gpp 22.101, Section 10 - Emergency Calls. 1203 */ getEmergencyServiceCategories()1204 public @EmergencyServiceCategories int getEmergencyServiceCategories() { 1205 return mEmergencyServiceCategories; 1206 } 1207 1208 /** 1209 * Get the emergency Uniform Resource Names (URN), only valid if {@link #getServiceType} 1210 * returns {@link #SERVICE_TYPE_EMERGENCY}. 1211 * 1212 * Reference: 3gpp 24.503, Section 5.1.6.8.1 - General; 1213 * 3gpp 22.101, Section 10 - Emergency Calls. 1214 */ getEmergencyUrns()1215 public @NonNull List<String> getEmergencyUrns() { 1216 return mEmergencyUrns; 1217 } 1218 1219 /** 1220 * Get the emergency call routing, only valid if {@link #getServiceType} returns 1221 * {@link #SERVICE_TYPE_EMERGENCY} 1222 * 1223 * If valid, the value is any of the following constants: 1224 * <ol> 1225 * <li>{@link EmergencyNumber#EMERGENCY_CALL_ROUTING_UNKNOWN} </li> 1226 * <li>{@link EmergencyNumber#EMERGENCY_CALL_ROUTING_NORMAL} </li> 1227 * <li>{@link EmergencyNumber#EMERGENCY_CALL_ROUTING_EMERGENCY} </li> 1228 * </ol> 1229 */ getEmergencyCallRouting()1230 public @EmergencyCallRouting int getEmergencyCallRouting() { 1231 return mEmergencyCallRouting; 1232 } 1233 1234 /** 1235 * Get if the emergency call is for testing purpose. 1236 */ isEmergencyCallTesting()1237 public boolean isEmergencyCallTesting() { 1238 return mEmergencyCallTesting; 1239 } 1240 1241 /** 1242 * Checks if we have known the user intent of the call is emergency. 1243 * 1244 * This is only used to specify when the dialed number is ambiguous when it can be identified 1245 * as both emergency number and any other non-emergency number; e.g. in some situation, 611 1246 * could be both an emergency number in a country and a non-emergency number of a carrier's 1247 * customer service hotline. 1248 */ hasKnownUserIntentEmergency()1249 public boolean hasKnownUserIntentEmergency() { 1250 return mHasKnownUserIntentEmergency; 1251 } 1252 1253 /** 1254 * Gets the {@link RtpHeaderExtensionType}s which have been accepted by both ends of the call. 1255 * <p> 1256 * According to RFC8285, RTP header extensions available to a call are determined using the 1257 * offer/accept phase of the SDP protocol (see RFC4566). 1258 * <p> 1259 * The offered header extension types supported by the framework and exposed to the 1260 * {@link ImsService} via {@link MmTelFeature#changeOfferedRtpHeaderExtensionTypes(Set)}. 1261 * 1262 * @return the {@link RtpHeaderExtensionType}s which were accepted by the other end of the call. 1263 */ getAcceptedRtpHeaderExtensionTypes()1264 public @NonNull Set<RtpHeaderExtensionType> getAcceptedRtpHeaderExtensionTypes() { 1265 return mAcceptedRtpHeaderExtensionTypes; 1266 } 1267 1268 /** 1269 * Sets the accepted {@link RtpHeaderExtensionType}s for this call. 1270 * <p> 1271 * According to RFC8285, RTP header extensions available to a call are determined using the 1272 * offer/accept phase of the SDP protocol (see RFC4566). 1273 * 1274 * @param rtpHeaderExtensions 1275 */ setAcceptedRtpHeaderExtensionTypes(@onNull Set<RtpHeaderExtensionType> rtpHeaderExtensions)1276 public void setAcceptedRtpHeaderExtensionTypes(@NonNull Set<RtpHeaderExtensionType> 1277 rtpHeaderExtensions) { 1278 mAcceptedRtpHeaderExtensionTypes.clear(); 1279 mAcceptedRtpHeaderExtensionTypes.addAll(rtpHeaderExtensions); 1280 } 1281 } 1282