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