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.presence; 30 31 import android.content.Context; 32 33 import com.android.ims.ImsConfig; 34 import com.android.ims.ImsException; 35 import com.android.ims.ImsManager; 36 37 import com.android.ims.internal.Logger; 38 39 public class PresenceSetting { 40 private static Logger logger = Logger.getLogger("PresenceSetting"); 41 private static Context sContext = null; 42 init(Context context)43 public static void init(Context context) { 44 sContext = context; 45 } 46 getCapabilityPollInterval()47 public static long getCapabilityPollInterval() { 48 long value = -1; 49 if (sContext != null) { 50 ImsManager imsManager = ImsManager.getInstance(sContext, 0); 51 if (imsManager != null) { 52 try { 53 ImsConfig imsConfig = imsManager.getConfigInterface(); 54 if (imsConfig != null) { 55 value = imsConfig.getProvisionedValue( 56 ImsConfig.ConfigConstants.CAPABILITIES_POLL_INTERVAL); 57 logger.debug("Read ImsConfig_CapabilityPollInterval: " + value); 58 } 59 } catch (ImsException ex) { 60 } 61 } 62 } 63 if (value <= 0) { 64 value = 604800L; 65 logger.error("Failed to get CapabilityPollInterval, the default: " + value); 66 } 67 return value; 68 } 69 getCapabilityCacheExpiration()70 public static long getCapabilityCacheExpiration() { 71 long value = -1; 72 if (sContext != null) { 73 ImsManager imsManager = ImsManager.getInstance(sContext, 0); 74 if (imsManager != null) { 75 try { 76 ImsConfig imsConfig = imsManager.getConfigInterface(); 77 if (imsConfig != null) { 78 value = imsConfig.getProvisionedValue( 79 ImsConfig.ConfigConstants.CAPABILITIES_CACHE_EXPIRATION); 80 logger.debug("Read ImsConfig_CapabilityCacheExpiration: " + value); 81 } 82 } catch (ImsException ex) { 83 } 84 } 85 } 86 if (value <= 0) { 87 value = 7776000L; 88 logger.error("Failed to get CapabilityCacheExpiration, the default: " + value); 89 } 90 return value; 91 } 92 getPublishTimer()93 public static int getPublishTimer() { 94 int value = -1; 95 if (sContext != null) { 96 ImsManager imsManager = ImsManager.getInstance(sContext, 0); 97 if (imsManager != null) { 98 try { 99 ImsConfig imsConfig = imsManager.getConfigInterface(); 100 if (imsConfig != null) { 101 value = imsConfig.getProvisionedValue( 102 ImsConfig.ConfigConstants.PUBLISH_TIMER); 103 logger.debug("Read ImsConfig_PublishTimer: " + value); 104 } 105 } catch (ImsException ex) { 106 } 107 } 108 } 109 if (value <= 0) { 110 value = (int)1200; 111 logger.error("Failed to get PublishTimer, the default: " + value); 112 } 113 return value; 114 } 115 getPublishTimerExtended()116 public static int getPublishTimerExtended() { 117 int value = -1; 118 if (sContext != null) { 119 ImsManager imsManager = ImsManager.getInstance(sContext, 0); 120 if (imsManager != null) { 121 try { 122 ImsConfig imsConfig = imsManager.getConfigInterface(); 123 if (imsConfig != null) { 124 value = imsConfig.getProvisionedValue( 125 ImsConfig.ConfigConstants.PUBLISH_TIMER_EXTENDED); 126 logger.debug("Read ImsConfig_PublishTimerExtended: " + value); 127 } 128 } catch (ImsException ex) { 129 } 130 } 131 } 132 if (value <= 0) { 133 value = (int)86400; 134 logger.error("Failed to get PublishTimerExtended, the default: " + value); 135 } 136 return value; 137 } 138 getMaxNumberOfEntriesInRequestContainedList()139 public static int getMaxNumberOfEntriesInRequestContainedList() { 140 int value = -1; 141 if (sContext != null) { 142 ImsManager imsManager = ImsManager.getInstance(sContext, 0); 143 if (imsManager != null) { 144 try { 145 ImsConfig imsConfig = imsManager.getConfigInterface(); 146 if (imsConfig != null) { 147 value = imsConfig.getProvisionedValue( 148 ImsConfig.ConfigConstants.MAX_NUMENTRIES_IN_RCL); 149 logger.debug("Read ImsConfig_MaxNumEntriesInRCL: " + value); 150 } 151 } catch (ImsException ex) { 152 } 153 } 154 } 155 if (value <= 0) { 156 value = (int)100; 157 logger.error("Failed to get MaxNumEntriesInRCL, the default: " + value); 158 } 159 return value; 160 } 161 getCapabilityPollListSubscriptionExpiration()162 public static int getCapabilityPollListSubscriptionExpiration() { 163 int value = -1; 164 if (sContext != null) { 165 ImsManager imsManager = ImsManager.getInstance(sContext, 0); 166 if (imsManager != null) { 167 try { 168 ImsConfig imsConfig = imsManager.getConfigInterface(); 169 if (imsConfig != null) { 170 value = imsConfig.getProvisionedValue( 171 ImsConfig.ConfigConstants.CAPAB_POLL_LIST_SUB_EXP); 172 logger.debug("Read ImsConfig_CapabPollListSubExp: " + value); 173 } 174 } catch (ImsException ex) { 175 } 176 } 177 } 178 if (value <= 0) { 179 value = (int)30; 180 logger.error("Failed to get CapabPollListSubExp, the default: " + value); 181 } 182 return value; 183 } 184 } 185 186