• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2015, Motorola Mobility LLC
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *     - Redistributions of source code must retain the above copyright
8  *       notice, this list of conditions and the following disclaimer.
9  *     - Redistributions in binary form must reproduce the above copyright
10  *       notice, this list of conditions and the following disclaimer in the
11  *       documentation and/or other materials provided with the distribution.
12  *     - Neither the name of Motorola Mobility nor the
13  *       names of its contributors may be used to endorse or promote products
14  *       derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MOTOROLA MOBILITY LLC BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
26  * DAMAGE.
27  */
28 
29 package com.android.service.ims;
30 
31 import java.lang.String;
32 
33 import android.os.PersistableBundle;
34 import android.telephony.CarrierConfigManager;
35 import android.telephony.TelephonyManager;
36 import android.content.Context;
37 import com.android.ims.ImsConfig;
38 import com.android.ims.ImsManager;
39 import com.android.ims.ImsException;
40 import android.os.SystemProperties;
41 
42 import com.android.ims.RcsManager.ResultCode;
43 
44 import com.android.ims.internal.Logger;
45 
46 public class RcsSettingUtils{
47     /*
48      * The logger
49      */
50     static private Logger logger = Logger.getLogger("RcsSettingUtils");
51 
RcsSettingUtils()52     public RcsSettingUtils() {
53     }
54 
isFeatureProvisioned(Context context, int featureId, boolean defaultValue)55     public static boolean isFeatureProvisioned(Context context,
56             int featureId, boolean defaultValue) {
57         CarrierConfigManager configManager = (CarrierConfigManager)
58                 context.getSystemService(Context.CARRIER_CONFIG_SERVICE);
59         // Don't need provision.
60         if (configManager != null) {
61             PersistableBundle config = configManager.getConfig();
62             if (config != null && !config.getBoolean(
63                     CarrierConfigManager.KEY_CARRIER_VOLTE_PROVISIONED_BOOL)) {
64                 return true;
65             }
66         }
67 
68         boolean provisioned = defaultValue;
69         ImsManager imsManager = ImsManager.getInstance(context, 0);
70         if (imsManager != null) {
71             try {
72                 ImsConfig imsConfig = imsManager.getConfigInterface();
73                 if (imsConfig != null) {
74                     provisioned = imsConfig.getProvisionedValue(featureId)
75                             == ImsConfig.FeatureValueConstants.ON;
76                 }
77             } catch (ImsException ex) {
78             }
79         }
80 
81         logger.debug("featureId=" + featureId + " provisioned=" + provisioned);
82         return provisioned;
83     }
84 
isVowifiProvisioned(Context context)85     public static boolean isVowifiProvisioned(Context context) {
86         return isFeatureProvisioned(context,
87                 ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED, false);
88     }
89 
isLvcProvisioned(Context context)90     public static boolean isLvcProvisioned(Context context) {
91         return isFeatureProvisioned(context,
92                 ImsConfig.ConfigConstants.LVC_SETTING_ENABLED, false);
93     }
94 
isEabProvisioned(Context context)95     public static boolean isEabProvisioned(Context context) {
96         return isFeatureProvisioned(context,
97                 ImsConfig.ConfigConstants.EAB_SETTING_ENABLED, false);
98     }
99 
getSIPT1Timer(Context context)100     public static int getSIPT1Timer(Context context) {
101         int sipT1Timer = 0;
102 
103         ImsManager imsManager = ImsManager.getInstance(context, 0);
104         if (imsManager != null) {
105             try {
106                 ImsConfig imsConfig = imsManager.getConfigInterface();
107                 if (imsConfig != null) {
108                     sipT1Timer = imsConfig.getProvisionedValue(
109                             ImsConfig.ConfigConstants.SIP_T1_TIMER);
110                 }
111             } catch (ImsException ex) {
112             }
113         }
114 
115         logger.debug("sipT1Timer=" + sipT1Timer);
116         return sipT1Timer;
117     }
118 
119     /**
120      * Capability discovery status of Enabled (1), or Disabled (0).
121      */
getCapabilityDiscoveryEnabled(Context context)122     public static boolean getCapabilityDiscoveryEnabled(Context context) {
123         boolean capabilityDiscoveryEnabled = false;
124 
125         ImsManager imsManager = ImsManager.getInstance(context, 0);
126         if (imsManager != null) {
127             try {
128                 ImsConfig imsConfig = imsManager.getConfigInterface();
129                 if (imsConfig != null) {
130                     capabilityDiscoveryEnabled = imsConfig.getProvisionedValue(
131                             ImsConfig.ConfigConstants.CAPABILITY_DISCOVERY_ENABLED)
132                             == ImsConfig.FeatureValueConstants.ON;
133                 }
134             } catch (ImsException ex) {
135             }
136         }
137 
138         logger.debug("capabilityDiscoveryEnabled=" + capabilityDiscoveryEnabled);
139         return capabilityDiscoveryEnabled;
140     }
141 
142     /**
143      * The Maximum number of MDNs contained in one Request Contained List.
144      */
getMaxNumbersInRCL(Context context)145     public static int getMaxNumbersInRCL(Context context) {
146         int maxNumbersInRCL = 100;
147 
148         ImsManager imsManager = ImsManager.getInstance(context, 0);
149         if (imsManager != null) {
150             try {
151                 ImsConfig imsConfig = imsManager.getConfigInterface();
152                 if (imsConfig != null) {
153                     maxNumbersInRCL = imsConfig.getProvisionedValue(
154                             ImsConfig.ConfigConstants.MAX_NUMENTRIES_IN_RCL);
155                 }
156             } catch (ImsException ex) {
157             }
158         }
159 
160         logger.debug("maxNumbersInRCL=" + maxNumbersInRCL);
161         return maxNumbersInRCL;
162     }
163 
164     /**
165      * Expiration timer for subscription of a Request Contained List, used in capability polling.
166      */
getCapabPollListSubExp(Context context)167     public static int getCapabPollListSubExp(Context context) {
168         int capabPollListSubExp = 30;
169 
170         ImsManager imsManager = ImsManager.getInstance(context, 0);
171         if (imsManager != null) {
172             try {
173                 ImsConfig imsConfig = imsManager.getConfigInterface();
174                 if (imsConfig != null) {
175                     capabPollListSubExp = imsConfig.getProvisionedValue(
176                             ImsConfig.ConfigConstants.CAPAB_POLL_LIST_SUB_EXP);
177                 }
178             } catch (ImsException ex) {
179             }
180         }
181 
182         logger.debug("capabPollListSubExp=" + capabPollListSubExp);
183         return capabPollListSubExp;
184     }
185 
186     /**
187      * Peiod of time the availability information of a contact is cached on device.
188      */
getAvailabilityCacheExpiration(Context context)189     public static int getAvailabilityCacheExpiration(Context context) {
190         int availabilityCacheExpiration = 30;
191 
192         ImsManager imsManager = ImsManager.getInstance(context, 0);
193         if (imsManager != null) {
194             try {
195                 ImsConfig imsConfig = imsManager.getConfigInterface();
196                 if (imsConfig != null) {
197                     availabilityCacheExpiration = imsConfig.getProvisionedValue(
198                             ImsConfig.ConfigConstants.AVAILABILITY_CACHE_EXPIRATION);
199                 }
200             } catch (ImsException ex) {
201             }
202         }
203 
204         logger.debug("availabilityCacheExpiration=" + availabilityCacheExpiration);
205         return availabilityCacheExpiration;
206     }
207 
isMobileDataEnabled(Context context)208     public static boolean isMobileDataEnabled(Context context) {
209         boolean mobileDataEnabled = false;
210         ImsManager imsManager = ImsManager.getInstance(context, 0);
211         if (imsManager != null) {
212             try {
213                 ImsConfig imsConfig = imsManager.getConfigInterface();
214                 if (imsConfig != null) {
215                     mobileDataEnabled = imsConfig.getProvisionedValue(
216                             ImsConfig.ConfigConstants.MOBILE_DATA_ENABLED)
217                             == ImsConfig.FeatureValueConstants.ON;
218                 }
219             } catch (ImsException ex) {
220             }
221         }
222 
223         logger.debug("mobileDataEnabled=" + mobileDataEnabled);
224         return mobileDataEnabled;
225     }
226 
setMobileDataEnabled(Context context, boolean mobileDataEnabled)227     public static void setMobileDataEnabled(Context context, boolean mobileDataEnabled) {
228         logger.debug("mobileDataEnabled=" + mobileDataEnabled);
229         ImsManager imsManager = ImsManager.getInstance(context, 0);
230         if (imsManager != null) {
231             try {
232                 ImsConfig imsConfig = imsManager.getConfigInterface();
233                 if (imsConfig != null) {
234                     imsConfig.setProvisionedValue(
235                             ImsConfig.ConfigConstants.MOBILE_DATA_ENABLED, mobileDataEnabled?
236                             ImsConfig.FeatureValueConstants.ON:ImsConfig.FeatureValueConstants.OFF);
237                 }
238             } catch (ImsException ex) {
239                 logger.debug("ImsException", ex);
240             }
241         }
242     }
243 
getPublishThrottle(Context context)244     public static int getPublishThrottle(Context context) {
245         int publishThrottle = 60000;
246 
247         ImsManager imsManager = ImsManager.getInstance(context, 0);
248         if (imsManager != null) {
249             try {
250                 ImsConfig imsConfig = imsManager.getConfigInterface();
251                 if (imsConfig != null) {
252                     publishThrottle = imsConfig.getProvisionedValue(
253                             ImsConfig.ConfigConstants.SOURCE_THROTTLE_PUBLISH);
254                 }
255             } catch (ImsException ex) {
256             }
257         }
258 
259         logger.debug("publishThrottle=" + publishThrottle);
260         return publishThrottle;
261     }
262 }
263 
264