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 1991d43cf9c985cc5a83795f256ef5c46ebb8fbdc1Tyler Gunnimport android.content.ContentResolver; 201063e2854a5904e8628894e0b5f32d46087c4639Evan Charltonimport android.provider.Settings; 211063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton 221063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton/** 231063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton * A helper class which serves only to make it easier to lookup timeout values. This class should 241063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton * never be instantiated, and only accessed through the {@link #get(String, long)} method. 251063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton * 261063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton * These methods are safe to call from any thread, including the UI thread. 271063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton */ 281063e2854a5904e8628894e0b5f32d46087c4639Evan Charltonpublic final class Timeouts { 291063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton /** A prefix to use for all keys so to not clobber the global namespace. */ 307cc70b4f0ad1064a4a0dce6056ad82b205887160Tyler Gunn private static final String PREFIX = "telecom."; 311063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton 321063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton private Timeouts() {} 331063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton 341063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton /** 351063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton * Returns the timeout value from Settings or the default value if it hasn't been changed. This 361063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton * method is safe to call from any thread, including the UI thread. 371063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton * 3891d43cf9c985cc5a83795f256ef5c46ebb8fbdc1Tyler Gunn * @param contentResolver The content resolved. 391063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton * @param key Settings key to retrieve. 401063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton * @param defaultValue Default value, in milliseconds. 411063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton * @return The timeout value from Settings or the default value if it hasn't been changed. 421063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton */ 4391d43cf9c985cc5a83795f256ef5c46ebb8fbdc1Tyler Gunn private static long get(ContentResolver contentResolver, String key, long defaultValue) { 4491d43cf9c985cc5a83795f256ef5c46ebb8fbdc1Tyler Gunn return Settings.Secure.getLong(contentResolver, PREFIX + key, defaultValue); 451063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton } 461063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton 471063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton /** 482174fb56907fddf5680355e097f4425f837983e2Santos Cordon * Returns the longest period, in milliseconds, to wait for the query for direct-to-voicemail 492174fb56907fddf5680355e097f4425f837983e2Santos Cordon * to complete. If the query goes beyond this timeout, the incoming call screen is shown to the 502174fb56907fddf5680355e097f4425f837983e2Santos Cordon * user. 512174fb56907fddf5680355e097f4425f837983e2Santos Cordon */ 5291d43cf9c985cc5a83795f256ef5c46ebb8fbdc1Tyler Gunn public static long getDirectToVoicemailMillis(ContentResolver contentResolver) { 5391d43cf9c985cc5a83795f256ef5c46ebb8fbdc1Tyler Gunn return get(contentResolver, "direct_to_voicemail_ms", 500L); 542174fb56907fddf5680355e097f4425f837983e2Santos Cordon } 55cf5b2918ca58b155911a66222ae5b4d21cb5b8ecSantos Cordon 56cf5b2918ca58b155911a66222ae5b4d21cb5b8ecSantos Cordon /** 57cf5b2918ca58b155911a66222ae5b4d21cb5b8ecSantos Cordon * Returns the amount of time to wait before disconnecting a call that was canceled via 58cf5b2918ca58b155911a66222ae5b4d21cb5b8ecSantos Cordon * NEW_OUTGOING_CALL broadcast. This timeout allows apps which repost the call using a gateway 59cf5b2918ca58b155911a66222ae5b4d21cb5b8ecSantos Cordon * to reuse the existing call, preventing the call from causing a start->end->start jank in the 60cf5b2918ca58b155911a66222ae5b4d21cb5b8ecSantos Cordon * in-call UI. 61cf5b2918ca58b155911a66222ae5b4d21cb5b8ecSantos Cordon */ 62cf5b2918ca58b155911a66222ae5b4d21cb5b8ecSantos Cordon public static long getNewOutgoingCallCancelMillis(ContentResolver contentResolver) { 638d3f269fcc8853b2d5ce467cdce6ef27b0122bf8Yorke Lee return get(contentResolver, "new_outgoing_call_cancel_ms", 400L); 64cf5b2918ca58b155911a66222ae5b4d21cb5b8ecSantos Cordon } 65a469f76c1710a945933910840f11f9fda0445d82Nancy Chen 66a469f76c1710a945933910840f11f9fda0445d82Nancy Chen /** 67a469f76c1710a945933910840f11f9fda0445d82Nancy Chen * Returns the amount of time to play each DTMF tone after post dial continue. 68a469f76c1710a945933910840f11f9fda0445d82Nancy Chen * This timeout allows the current tone to play for a certain amount of time before either being 69a469f76c1710a945933910840f11f9fda0445d82Nancy Chen * interrupted by the next tone or terminated. 70a469f76c1710a945933910840f11f9fda0445d82Nancy Chen */ 71a469f76c1710a945933910840f11f9fda0445d82Nancy Chen public static long getDelayBetweenDtmfTonesMillis(ContentResolver contentResolver) { 72a469f76c1710a945933910840f11f9fda0445d82Nancy Chen return get(contentResolver, "delay_between_dtmf_tones_ms", 300L); 73a469f76c1710a945933910840f11f9fda0445d82Nancy Chen } 74a469f76c1710a945933910840f11f9fda0445d82Nancy Chen 75646fa3d6eaea71fb4c3270fde1a30eeb7c5e4288Sailesh Nepal /** 76646fa3d6eaea71fb4c3270fde1a30eeb7c5e4288Sailesh Nepal * Returns the amount of time to wait for an emergency call to be placed before routing to 77646fa3d6eaea71fb4c3270fde1a30eeb7c5e4288Sailesh Nepal * a different call service. A value of 0 or less means no timeout should be used. 78646fa3d6eaea71fb4c3270fde1a30eeb7c5e4288Sailesh Nepal */ 79646fa3d6eaea71fb4c3270fde1a30eeb7c5e4288Sailesh Nepal public static long getEmergencyCallTimeoutMillis(ContentResolver contentResolver) { 80646fa3d6eaea71fb4c3270fde1a30eeb7c5e4288Sailesh Nepal return get(contentResolver, "emergency_call_timeout_millis", 25000L /* 25 seconds */); 81646fa3d6eaea71fb4c3270fde1a30eeb7c5e4288Sailesh Nepal } 82646fa3d6eaea71fb4c3270fde1a30eeb7c5e4288Sailesh Nepal 83646fa3d6eaea71fb4c3270fde1a30eeb7c5e4288Sailesh Nepal /** 84646fa3d6eaea71fb4c3270fde1a30eeb7c5e4288Sailesh Nepal * Returns the amount of time to wait for an emergency call to be placed before routing to 85646fa3d6eaea71fb4c3270fde1a30eeb7c5e4288Sailesh Nepal * a different call service. This timeout is used only when the radio is powered off (for 86646fa3d6eaea71fb4c3270fde1a30eeb7c5e4288Sailesh Nepal * example in airplane mode). A value of 0 or less means no timeout should be used. 87646fa3d6eaea71fb4c3270fde1a30eeb7c5e4288Sailesh Nepal */ 88646fa3d6eaea71fb4c3270fde1a30eeb7c5e4288Sailesh Nepal public static long getEmergencyCallTimeoutRadioOffMillis(ContentResolver contentResolver) { 89646fa3d6eaea71fb4c3270fde1a30eeb7c5e4288Sailesh Nepal return get(contentResolver, "emergency_call_timeout_radio_off_millis", 90646fa3d6eaea71fb4c3270fde1a30eeb7c5e4288Sailesh Nepal 60000L /* 1 minute */); 91646fa3d6eaea71fb4c3270fde1a30eeb7c5e4288Sailesh Nepal } 924995e781ab0842212ef7d78cffa94bf5dcedb47eRoshan Pius 934995e781ab0842212ef7d78cffa94bf5dcedb47eRoshan Pius /** 944995e781ab0842212ef7d78cffa94bf5dcedb47eRoshan Pius * Returns the amount of delay before unbinding the in-call services after all the calls 954995e781ab0842212ef7d78cffa94bf5dcedb47eRoshan Pius * are removed. 964995e781ab0842212ef7d78cffa94bf5dcedb47eRoshan Pius */ 974995e781ab0842212ef7d78cffa94bf5dcedb47eRoshan Pius public static long getCallRemoveUnbindInCallServicesDelay(ContentResolver contentResolver) { 984995e781ab0842212ef7d78cffa94bf5dcedb47eRoshan Pius return get(contentResolver, "call_remove_unbind_in_call_services_delay", 994995e781ab0842212ef7d78cffa94bf5dcedb47eRoshan Pius 2000L /* 2 seconds */); 1004995e781ab0842212ef7d78cffa94bf5dcedb47eRoshan Pius } 1011063e2854a5904e8628894e0b5f32d46087c4639Evan Charlton} 102