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