blob: 3ae3f1d4d31f54cd2284c0d1b0dc8daf7eebfc66 [file] [log] [blame]
Sailesh Nepal129f1e62014-03-17 21:13:00 -07001/*
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 Charlton1063e282014-03-05 19:31:21 -080016
17package com.android.telecomm;
18
19import android.provider.Settings;
Evan Charlton1063e282014-03-05 19:31:21 -080020
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 */
27public 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 Cordon2174fb52014-05-29 08:22:56 -070047 * 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 Cordona1610702014-06-04 20:22:56 -070051 public static long getDirectToVoicemailMillis() {
Santos Cordon2174fb52014-05-29 08:22:56 -070052 return get("direct_to_voicemail_ms", 500L);
53 }
Santos Cordona1610702014-06-04 20:22:56 -070054
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 Charlton1063e282014-03-05 19:31:21 -080061}