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.Manifest; 20 import android.annotation.CallbackExecutor; 21 import android.annotation.NonNull; 22 import android.annotation.Nullable; 23 import android.annotation.RequiresFeature; 24 import android.annotation.RequiresPermission; 25 import android.annotation.SdkConstant; 26 import android.annotation.StringDef; 27 import android.annotation.SystemApi; 28 import android.annotation.WorkerThread; 29 import android.content.pm.PackageManager; 30 import android.os.Binder; 31 import android.os.RemoteException; 32 import android.os.ServiceSpecificException; 33 import android.telephony.CarrierConfigManager; 34 import android.telephony.SubscriptionManager; 35 import android.telephony.TelephonyFrameworkInitializer; 36 import android.telephony.TelephonyManager; 37 import android.telephony.ims.aidl.IFeatureProvisioningCallback; 38 import android.telephony.ims.aidl.IImsConfigCallback; 39 import android.telephony.ims.aidl.IRcsConfigCallback; 40 import android.telephony.ims.feature.MmTelFeature; 41 import android.telephony.ims.stub.ImsConfigImplBase; 42 import android.telephony.ims.stub.ImsRegistrationImplBase; 43 44 import com.android.internal.telephony.ITelephony; 45 46 import java.lang.annotation.Retention; 47 import java.lang.annotation.RetentionPolicy; 48 import java.util.concurrent.Executor; 49 50 /** 51 * Manages IMS provisioning and configuration parameters, as well as callbacks for apps to listen 52 * to changes in these configurations. 53 * 54 * IMS provisioning keys are defined per carrier or OEM using OMA-DM or other provisioning 55 * applications and may vary. It is up to the carrier and OEM applications to ensure that the 56 * correct provisioning keys are being used when integrating with a vendor's ImsService. 57 * 58 * Use {@link android.telephony.ims.ImsManager#getProvisioningManager(int)} to get an instance of 59 * this manager. 60 */ 61 @RequiresFeature(PackageManager.FEATURE_TELEPHONY_IMS) 62 public class ProvisioningManager { 63 64 private static final String TAG = "ProvisioningManager"; 65 66 /**@hide*/ 67 @StringDef(prefix = "STRING_QUERY_RESULT_ERROR_", value = { 68 STRING_QUERY_RESULT_ERROR_GENERIC, 69 STRING_QUERY_RESULT_ERROR_NOT_READY 70 }) 71 @Retention(RetentionPolicy.SOURCE) 72 public @interface StringResultError {} 73 74 /** 75 * The query from {@link #getProvisioningStringValue(int)} has resulted in an unspecified error. 76 * @hide 77 */ 78 @SystemApi 79 public static final String STRING_QUERY_RESULT_ERROR_GENERIC = 80 "STRING_QUERY_RESULT_ERROR_GENERIC"; 81 82 /** 83 * The query from {@link #getProvisioningStringValue(int)} has resulted in an error because the 84 * ImsService implementation was not ready for provisioning queries. 85 * @hide 86 */ 87 @SystemApi 88 public static final String STRING_QUERY_RESULT_ERROR_NOT_READY = 89 "STRING_QUERY_RESULT_ERROR_NOT_READY"; 90 91 /** 92 * There is no existing configuration for the queried provisioning key. 93 * @hide 94 */ 95 public static final int PROVISIONING_RESULT_UNKNOWN = -1; 96 97 /** 98 * The integer result of provisioning for the queried key is disabled. 99 * @hide 100 */ 101 @SystemApi 102 public static final int PROVISIONING_VALUE_DISABLED = 0; 103 104 /** 105 * The integer result of provisioning for the queried key is enabled. 106 * @hide 107 */ 108 @SystemApi 109 public static final int PROVISIONING_VALUE_ENABLED = 1; 110 111 112 // Inheriting values from ImsConfig for backwards compatibility. 113 /** 114 * AMR CODEC Mode Value set, 0-7 in comma separated sequence. 115 * <p> 116 * This corresponds to the {@code mode-set} parameter for the AMR codec. 117 * See 3GPP TS 26.101 Table 1A for more information. 118 * <p> 119 * <UL> 120 * <LI>0 - AMR 4.75 kbit/s</LI> 121 * <LI>1 - AMR 5.15 kbit/s</LI> 122 * <LI>2 - AMR 5.90 kbit/s</LI> 123 * <LI>3 - AMR 6.70 kbit/s (PDC-EFR)</LI> 124 * <LI>4 - AMR 7.40 kbit/s (TDMA-EFR)</LI> 125 * <LI>5 - AMR 7.95 kbit/s</LI> 126 * <LI>6 - AMR 10.2 kbit/s</LI> 127 * <LI>7 - AMR 12.2 kbit/s (GSM-EFR)</LI> 128 * </UL> 129 * <p> 130 * Value is in String format. 131 * @see #setProvisioningIntValue(int, int) 132 * @see #getProvisioningIntValue(int) 133 * @hide 134 */ 135 public static final int KEY_AMR_CODEC_MODE_SET_VALUES = 0; 136 137 /** 138 * Wide Band AMR CODEC Mode Value set,0-7 in comma separated sequence. 139 * <p> 140 * This corresponds to the {@code mode-set} parameter for the AMR wideband codec. 141 * See 3GPP TS 26.101 Table 1A for more information. 142 * <p> 143 * <UL> 144 * <LI>0 - AMR 4.75 kbit/s</LI> 145 * <LI>1 - AMR 5.15 kbit/s</LI> 146 * <LI>2 - AMR 5.90 kbit/s</LI> 147 * <LI>3 - AMR 6.70 kbit/s (PDC-EFR)</LI> 148 * <LI>4 - AMR 7.40 kbit/s (TDMA-EFR)</LI> 149 * <LI>5 - AMR 7.95 kbit/s</LI> 150 * <LI>6 - AMR 10.2 kbit/s</LI> 151 * <LI>7 - AMR 12.2 kbit/s (GSM-EFR)</LI> 152 * </UL> 153 * <p> 154 * Value is in String format. 155 * @see #setProvisioningStringValue(int, String) 156 * @see #getProvisioningStringValue(int) 157 * @hide 158 */ 159 public static final int KEY_AMR_WB_CODEC_MODE_SET_VALUES = 1; 160 161 /** 162 * SIP Session Timer value (seconds). 163 * <p> 164 * See RFC4028 for more information. 165 * <p> 166 * Value is in Integer format. 167 * @see #setProvisioningIntValue(int, int) 168 * @see #getProvisioningIntValue(int) 169 * @hide 170 */ 171 public static final int KEY_SIP_SESSION_TIMER_SEC = 2; 172 173 /** 174 * Minimum SIP Session Expiration Timer in (seconds). 175 * <p> 176 * See RFC4028 for more information. 177 * <p> 178 * Value is in Integer format. 179 * @see #setProvisioningIntValue(int, int) 180 * @see #getProvisioningIntValue(int) 181 * @hide 182 */ 183 public static final int KEY_MINIMUM_SIP_SESSION_EXPIRATION_TIMER_SEC = 3; 184 185 /** 186 * SIP_INVITE cancellation time out value (in milliseconds). Integer format. 187 * <p> 188 * See RFC4028 for more information. 189 * <p> 190 * Value is in Integer format. 191 * @see #setProvisioningIntValue(int, int) 192 * @see #getProvisioningIntValue(int) 193 * @hide 194 */ 195 public static final int KEY_SIP_INVITE_CANCELLATION_TIMER_MS = 4; 196 197 /** 198 * Delay time when an iRAT transitions from eHRPD/HRPD/1xRTT to LTE. 199 * Value is in Integer format. 200 * @see #setProvisioningIntValue(int, int) 201 * @see #getProvisioningIntValue(int) 202 * @hide 203 */ 204 public static final int KEY_TRANSITION_TO_LTE_DELAY_MS = 5; 205 206 /** 207 * Silent redial status of Enabled (True), or Disabled (False). 208 * Value is in boolean format. 209 * @see #setProvisioningIntValue(int, int) 210 * @see #getProvisioningIntValue(int) 211 * @hide 212 */ 213 public static final int KEY_ENABLE_SILENT_REDIAL = 6; 214 215 /** 216 * An integer key representing the SIP T1 timer value in milliseconds for the associated 217 * subscription. 218 * <p> 219 * The SIP T1 timer is an estimate of the round-trip time and will retransmit 220 * INVITE transactions that are longer than T1 milliseconds over unreliable transports, doubling 221 * the time before retransmission every time there is no response. See RFC3261, section 17.1.1.1 222 * for more details. 223 * <p> 224 * The value is an integer. 225 * @see #setProvisioningIntValue(int, int) 226 * @see #getProvisioningIntValue(int) 227 * @hide 228 */ 229 public static final int KEY_T1_TIMER_VALUE_MS = 7; 230 231 /** 232 * SIP T2 timer value in milliseconds. See RFC 3261 for information. 233 * <p> 234 * The T2 timer is the maximum retransmit interval for non-INVITE requests and INVITE responses. 235 * <p> 236 * Value is in Integer format. 237 * @see #setProvisioningIntValue(int, int) 238 * @see #getProvisioningIntValue(int) 239 * @hide 240 */ 241 public static final int KEY_T2_TIMER_VALUE_MS = 8; 242 243 /** 244 * SIP TF timer value in milliseconds. See RFC 3261 for information. 245 * <p> 246 * The TF timer is the non-INVITE transaction timeout timer. 247 * <p> 248 * Value is in Integer format. 249 * @see #setProvisioningIntValue(int, int) 250 * @see #getProvisioningIntValue(int) 251 * @hide 252 */ 253 public static final int KEY_TF_TIMER_VALUE_MS = 9; 254 255 /** 256 * An integer key representing the voice over LTE (VoLTE) provisioning status for the 257 * associated subscription. Determines whether the user can register for voice services over 258 * LTE. 259 * <p> 260 * Use {@link #PROVISIONING_VALUE_ENABLED} to enable VoLTE provisioning and 261 * {@link #PROVISIONING_VALUE_DISABLED} to disable VoLTE provisioning. 262 * @see #setProvisioningIntValue(int, int) 263 * @see #getProvisioningIntValue(int) 264 * @hide 265 */ 266 public static final int KEY_VOLTE_PROVISIONING_STATUS = 10; 267 268 /** 269 * An integer key representing the video telephony (VT) provisioning status for the 270 * associated subscription. Determines whether the user can register for video services over 271 * LTE. 272 * <p> 273 * Use {@link #PROVISIONING_VALUE_ENABLED} to enable VT provisioning and 274 * {@link #PROVISIONING_VALUE_DISABLED} to disable VT provisioning. 275 * @see #setProvisioningIntValue(int, int) 276 * @see #getProvisioningIntValue(int) 277 * @hide 278 */ 279 public static final int KEY_VT_PROVISIONING_STATUS = 11; 280 281 /** 282 * Domain Name for the device to populate the request URI for REGISTRATION. 283 * Value is in String format. 284 * @see #setProvisioningStringValue(int, String) 285 * @see #getProvisioningStringValue(int) 286 * @hide 287 */ 288 public static final int KEY_REGISTRATION_DOMAIN_NAME = 12; 289 290 /** 291 * Device Outgoing SMS based on either 3GPP or 3GPP2 standards. 292 * Value is in Integer format. 293 * Valid values are {@link #SMS_FORMAT_3GPP} and {@link #SMS_FORMAT_3GPP2}. 294 * @see #setProvisioningIntValue(int, int) 295 * @see #getProvisioningIntValue(int) 296 * @hide 297 */ 298 public static final int KEY_SMS_FORMAT = 13; 299 300 /** 301 * Value used with {@link #KEY_SMS_FORMAT} to indicate 3GPP2 SMS format is used. 302 * See {@link android.telephony.SmsMessage#FORMAT_3GPP2} for more information. 303 * @hide 304 */ 305 public static final int SMS_FORMAT_3GPP2 = 0; 306 307 /** 308 * Value used with {@link #KEY_SMS_FORMAT} to indicate 3GPP SMS format is used. 309 * See {@link android.telephony.SmsMessage#FORMAT_3GPP} for more information. 310 * @hide 311 */ 312 public static final int SMS_FORMAT_3GPP = 1; 313 314 /** 315 * Turns SMS over IMS ON/OFF on the device. 316 * Value is in Integer format. ON (1), OFF(0). 317 * @see #setProvisioningIntValue(int, int) 318 * @see #getProvisioningIntValue(int) 319 * @hide 320 */ 321 public static final int KEY_SMS_OVER_IP_ENABLED = 14; 322 323 /** 324 * An integer key associated with the carrier configured SIP PUBLISH timer, which dictates the 325 * expiration time in seconds for published online availability in RCS presence. 326 * <p> 327 * Value is in Integer format. 328 * @see #setProvisioningIntValue(int, int) 329 * @see #getProvisioningIntValue(int) 330 * @hide 331 */ 332 public static final int KEY_RCS_PUBLISH_TIMER_SEC = 15; 333 334 /** 335 * An integer key associated with the carrier configured expiration time in seconds for 336 * published offline availability in RCS presence provided, which is provided to the network. 337 * <p> 338 * Value is in Integer format. 339 * @see #setProvisioningIntValue(int, int) 340 * @see #getProvisioningIntValue(int) 341 * @hide 342 */ 343 public static final int KEY_RCS_PUBLISH_OFFLINE_AVAILABILITY_TIMER_SEC = 16; 344 345 /** 346 * An integer key associated with whether or not capability discovery is provisioned for this 347 * subscription. Any capability requests will be ignored by the RCS service. 348 * <p> 349 * The value is an integer, either {@link #PROVISIONING_VALUE_DISABLED} if capability 350 * discovery is disabled or {@link #PROVISIONING_VALUE_ENABLED} if capability discovery is 351 * enabled. 352 * @see #setProvisioningIntValue(int, int) 353 * @see #getProvisioningIntValue(int) 354 * @hide 355 */ 356 public static final int KEY_RCS_CAPABILITY_DISCOVERY_ENABLED = 17; 357 358 /** 359 * An integer key associated with the period of time in seconds the capability information of 360 * each contact is cached on the device. 361 * <p> 362 * Seconds are used because this is usually measured in the span of days. 363 * <p> 364 * Value is in Integer format. 365 * @see #setProvisioningIntValue(int, int) 366 * @see #getProvisioningIntValue(int) 367 * @hide 368 */ 369 public static final int KEY_RCS_CAPABILITIES_CACHE_EXPIRATION_SEC = 18; 370 371 /** 372 * An integer key associated with the period of time in seconds that the availability 373 * information of a contact is cached on the device, which is based on the carrier provisioning 374 * configuration from the network. 375 * <p> 376 * Value is in Integer format. 377 * @see #setProvisioningIntValue(int, int) 378 * @see #getProvisioningIntValue(int) 379 * @hide 380 */ 381 public static final int KEY_RCS_AVAILABILITY_CACHE_EXPIRATION_SEC = 19; 382 383 /** 384 * An integer key associated with the carrier configured interval in seconds expected between 385 * successive capability polling attempts, which is based on the carrier provisioning 386 * configuration from the network. 387 * <p> 388 * Value is in Integer format. 389 * @see #setProvisioningIntValue(int, int) 390 * @see #getProvisioningIntValue(int) 391 * @hide 392 */ 393 public static final int KEY_RCS_CAPABILITIES_POLL_INTERVAL_SEC = 20; 394 395 /** 396 * An integer key representing the minimum time allowed between two consecutive presence publish 397 * messages from the device in milliseconds. 398 * <p> 399 * Value is in Integer format. 400 * @see #setProvisioningIntValue(int, int) 401 * @see #getProvisioningIntValue(int) 402 * @hide 403 */ 404 public static final int KEY_RCS_PUBLISH_SOURCE_THROTTLE_MS = 21; 405 406 /** 407 * An integer key associated with the maximum number of MDNs contained in one SIP Request 408 * Contained List (RCS) used to retrieve the RCS capabilities of the contacts book. 409 * <p> 410 * Value is in Integer format. 411 * @see #setProvisioningIntValue(int, int) 412 * @see #getProvisioningIntValue(int) 413 * @hide 414 */ 415 public static final int KEY_RCS_MAX_NUM_ENTRIES_IN_RCL = 22; 416 417 /** 418 * An integer associated with the expiration timer used during the SIP subscription of a 419 * Request Contained List (RCL), which is used to retrieve the RCS capabilities of the contact 420 * book. This timer value is sent in seconds to the network. 421 * <p> 422 * Value is in Integer format. 423 * @see #setProvisioningIntValue(int, int) 424 * @see #getProvisioningIntValue(int) 425 * @hide 426 */ 427 public static final int KEY_RCS_CAPABILITY_POLL_LIST_SUB_EXP_SEC = 23; 428 429 /** 430 * Applies compression to LIST Subscription. 431 * Value is in Integer format. Enable (1), Disable(0). 432 * @see #setProvisioningIntValue(int, int) 433 * @see #getProvisioningIntValue(int) 434 * @hide 435 */ 436 public static final int KEY_USE_GZIP_FOR_LIST_SUBSCRIPTION = 24; 437 438 /** 439 * An integer key representing the RCS enhanced address book (EAB) provisioning status for the 440 * associated subscription. Determines whether or not SIP OPTIONS or presence will be used to 441 * retrieve RCS capabilities for the user's contacts. 442 * <p> 443 * Use {@link #PROVISIONING_VALUE_ENABLED} to enable EAB provisioning and 444 * {@link #PROVISIONING_VALUE_DISABLED} to disable EAB provisioning. 445 * @see #setProvisioningIntValue(int, int) 446 * @see #getProvisioningIntValue(int) 447 * @hide 448 */ 449 public static final int KEY_EAB_PROVISIONING_STATUS = 25; 450 451 /** 452 * Override the user-defined WiFi Roaming enabled setting for this subscription, defined in 453 * {@link android.telephony.SubscriptionManager#WFC_ROAMING_ENABLED_CONTENT_URI}, 454 * for the purposes of provisioning the subscription for WiFi Calling. 455 * 456 * @see #setProvisioningIntValue(int, int) 457 * @see #getProvisioningIntValue(int) 458 * @hide 459 */ 460 @SystemApi 461 public static final int KEY_VOICE_OVER_WIFI_ROAMING_ENABLED_OVERRIDE = 26; 462 463 /** 464 * Override the user-defined WiFi mode for this subscription, defined in 465 * {@link android.telephony.SubscriptionManager#WFC_MODE_CONTENT_URI}, 466 * for the purposes of provisioning this subscription for WiFi Calling. 467 * 468 * Valid values for this key are: 469 * {@link ImsMmTelManager#WIFI_MODE_WIFI_ONLY}, 470 * {@link ImsMmTelManager#WIFI_MODE_CELLULAR_PREFERRED}, or 471 * {@link ImsMmTelManager#WIFI_MODE_WIFI_PREFERRED}. 472 * 473 * @see #setProvisioningIntValue(int, int) 474 * @see #getProvisioningIntValue(int) 475 * @hide 476 */ 477 @SystemApi 478 public static final int KEY_VOICE_OVER_WIFI_MODE_OVERRIDE = 27; 479 480 /** 481 * Enable voice over wifi. Enabled (1), or Disabled (0). 482 * Value is in Integer format. 483 * @see #setProvisioningIntValue(int, int) 484 * @see #getProvisioningIntValue(int) 485 * @hide 486 */ 487 public static final int KEY_VOICE_OVER_WIFI_ENABLED_OVERRIDE = 28; 488 489 /** 490 * Mobile data enabled. 491 * Value is in Integer format. On (1), OFF(0). 492 * @see #setProvisioningIntValue(int, int) 493 * @see #getProvisioningIntValue(int) 494 * @hide 495 */ 496 public static final int KEY_MOBILE_DATA_ENABLED = 29; 497 498 /** 499 * VoLTE user opted in status. 500 * Value is in Integer format. Opted-in (1) Opted-out (0). 501 * @see #setProvisioningIntValue(int, int) 502 * @see #getProvisioningIntValue(int) 503 * @hide 504 */ 505 public static final int KEY_VOLTE_USER_OPT_IN_STATUS = 30; 506 507 /** 508 * Proxy for Call Session Control Function(P-CSCF) address for Local-BreakOut(LBO). 509 * Value is in String format. 510 * @hide 511 */ 512 public static final int KEY_LOCAL_BREAKOUT_PCSCF_ADDRESS = 31; 513 514 /** 515 * Keep Alive Enabled for SIP. 516 * Value is in Integer format. 517 * @see #setProvisioningIntValue(int, int) 518 * @see #getProvisioningIntValue(int) 519 * @hide 520 */ 521 public static final int KEY_SIP_KEEP_ALIVE_ENABLED = 32; 522 523 /** 524 * Registration retry Base Time value in seconds, which is based off of the carrier 525 * configuration. 526 * Value is in Integer format. 527 * @see #setProvisioningIntValue(int, int) 528 * @see #getProvisioningIntValue(int) 529 * @hide 530 */ 531 public static final int KEY_REGISTRATION_RETRY_BASE_TIME_SEC = 33; 532 533 /** 534 * Registration retry Max Time value in seconds, which is based off of the carrier 535 * configuration. 536 * Value is in Integer format. 537 * @see #setProvisioningIntValue(int, int) 538 * @see #getProvisioningIntValue(int) 539 * @hide 540 */ 541 public static final int KEY_REGISTRATION_RETRY_MAX_TIME_SEC = 34; 542 543 /** 544 * Smallest RTP port for speech codec. 545 * Value is in integer format. 546 * @see #setProvisioningIntValue(int, int) 547 * @see #getProvisioningIntValue(int) 548 * @hide 549 */ 550 551 public static final int KEY_RTP_SPEECH_START_PORT = 35; 552 553 /** 554 * Largest RTP port for speech code. 555 * Value is in Integer format. 556 * @see #setProvisioningIntValue(int, int) 557 * @see #getProvisioningIntValue(int) 558 * @hide 559 */ 560 public static final int KEY_RTP_SPEECH_END_PORT = 36; 561 562 /** 563 * SIP Timer A's value in milliseconds. Timer A is the INVITE request retransmit interval (in 564 * milliseconds), for UDP only. 565 * Value is in Integer format. 566 * @see #setProvisioningIntValue(int, int) 567 * @see #getProvisioningIntValue(int) 568 * @hide 569 */ 570 public static final int KEY_SIP_INVITE_REQUEST_TRANSMIT_INTERVAL_MS = 37; 571 572 /** 573 * SIP Timer B's value in milliseconds. Timer B is the wait time for INVITE message to be, 574 * in milliseconds. 575 * Value is in Integer format. 576 * @see #setProvisioningIntValue(int, int) 577 * @see #getProvisioningIntValue(int) 578 * @hide 579 */ 580 public static final int KEY_SIP_INVITE_ACK_WAIT_TIME_MS = 38; 581 582 /** 583 * SIP Timer D's value in milliseconds. Timer D is the wait time for response retransmits of 584 * the invite client transactions, in milliseconds. 585 * Value is in Integer format. 586 * @see #setProvisioningIntValue(int, int) 587 * @see #getProvisioningIntValue(int) 588 * @hide 589 */ 590 public static final int KEY_SIP_INVITE_RESPONSE_RETRANSMIT_WAIT_TIME_MS = 39; 591 592 /** 593 * SIP Timer E's value in milliseconds. Timer E is the value Non-INVITE request retransmit 594 * interval (in milliseconds), for UDP only. 595 * Value is in Integer format. 596 * @see #setProvisioningIntValue(int, int) 597 * @see #getProvisioningIntValue(int) 598 * @hide 599 */ 600 public static final int KEY_SIP_NON_INVITE_REQUEST_RETRANSMIT_INTERVAL_MS = 40; 601 602 /** 603 * SIP Timer F's value in milliseconds. Timer F is the Non-INVITE transaction timeout timer, 604 * in milliseconds. 605 * Value is in Integer format. 606 * @see #setProvisioningIntValue(int, int) 607 * @see #getProvisioningIntValue(int) 608 * @hide 609 */ 610 public static final int KEY_SIP_NON_INVITE_TRANSACTION_TIMEOUT_TIMER_MS = 41; 611 612 /** 613 * SIP Timer G's value in milliseconds. Timer G is the value of INVITE response 614 * retransmit interval. 615 * Value is in Integer format. 616 * @see #setProvisioningIntValue(int, int) 617 * @see #getProvisioningIntValue(int) 618 * @hide 619 */ 620 public static final int KEY_SIP_INVITE_RESPONSE_RETRANSMIT_INTERVAL_MS = 42; 621 622 /** 623 * SIP Timer H's value in milliseconds. Timer H is the value of wait time for 624 * ACK receipt. 625 * Value is in Integer format. 626 * @see #setProvisioningIntValue(int, int) 627 * @see #getProvisioningIntValue(int) 628 * @hide 629 */ 630 public static final int KEY_SIP_ACK_RECEIPT_WAIT_TIME_MS = 43; 631 632 /** 633 * SIP Timer I's value in milliseconds. Timer I is the value of wait time for 634 * ACK retransmits. 635 * Value is in Integer format. 636 * @see #setProvisioningIntValue(int, int) 637 * @see #getProvisioningIntValue(int) 638 * @hide 639 */ 640 public static final int KEY_SIP_ACK_RETRANSMIT_WAIT_TIME_MS = 44; 641 642 /** 643 * SIP Timer J's value in milliseconds. Timer J is the value of wait time for 644 * non-invite request retransmission. 645 * Value is in Integer format. 646 * @see #setProvisioningIntValue(int, int) 647 * @see #getProvisioningIntValue(int) 648 * @hide 649 */ 650 public static final int KEY_SIP_NON_INVITE_REQUEST_RETRANSMISSION_WAIT_TIME_MS = 45; 651 652 /** 653 * SIP Timer K's value in milliseconds. Timer K is the value of wait time for 654 * non-invite response retransmits. 655 * Value is in Integer format. 656 * @see #setProvisioningIntValue(int, int) 657 * @see #getProvisioningIntValue(int) 658 * @hide 659 */ 660 public static final int KEY_SIP_NON_INVITE_RESPONSE_RETRANSMISSION_WAIT_TIME_MS = 46; 661 662 /** 663 * AMR WB octet aligned dynamic payload type. 664 * Value is in Integer format. 665 * @see #setProvisioningIntValue(int, int) 666 * @see #getProvisioningIntValue(int) 667 * @hide 668 */ 669 public static final int KEY_AMR_WB_OCTET_ALIGNED_PAYLOAD_TYPE = 47; 670 671 /** 672 * AMR WB bandwidth efficient payload type. 673 * Value is in Integer format. 674 * @see #setProvisioningIntValue(int, int) 675 * @see #getProvisioningIntValue(int) 676 * @hide 677 */ 678 public static final int KEY_AMR_WB_BANDWIDTH_EFFICIENT_PAYLOAD_TYPE = 48; 679 680 /** 681 * AMR octet aligned dynamic payload type. 682 * Value is in Integer format. 683 * @see #setProvisioningIntValue(int, int) 684 * @see #getProvisioningIntValue(int) 685 * @hide 686 */ 687 public static final int KEY_AMR_OCTET_ALIGNED_PAYLOAD_TYPE = 49; 688 689 /** 690 * AMR bandwidth efficient payload type. 691 * Value is in Integer format. 692 * @see #setProvisioningIntValue(int, int) 693 * @see #getProvisioningIntValue(int) 694 * @hide 695 */ 696 public static final int KEY_AMR_BANDWIDTH_EFFICIENT_PAYLOAD_TYPE = 50; 697 698 /** 699 * DTMF WB payload type. 700 * Value is in Integer format. 701 * @see #setProvisioningIntValue(int, int) 702 * @see #getProvisioningIntValue(int) 703 * @hide 704 */ 705 public static final int KEY_DTMF_WB_PAYLOAD_TYPE = 51; 706 707 /** 708 * DTMF NB payload type. 709 * Value is in Integer format. 710 * @see #setProvisioningIntValue(int, int) 711 * @see #getProvisioningIntValue(int) 712 * @hide 713 */ 714 public static final int KEY_DTMF_NB_PAYLOAD_TYPE = 52; 715 716 /** 717 * AMR Default encoding mode. 718 * Value is in Integer format. 719 * @see #setProvisioningIntValue(int, int) 720 * @see #getProvisioningIntValue(int) 721 * @hide 722 */ 723 public static final int KEY_AMR_DEFAULT_ENCODING_MODE = 53; 724 725 /** 726 * SMS Public Service Identity. 727 * Value is in String format. 728 * @hide 729 */ 730 public static final int KEY_SMS_PUBLIC_SERVICE_IDENTITY = 54; 731 732 /** 733 * Video Quality - VideoQualityFeatureValuesConstants. 734 * Valid values are: {@link #VIDEO_QUALITY_HIGH} and {@link #VIDEO_QUALITY_LOW}. 735 * Value is in Integer format. 736 * @see #setProvisioningIntValue(int, int) 737 * @see #getProvisioningIntValue(int) 738 * @hide 739 */ 740 public static final int KEY_VIDEO_QUALITY = 55; 741 742 /** 743 * Used with {@link #KEY_VIDEO_QUALITY} to indicate low video quality. 744 * @hide 745 */ 746 public static final int VIDEO_QUALITY_LOW = 0; 747 748 /** 749 * Used with {@link #KEY_VIDEO_QUALITY} to indicate high video quality. 750 * @hide 751 */ 752 public static final int VIDEO_QUALITY_HIGH = 1; 753 754 /** 755 * LTE to WIFI handover threshold. 756 * Handover from LTE to WiFi if LTE < THLTE1 and WiFi >= {@link #KEY_WIFI_THRESHOLD_A}. 757 * Value is in Integer format. 758 * @see #setProvisioningIntValue(int, int) 759 * @see #getProvisioningIntValue(int) 760 * @hide 761 */ 762 public static final int KEY_LTE_THRESHOLD_1 = 56; 763 764 /** 765 * WIFI to LTE handover threshold. 766 * Handover from WiFi to LTE if LTE >= {@link #KEY_LTE_THRESHOLD_3} or (WiFi < {@link 767 * #KEY_WIFI_THRESHOLD_B} and LTE >= {@link #KEY_LTE_THRESHOLD_2}). 768 * Value is in Integer format. 769 * 770 * @see #setProvisioningIntValue(int, int) 771 * @see #getProvisioningIntValue(int) 772 * @hide 773 */ 774 public static final int KEY_LTE_THRESHOLD_2 = 57; 775 776 /** 777 * LTE to WIFI handover threshold. 778 * Handover from WiFi to LTE if LTE >= {@link #KEY_LTE_THRESHOLD_3} or (WiFi < {@link 779 * #KEY_WIFI_THRESHOLD_B} and LTE >= {@link #KEY_LTE_THRESHOLD_2}). 780 * Value is in Integer format. 781 * 782 * @see #setProvisioningIntValue(int, int) 783 * @see #getProvisioningIntValue(int) 784 * @hide 785 */ 786 public static final int KEY_LTE_THRESHOLD_3 = 58; 787 788 /** 789 * 1x to WIFI handover threshold. 790 * Handover from 1x to WiFi if 1x < {@link #KEY_1X_THRESHOLD}. 791 * Value is in Integer format. 792 * @see #setProvisioningIntValue(int, int) 793 * @see #getProvisioningIntValue(int) 794 * @hide 795 */ 796 public static final int KEY_1X_THRESHOLD = 59; 797 798 /** 799 * LTE to WIFI threshold A. 800 * Handover from LTE to WiFi if LTE < {@link #KEY_LTE_THRESHOLD_1} and WiFi >= {@link 801 * #KEY_WIFI_THRESHOLD_A}. 802 * Value is in Integer format. 803 * 804 * @see #setProvisioningIntValue(int, int) 805 * @see #getProvisioningIntValue(int) 806 * @hide 807 */ 808 public static final int KEY_WIFI_THRESHOLD_A = 60; 809 810 /** 811 * WiFi to LTRE handover threshold B. 812 * Handover from WiFi to LTE if LTE >= {@link #KEY_LTE_THRESHOLD_3} or (WiFi < 813 * {@link #KEY_WIFI_THRESHOLD_B} and LTE >= {@link #KEY_LTE_THRESHOLD_2}). 814 * Value is in Integer format. 815 * @see #setProvisioningIntValue(int, int) 816 * @see #getProvisioningIntValue(int) 817 * @hide 818 */ 819 public static final int KEY_WIFI_THRESHOLD_B = 61; 820 821 /** 822 * LTE ePDG timer (in seconds). 823 * Device shall not handover back to LTE until the T_ePDG_LTE timer expires. 824 * Value is in Integer format. 825 * @see #setProvisioningIntValue(int, int) 826 * @see #getProvisioningIntValue(int) 827 * @hide 828 */ 829 public static final int KEY_LTE_EPDG_TIMER_SEC = 62; 830 831 /** 832 * WiFi ePDG timer (in seconds). 833 * Device shall not handover back to WiFi until the T_ePDG_WiFi timer expires. 834 * Value is in Integer format. 835 * @see #setProvisioningIntValue(int, int) 836 * @see #getProvisioningIntValue(int) 837 * @hide 838 */ 839 public static final int KEY_WIFI_EPDG_TIMER_SEC = 63; 840 841 /** 842 * 1x ePDG timer (in seconds). 843 * Device shall not re-register on 1x until the T_ePDG_1x timer expires. 844 * @hide 845 */ 846 public static final int KEY_1X_EPDG_TIMER_SEC = 64; 847 848 /** 849 * MultiEndpoint status: Enabled (1), or Disabled (0). 850 * Value is in Integer format. 851 * @see #setProvisioningIntValue(int, int) 852 * @see #getProvisioningIntValue(int) 853 * @hide 854 */ 855 public static final int KEY_MULTIENDPOINT_ENABLED = 65; 856 857 /** 858 * RTT status: Enabled (1), or Disabled (0). 859 * Value is in Integer format. 860 * @see #setProvisioningIntValue(int, int) 861 * @see #getProvisioningIntValue(int) 862 * @hide 863 */ 864 public static final int KEY_RTT_ENABLED = 66; 865 866 /** 867 * An obfuscated string defined by the carrier to indicate VoWiFi entitlement status. 868 * 869 * <p>Implementation note: how to generate the value and how it affects VoWiFi service 870 * should follow carrier requirements. For example, set an empty string could result in 871 * VoWiFi being disabled by IMS service, and set to a specific string could enable. 872 * 873 * <p>Value is in String format. 874 * @see #setProvisioningStringValue(int, String) 875 * @see #getProvisioningStringValue(int) 876 * @hide 877 */ 878 @SystemApi 879 public static final int KEY_VOICE_OVER_WIFI_ENTITLEMENT_ID = 67; 880 881 /** 882 * An integer key representing the voice over IMS opt-in provisioning status for the 883 * associated subscription. Determines whether the user can see for voice services over 884 * IMS. 885 * 886 * <p> The flag will force to show the VoLTE option in settings irrespective of others VoLTE 887 * carrier config which hide the VoLTE option (e.g. 888 * {@link CarrierConfigManager#KEY_HIDE_ENHANCED_4G_LTE_BOOL}). 889 * 890 * <p>Use {@link #PROVISIONING_VALUE_ENABLED} to enable VoIMS provisioning and 891 * {@link #PROVISIONING_VALUE_DISABLED} to disable VoIMS provisioning. 892 * @see #setProvisioningIntValue(int, int) 893 * @see #getProvisioningIntValue(int) 894 * @hide 895 */ 896 public static final int KEY_VOIMS_OPT_IN_STATUS = 68; 897 898 /** 899 * Callback for IMS provisioning changes. 900 * @hide 901 */ 902 @SystemApi 903 public static class Callback { 904 905 private static class CallbackBinder extends IImsConfigCallback.Stub { 906 907 private final Callback mLocalConfigurationCallback; 908 private Executor mExecutor; 909 CallbackBinder(Callback localConfigurationCallback)910 private CallbackBinder(Callback localConfigurationCallback) { 911 mLocalConfigurationCallback = localConfigurationCallback; 912 } 913 914 @Override onIntConfigChanged(int item, int value)915 public final void onIntConfigChanged(int item, int value) { 916 final long callingIdentity = Binder.clearCallingIdentity(); 917 try { 918 mExecutor.execute(() -> 919 mLocalConfigurationCallback.onProvisioningIntChanged(item, value)); 920 } finally { 921 restoreCallingIdentity(callingIdentity); 922 } 923 } 924 925 @Override onStringConfigChanged(int item, String value)926 public final void onStringConfigChanged(int item, String value) { 927 final long callingIdentity = Binder.clearCallingIdentity(); 928 try { 929 mExecutor.execute(() -> 930 mLocalConfigurationCallback.onProvisioningStringChanged(item, value)); 931 } finally { 932 restoreCallingIdentity(callingIdentity); 933 } 934 } 935 setExecutor(Executor executor)936 private void setExecutor(Executor executor) { 937 mExecutor = executor; 938 } 939 } 940 941 private final CallbackBinder mBinder = new CallbackBinder(this); 942 943 /** 944 * Called when a provisioning item has changed. 945 * @param item the IMS provisioning key constant, as defined by the OEM. 946 * @param value the new integer value of the IMS provisioning key. 947 */ onProvisioningIntChanged(int item, int value)948 public void onProvisioningIntChanged(int item, int value) { 949 // Base Implementation 950 } 951 952 /** 953 * Called when a provisioning item has changed. 954 * @param item the IMS provisioning key constant, as defined by the OEM. 955 * @param value the new String value of the IMS configuration constant. 956 */ onProvisioningStringChanged(int item, @NonNull String value)957 public void onProvisioningStringChanged(int item, @NonNull String value) { 958 // Base Implementation 959 } 960 961 /**@hide*/ getBinder()962 public final IImsConfigCallback getBinder() { 963 return mBinder; 964 } 965 966 /**@hide*/ setExecutor(Executor executor)967 public void setExecutor(Executor executor) { 968 mBinder.setExecutor(executor); 969 } 970 } 971 972 /** 973 * Callback for IMS provisioning feature changes. 974 */ 975 public abstract static class FeatureProvisioningCallback { 976 977 private static class CallbackBinder extends IFeatureProvisioningCallback.Stub { 978 979 private final FeatureProvisioningCallback mFeatureProvisioningCallback; 980 private Executor mExecutor; 981 CallbackBinder(FeatureProvisioningCallback featureProvisioningCallback)982 private CallbackBinder(FeatureProvisioningCallback featureProvisioningCallback) { 983 mFeatureProvisioningCallback = featureProvisioningCallback; 984 } 985 986 @Override onFeatureProvisioningChanged( int capability, int tech, boolean isProvisioned)987 public final void onFeatureProvisioningChanged( 988 int capability, int tech, boolean isProvisioned) { 989 final long callingIdentity = Binder.clearCallingIdentity(); 990 try { 991 mExecutor.execute(() -> 992 mFeatureProvisioningCallback.onFeatureProvisioningChanged( 993 capability, tech, isProvisioned)); 994 } finally { 995 restoreCallingIdentity(callingIdentity); 996 } 997 } 998 999 @Override onRcsFeatureProvisioningChanged( int capability, int tech, boolean isProvisioned)1000 public final void onRcsFeatureProvisioningChanged( 1001 int capability, int tech, boolean isProvisioned) { 1002 final long callingIdentity = Binder.clearCallingIdentity(); 1003 try { 1004 mExecutor.execute(() -> 1005 mFeatureProvisioningCallback.onRcsFeatureProvisioningChanged( 1006 capability, tech, isProvisioned)); 1007 } finally { 1008 restoreCallingIdentity(callingIdentity); 1009 } 1010 } 1011 setExecutor(Executor executor)1012 private void setExecutor(Executor executor) { 1013 mExecutor = executor; 1014 } 1015 } 1016 1017 private final CallbackBinder mBinder = new CallbackBinder(this); 1018 1019 /** 1020 * The IMS MMTEL provisioning has changed for a specific capability and IMS 1021 * registration technology. 1022 * @param capability The MMTEL capability that provisioning has changed for. 1023 * @param tech The IMS registration technology associated with the MMTEL capability that 1024 * provisioning has changed for. 1025 * @param isProvisioned {@code true} if the capability is provisioned for the technology 1026 * specified, or {@code false} if the capability is not provisioned for the technology 1027 * specified. 1028 */ onFeatureProvisioningChanged( @mTelFeature.MmTelCapabilities.MmTelCapability int capability, @ImsRegistrationImplBase.ImsRegistrationTech int tech, boolean isProvisioned)1029 public abstract void onFeatureProvisioningChanged( 1030 @MmTelFeature.MmTelCapabilities.MmTelCapability int capability, 1031 @ImsRegistrationImplBase.ImsRegistrationTech int tech, 1032 boolean isProvisioned); 1033 1034 /** 1035 * The IMS RCS provisioning has changed for a specific capability and IMS 1036 * registration technology. 1037 * @param capability The RCS capability that provisioning has changed for. 1038 * @param tech The IMS registration technology associated with the RCS capability that 1039 * provisioning has changed for. 1040 * @param isProvisioned {@code true} if the capability is provisioned for the technology 1041 * specified, or {@code false} if the capability is not provisioned for the technology 1042 * specified. 1043 */ onRcsFeatureProvisioningChanged( @msRcsManager.RcsImsCapabilityFlag int capability, @ImsRegistrationImplBase.ImsRegistrationTech int tech, boolean isProvisioned)1044 public abstract void onRcsFeatureProvisioningChanged( 1045 @ImsRcsManager.RcsImsCapabilityFlag int capability, 1046 @ImsRegistrationImplBase.ImsRegistrationTech int tech, 1047 boolean isProvisioned); 1048 1049 /**@hide*/ getBinder()1050 public final IFeatureProvisioningCallback getBinder() { 1051 return mBinder; 1052 } 1053 1054 /**@hide*/ setExecutor(Executor executor)1055 public void setExecutor(Executor executor) { 1056 mBinder.setExecutor(executor); 1057 } 1058 } 1059 1060 private int mSubId; 1061 1062 /** 1063 * The callback for RCS provisioning changes. 1064 * @hide 1065 */ 1066 @SystemApi 1067 public static class RcsProvisioningCallback { 1068 private static class CallbackBinder extends IRcsConfigCallback.Stub { 1069 1070 private final RcsProvisioningCallback mLocalCallback; 1071 private Executor mExecutor; 1072 CallbackBinder(RcsProvisioningCallback localCallback)1073 private CallbackBinder(RcsProvisioningCallback localCallback) { 1074 mLocalCallback = localCallback; 1075 } 1076 1077 @Override onConfigurationChanged(byte[] configXml)1078 public void onConfigurationChanged(byte[] configXml) { 1079 final long identity = Binder.clearCallingIdentity(); 1080 try { 1081 mExecutor.execute(() -> mLocalCallback.onConfigurationChanged(configXml)); 1082 } finally { 1083 Binder.restoreCallingIdentity(identity); 1084 } 1085 } 1086 1087 @Override onAutoConfigurationErrorReceived(int errorCode, String errorString)1088 public void onAutoConfigurationErrorReceived(int errorCode, String errorString) { 1089 final long identity = Binder.clearCallingIdentity(); 1090 try { 1091 mExecutor.execute(() -> mLocalCallback.onAutoConfigurationErrorReceived( 1092 errorCode, errorString)); 1093 } finally { 1094 Binder.restoreCallingIdentity(identity); 1095 } 1096 } 1097 1098 @Override onConfigurationReset()1099 public void onConfigurationReset() { 1100 final long identity = Binder.clearCallingIdentity(); 1101 try { 1102 mExecutor.execute(() -> mLocalCallback.onConfigurationReset()); 1103 } finally { 1104 Binder.restoreCallingIdentity(identity); 1105 } 1106 } 1107 1108 @Override onRemoved()1109 public void onRemoved() { 1110 final long identity = Binder.clearCallingIdentity(); 1111 try { 1112 mExecutor.execute(() -> mLocalCallback.onRemoved()); 1113 } finally { 1114 Binder.restoreCallingIdentity(identity); 1115 } 1116 } 1117 1118 @Override onPreProvisioningReceived(byte[] configXml)1119 public void onPreProvisioningReceived(byte[] configXml) { 1120 final long identity = Binder.clearCallingIdentity(); 1121 try { 1122 mExecutor.execute(() -> mLocalCallback.onPreProvisioningReceived(configXml)); 1123 } finally { 1124 Binder.restoreCallingIdentity(identity); 1125 } 1126 } 1127 setExecutor(Executor executor)1128 private void setExecutor(Executor executor) { 1129 mExecutor = executor; 1130 } 1131 } 1132 1133 private final CallbackBinder mBinder = new CallbackBinder(this); 1134 1135 /** 1136 * RCS configuration received via OTA provisioning. Configuration may change 1137 * due to various triggers defined in GSMA RCC.14 for ACS(auto configuration 1138 * server) or other operator defined triggers. If RCS provisioning is already 1139 * completed at the time of callback registration, then this method shall be 1140 * invoked with the current configuration. 1141 * @param configXml The RCS configuration XML received by OTA. It is defined 1142 * by GSMA RCC.07. 1143 */ onConfigurationChanged(@onNull byte[] configXml)1144 public void onConfigurationChanged(@NonNull byte[] configXml) {} 1145 1146 /** 1147 * Errors during autoconfiguration connection setup are notified by the 1148 * ACS(auto configuration server) client using this interface. 1149 * @param errorCode HTTP error received during connection setup defined in 1150 * GSMA RCC.14 2.4.3, like {@link java.net.HttpURLConnection#HTTP_UNAUTHORIZED}, 1151 * {@link java.net.HttpURLConnection#HTTP_FORBIDDEN}, etc. 1152 * @param errorString reason phrase received with the error 1153 */ onAutoConfigurationErrorReceived(int errorCode, @NonNull String errorString)1154 public void onAutoConfigurationErrorReceived(int errorCode, 1155 @NonNull String errorString) {} 1156 1157 /** 1158 * When the previously valid RCS configuration is cleaned up by telephony for 1159 * any case like SIM removed, default messaging application changed, etc., 1160 * this method will be invoked to notify the application regarding this change. 1161 */ onConfigurationReset()1162 public void onConfigurationReset() {} 1163 1164 /** 1165 * When the RCS application is no longer the Default messaging application, 1166 * or when the subscription associated with this callback is removed (SIM 1167 * removed, ESIM swap,etc...), callback will automatically be removed and 1168 * the below method is invoked. There is a possibility that the method is 1169 * invoked after the subscription has become inactive 1170 */ onRemoved()1171 public void onRemoved() {} 1172 1173 /** 1174 * Some carriers using ACS (auto configuration server) may send a carrier-specific 1175 * pre-provisioning configuration XML if the user has not been provisioned for RCS 1176 * services yet. When this provisioning XML is received, the framework will move 1177 * into a "not provisioned" state for RCS. In order for provisioning to proceed, 1178 * the application must parse this configuration XML and perform the carrier specific 1179 * opt-in flow for RCS services. If the user accepts, {@link #triggerRcsReconfiguration} 1180 * must be called in order for the device to move out of this state and try to fetch 1181 * the RCS provisioning information. 1182 * 1183 * @param configXml the pre-provisioning config in carrier specified format. 1184 */ onPreProvisioningReceived(@onNull byte[] configXml)1185 public void onPreProvisioningReceived(@NonNull byte[] configXml) {} 1186 1187 /**@hide*/ getBinder()1188 public final IRcsConfigCallback getBinder() { 1189 return mBinder; 1190 } 1191 1192 /**@hide*/ setExecutor(Executor executor)1193 public void setExecutor(Executor executor) { 1194 mBinder.setExecutor(executor); 1195 } 1196 } 1197 1198 /** 1199 * Create a new {@link ProvisioningManager} for the subscription specified. 1200 * 1201 * @param subId The ID of the subscription that this ProvisioningManager will use. 1202 * @see android.telephony.SubscriptionManager#getActiveSubscriptionInfoList() 1203 * @throws IllegalArgumentException if the subscription is invalid. 1204 * @hide 1205 */ 1206 @SystemApi createForSubscriptionId(int subId)1207 public static @NonNull ProvisioningManager createForSubscriptionId(int subId) { 1208 if (!SubscriptionManager.isValidSubscriptionId(subId)) { 1209 throw new IllegalArgumentException("Invalid subscription ID"); 1210 } 1211 1212 return new ProvisioningManager(subId); 1213 } 1214 1215 /**@hide*/ 1216 //@SystemApi ProvisioningManager(int subId)1217 public ProvisioningManager(int subId) { 1218 mSubId = subId; 1219 } 1220 1221 /** 1222 * Register a new {@link Callback} to listen to changes to changes in IMS provisioning. 1223 * 1224 * When the subscription associated with this callback is removed (SIM removed, ESIM swap, 1225 * etc...), this callback will automatically be removed. 1226 * 1227 * <p> Requires Permission: 1228 * <ul> 1229 * <li>{@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE},</li> 1230 * </ul> 1231 * 1232 * @param executor The {@link Executor} to call the callback methods on 1233 * @param callback The provisioning callbackto be registered. 1234 * @see #unregisterProvisioningChangedCallback(Callback) 1235 * @see SubscriptionManager.OnSubscriptionsChangedListener 1236 * @throws IllegalArgumentException if the subscription associated with this callback is not 1237 * active (SIM is not inserted, ESIM inactive) or the subscription is invalid. 1238 * @throws ImsException if the subscription associated with this callback is valid, but 1239 * the {@link ImsService} associated with the subscription is not available. This can happen if 1240 * the service crashed, for example. See {@link ImsException#getCode()} for a more detailed 1241 * reason. 1242 * @hide 1243 */ 1244 @SystemApi 1245 @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE) registerProvisioningChangedCallback(@onNull @allbackExecutor Executor executor, @NonNull Callback callback)1246 public void registerProvisioningChangedCallback(@NonNull @CallbackExecutor Executor executor, 1247 @NonNull Callback callback) throws ImsException { 1248 callback.setExecutor(executor); 1249 try { 1250 getITelephony().registerImsProvisioningChangedCallback(mSubId, callback.getBinder()); 1251 } catch (ServiceSpecificException e) { 1252 throw new ImsException(e.getMessage(), e.errorCode); 1253 } catch (RemoteException | IllegalStateException e) { 1254 throw new ImsException(e.getMessage(), ImsException.CODE_ERROR_SERVICE_UNAVAILABLE); 1255 } 1256 } 1257 1258 /** 1259 * Unregister an existing {@link Callback}. When the subscription associated with this 1260 * callback is removed (SIM removed, ESIM swap, etc...), this callback will automatically be 1261 * removed. If this method is called for an inactive subscription, it will result in a no-op. 1262 * 1263 * <p> Requires Permission: 1264 * <ul> 1265 * <li>{@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE},</li> 1266 * </ul> 1267 * 1268 * @param callback The existing {@link Callback} to be removed. 1269 * @see #registerProvisioningChangedCallback(Executor, Callback) 1270 * 1271 * @throws IllegalArgumentException if the subscription associated with this callback is 1272 * invalid. 1273 * @hide 1274 */ 1275 @SystemApi 1276 @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE) unregisterProvisioningChangedCallback(@onNull Callback callback)1277 public void unregisterProvisioningChangedCallback(@NonNull Callback callback) { 1278 try { 1279 getITelephony().unregisterImsProvisioningChangedCallback(mSubId, callback.getBinder()); 1280 } catch (RemoteException e) { 1281 throw e.rethrowAsRuntimeException(); 1282 } 1283 } 1284 1285 /** 1286 * Register a new {@link FeatureProvisioningCallback}, which is used to listen for 1287 * IMS feature provisioning updates. 1288 * <p> 1289 * When the subscription associated with this callback is removed (SIM removed, 1290 * ESIM swap,etc...), this callback will automatically be removed. 1291 * 1292 * <p> Requires Permission: 1293 * <ul> 1294 * <li> android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE,</li> 1295 * <li>{@link android.Manifest.permission#READ_PRECISE_PHONE_STATE},</li> 1296 * <li>or that the caller has carrier privileges (see 1297 * {@link TelephonyManager#hasCarrierPrivileges()}).</li> 1298 * </ul> 1299 * 1300 * @param executor The executor that the callback methods will be called on. 1301 * @param callback The callback instance being registered. 1302 * @throws ImsException if the subscription associated with this callback is 1303 * valid, but the service crashed, for example. See 1304 * {@link ImsException#getCode()} for a more detailed reason. 1305 * @throws UnsupportedOperationException If the device does not have 1306 * {@link PackageManager#FEATURE_TELEPHONY_IMS}. 1307 */ 1308 @RequiresPermission(Manifest.permission.READ_PRECISE_PHONE_STATE) registerFeatureProvisioningChangedCallback( @onNull @allbackExecutor Executor executor, @NonNull FeatureProvisioningCallback callback)1309 public void registerFeatureProvisioningChangedCallback( 1310 @NonNull @CallbackExecutor Executor executor, 1311 @NonNull FeatureProvisioningCallback callback) throws ImsException { 1312 callback.setExecutor(executor); 1313 try { 1314 getITelephony().registerFeatureProvisioningChangedCallback(mSubId, 1315 callback.getBinder()); 1316 } catch (ServiceSpecificException e) { 1317 throw new ImsException(e.getMessage(), e.errorCode); 1318 } catch (RemoteException | IllegalStateException e) { 1319 throw new ImsException(e.getMessage(), ImsException.CODE_ERROR_SERVICE_UNAVAILABLE); 1320 } 1321 } 1322 1323 /** 1324 * Unregisters a previously registered {@link FeatureProvisioningCallback} 1325 * instance. When the subscription associated with this 1326 * callback is removed (SIM removed, ESIM swap, etc...), this callback will 1327 * automatically be removed. If this method is called for an inactive 1328 * subscription, it will result in a no-op. 1329 * 1330 * @param callback The existing {@link FeatureProvisioningCallback} to be removed. 1331 * @see #registerFeatureProvisioningChangedCallback(Executor, FeatureProvisioningCallback) 1332 * @throws UnsupportedOperationException If the device does not have 1333 * {@link PackageManager#FEATURE_TELEPHONY_IMS}. 1334 */ unregisterFeatureProvisioningChangedCallback( @onNull FeatureProvisioningCallback callback)1335 public void unregisterFeatureProvisioningChangedCallback( 1336 @NonNull FeatureProvisioningCallback callback) { 1337 try { 1338 getITelephony().unregisterFeatureProvisioningChangedCallback(mSubId, 1339 callback.getBinder()); 1340 } catch (RemoteException e) { 1341 throw e.rethrowAsRuntimeException(); 1342 } 1343 } 1344 1345 /** 1346 * Query for the integer value associated with the provided key. 1347 * 1348 * This operation is blocking and should not be performed on the UI thread. 1349 * 1350 * @param key An integer that represents the provisioning key, which is defined by the OEM. 1351 * @return an integer value for the provided key, or 1352 * {@link ImsConfigImplBase#CONFIG_RESULT_UNKNOWN} if the key doesn't exist. 1353 * @throws IllegalArgumentException if the key provided was invalid. 1354 * @throws UnsupportedOperationException If the device does not have 1355 * {@link PackageManager#FEATURE_TELEPHONY_IMS}. 1356 * @hide 1357 */ 1358 @SystemApi 1359 @WorkerThread 1360 @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE) getProvisioningIntValue(int key)1361 public int getProvisioningIntValue(int key) { 1362 try { 1363 return getITelephony().getImsProvisioningInt(mSubId, key); 1364 } catch (RemoteException e) { 1365 throw e.rethrowAsRuntimeException(); 1366 } 1367 } 1368 1369 /** 1370 * Query for the String value associated with the provided key. 1371 * 1372 * This operation is blocking and should not be performed on the UI thread. 1373 * 1374 * @param key A String that represents the provisioning key, which is defined by the OEM. 1375 * @return a String value for the provided key, {@code null} if the key doesn't exist, or 1376 * {@link StringResultError} if there was an error getting the value for the provided key. 1377 * @throws IllegalArgumentException if the key provided was invalid. 1378 * @throws UnsupportedOperationException If the device does not have 1379 * {@link PackageManager#FEATURE_TELEPHONY_IMS}. 1380 * @hide 1381 */ 1382 @SystemApi 1383 @WorkerThread 1384 @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE) getProvisioningStringValue(int key)1385 public @Nullable @StringResultError String getProvisioningStringValue(int key) { 1386 try { 1387 return getITelephony().getImsProvisioningString(mSubId, key); 1388 } catch (RemoteException e) { 1389 throw e.rethrowAsRuntimeException(); 1390 } 1391 } 1392 1393 /** 1394 * Set the integer value associated with the provided key. 1395 * 1396 * This operation is blocking and should not be performed on the UI thread. 1397 * 1398 * Use {@link #setProvisioningStringValue(int, String)} with proper namespacing (to be defined 1399 * per OEM or carrier) when possible instead to avoid key collision if needed. 1400 * @param key An integer that represents the provisioning key, which is defined by the OEM. 1401 * @param value a integer value for the provided key. 1402 * @return the result of setting the configuration value. 1403 * @throws UnsupportedOperationException If the device does not have 1404 * {@link PackageManager#FEATURE_TELEPHONY_IMS}. 1405 * @hide 1406 * 1407 * Note: For compatibility purposes, the integer values [0 - 99] used in 1408 * {@link #setProvisioningIntValue(int, int)} have been reserved for existing provisioning keys 1409 * previously defined in the Android framework. Please do not redefine new provisioning keys 1410 * in this range or it may generate collisions with existing keys. Some common constants have 1411 * also been defined in this class to make integrating with other system apps easier. 1412 */ 1413 @SystemApi 1414 @WorkerThread 1415 @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) setProvisioningIntValue(int key, int value)1416 public @ImsConfigImplBase.SetConfigResult int setProvisioningIntValue(int key, int value) { 1417 try { 1418 return getITelephony().setImsProvisioningInt(mSubId, key, value); 1419 } catch (RemoteException e) { 1420 throw e.rethrowAsRuntimeException(); 1421 } 1422 } 1423 1424 /** 1425 * Set the String value associated with the provided key. 1426 * 1427 * This operation is blocking and should not be performed on the UI thread. 1428 * 1429 * @param key A String that represents the provisioning key, which is defined by the OEM and 1430 * should be appropriately namespaced to avoid collision. 1431 * @param value a String value for the provided key. 1432 * @return the result of setting the configuration value. 1433 * @throws UnsupportedOperationException If the device does not have 1434 * {@link PackageManager#FEATURE_TELEPHONY_IMS}. 1435 * @hide 1436 */ 1437 @SystemApi 1438 @WorkerThread 1439 @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) setProvisioningStringValue(int key, @NonNull String value)1440 public @ImsConfigImplBase.SetConfigResult int setProvisioningStringValue(int key, 1441 @NonNull String value) { 1442 try { 1443 return getITelephony().setImsProvisioningString(mSubId, key, value); 1444 } catch (RemoteException e) { 1445 throw e.rethrowAsRuntimeException(); 1446 } 1447 } 1448 1449 /** 1450 * Set the provisioning status for the IMS MmTel capability using the specified subscription. 1451 * 1452 * Provisioning may or may not be required, depending on the carrier configuration. If 1453 * provisioning is not required for the carrier associated with this subscription or the device 1454 * does not support the capability/technology combination specified, this operation will be a 1455 * no-op. 1456 * 1457 * <p>Requires Permission: 1458 * <ul> 1459 * <li>{@link android.Manifest.permission#MODIFY_PHONE_STATE},</li> 1460 * <li>or that the calling app has carrier privileges (see</li> 1461 * <li>{@link TelephonyManager#hasCarrierPrivileges}).</li> 1462 * </ul> 1463 * 1464 * @see CarrierConfigManager.Ims#KEY_MMTEL_REQUIRES_PROVISIONING_BUNDLE 1465 * @param isProvisioned true if the device is provisioned for UT over IMS, false otherwise. 1466 * 1467 * @throws UnsupportedOperationException If the device does not have 1468 * {@link PackageManager#FEATURE_TELEPHONY_IMS}. 1469 */ 1470 @WorkerThread 1471 @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) setProvisioningStatusForCapability( @mTelFeature.MmTelCapabilities.MmTelCapability int capability, @ImsRegistrationImplBase.ImsRegistrationTech int tech, boolean isProvisioned)1472 public void setProvisioningStatusForCapability( 1473 @MmTelFeature.MmTelCapabilities.MmTelCapability int capability, 1474 @ImsRegistrationImplBase.ImsRegistrationTech int tech, boolean isProvisioned) { 1475 1476 try { 1477 getITelephony().setImsProvisioningStatusForCapability(mSubId, capability, tech, 1478 isProvisioned); 1479 } catch (RemoteException e) { 1480 throw e.rethrowAsRuntimeException(); 1481 } 1482 } 1483 1484 /** 1485 * Get the provisioning status for the IMS MmTel capability specified. 1486 * 1487 * If provisioning is not required for the queried {@code capability} and 1488 * {@code tech} combination specified, this method will 1489 * always return {@code true}. 1490 * 1491 * <p> Requires Permission: 1492 * <ul> 1493 * <li>android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE,</li> 1494 * <li>{@link android.Manifest.permission#READ_PRECISE_PHONE_STATE},</li> 1495 * <li>or that the caller has carrier privileges (see 1496 * {@link TelephonyManager#hasCarrierPrivileges()}).</li> 1497 * </ul> 1498 * 1499 * @see CarrierConfigManager.Ims#KEY_MMTEL_REQUIRES_PROVISIONING_BUNDLE 1500 * @return true if the device is provisioned for the capability or does not require 1501 * provisioning, false if the capability does require provisioning and has not been 1502 * provisioned yet. 1503 * 1504 * @throws UnsupportedOperationException If the device does not have 1505 * {@link PackageManager#FEATURE_TELEPHONY_IMS}. 1506 */ 1507 @WorkerThread 1508 @RequiresPermission(Manifest.permission.READ_PRECISE_PHONE_STATE) getProvisioningStatusForCapability( @mTelFeature.MmTelCapabilities.MmTelCapability int capability, @ImsRegistrationImplBase.ImsRegistrationTech int tech)1509 public boolean getProvisioningStatusForCapability( 1510 @MmTelFeature.MmTelCapabilities.MmTelCapability int capability, 1511 @ImsRegistrationImplBase.ImsRegistrationTech int tech) { 1512 try { 1513 return getITelephony().getImsProvisioningStatusForCapability(mSubId, capability, tech); 1514 } catch (RemoteException e) { 1515 throw e.rethrowAsRuntimeException(); 1516 } 1517 } 1518 1519 /** 1520 * Get the provisioning status for the IMS RCS capability specified. 1521 * 1522 * If provisioning is not required for the queried 1523 * {@code capability} or if the device does not support IMS 1524 * this method will always return {@code true}. 1525 * 1526 * @see CarrierConfigManager.Ims#KEY_CARRIER_RCS_PROVISIONING_REQUIRED_BOOL 1527 * @return true if the device is provisioned for the capability or does not require 1528 * provisioning, false if the capability does require provisioning and has not been 1529 * provisioned yet. 1530 * @throws UnsupportedOperationException If the device does not have 1531 * {@link PackageManager#FEATURE_TELEPHONY_IMS}. 1532 * 1533 * @deprecated Use {@link #getRcsProvisioningStatusForCapability(int, int)} instead, 1534 * as this only retrieves provisioning information for 1535 * {@link ImsRegistrationImplBase#REGISTRATION_TECH_LTE} 1536 * @hide 1537 */ 1538 @Deprecated 1539 @SystemApi 1540 @WorkerThread 1541 @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE) getRcsProvisioningStatusForCapability( @msRcsManager.RcsImsCapabilityFlag int capability)1542 public boolean getRcsProvisioningStatusForCapability( 1543 @ImsRcsManager.RcsImsCapabilityFlag int capability) { 1544 try { 1545 return getITelephony().getRcsProvisioningStatusForCapability(mSubId, capability, 1546 ImsRegistrationImplBase.REGISTRATION_TECH_LTE); 1547 } catch (RemoteException e) { 1548 throw e.rethrowAsRuntimeException(); 1549 } 1550 } 1551 1552 /** 1553 * Get the provisioning status for the IMS RCS capability specified. 1554 * 1555 * If provisioning is not required for the queried 1556 * {@code capability} or if the device does not support IMS 1557 * this method will always return {@code true}. 1558 * 1559 * <p> Requires Permission: 1560 * <ul> 1561 * <li>{@link android.Manifest.permission#READ_PRECISE_PHONE_STATE},</li> 1562 * <li>or that the caller has carrier privileges (see 1563 * {@link TelephonyManager#hasCarrierPrivileges()}).</li> 1564 * </ul> 1565 * 1566 * @see CarrierConfigManager.Ims#KEY_RCS_REQUIRES_PROVISIONING_BUNDLE 1567 * @return true if the device is provisioned for the capability or does not require 1568 * provisioning, false if the capability does require provisioning and has not been 1569 * provisioned yet. 1570 * 1571 * @throws UnsupportedOperationException If the device does not have 1572 * {@link PackageManager#FEATURE_TELEPHONY_IMS}. 1573 */ 1574 @WorkerThread 1575 @RequiresPermission(Manifest.permission.READ_PRECISE_PHONE_STATE) getRcsProvisioningStatusForCapability( @msRcsManager.RcsImsCapabilityFlag int capability, @ImsRegistrationImplBase.ImsRegistrationTech int tech)1576 public boolean getRcsProvisioningStatusForCapability( 1577 @ImsRcsManager.RcsImsCapabilityFlag int capability, 1578 @ImsRegistrationImplBase.ImsRegistrationTech int tech) { 1579 try { 1580 return getITelephony().getRcsProvisioningStatusForCapability(mSubId, capability, tech); 1581 } catch (RemoteException e) { 1582 throw e.rethrowAsRuntimeException(); 1583 } 1584 } 1585 1586 /** 1587 * Set the provisioning status for the IMS RCS capability using the specified subscription. 1588 * 1589 * <p> Requires Permission: 1590 * <ul> 1591 * <li>{@link android.Manifest.permission#MODIFY_PHONE_STATE}</li> 1592 * <li>or that the caller has carrier privileges (see 1593 * {@link TelephonyManager#hasCarrierPrivileges()}).</li> 1594 * </ul> 1595 1596 * Provisioning may or may not be required, depending on the carrier configuration. If 1597 * provisioning is not required for the carrier associated with this subscription or the device 1598 * does not support the capability/technology combination specified, this operation will be a 1599 * no-op. 1600 * 1601 * @see CarrierConfigManager#KEY_CARRIER_RCS_PROVISIONING_REQUIRED_BOOL 1602 * @param isProvisioned true if the device is provisioned for the RCS capability specified, 1603 * false otherwise. 1604 * @throws UnsupportedOperationException If the device does not have 1605 * {@link PackageManager#FEATURE_TELEPHONY_IMS}. 1606 * 1607 * @deprecated Use {@link #setRcsProvisioningStatusForCapability(int, int, boolean)} instead, 1608 * as this method only sets provisioning information for 1609 * {@link ImsRegistrationImplBase#REGISTRATION_TECH_LTE} 1610 * @hide 1611 */ 1612 @Deprecated 1613 @SystemApi 1614 @WorkerThread 1615 @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) setRcsProvisioningStatusForCapability( @msRcsManager.RcsImsCapabilityFlag int capability, boolean isProvisioned)1616 public void setRcsProvisioningStatusForCapability( 1617 @ImsRcsManager.RcsImsCapabilityFlag int capability, 1618 boolean isProvisioned) { 1619 try { 1620 getITelephony().setRcsProvisioningStatusForCapability(mSubId, capability, 1621 ImsRegistrationImplBase.REGISTRATION_TECH_LTE, isProvisioned); 1622 } catch (RemoteException e) { 1623 throw e.rethrowAsRuntimeException(); 1624 } 1625 } 1626 1627 /** 1628 * Set the provisioning status for the IMS RCS capability using the specified subscription. 1629 * 1630 * Provisioning may or may not be required, depending on the carrier configuration. If 1631 * provisioning is not required for the carrier associated with this subscription or the device 1632 * does not support the capability/technology combination specified, this operation will be a 1633 * no-op. 1634 * 1635 * <p> Requires Permission: 1636 * <ul> 1637 * <li>{@link android.Manifest.permission#MODIFY_PHONE_STATE},</li> 1638 * <li>or that the caller has carrier privileges (see 1639 * {@link TelephonyManager#hasCarrierPrivileges()}).</li> 1640 * </ul> 1641 * 1642 * @see CarrierConfigManager.Ims#KEY_RCS_REQUIRES_PROVISIONING_BUNDLE 1643 * @param isProvisioned true if the device is provisioned for the RCS capability specified, 1644 * false otherwise. 1645 * 1646 * @throws UnsupportedOperationException If the device does not have 1647 * {@link PackageManager#FEATURE_TELEPHONY_IMS}. 1648 */ 1649 @WorkerThread 1650 @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) setRcsProvisioningStatusForCapability( @msRcsManager.RcsImsCapabilityFlag int capability, @ImsRegistrationImplBase.ImsRegistrationTech int tech, boolean isProvisioned)1651 public void setRcsProvisioningStatusForCapability( 1652 @ImsRcsManager.RcsImsCapabilityFlag int capability, 1653 @ImsRegistrationImplBase.ImsRegistrationTech int tech, boolean isProvisioned) { 1654 try { 1655 getITelephony().setRcsProvisioningStatusForCapability(mSubId, capability, 1656 tech, isProvisioned); 1657 } catch (RemoteException e) { 1658 throw e.rethrowAsRuntimeException(); 1659 } 1660 } 1661 1662 /** 1663 * Indicates whether provisioning for the MMTEL capability and IMS registration technology 1664 * specified is required or not 1665 * 1666 * <p> Requires Permission: 1667 * <ul> 1668 * <li> android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE,</li> 1669 * <li>{@link android.Manifest.permission#READ_PRECISE_PHONE_STATE},</li> 1670 * <li> or that the caller has carrier privileges (see 1671 * {@link TelephonyManager#hasCarrierPrivileges()}).</li> 1672 * </ul> 1673 * 1674 * @return true if provisioning is required for the MMTEL capability and IMS 1675 * registration technology specified, false if it is not required or if the device does not 1676 * support IMS. 1677 * 1678 * @throws UnsupportedOperationException If the device does not have 1679 * {@link PackageManager#FEATURE_TELEPHONY_IMS}. 1680 */ 1681 @RequiresPermission(Manifest.permission.READ_PRECISE_PHONE_STATE) isProvisioningRequiredForCapability( @mTelFeature.MmTelCapabilities.MmTelCapability int capability, @ImsRegistrationImplBase.ImsRegistrationTech int tech)1682 public boolean isProvisioningRequiredForCapability( 1683 @MmTelFeature.MmTelCapabilities.MmTelCapability int capability, 1684 @ImsRegistrationImplBase.ImsRegistrationTech int tech) { 1685 try { 1686 return getITelephony().isProvisioningRequiredForCapability(mSubId, capability, tech); 1687 } catch (RemoteException e) { 1688 throw e.rethrowAsRuntimeException(); 1689 } 1690 } 1691 1692 1693 /** 1694 * Indicates whether provisioning for the RCS capability and IMS registration technology 1695 * specified is required or not 1696 * 1697 * <p> Requires Permission: 1698 * <ul> 1699 * <li> android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE,</li> 1700 * <li>{@link android.Manifest.permission#READ_PRECISE_PHONE_STATE},</li> 1701 * <li> or that the caller has carrier privileges (see 1702 * {@link TelephonyManager#hasCarrierPrivileges()}).</li> 1703 * </ul> 1704 * 1705 * @return true if provisioning is required for the RCS capability and IMS 1706 * registration technology specified, false if it is not required or if the device does not 1707 * support IMS. 1708 * 1709 * @throws UnsupportedOperationException If the device does not have 1710 * {@link PackageManager#FEATURE_TELEPHONY_IMS}. 1711 */ 1712 @RequiresPermission(Manifest.permission.READ_PRECISE_PHONE_STATE) isRcsProvisioningRequiredForCapability( @msRcsManager.RcsImsCapabilityFlag int capability, @ImsRegistrationImplBase.ImsRegistrationTech int tech)1713 public boolean isRcsProvisioningRequiredForCapability( 1714 @ImsRcsManager.RcsImsCapabilityFlag int capability, 1715 @ImsRegistrationImplBase.ImsRegistrationTech int tech) { 1716 try { 1717 return getITelephony().isRcsProvisioningRequiredForCapability(mSubId, capability, tech); 1718 } catch (RemoteException e) { 1719 throw e.rethrowAsRuntimeException(); 1720 } 1721 } 1722 1723 1724 /** 1725 * Notify the framework that an RCS autoconfiguration XML file has been received for 1726 * provisioning. This API is only valid if the device supports IMS, which can be checked using 1727 * {@link PackageManager#hasSystemFeature}. 1728 * 1729 * <p>Requires Permission: 1730 * <ul> 1731 * <li>{@link Manifest.permission#MODIFY_PHONE_STATE},</li> 1732 * <li>or that the calling app has carrier privileges (see 1733 * {@link TelephonyManager#hasCarrierPrivileges()}).</li> 1734 * </ul> 1735 * 1736 * @param config The XML file to be read. ASCII/UTF8 encoded text if not compressed. 1737 * @param isCompressed The XML file is compressed in gzip format and must be decompressed 1738 * before being read. 1739 * 1740 * @throws UnsupportedOperationException If the device does not have 1741 * {@link PackageManager#FEATURE_TELEPHONY_IMS_SINGLE_REGISTRATION}. 1742 * @hide 1743 */ 1744 @SystemApi 1745 @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) 1746 @RequiresFeature(PackageManager.FEATURE_TELEPHONY_IMS_SINGLE_REGISTRATION) notifyRcsAutoConfigurationReceived(@onNull byte[] config, boolean isCompressed)1747 public void notifyRcsAutoConfigurationReceived(@NonNull byte[] config, boolean isCompressed) { 1748 if (config == null) { 1749 throw new IllegalArgumentException("Must include a non-null config XML file."); 1750 } 1751 1752 try { 1753 getITelephony().notifyRcsAutoConfigurationReceived(mSubId, config, isCompressed); 1754 } catch (RemoteException e) { 1755 throw e.rethrowAsRuntimeException(); 1756 } 1757 } 1758 1759 /** 1760 * Provides the single registration capability of the device and the carrier. 1761 * 1762 * <p>This intent only provides the capability and not the current provisioning status of 1763 * the RCS VoLTE single registration feature. Only default messaging application may receive 1764 * the intent. 1765 * 1766 * <p>Contains {@link #EXTRA_SUBSCRIPTION_ID} to specify the subscription index for which 1767 * the intent is valid. and {@link #EXTRA_STATUS} to specify RCS VoLTE single registration 1768 * status. 1769 * @hide 1770 */ 1771 @SystemApi 1772 @RequiresPermission(Manifest.permission.PERFORM_IMS_SINGLE_REGISTRATION) 1773 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION) 1774 public static final String ACTION_RCS_SINGLE_REGISTRATION_CAPABILITY_UPDATE = 1775 "android.telephony.ims.action.RCS_SINGLE_REGISTRATION_CAPABILITY_UPDATE"; 1776 1777 /** 1778 * Integer extra to specify subscription index. 1779 * @hide 1780 */ 1781 @SystemApi 1782 public static final String EXTRA_SUBSCRIPTION_ID = 1783 "android.telephony.ims.extra.SUBSCRIPTION_ID"; 1784 1785 /** 1786 * Integer extra to specify RCS single registration status 1787 * 1788 * <p>The value can be {@link #STATUS_CAPABLE}, {@link #STATUS_DEVICE_NOT_CAPABLE}, 1789 * {@link #STATUS_CARRIER_NOT_CAPABLE}, or bitwise OR of 1790 * {@link #STATUS_DEVICE_NOT_CAPABLE} and {@link #STATUS_CARRIER_NOT_CAPABLE}. 1791 * @hide 1792 */ 1793 @SystemApi 1794 public static final String EXTRA_STATUS = "android.telephony.ims.extra.STATUS"; 1795 1796 /** 1797 * RCS VoLTE single registration is supported by the device and carrier. 1798 * @hide 1799 */ 1800 @SystemApi 1801 public static final int STATUS_CAPABLE = 0; 1802 1803 /** 1804 * RCS VoLTE single registration is not supported by the device. 1805 * @hide 1806 */ 1807 @SystemApi 1808 public static final int STATUS_DEVICE_NOT_CAPABLE = 0x01; 1809 1810 /** 1811 * RCS VoLTE single registration is not supported by the carrier 1812 * @hide 1813 */ 1814 @SystemApi 1815 public static final int STATUS_CARRIER_NOT_CAPABLE = 0x01 << 1; 1816 1817 /** 1818 * Provide the client configuration parameters of the RCS application. 1819 * 1820 * <p>When this application is also the default messaging application, and RCS 1821 * provisioning is done using autoconfiguration, then these parameters shall be 1822 * sent in the HTTP get request to fetch the RCS provisioning. RCS client 1823 * configuration must be provided by the application before registering for the 1824 * provisioning status events 1825 * {@link #registerRcsProvisioningCallback(Executor, RcsProvisioningCallback)} 1826 * When the IMS/RCS service receives the RCS client configuration, it will detect 1827 * the change in the configuration, and trigger the auto-configuration as needed. 1828 * @param rcc RCS client configuration {@link RcsClientConfiguration} 1829 * 1830 * @throws UnsupportedOperationException If the device does not have 1831 * {@link PackageManager#FEATURE_TELEPHONY_IMS_SINGLE_REGISTRATION}. 1832 * @hide 1833 */ 1834 @SystemApi 1835 @RequiresPermission(Manifest.permission.PERFORM_IMS_SINGLE_REGISTRATION) 1836 @RequiresFeature(PackageManager.FEATURE_TELEPHONY_IMS_SINGLE_REGISTRATION) setRcsClientConfiguration( @onNull RcsClientConfiguration rcc)1837 public void setRcsClientConfiguration( 1838 @NonNull RcsClientConfiguration rcc) throws ImsException { 1839 try { 1840 getITelephony().setRcsClientConfiguration(mSubId, rcc); 1841 } catch (ServiceSpecificException e) { 1842 throw new ImsException(e.getMessage(), e.errorCode); 1843 } catch (RemoteException | IllegalStateException e) { 1844 throw new ImsException(e.getMessage(), ImsException.CODE_ERROR_SERVICE_UNAVAILABLE); 1845 } 1846 } 1847 1848 /** 1849 * Returns a flag to indicate whether or not the device supports IMS single registration for 1850 * MMTEL and RCS features as well as if the carrier has provisioned the feature. 1851 * 1852 * <p> Requires Permission: 1853 * <ul> 1854 * <li>{@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE},</li> 1855 * <li>{@link android.Manifest.permission#PERFORM_IMS_SINGLE_REGISTRATION},</li> 1856 * <li>or that the calling app has carrier privileges (see 1857 * {@link TelephonyManager#hasCarrierPrivileges()}).</li> 1858 * </ul> 1859 * 1860 * @return true if IMS single registration is capable at this time, or false otherwise 1861 * @throws ImsException If the remote ImsService is not available for any reason or 1862 * the subscription associated with this instance is no longer active. 1863 * See {@link ImsException#getCode()} for more information. 1864 * @see PackageManager#FEATURE_TELEPHONY_IMS_SINGLE_REGISTRATION for whether or not this 1865 * device supports IMS single registration. 1866 * @hide 1867 */ 1868 @SystemApi 1869 @RequiresPermission(anyOf = { 1870 Manifest.permission.READ_PRIVILEGED_PHONE_STATE, 1871 Manifest.permission.PERFORM_IMS_SINGLE_REGISTRATION}) 1872 @RequiresFeature(PackageManager.FEATURE_TELEPHONY_IMS_SINGLE_REGISTRATION) isRcsVolteSingleRegistrationCapable()1873 public boolean isRcsVolteSingleRegistrationCapable() throws ImsException { 1874 try { 1875 return getITelephony().isRcsVolteSingleRegistrationCapable(mSubId); 1876 } catch (RemoteException | IllegalStateException e) { 1877 throw new ImsException(e.getMessage(), ImsException.CODE_ERROR_SERVICE_UNAVAILABLE); 1878 } catch (ServiceSpecificException e) { 1879 throw new ImsException(e.getMessage(), e.errorCode); 1880 } 1881 } 1882 1883 /** 1884 * Registers a new {@link RcsProvisioningCallback} to listen to changes to 1885 * RCS provisioning xml. 1886 * 1887 * <p>RCS application must be the default messaging application and must 1888 * have already registered its {@link RcsClientConfiguration} by using 1889 * {@link #setRcsClientConfiguration} before it registers the provisioning 1890 * callback. If ProvisioningManager has a valid RCS configuration at the 1891 * time of callback registration and a reconfiguration is not required 1892 * due to RCS client parameters change, then the callback shall be invoked 1893 * immediately with the xml. 1894 * When the subscription associated with this callback is removed (SIM removed, 1895 * ESIM swap,etc...), this callback will automatically be removed. 1896 * <p> Requires Permission: 1897 * <ul> 1898 * <li>{@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE},</li> 1899 * <li>{@link android.Manifest.permission#PERFORM_IMS_SINGLE_REGISTRATION},</li> 1900 * </ul> 1901 * 1902 * @param executor The {@link Executor} to call the callback methods on 1903 * @param callback The rcs provisioning callback to be registered. 1904 * @see #unregisterRcsProvisioningCallback(RcsProvisioningCallback) 1905 * @see SubscriptionManager.OnSubscriptionsChangedListener 1906 * @throws IllegalArgumentException if the subscription associated with this 1907 * callback is not active (SIM is not inserted, ESIM inactive) or the 1908 * subscription is invalid. 1909 * @throws ImsException if the subscription associated with this callback is 1910 * valid, but the {@link ImsService} associated with the subscription is not 1911 * available. This can happen if the service crashed, for example. 1912 * It shall also throw this exception when the RCS client parameters for the 1913 * application are not valid. In that case application must set the client 1914 * params (See {@link #setRcsClientConfiguration}) and re register the 1915 * callback. 1916 * See {@link ImsException#getCode()} for a more detailed reason. 1917 * @throws UnsupportedOperationException If the device does not have 1918 * {@link PackageManager#FEATURE_TELEPHONY_IMS_SINGLE_REGISTRATION}. 1919 * @hide 1920 */ 1921 @SystemApi 1922 @RequiresPermission(anyOf = { 1923 Manifest.permission.READ_PRIVILEGED_PHONE_STATE, 1924 Manifest.permission.PERFORM_IMS_SINGLE_REGISTRATION}) 1925 @RequiresFeature(PackageManager.FEATURE_TELEPHONY_IMS_SINGLE_REGISTRATION) registerRcsProvisioningCallback( @onNull @allbackExecutor Executor executor, @NonNull RcsProvisioningCallback callback)1926 public void registerRcsProvisioningCallback( 1927 @NonNull @CallbackExecutor Executor executor, 1928 @NonNull RcsProvisioningCallback callback) throws ImsException { 1929 callback.setExecutor(executor); 1930 try { 1931 getITelephony().registerRcsProvisioningCallback(mSubId, callback.getBinder()); 1932 } catch (ServiceSpecificException e) { 1933 throw new ImsException(e.getMessage(), e.errorCode); 1934 } catch (RemoteException | IllegalStateException e) { 1935 throw new ImsException(e.getMessage(), ImsException.CODE_ERROR_SERVICE_UNAVAILABLE); 1936 } 1937 } 1938 1939 /** 1940 * Unregister an existing {@link RcsProvisioningCallback}. Application can 1941 * unregister when its no longer interested in the provisioning updates 1942 * like when a user disables RCS from the UI/settings. 1943 * When the subscription associated with this callback is removed (SIM 1944 * removed, ESIM swap, etc...), this callback will automatically be 1945 * removed. If this method is called for an inactive subscription, it 1946 * will result in a no-op. 1947 * <p> Requires Permission: 1948 * <ul> 1949 * <li>{@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE},</li> 1950 * <li>{@link android.Manifest.permission#PERFORM_IMS_SINGLE_REGISTRATION},</li> 1951 * </ul> 1952 * 1953 * @param callback The existing {@link RcsProvisioningCallback} to be 1954 * removed. 1955 * @see #registerRcsProvisioningCallback(Executor, RcsProvisioningCallback) 1956 * @throws IllegalArgumentException if the subscription associated with 1957 * this callback is invalid. 1958 * @throws UnsupportedOperationException If the device does not have 1959 * {@link PackageManager#FEATURE_TELEPHONY_IMS_SINGLE_REGISTRATION}. 1960 * @hide 1961 */ 1962 @SystemApi 1963 @RequiresPermission(anyOf = { 1964 Manifest.permission.READ_PRIVILEGED_PHONE_STATE, 1965 Manifest.permission.PERFORM_IMS_SINGLE_REGISTRATION}) 1966 @RequiresFeature(PackageManager.FEATURE_TELEPHONY_IMS_SINGLE_REGISTRATION) unregisterRcsProvisioningCallback( @onNull RcsProvisioningCallback callback)1967 public void unregisterRcsProvisioningCallback( 1968 @NonNull RcsProvisioningCallback callback) { 1969 try { 1970 getITelephony().unregisterRcsProvisioningCallback( 1971 mSubId, callback.getBinder()); 1972 } catch (RemoteException e) { 1973 throw e.rethrowAsRuntimeException(); 1974 } 1975 } 1976 1977 /** 1978 * Reconfiguration triggered by the RCS application. Most likely cause 1979 * is the 403 forbidden to a HTTP request. This API is only valid if the device supports IMS, 1980 * which can be checked using {@link PackageManager#hasSystemFeature} 1981 * 1982 * <p>When this api is called, the RCS configuration for the associated 1983 * subscription will be removed, and the application which has registered 1984 * {@link RcsProvisioningCallback} may expect to receive 1985 * {@link RcsProvisioningCallback#onConfigurationReset}, then 1986 * {@link RcsProvisioningCallback#onConfigurationChanged} when the new 1987 * RCS configuration is received and notified by {@link #notifyRcsAutoConfigurationReceived} 1988 * 1989 * @throws UnsupportedOperationException If the device does not have 1990 * {@link PackageManager#FEATURE_TELEPHONY_IMS_SINGLE_REGISTRATION}. 1991 * @hide 1992 */ 1993 @SystemApi 1994 @RequiresPermission(Manifest.permission.PERFORM_IMS_SINGLE_REGISTRATION) 1995 @RequiresFeature(PackageManager.FEATURE_TELEPHONY_IMS_SINGLE_REGISTRATION) triggerRcsReconfiguration()1996 public void triggerRcsReconfiguration() { 1997 try { 1998 getITelephony().triggerRcsReconfiguration(mSubId); 1999 } catch (RemoteException e) { 2000 throw e.rethrowAsRuntimeException(); 2001 } 2002 } 2003 getITelephony()2004 private static ITelephony getITelephony() { 2005 ITelephony binder = ITelephony.Stub.asInterface( 2006 TelephonyFrameworkInitializer 2007 .getTelephonyServiceManager() 2008 .getTelephonyServiceRegisterer() 2009 .get()); 2010 if (binder == null) { 2011 throw new RuntimeException("Could not find Telephony Service."); 2012 } 2013 return binder; 2014 } 2015 } 2016