ImsConfig.java revision 1d4a9a47e0c28988fe46a37969f2c39e31a16be1
1/*
2 * Copyright (c) 2014 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
17package com.android.ims;
18
19import android.content.Context;
20import android.os.RemoteException;
21import android.telephony.Rlog;
22
23import com.android.ims.ImsConfigListener;
24import com.android.ims.ImsReasonInfo;
25import com.android.ims.internal.IImsConfig;
26/**
27 * Provides APIs to get/set the IMS service feature/capability/parameters.
28 * The config items include:
29 * 1) Items provisioned by the operator.
30 * 2) Items configured by user. Mainly service feature class.
31 *
32 * @hide
33 */
34public class ImsConfig {
35    private static final String TAG = "ImsConfig";
36    private boolean DBG = true;
37    private final IImsConfig miConfig;
38    private Context mContext;
39
40    /**
41    * Defines IMS service/capability feature constants.
42    */
43    public static class FeatureConstants {
44        public static final int FEATURE_TYPE_UNKNOWN = -1;
45
46        /**
47         * FEATURE_TYPE_VOLTE supports features defined in 3GPP and
48         * GSMA IR.92 over LTE.
49         */
50        public static final int FEATURE_TYPE_VOICE_OVER_LTE = 0;
51
52        /**
53         * FEATURE_TYPE_LVC supports features defined in 3GPP and
54         * GSMA IR.94 over LTE.
55         */
56        public static final int FEATURE_TYPE_VIDEO_OVER_LTE = 1;
57
58        /**
59         * FEATURE_TYPE_VOICE_OVER_WIFI supports features defined in 3GPP and
60         * GSMA IR.92 over WiFi.
61         */
62        public static final int FEATURE_TYPE_VOICE_OVER_WIFI = 2;
63
64        /**
65         * FEATURE_TYPE_VIDEO_OVER_WIFI supports features defined in 3GPP and
66         * GSMA IR.94 over WiFi.
67         */
68        public static final int FEATURE_TYPE_VIDEO_OVER_WIFI = 3;
69
70        /**
71         * FEATURE_TYPE_UT supports features defined in 3GPP and
72         * GSMA IR.92 over LTE.
73         */
74        public static final int FEATURE_TYPE_UT_OVER_LTE = 4;
75
76       /**
77         * FEATURE_TYPE_UT_OVER_WIFI supports features defined in 3GPP and
78         * GSMA IR.92 over WiFi.
79         */
80        public static final int FEATURE_TYPE_UT_OVER_WIFI = 5;
81    }
82
83    /**
84    * Defines IMS service/capability parameters.
85    */
86    public static class ConfigConstants {
87
88        // Define IMS config items
89        public static final int CONFIG_START = 0;
90
91        // Define operator provisioned config items
92        public static final int PROVISIONED_CONFIG_START = CONFIG_START;
93
94        /**
95         * AMR CODEC Mode Value set, 0-7 in comma separated sequence.
96         * Value is in String format.
97         */
98        public static final int VOCODER_AMRMODESET = CONFIG_START;
99
100        /**
101         * Wide Band AMR CODEC Mode Value set,0-7 in comma separated sequence.
102         * Value is in String format.
103         */
104        public static final int VOCODER_AMRWBMODESET = 1;
105
106        /**
107         * SIP Session Timer value (seconds).
108         * Value is in Integer format.
109         */
110        public static final int SIP_SESSION_TIMER = 2;
111
112        /**
113         * Minimum SIP Session Expiration Timer in (seconds).
114         * Value is in Integer format.
115         */
116        public static final int MIN_SE = 3;
117
118        /**
119         * SIP_INVITE cancellation time out value (in milliseconds). Integer format.
120         * Value is in Integer format.
121         */
122        public static final int CANCELLATION_TIMER = 4;
123
124        /**
125         * Delay time when an iRAT transition from eHRPD/HRPD/1xRTT to LTE.
126         * Value is in Integer format.
127         */
128        public static final int TDELAY = 5;
129
130        /**
131         * Silent redial status of Enabled (True), or Disabled (False).
132         * Value is in Integer format.
133         */
134        public static final int SILENT_REDIAL_ENABLE = 6;
135
136        /**
137         * SIP T1 timer value in milliseconds. See RFC 3261 for define.
138         * Value is in Integer format.
139         */
140        public static final int SIP_T1_TIMER = 7;
141
142        /**
143         * SIP T2 timer value in milliseconds.  See RFC 3261 for define.
144         * Value is in Integer format.
145         */
146        public static final int SIP_T2_TIMER  = 8;
147
148         /**
149         * SIP TF timer value in milliseconds.  See RFC 3261 for define.
150         * Value is in Integer format.
151         */
152        public static final int SIP_TF_TIMER = 9;
153
154        /**
155         * VoLTE status for VLT/s status of Enabled (1), or Disabled (0).
156         * Value is in Integer format.
157         */
158        public static final int VLT_SETTING_ENABLED = 10;
159
160        /**
161         * VoLTE status for LVC/s status of Enabled (1), or Disabled (0).
162         * Value is in Integer format.
163         */
164        public static final int LVC_SETTING_ENABLED = 11;
165        /**
166         * Domain Name for the device to populate the request URI for REGISTRATION.
167         * Value is in String format.
168         */
169        public static final int DOMAIN_NAME = 12;
170         /**
171         * Device Outgoing SMS based on either 3GPP or 3GPP2 standards.
172         * Value is in Integer format. 3GPP2(0), 3GPP(1)
173         */
174        public static final int SMS_FORMAT = 13;
175         /**
176         * Turns IMS ON/OFF on the device.
177         * Value is in Integer format. ON (1), OFF(0).
178         */
179        public static final int SMS_OVER_IP = 14;
180        /**
181         * Requested expiration for Published Online availability.
182         * Value is in Integer format.
183         */
184        public static final int PUBLISH_TIMER = 15;
185        /**
186         * Requested expiration for Published Offline availability.
187         * Value is in Integer format.
188         */
189        public static final int PUBLISH_TIMER_EXTENDED = 16;
190        /**
191         * Period of time the capability information of the  contact is cached on handset.
192         * Value is in Integer format.
193         */
194        public static final int CAPABILITIES_CACHE_EXPIRATION = 17;
195        /**
196         * Peiod of time the availability information of a contact is cached on device.
197         * Value is in Integer format.
198         */
199        public static final int AVAILABILITY_CACHE_EXPIRATION = 18;
200        /**
201         * Interval between successive capabilities polling.
202         * Value is in Integer format.
203         */
204        public static final int CAPABILITIES_POLL_INTERVAL = 19;
205        /**
206         * Minimum time between two published messages from the device.
207         * Value is in Integer format.
208         */
209        public static final int SOURCE_THROTTLE_PUBLISH = 20;
210        /**
211         * The Maximum number of MDNs contained in one Request Contained List.
212         * Value is in Integer format.
213         */
214        public static final int MAX_NUMENTRIES_IN_RCL = 21;
215        /**
216         * Expiration timer for subscription of a Request Contained List, used in capability polling.
217         * Value is in Integer format.
218         */
219        public static final int CAPAB_POLL_LIST_SUB_EXP = 22;
220        /**
221         * Applies compression to LIST Subscription.
222         * Value is in Integer format. Enable (1), Disable(0).
223         */
224        public static final int GZIP_FLAG = 23;
225        /**
226         * VOLTE Status for EAB/s status of Enabled (1), or Disabled (0).
227         * Value is in Integer format.
228         */
229        public static final int EAB_SETTING_ENABLED = 24;
230        /**
231         * Wi-Fi calling roaming status.
232         * Value is in Integer format. ON (1), OFF(0).
233         */
234        public static final int VOICE_OVER_WIFI_ROAMING = 25;
235        /**
236         * Wi-Fi calling modem - WfcModeFeatureValueConstants.
237         * Value is in Integer format.
238         */
239        public static final int VOICE_OVER_WIFI_MODE = 26;
240        /**
241         * Mobile data enabled.
242         * Value is in Integer format. On (1), OFF(0).
243         */
244        public static final int MOBILE_DATA_ENABLED = 27;
245        /**
246         * VoLTE user opted in status.
247         * Value is in Integer format. Opted-in (1) Opted-out (0).
248         */
249        public static final int VOLTE_USER_OPT_IN_STATUS = 28;
250        /**
251         * Proxy for Call Session Control Function(P-CSCF) address for Local-BreakOut(LBO).
252         * Value is in String format.
253         */
254        public static final int LBO_PCSCF_ADDRESS = 29;
255        /**
256         * Keep Alive Enabled for SIP.
257         * Value is in Integer format. On(1), OFF(0).
258         */
259        public static final int KEEP_ALIVE_ENABLED = 30;
260        /**
261         * Registration retry Base Time value in seconds.
262         * Value is in Integer format.
263         */
264        public static final int REGISTRATION_RETRY_BASE_TIME_SEC = 31;
265        /**
266         * Registration retry Max Time value in seconds.
267         * Value is in Integer format.
268         */
269        public static final int REGISTRATION_RETRY_MAX_TIME_SEC = 32;
270        /**
271         * Smallest RTP port for speech codec.
272         * Value is in integer format.
273         */
274        public static final int SPEECH_START_PORT = 33;
275        /**
276         * Largest RTP port for speech code.
277         * Value is in Integer format.
278         */
279        public static final int SPEECH_END_PORT = 34;
280        /**
281         * SIP Timer A's value in milliseconds. Timer A is the INVITE request
282         * retransmit interval, for UDP only.
283         * Value is in Integer format.
284         */
285        public static final int SIP_INVITE_REQ_RETX_INTERVAL_MSEC = 35;
286        /**
287         * SIP Timer B's value in milliseconds. Timer B is the wait time for
288         * INVITE message to be acknowledged.
289         * Value is in Integer format.
290         */
291        public static final int SIP_INVITE_RSP_WAIT_TIME_MSEC = 36;
292        /**
293         * SIP Timer D's value in milliseconds. Timer D is the wait time for
294         * response retransmits of the invite client transactions.
295         * Value is in Integer format.
296         */
297        public static final int SIP_INVITE_RSP_RETX_WAIT_TIME_MSEC = 37;
298        /**
299         * SIP Timer E's value in milliseconds. Timer E is the value Non-INVITE
300         * request retransmit interval, for UDP only.
301         * Value is in Integer format.
302         */
303        public static final int SIP_NON_INVITE_REQ_RETX_INTERVAL_MSEC = 38;
304        /**
305         * SIP Timer F's value in milliseconds. Timer F is the Non-INVITE transaction
306         * timeout timer.
307         * Value is in Integer format.
308         */
309        public static final int SIP_NON_INVITE_TXN_TIMEOUT_TIMER_MSEC = 39;
310        /**
311         * SIP Timer G's value in milliseconds. Timer G is the value of INVITE response
312         * retransmit interval.
313         * Value is in Integer format.
314         */
315        public static final int SIP_INVITE_RSP_RETX_INTERVAL_MSEC = 40;
316        /**
317         * SIP Timer H's value in milliseconds. Timer H is the value of wait time for
318         * ACK receipt.
319         * Value is in Integer format.
320         */
321        public static final int SIP_ACK_RECEIPT_WAIT_TIME_MSEC = 41;
322        /**
323         * SIP Timer I's value in milliseconds. Timer I is the value of wait time for
324         * ACK retransmits.
325         * Value is in Integer format.
326         */
327        public static final int SIP_ACK_RETX_WAIT_TIME_MSEC = 42;
328        /**
329         * SIP Timer J's value in milliseconds. Timer J is the value of wait time for
330         * non-invite request retransmission.
331         * Value is in Integer format.
332         */
333        public static final int SIP_NON_INVITE_REQ_RETX_WAIT_TIME_MSEC = 43;
334        /**
335         * SIP Timer K's value in milliseconds. Timer K is the value of wait time for
336         * non-invite response retransmits.
337         * Value is in Integer format.
338         */
339        public static final int SIP_NON_INVITE_RSP_RETX_WAIT_TIME_MSEC = 44;
340        /**
341         * AMR WB octet aligned dynamic payload type.
342         * Value is in Integer format.
343         */
344        public static final int AMR_WB_OCTET_ALIGNED_PT = 45;
345        /**
346         * AMR WB bandwidth efficient payload type.
347         * Value is in Integer format.
348         */
349        public static final int AMR_WB_BANDWIDTH_EFFICIENT_PT = 46;
350        /**
351         * AMR octet aligned dynamic payload type.
352         * Value is in Integer format.
353         */
354        public static final int AMR_OCTET_ALIGNED_PT = 47;
355        /**
356         * AMR bandwidth efficient payload type.
357         * Value is in Integer format.
358         */
359        public static final int AMR_BANDWIDTH_EFFICIENT_PT = 48;
360        /**
361         * DTMF WB payload type.
362         * Value is in Integer format.
363         */
364        public static final int DTMF_WB_PT = 49;
365        /**
366         * DTMF NB payload type.
367         * Value is in Integer format.
368         */
369        public static final int DTMF_NB_PT = 50;
370        /**
371         * AMR Default encoding mode.
372         * Value is in Integer format.
373         */
374        public static final int AMR_DEFAULT_MODE = 51;
375        /**
376         * SMS Public Service Identity.
377         * Value is in String format.
378         */
379        public static final int SMS_PSI = 52;
380
381        // Expand the operator config items as needed here, need to change
382        // PROVISIONED_CONFIG_END after that.
383        public static final int PROVISIONED_CONFIG_END = SMS_PSI;
384
385        // Expand the operator config items as needed here.
386    }
387
388    /**
389    * Defines IMS set operation status.
390    */
391    public static class OperationStatusConstants {
392        public static final int UNKNOWN = -1;
393        public static final int SUCCESS = 0;
394        public static final int FAILED =  1;
395        public static final int UNSUPPORTED_CAUSE_NONE = 2;
396        public static final int UNSUPPORTED_CAUSE_RAT = 3;
397        public static final int UNSUPPORTED_CAUSE_DISABLED = 4;
398    }
399
400    /**
401     * Defines IMS get operation values.
402     */
403    public static class OperationValuesConstants {
404        /**
405         * Values related to Video Quality
406         */
407        public static final int VIDEO_QUALITY_UNKNOWN = -1;
408        public static final int VIDEO_QUALITY_LOW = 0;
409        public static final int VIDEO_QUALITY_HIGH = 1;
410    }
411
412   /**
413    * Defines IMS feature value.
414    */
415    public static class FeatureValueConstants {
416        public static final int OFF = 0;
417        public static final int ON = 1;
418    }
419
420    /**
421     * Defines IMS feature value.
422     */
423    public static class WfcModeFeatureValueConstants {
424        public static final int WIFI_ONLY = 0;
425        public static final int CELLULAR_PREFERRED = 1;
426        public static final int WIFI_PREFERRED = 2;
427    }
428
429    public ImsConfig(IImsConfig iconfig, Context context) {
430        if (DBG) Rlog.d(TAG, "ImsConfig creates");
431        miConfig = iconfig;
432        mContext = context;
433    }
434
435    /**
436     * Gets the provisioned value for IMS service/capabilities parameters used by IMS stack.
437     * This function should not be called from the mainthread as it could block the
438     * mainthread.
439     *
440     * @param item, as defined in com.android.ims.ImsConfig#ConfigConstants.
441     * @return the value in Integer format.
442     *
443     * @throws ImsException if calling the IMS service results in an error.
444     */
445    public int getProvisionedValue(int item) throws ImsException {
446        int ret = 0;
447        try {
448            ret = miConfig.getProvisionedValue(item);
449        }  catch (RemoteException e) {
450            throw new ImsException("getValue()", e,
451                    ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE);
452        }
453        if (DBG) Rlog.d(TAG, "getProvisionedValue(): item = " + item + ", ret =" + ret);
454
455        return ret;
456    }
457
458    /**
459     * Gets the provisioned value for IMS service/capabilities parameters used by IMS stack.
460     * This function should not be called from the mainthread as it could block the
461     * mainthread.
462     *
463     * @param item, as defined in com.android.ims.ImsConfig#ConfigConstants.
464     * @return value in String format.
465     *
466     * @throws ImsException if calling the IMS service results in an error.
467     */
468    public String getProvisionedStringValue(int item) throws ImsException {
469        String ret = "Unknown";
470        try {
471            ret = miConfig.getProvisionedStringValue(item);
472        }  catch (RemoteException e) {
473            throw new ImsException("getProvisionedStringValue()", e,
474                    ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE);
475        }
476        if (DBG) Rlog.d(TAG, "getProvisionedStringValue(): item = " + item + ", ret =" + ret);
477
478        return ret;
479    }
480
481    /**
482     * Sets the value for IMS service/capabilities parameters by
483     * the operator device management entity.
484     * This function should not be called from main thread as it could block
485     * mainthread.
486     *
487     * @param item, as defined in com.android.ims.ImsConfig#ConfigConstants.
488     * @param value in Integer format.
489     * @return as defined in com.android.ims.ImsConfig#OperationStatusConstants
490     *
491     * @throws ImsException if calling the IMS service results in an error.
492     */
493    public int setProvisionedValue(int item, int value)
494            throws ImsException {
495        int ret = ImsConfig.OperationStatusConstants.UNKNOWN;
496        if (DBG) {
497            Rlog.d(TAG, "setProvisionedValue(): item = " + item +
498                    "value = " + value);
499        }
500        try {
501            ret = miConfig.setProvisionedValue(item, value);
502        }  catch (RemoteException e) {
503            throw new ImsException("setProvisionedValue()", e,
504                    ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE);
505        }
506        if (DBG) {
507            Rlog.d(TAG, "setProvisionedValue(): item = " + item +
508                    " value = " + value + " ret = " + ret);
509        }
510        return ret;
511    }
512
513    /**
514     * Sets the value for IMS service/capabilities parameters by
515     * the operator device management entity.
516     * This function should not be called from main thread as it could block
517     * mainthread.
518     *
519     * @param item, as defined in com.android.ims.ImsConfig#ConfigConstants.
520     * @param value in String format.
521     * @return as defined in com.android.ims.ImsConfig#OperationStatusConstants
522     *
523     * @throws ImsException if calling the IMS service results in an error.
524     */
525    public int setProvisionedStringValue(int item, String value)
526            throws ImsException {
527        int ret = ImsConfig.OperationStatusConstants.UNKNOWN;
528        try {
529            ret = miConfig.setProvisionedStringValue(item, value);
530        }  catch (RemoteException e) {
531            throw new ImsException("setProvisionedStringValue()", e,
532                    ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE);
533        }
534        if (DBG) {
535            Rlog.d(TAG, "setProvisionedStringValue(): item = " + item +
536                    ", value =" + value);
537        }
538        return ret;
539    }
540
541    /**
542     * Gets the value for IMS feature item for specified network type.
543     *
544     * @param feature, defined as in FeatureConstants.
545     * @param network, defined as in android.telephony.TelephonyManager#NETWORK_TYPE_XXX.
546     * @param listener, provided to be notified for the feature on/off status.
547     * @return void
548     *
549     * @throws ImsException if calling the IMS service results in an error.
550     */
551    public void getFeatureValue(int feature, int network,
552            ImsConfigListener listener) throws ImsException {
553        if (DBG) {
554            Rlog.d(TAG, "getFeatureValue: feature = " + feature + ", network =" + network +
555                    ", listener =" + listener);
556        }
557        try {
558            miConfig.getFeatureValue(feature, network, listener);
559        } catch (RemoteException e) {
560            throw new ImsException("getFeatureValue()", e,
561                    ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE);
562        }
563    }
564
565    /**
566     * Sets the value for IMS feature item for specified network type.
567     *
568     * @param feature, as defined in FeatureConstants.
569     * @param network, as defined in android.telephony.TelephonyManager#NETWORK_TYPE_XXX.
570     * @param value, as defined in FeatureValueConstants.
571     * @param listener, provided if caller needs to be notified for set result.
572     * @return void
573     *
574     * @throws ImsException if calling the IMS service results in an error.
575     */
576    public void setFeatureValue(int feature, int network, int value,
577            ImsConfigListener listener) throws ImsException {
578        if (DBG) {
579            Rlog.d(TAG, "setFeatureValue: feature = " + feature + ", network =" + network +
580                    ", value =" + value + ", listener =" + listener);
581        }
582        try {
583            miConfig.setFeatureValue(feature, network, value, listener);
584        } catch (RemoteException e) {
585            throw new ImsException("setFeatureValue()", e,
586                    ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE);
587        }
588    }
589
590    /**
591     * Gets the value for IMS Volte provisioned.
592     * It should be the same as operator provisioned value if applies.
593     *
594     * @return boolean
595     *
596     * @throws ImsException if calling the IMS service results in an error.
597     */
598    public boolean getVolteProvisioned() throws ImsException {
599        try {
600           return miConfig.getVolteProvisioned();
601        } catch (RemoteException e) {
602            throw new ImsException("getVolteProvisioned()", e,
603                    ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE);
604        }
605    }
606
607    /**
608     * Gets the value for IMS feature item for video call quality.
609     *
610     * @param listener, provided if caller needs to be notified for set result.
611     * @return void
612     *
613     * @throws ImsException if calling the IMS service results in an error.
614     */
615    public void getVideoQuality(ImsConfigListener listener) throws ImsException {
616        try {
617            miConfig.getVideoQuality(listener);
618        } catch (RemoteException e) {
619            throw new ImsException("getVideoQuality()", e,
620                    ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE);
621        }
622    }
623
624    /**
625     * Sets the value for IMS feature item video quality.
626     *
627     * @param quality, defines the value of video quality.
628     * @param listener, provided if caller needs to be notified for set result.
629     * @return void
630     *
631     * @throws ImsException if calling the IMS service results in an error.
632     */
633     public void setVideoQuality(int quality, ImsConfigListener listener) throws ImsException {
634        try {
635            miConfig.setVideoQuality(quality, listener);
636        } catch (RemoteException e) {
637            throw new ImsException("setVideoQuality()", e,
638                    ImsReasonInfo.CODE_LOCAL_SERVICE_UNAVAILABLE);
639        }
640     }
641}
642