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