Sailesh Nepal | 129f1e6 | 2014-03-17 21:13:00 -0700 | [diff] [blame] | 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 | */ |
Evan Charlton | 1063e28 | 2014-03-05 19:31:21 -0800 | [diff] [blame] | 16 | |
| 17 | package com.android.telecomm; |
| 18 | |
| 19 | import android.provider.Settings; |
Evan Charlton | 1063e28 | 2014-03-05 19:31:21 -0800 | [diff] [blame] | 20 | |
| 21 | /** |
| 22 | * A helper class which serves only to make it easier to lookup timeout values. This class should |
| 23 | * never be instantiated, and only accessed through the {@link #get(String, long)} method. |
| 24 | * |
| 25 | * These methods are safe to call from any thread, including the UI thread. |
| 26 | */ |
| 27 | public final class Timeouts { |
| 28 | /** A prefix to use for all keys so to not clobber the global namespace. */ |
| 29 | private static final String PREFIX = "telecomm."; |
| 30 | |
| 31 | private Timeouts() {} |
| 32 | |
| 33 | /** |
| 34 | * Returns the timeout value from Settings or the default value if it hasn't been changed. This |
| 35 | * method is safe to call from any thread, including the UI thread. |
| 36 | * |
| 37 | * @param key Settings key to retrieve. |
| 38 | * @param defaultValue Default value, in milliseconds. |
| 39 | * @return The timeout value from Settings or the default value if it hasn't been changed. |
| 40 | */ |
| 41 | private static long get(String key, long defaultValue) { |
| 42 | return Settings.Secure.getLong( |
| 43 | TelecommApp.getInstance().getContentResolver(), PREFIX + key, defaultValue); |
| 44 | } |
| 45 | |
| 46 | /** |
Santos Cordon | 2174fb5 | 2014-05-29 08:22:56 -0700 | [diff] [blame] | 47 | * Returns the longest period, in milliseconds, to wait for the query for direct-to-voicemail |
| 48 | * to complete. If the query goes beyond this timeout, the incoming call screen is shown to the |
| 49 | * user. |
| 50 | */ |
Santos Cordon | a161070 | 2014-06-04 20:22:56 -0700 | [diff] [blame] | 51 | public static long getDirectToVoicemailMillis() { |
Santos Cordon | 2174fb5 | 2014-05-29 08:22:56 -0700 | [diff] [blame] | 52 | return get("direct_to_voicemail_ms", 500L); |
| 53 | } |
Santos Cordon | a161070 | 2014-06-04 20:22:56 -0700 | [diff] [blame] | 54 | |
| 55 | /** |
| 56 | * Returns the amount of time that a connection service has to respond to a "conference" action. |
| 57 | */ |
| 58 | public static long getConferenceCallExpireMillis() { |
| 59 | return get("conference_call_expire_ms", 15 * 1000L); |
| 60 | } |
Evan Charlton | 1063e28 | 2014-03-05 19:31:21 -0800 | [diff] [blame] | 61 | } |