blob: d13091f7f09bfb63d0f79e589790a7fbf53f3717 [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;
20import android.telecomm.CallServiceProvider;
Evan Charlton1063e282014-03-05 19:31:21 -080021
22/**
23 * A helper class which serves only to make it easier to lookup timeout values. This class should
24 * never be instantiated, and only accessed through the {@link #get(String, long)} method.
25 *
26 * These methods are safe to call from any thread, including the UI thread.
27 */
28public final class Timeouts {
29 /** A prefix to use for all keys so to not clobber the global namespace. */
30 private static final String PREFIX = "telecomm.";
31
32 private Timeouts() {}
33
34 /**
35 * Returns the timeout value from Settings or the default value if it hasn't been changed. This
36 * method is safe to call from any thread, including the UI thread.
37 *
38 * @param key Settings key to retrieve.
39 * @param defaultValue Default value, in milliseconds.
40 * @return The timeout value from Settings or the default value if it hasn't been changed.
41 */
42 private static long get(String key, long defaultValue) {
43 return Settings.Secure.getLong(
44 TelecommApp.getInstance().getContentResolver(), PREFIX + key, defaultValue);
45 }
46
47 /**
48 * @return The longest period in milliseconds each {@link CallServiceProvider} lookup cycle is
49 * allowed to span over.
50 */
Sailesh Nepal8c85dee2014-04-07 22:21:40 -070051 public static long getProviderLookupMillis() {
Sailesh Nepalee642762014-03-06 20:41:02 -080052 return get("provider_lookup_ms", 1000);
Evan Charlton1063e282014-03-05 19:31:21 -080053 }
54
55 /**
Evan Charlton1063e282014-03-05 19:31:21 -080056 * Returns the longest period, in milliseconds, each new outgoing call is allowed to wait before
57 * being established. If the call does not connect before this time, abort the call.
Evan Charlton1063e282014-03-05 19:31:21 -080058 */
Sailesh Nepal8c85dee2014-04-07 22:21:40 -070059 public static long getNewOutgoingCallMillis() {
Santos Cordonc499c1c2014-04-14 17:13:14 -070060 return get("new_outgoing_call_ms", 60 * 1000L);
Evan Charlton1063e282014-03-05 19:31:21 -080061 }
Santos Cordon2174fb52014-05-29 08:22:56 -070062
63 /**
64 * Returns the longest period, in milliseconds, to wait for the query for direct-to-voicemail
65 * to complete. If the query goes beyond this timeout, the incoming call screen is shown to the
66 * user.
67 */
68 public static long getDirectToVoicemail() {
69 return get("direct_to_voicemail_ms", 500L);
70 }
Evan Charlton1063e282014-03-05 19:31:21 -080071}