Timeouts.java revision 7cc70b4f0ad1064a4a0dce6056ad82b205887160
1129f1e63c578e8beb98b87d8cd3a77cb2273dc88Sailesh Nepal/* 2129f1e63c578e8beb98b87d8cd3a77cb2273dc88Sailesh Nepal * Copyright (C) 2014 The Android Open Source Project 3129f1e63c578e8beb98b87d8cd3a77cb2273dc88Sailesh Nepal * 4129f1e63c578e8beb98b87d8cd3a77cb2273dc88Sailesh Nepal * Licensed under the Apache License, Version 2.0 (the "License"); 5129f1e63c578e8beb98b87d8cd3a77cb2273dc88Sailesh Nepal * you may not use this file except in compliance with the License. 6129f1e63c578e8beb98b87d8cd3a77cb2273dc88Sailesh Nepal * You may obtain a copy of the License at 7129f1e63c578e8beb98b87d8cd3a77cb2273dc88Sailesh Nepal * 8129f1e63c578e8beb98b87d8cd3a77cb2273dc88Sailesh Nepal * http://www.apache.org/licenses/LICENSE-2.0 9129f1e63c578e8beb98b87d8cd3a77cb2273dc88Sailesh Nepal * 10129f1e63c578e8beb98b87d8cd3a77cb2273dc88Sailesh Nepal * Unless required by applicable law or agreed to in writing, software 11129f1e63c578e8beb98b87d8cd3a77cb2273dc88Sailesh Nepal * distributed under the License is distributed on an "AS IS" BASIS, 12129f1e63c578e8beb98b87d8cd3a77cb2273dc88Sailesh Nepal * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13129f1e63c578e8beb98b87d8cd3a77cb2273dc88Sailesh Nepal * See the License for the specific language governing permissions and 14129f1e63c578e8beb98b87d8cd3a77cb2273dc88Sailesh Nepal * limitations under the License. 15129f1e63c578e8beb98b87d8cd3a77cb2273dc88Sailesh Nepal */ 161063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton 177cc70b4f0ad1064a4a0dce6056ad82b205887160Tyler Gunnpackage com.android.server.telecom; 181063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton 191063e2854a5904e8628894e0b5f32d46087c4639Evan Charltonimport android.provider.Settings; 201063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton 211063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton/** 221063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton * A helper class which serves only to make it easier to lookup timeout values. This class should 231063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton * never be instantiated, and only accessed through the {@link #get(String, long)} method. 241063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton * 251063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton * These methods are safe to call from any thread, including the UI thread. 261063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton */ 271063e2854a5904e8628894e0b5f32d46087c4639Evan Charltonpublic final class Timeouts { 281063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton /** A prefix to use for all keys so to not clobber the global namespace. */ 297cc70b4f0ad1064a4a0dce6056ad82b205887160Tyler Gunn private static final String PREFIX = "telecom."; 301063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton 311063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton private Timeouts() {} 321063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton 331063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton /** 341063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton * Returns the timeout value from Settings or the default value if it hasn't been changed. This 351063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton * method is safe to call from any thread, including the UI thread. 361063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton * 371063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton * @param key Settings key to retrieve. 381063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton * @param defaultValue Default value, in milliseconds. 391063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton * @return The timeout value from Settings or the default value if it hasn't been changed. 401063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton */ 411063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton private static long get(String key, long defaultValue) { 421063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton return Settings.Secure.getLong( 437cc70b4f0ad1064a4a0dce6056ad82b205887160Tyler Gunn TelecomApp.getInstance().getContentResolver(), PREFIX + key, defaultValue); 441063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton } 451063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton 461063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton /** 472174fb56907fddf5680355e097f4425f837983e2Santos Cordon * Returns the longest period, in milliseconds, to wait for the query for direct-to-voicemail 482174fb56907fddf5680355e097f4425f837983e2Santos Cordon * to complete. If the query goes beyond this timeout, the incoming call screen is shown to the 492174fb56907fddf5680355e097f4425f837983e2Santos Cordon * user. 502174fb56907fddf5680355e097f4425f837983e2Santos Cordon */ 51a161070ea054f91a5b2d5b4e3413381134d548b8Santos Cordon public static long getDirectToVoicemailMillis() { 522174fb56907fddf5680355e097f4425f837983e2Santos Cordon return get("direct_to_voicemail_ms", 500L); 532174fb56907fddf5680355e097f4425f837983e2Santos Cordon } 541063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton} 55