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; |
| 20 | import android.telecomm.CallServiceProvider; |
| 21 | import android.telecomm.CallServiceSelector; |
| 22 | |
| 23 | /** |
| 24 | * A helper class which serves only to make it easier to lookup timeout values. This class should |
| 25 | * never be instantiated, and only accessed through the {@link #get(String, long)} method. |
| 26 | * |
| 27 | * These methods are safe to call from any thread, including the UI thread. |
| 28 | */ |
| 29 | public final class Timeouts { |
| 30 | /** A prefix to use for all keys so to not clobber the global namespace. */ |
| 31 | private static final String PREFIX = "telecomm."; |
| 32 | |
| 33 | private Timeouts() {} |
| 34 | |
| 35 | /** |
| 36 | * Returns the timeout value from Settings or the default value if it hasn't been changed. This |
| 37 | * method is safe to call from any thread, including the UI thread. |
| 38 | * |
| 39 | * @param key Settings key to retrieve. |
| 40 | * @param defaultValue Default value, in milliseconds. |
| 41 | * @return The timeout value from Settings or the default value if it hasn't been changed. |
| 42 | */ |
| 43 | private static long get(String key, long defaultValue) { |
| 44 | return Settings.Secure.getLong( |
| 45 | TelecommApp.getInstance().getContentResolver(), PREFIX + key, defaultValue); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * @return The longest period in milliseconds each {@link CallServiceProvider} lookup cycle is |
| 50 | * allowed to span over. |
| 51 | */ |
Sailesh Nepal | 8c85dee | 2014-04-07 22:21:40 -0700 | [diff] [blame] | 52 | public static long getProviderLookupMillis() { |
Sailesh Nepal | ee64276 | 2014-03-06 20:41:02 -0800 | [diff] [blame] | 53 | return get("provider_lookup_ms", 1000); |
Evan Charlton | 1063e28 | 2014-03-05 19:31:21 -0800 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | /** |
Evan Charlton | 1063e28 | 2014-03-05 19:31:21 -0800 | [diff] [blame] | 57 | * Returns the longest period, in milliseconds, each new outgoing call is allowed to wait before |
| 58 | * being established. If the call does not connect before this time, abort the call. |
Evan Charlton | 1063e28 | 2014-03-05 19:31:21 -0800 | [diff] [blame] | 59 | */ |
Sailesh Nepal | 8c85dee | 2014-04-07 22:21:40 -0700 | [diff] [blame] | 60 | public static long getNewOutgoingCallMillis() { |
Santos Cordon | c499c1c | 2014-04-14 17:13:14 -0700 | [diff] [blame] | 61 | return get("new_outgoing_call_ms", 60 * 1000L); |
Evan Charlton | 1063e28 | 2014-03-05 19:31:21 -0800 | [diff] [blame] | 62 | } |
| 63 | } |