1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License
15  */
16 
17 package com.android.ims;
18 
19 import android.os.Handler;
20 import android.os.HandlerExecutor;
21 import android.os.Looper;
22 import android.os.RemoteException;
23 import android.telephony.Rlog;
24 import android.telephony.ims.ImsReasonInfo;
25 import android.telephony.ims.ProvisioningManager;
26 import android.telephony.ims.aidl.IImsConfig;
27 import android.telephony.ims.aidl.IImsConfigCallback;
28 
29 import java.util.concurrent.Executor;
30 
31 /**
32  * Provides APIs to get/set the IMS service feature/capability/parameters.
33  * The config items include:
34  * 1) Items provisioned by the operator.
35  * 2) Items configured by user. Mainly service feature class.
36  *
37  * @deprecated Use {@link  ProvisioningManager} to change these configurations in the ImsService.
38  * @hide
39  */
40 @Deprecated
41 public class ImsConfig {
42     private static final String TAG = "ImsConfig";
43     private boolean DBG = true;
44     private final IImsConfig miConfig;
45 
46     /**
47      * Broadcast action: the feature enable status was changed
48      *
49      * @hide
50      */
51     public static final String ACTION_IMS_FEATURE_CHANGED =
52             "com.android.intent.action.IMS_FEATURE_CHANGED";
53 
54     /**
55      * Broadcast action: the configuration was changed
56      * @deprecated Use {@link android.telephony.ims.ProvisioningManager.Callback} instead.
57      * @hide
58      */
59     public static final String ACTION_IMS_CONFIG_CHANGED =
60             "com.android.intent.action.IMS_CONFIG_CHANGED";
61 
62     /**
63      * Extra parameter "item" of intent ACTION_IMS_FEATURE_CHANGED and ACTION_IMS_CONFIG_CHANGED.
64      * It is the value of FeatureConstants or ConfigConstants.
65      *
66      * @hide
67      */
68     public static final String EXTRA_CHANGED_ITEM = "item";
69 
70     /**
71      * Extra parameter "value" of intent ACTION_IMS_FEATURE_CHANGED and ACTION_IMS_CONFIG_CHANGED.
72      * It is the new value of "item".
73      *
74      * @hide
75      */
76     public static final String EXTRA_NEW_VALUE = "value";
77 
78     /**
79     * Defines IMS service/capability feature constants.
80     * @deprecated Use
81      * {@link android.telephony.ims.feature.MmTelFeature.MmTelCapabilities.MmTelCapability} instead.
82     */
83     public static class FeatureConstants {
84         public static final int FEATURE_TYPE_UNKNOWN = -1;
85 
86         /**
87          * FEATURE_TYPE_VOLTE supports features defined in 3GPP and
88          * GSMA IR.92 over LTE.
89          */
90         public static final int FEATURE_TYPE_VOICE_OVER_LTE = 0;
91 
92         /**
93          * FEATURE_TYPE_LVC supports features defined in 3GPP and
94          * GSMA IR.94 over LTE.
95          */
96         public static final int FEATURE_TYPE_VIDEO_OVER_LTE = 1;
97 
98         /**
99          * FEATURE_TYPE_VOICE_OVER_WIFI supports features defined in 3GPP and
100          * GSMA IR.92 over WiFi.
101          */
102         public static final int FEATURE_TYPE_VOICE_OVER_WIFI = 2;
103 
104         /**
105          * FEATURE_TYPE_VIDEO_OVER_WIFI supports features defined in 3GPP and
106          * GSMA IR.94 over WiFi.
107          */
108         public static final int FEATURE_TYPE_VIDEO_OVER_WIFI = 3;
109 
110         /**
111          * FEATURE_TYPE_UT supports features defined in 3GPP and
112          * GSMA IR.92 over LTE.
113          */
114         public static final int FEATURE_TYPE_UT_OVER_LTE = 4;
115 
116        /**
117          * FEATURE_TYPE_UT_OVER_WIFI supports features defined in 3GPP and
118          * GSMA IR.92 over WiFi.
119          */
120         public static final int FEATURE_TYPE_UT_OVER_WIFI = 5;
121     }
122 
123     /**
124     * Defines IMS service/capability parameters.
125     */
126     public static class ConfigConstants {
127 
128         // Define IMS config items
129         public static final int CONFIG_START = 0;
130 
131         // Define operator provisioned config items
132         public static final int PROVISIONED_CONFIG_START = CONFIG_START;
133 
134         /**
135          * AMR CODEC Mode Value set, 0-7 in comma separated sequence.
136          * Value is in String format.
137          */
138         public static final int VOCODER_AMRMODESET = CONFIG_START;
139 
140         /**
141          * Wide Band AMR CODEC Mode Value set,0-7 in comma separated sequence.
142          * Value is in String format.
143          */
144         public static final int VOCODER_AMRWBMODESET = 1;
145 
146         /**
147          * SIP Session Timer value (seconds).
148          * Value is in Integer format.
149          */
150         public static final int SIP_SESSION_TIMER = 2;
151 
152         /**
153          * Minimum SIP Session Expiration Timer in (seconds).
154          * Value is in Integer format.
155          */
156         public static final int MIN_SE = 3;
157 
158         /**
159          * SIP_INVITE cancellation time out value (in milliseconds). Integer format.
160          * Value is in Integer format.
161          */
162         public static final int CANCELLATION_TIMER = 4;
163 
164         /**
165          * Delay time when an iRAT transition from eHRPD/HRPD/1xRTT to LTE.
166          * Value is in Integer format.
167          */
168         public static final int TDELAY = 5;
169 
170         /**
171          * Silent redial status of Enabled (True), or Disabled (False).
172          * Value is in Integer format.
173          */
174         public static final int SILENT_REDIAL_ENABLE = 6;
175 
176         /**
177          * SIP T1 timer value in milliseconds. See RFC 3261 for define.
178          * Value is in Integer format.
179          */
180         public static final int SIP_T1_TIMER = 7;
181 
182         /**
183          * SIP T2 timer value in milliseconds.  See RFC 3261 for define.
184          * Value is in Integer format.
185          */
186         public static final int SIP_T2_TIMER  = 8;
187 
188          /**
189          * SIP TF timer value in milliseconds.  See RFC 3261 for define.
190          * Value is in Integer format.
191          */
192         public static final int SIP_TF_TIMER = 9;
193 
194         /**
195          * VoLTE status for VLT/s status of Enabled (1), or Disabled (0).
196          * Value is in Integer format.
197          */
198         public static final int VLT_SETTING_ENABLED = 10;
199 
200         /**
201          * VoLTE status for LVC/s status of Enabled (1), or Disabled (0).
202          * Value is in Integer format.
203          */
204         public static final int LVC_SETTING_ENABLED = 11;
205         /**
206          * Domain Name for the device to populate the request URI for REGISTRATION.
207          * Value is in String format.
208          */
209         public static final int DOMAIN_NAME = 12;
210          /**
211          * Device Outgoing SMS based on either 3GPP or 3GPP2 standards.
212          * Value is in Integer format. 3GPP2(0), 3GPP(1)
213          */
214         public static final int SMS_FORMAT = 13;
215          /**
216          * Turns IMS ON/OFF on the device.
217          * Value is in Integer format. ON (1), OFF(0).
218          */
219         public static final int SMS_OVER_IP = 14;
220         /**
221          * Requested expiration for Published Online availability.
222          * Value is in Integer format.
223          */
224         public static final int PUBLISH_TIMER = 15;
225         /**
226          * Requested expiration for Published Offline availability.
227          * Value is in Integer format.
228          */
229         public static final int PUBLISH_TIMER_EXTENDED = 16;
230         /**
231          *
232          * Value is in Integer format.
233          */
234         public static final int CAPABILITY_DISCOVERY_ENABLED = 17;
235         /**
236          * Period of time the capability information of the  contact is cached on handset.
237          * Value is in Integer format.
238          */
239         public static final int CAPABILITIES_CACHE_EXPIRATION = 18;
240         /**
241          * Peiod of time the availability information of a contact is cached on device.
242          * Value is in Integer format.
243          */
244         public static final int AVAILABILITY_CACHE_EXPIRATION = 19;
245         /**
246          * Interval between successive capabilities polling.
247          * Value is in Integer format.
248          */
249         public static final int CAPABILITIES_POLL_INTERVAL = 20;
250         /**
251          * Minimum time between two published messages from the device.
252          * Value is in Integer format.
253          */
254         public static final int SOURCE_THROTTLE_PUBLISH = 21;
255         /**
256          * The Maximum number of MDNs contained in one Request Contained List.
257          * Value is in Integer format.
258          */
259         public static final int MAX_NUMENTRIES_IN_RCL = 22;
260         /**
261          * Expiration timer for subscription of a Request Contained List, used in capability
262          * polling.
263          * Value is in Integer format.
264          */
265         public static final int CAPAB_POLL_LIST_SUB_EXP = 23;
266         /**
267          * Applies compression to LIST Subscription.
268          * Value is in Integer format. Enable (1), Disable(0).
269          */
270         public static final int GZIP_FLAG = 24;
271         /**
272          * VOLTE Status for EAB/s status of Enabled (1), or Disabled (0).
273          * Value is in Integer format.
274          */
275         public static final int EAB_SETTING_ENABLED = 25;
276         /**
277          * Wi-Fi calling roaming status.
278          * Value is in Integer format. ON (1), OFF(0).
279          */
280         public static final int VOICE_OVER_WIFI_ROAMING =
281                 ProvisioningManager.KEY_VOICE_OVER_WIFI_ROAMING_ENABLED_OVERRIDE;
282         /**
283          * Wi-Fi calling modem - WfcModeFeatureValueConstants.
284          * Value is in Integer format.
285          */
286         public static final int VOICE_OVER_WIFI_MODE =
287                 ProvisioningManager.KEY_VOICE_OVER_WIFI_MODE_OVERRIDE;
288         /**
289          * VOLTE Status for voice over wifi status of Enabled (1), or Disabled (0).
290          * Value is in Integer format.
291          */
292         public static final int VOICE_OVER_WIFI_SETTING_ENABLED = 28;
293         /**
294          * Mobile data enabled.
295          * Value is in Integer format. On (1), OFF(0).
296          */
297         public static final int MOBILE_DATA_ENABLED = 29;
298         /**
299          * VoLTE user opted in status.
300          * Value is in Integer format. Opted-in (1) Opted-out (0).
301          */
302         public static final int VOLTE_USER_OPT_IN_STATUS = 30;
303         /**
304          * Proxy for Call Session Control Function(P-CSCF) address for Local-BreakOut(LBO).
305          * Value is in String format.
306          */
307         public static final int LBO_PCSCF_ADDRESS = 31;
308         /**
309          * Keep Alive Enabled for SIP.
310          * Value is in Integer format. On(1), OFF(0).
311          */
312         public static final int KEEP_ALIVE_ENABLED = 32;
313         /**
314          * Registration retry Base Time value in seconds.
315          * Value is in Integer format.
316          */
317         public static final int REGISTRATION_RETRY_BASE_TIME_SEC = 33;
318         /**
319          * Registration retry Max Time value in seconds.
320          * Value is in Integer format.
321          */
322         public static final int REGISTRATION_RETRY_MAX_TIME_SEC = 34;
323         /**
324          * Smallest RTP port for speech codec.
325          * Value is in integer format.
326          */
327         public static final int SPEECH_START_PORT = 35;
328         /**
329          * Largest RTP port for speech code.
330          * Value is in Integer format.
331          */
332         public static final int SPEECH_END_PORT = 36;
333         /**
334          * SIP Timer A's value in milliseconds. Timer A is the INVITE request
335          * retransmit interval, for UDP only.
336          * Value is in Integer format.
337          */
338         public static final int SIP_INVITE_REQ_RETX_INTERVAL_MSEC = 37;
339         /**
340          * SIP Timer B's value in milliseconds. Timer B is the wait time for
341          * INVITE message to be acknowledged.
342          * Value is in Integer format.
343          */
344         public static final int SIP_INVITE_RSP_WAIT_TIME_MSEC = 38;
345         /**
346          * SIP Timer D's value in milliseconds. Timer D is the wait time for
347          * response retransmits of the invite client transactions.
348          * Value is in Integer format.
349          */
350         public static final int SIP_INVITE_RSP_RETX_WAIT_TIME_MSEC = 39;
351         /**
352          * SIP Timer E's value in milliseconds. Timer E is the value Non-INVITE
353          * request retransmit interval, for UDP only.
354          * Value is in Integer format.
355          */
356         public static final int SIP_NON_INVITE_REQ_RETX_INTERVAL_MSEC = 40;
357         /**
358          * SIP Timer F's value in milliseconds. Timer F is the Non-INVITE transaction
359          * timeout timer.
360          * Value is in Integer format.
361          */
362         public static final int SIP_NON_INVITE_TXN_TIMEOUT_TIMER_MSEC = 41;
363         /**
364          * SIP Timer G's value in milliseconds. Timer G is the value of INVITE response
365          * retransmit interval.
366          * Value is in Integer format.
367          */
368         public static final int SIP_INVITE_RSP_RETX_INTERVAL_MSEC = 42;
369         /**
370          * SIP Timer H's value in milliseconds. Timer H is the value of wait time for
371          * ACK receipt.
372          * Value is in Integer format.
373          */
374         public static final int SIP_ACK_RECEIPT_WAIT_TIME_MSEC = 43;
375         /**
376          * SIP Timer I's value in milliseconds. Timer I is the value of wait time for
377          * ACK retransmits.
378          * Value is in Integer format.
379          */
380         public static final int SIP_ACK_RETX_WAIT_TIME_MSEC = 44;
381         /**
382          * SIP Timer J's value in milliseconds. Timer J is the value of wait time for
383          * non-invite request retransmission.
384          * Value is in Integer format.
385          */
386         public static final int SIP_NON_INVITE_REQ_RETX_WAIT_TIME_MSEC = 45;
387         /**
388          * SIP Timer K's value in milliseconds. Timer K is the value of wait time for
389          * non-invite response retransmits.
390          * Value is in Integer format.
391          */
392         public static final int SIP_NON_INVITE_RSP_RETX_WAIT_TIME_MSEC = 46;
393         /**
394          * AMR WB octet aligned dynamic payload type.
395          * Value is in Integer format.
396          */
397         public static final int AMR_WB_OCTET_ALIGNED_PT = 47;
398         /**
399          * AMR WB bandwidth efficient payload type.
400          * Value is in Integer format.
401          */
402         public static final int AMR_WB_BANDWIDTH_EFFICIENT_PT = 48;
403         /**
404          * AMR octet aligned dynamic payload type.
405          * Value is in Integer format.
406          */
407         public static final int AMR_OCTET_ALIGNED_PT = 49;
408         /**
409          * AMR bandwidth efficient payload type.
410          * Value is in Integer format.
411          */
412         public static final int AMR_BANDWIDTH_EFFICIENT_PT = 50;
413         /**
414          * DTMF WB payload type.
415          * Value is in Integer format.
416          */
417         public static final int DTMF_WB_PT = 51;
418         /**
419          * DTMF NB payload type.
420          * Value is in Integer format.
421          */
422         public static final int DTMF_NB_PT = 52;
423         /**
424          * AMR Default encoding mode.
425          * Value is in Integer format.
426          */
427         public static final int AMR_DEFAULT_MODE = 53;
428         /**
429          * SMS Public Service Identity.
430          * Value is in String format.
431          */
432         public static final int SMS_PSI = 54;
433         /**
434          * Video Quality - VideoQualityFeatureValuesConstants.
435          * Value is in Integer format.
436          */
437         public static final int VIDEO_QUALITY = 55;
438         /**
439          * LTE threshold.
440          * Handover from LTE to WiFi if LTE < THLTE1 and WiFi >= VOWT_A.
441          */
442         public static final int TH_LTE1 = 56;
443         /**
444          * LTE threshold.
445          * Handover from WiFi to LTE if LTE >= THLTE3 or (WiFi < VOWT_B and LTE >= THLTE2).
446          */
447         public static final int TH_LTE2 = 57;
448         /**
449          * LTE threshold.
450          * Handover from WiFi to LTE if LTE >= THLTE3 or (WiFi < VOWT_B and LTE >= THLTE2).
451          */
452         public static final int TH_LTE3 = 58;
453         /**
454          * 1x threshold.
455          * Handover from 1x to WiFi if 1x < TH1x
456          */
457         public static final int TH_1x = 59;
458         /**
459          * WiFi threshold.
460          * Handover from LTE to WiFi if LTE < THLTE1 and WiFi >= VOWT_A.
461          */
462         public static final int VOWT_A = 60;
463         /**
464          * WiFi threshold.
465          * Handover from WiFi to LTE if LTE >= THLTE3 or (WiFi < VOWT_B and LTE >= THLTE2).
466          */
467         public static final int VOWT_B = 61;
468         /**
469          * LTE ePDG timer.
470          * Device shall not handover back to LTE until the T_ePDG_LTE timer expires.
471          */
472         public static final int T_EPDG_LTE = 62;
473         /**
474          * WiFi ePDG timer.
475          * Device shall not handover back to WiFi until the T_ePDG_WiFi timer expires.
476          */
477         public static final int T_EPDG_WIFI = 63;
478         /**
479          * 1x ePDG timer.
480          * Device shall not re-register on 1x until the T_ePDG_1x timer expires.
481          */
482         public static final int T_EPDG_1X = 64;
483         /**
484          * MultiEndpoint status: Enabled (1), or Disabled (0).
485          * Value is in Integer format.
486          */
487         public static final int VICE_SETTING_ENABLED = 65;
488 
489         /**
490          * RTT status: Enabled (1), or Disabled (0).
491          * Value is in Integer format.
492          */
493         public static final int RTT_SETTING_ENABLED = 66;
494 
495         // Expand the operator config items as needed here, need to change
496         // PROVISIONED_CONFIG_END after that.
497         public static final int PROVISIONED_CONFIG_END = RTT_SETTING_ENABLED;
498 
499         // Expand the operator config items as needed here.
500     }
501 
502     /**
503     * Defines IMS set operation status.
504     */
505     public static class OperationStatusConstants {
506         public static final int UNKNOWN = -1;
507         public static final int SUCCESS = 0;
508         public static final int FAILED =  1;
509         public static final int UNSUPPORTED_CAUSE_NONE = 2;
510         public static final int UNSUPPORTED_CAUSE_RAT = 3;
511         public static final int UNSUPPORTED_CAUSE_DISABLED = 4;
512     }
513 
514     /**
515      * Defines IMS get operation values.
516      */
517     public static class OperationValuesConstants {
518         /**
519          * Values related to Video Quality
520          */
521         public static final int VIDEO_QUALITY_UNKNOWN = -1;
522         public static final int VIDEO_QUALITY_LOW = 0;
523         public static final int VIDEO_QUALITY_HIGH = 1;
524     }
525 
526     /**
527      * Defines IMS video quality feature value.
528      */
529     public static class VideoQualityFeatureValuesConstants {
530         public static final int LOW = 0;
531         public static final int HIGH = 1;
532     }
533 
534    /**
535     * Defines IMS feature value.
536     */
537     public static class FeatureValueConstants {
538         public static final int ERROR = -1;
539         public static final int OFF = 0;
540         public static final int ON = 1;
541     }
542 
543     /**
544      * Defines IMS feature value.
545      */
546     public static class WfcModeFeatureValueConstants {
547         public static final int WIFI_ONLY = 0;
548         public static final int CELLULAR_PREFERRED = 1;
549         public static final int WIFI_PREFERRED = 2;
550     }
551 
ImsConfig(IImsConfig iconfig)552     public ImsConfig(IImsConfig iconfig) {
553         miConfig = iconfig;
554     }
555 
556     /**
557      * @deprecated see {@link #getConfigInt(int)} instead.
558      */
getProvisionedValue(int item)559     public int getProvisionedValue(int item) throws ImsException {
560         return getConfigInt(item);
561     }
562 
563     /**
564      * Gets the configuration value for IMS service/capabilities parameters used by IMS stack.
565      *
566      * @param item, as defined in com.android.ims.ImsConfig#ConfigConstants.
567      * @return the value in Integer format.
568      * @throws ImsException if the ImsService is unavailable.
569      */
getConfigInt(int item)570     public int getConfigInt(int item) throws ImsException {
571         int ret = 0;
572         try {
573             ret = miConfig.getConfigInt(item);
574         }  catch (RemoteException e) {
575             throw new ImsException("getInt()", e,
576                     ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE);
577         }
578         if (DBG) Rlog.d(TAG, "getInt(): item = " + item + ", ret =" + ret);
579 
580         return ret;
581     }
582 
583     /**
584      * @deprecated see {@link #getConfigString(int)} instead
585      */
getProvisionedStringValue(int item)586     public String getProvisionedStringValue(int item) throws ImsException {
587         return getConfigString(item);
588     }
589 
590     /**
591      * Gets the configuration value for IMS service/capabilities parameters used by IMS stack.
592      *
593      * @param item, as defined in com.android.ims.ImsConfig#ConfigConstants.
594      * @return value in String format.
595      *
596      * @throws ImsException if the ImsService is unavailable.
597      */
getConfigString(int item)598     public String getConfigString(int item) throws ImsException {
599         String ret = "Unknown";
600         try {
601             ret = miConfig.getConfigString(item);
602         }  catch (RemoteException e) {
603             throw new ImsException("getConfigString()", e,
604                     ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE);
605         }
606         if (DBG) Rlog.d(TAG, "getConfigString(): item = " + item + ", ret =" + ret);
607 
608         return ret;
609     }
610 
611     /**
612      * @deprecated see {@link #setConfig(int, int)} instead.
613      */
setProvisionedValue(int item, int value)614     public int setProvisionedValue(int item, int value) throws ImsException {
615         return setConfig(item, value);
616     }
617 
618     /**
619      * @deprecated see {@link #setConfig(int, String)} instead.
620      */
setProvisionedStringValue(int item, String value)621     public int setProvisionedStringValue(int item, String value) throws ImsException {
622         return setConfig(item, value);
623     }
624 
625     /**
626      * Sets the value for ImsService configuration item.
627      *
628      * @param item, as defined in com.android.ims.ImsConfig#ConfigConstants.
629      * @param value in Integer format.
630      * @return as defined in com.android.ims.ImsConfig#OperationStatusConstants
631      *
632      * @throws ImsException if the ImsService is unavailable.
633      */
setConfig(int item, int value)634     public int setConfig(int item, int value) throws ImsException {
635         int ret = OperationStatusConstants.UNKNOWN;
636         if (DBG) {
637             Rlog.d(TAG, "setConfig(): item = " + item +
638                     "value = " + value);
639         }
640         try {
641             ret = miConfig.setConfigInt(item, value);
642         }  catch (RemoteException e) {
643             throw new ImsException("setConfig()", e,
644                     ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE);
645         }
646         if (DBG) {
647             Rlog.d(TAG, "setConfig(): item = " + item +
648                     " value = " + value + " ret = " + ret);
649         }
650 
651         return ret;
652 
653     }
654 
655     /**
656      * Sets the value for ImsService configuration item.
657      *
658      * @param item, as defined in com.android.ims.ImsConfig#ConfigConstants.
659      * @param value in Integer format.
660      * @return as defined in com.android.ims.ImsConfig#OperationStatusConstants
661      *
662      * @throws ImsException if the ImsService is unavailable.
663      */
setConfig(int item, String value)664     public int setConfig(int item, String value) throws ImsException {
665         int ret = OperationStatusConstants.UNKNOWN;
666         if (DBG) {
667             Rlog.d(TAG, "setConfig(): item = " + item +
668                     "value = " + value);
669         }
670         try {
671             ret = miConfig.setConfigString(item, value);
672         }  catch (RemoteException e) {
673             throw new ImsException("setConfig()", e,
674                     ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE);
675         }
676         if (DBG) {
677             Rlog.d(TAG, "setConfig(): item = " + item +
678                     " value = " + value + " ret = " + ret);
679         }
680 
681         return ret;
682     }
683 
684     /**
685      * Adds a {@link ProvisioningManager.Callback} to the ImsService to notify when a Configuration
686      * item has changed.
687      *
688      * Make sure to call {@link #removeConfigCallback(IImsConfigCallback)} when finished
689      * using this callback.
690      */
addConfigCallback(ProvisioningManager.Callback callback)691     public void addConfigCallback(ProvisioningManager.Callback callback) throws ImsException {
692         callback.setExecutor(getThreadExecutor());
693         addConfigCallback(callback.getBinder());
694     }
695 
696     /**
697      * Adds a {@link IImsConfigCallback} to the ImsService to notify when a Configuration
698      * item has changed.
699      *
700      * Make sure to call {@link #removeConfigCallback(IImsConfigCallback)} when finished
701      * using this callback.
702      */
addConfigCallback(IImsConfigCallback callback)703     public void addConfigCallback(IImsConfigCallback callback) throws ImsException {
704         if (DBG) Rlog.d(TAG, "addConfigCallback: " + callback);
705         try {
706             miConfig.addImsConfigCallback(callback);
707         }  catch (RemoteException e) {
708             throw new ImsException("addConfigCallback()", e,
709                     ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE);
710         }
711     }
712 
713     /**
714      * Removes an existing {@link IImsConfigCallback} from the ImsService.
715      */
removeConfigCallback(IImsConfigCallback callback)716     public void removeConfigCallback(IImsConfigCallback callback) throws ImsException {
717         if (DBG) Rlog.d(TAG, "removeConfigCallback: " + callback);
718         try {
719             miConfig.removeImsConfigCallback(callback);
720         }  catch (RemoteException e) {
721             throw new ImsException("removeConfigCallback()", e,
722                     ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE);
723         }
724     }
725 
726     /**
727      * @return true if the binder connection is alive, false otherwise.
728      */
isBinderAlive()729     public boolean isBinderAlive() {
730         return miConfig.asBinder().isBinderAlive();
731     }
732 
getThreadExecutor()733     private Executor getThreadExecutor() {
734         if (Looper.myLooper() == null) {
735             Looper.prepare();
736         }
737         return new HandlerExecutor(new Handler(Looper.myLooper()));
738     }
739 }
740