blob: a69319d3515973aa6ae1e2634c838460d5d7a4ef [file] [log] [blame]
Evan Charlton1063e282014-03-05 19:31:21 -08001// Copyright 2014 Google Inc. All Rights Reserved.
2
3package com.android.telecomm;
4
5import android.provider.Settings;
6import android.telecomm.CallServiceProvider;
7import android.telecomm.CallServiceSelector;
8
9/**
10 * A helper class which serves only to make it easier to lookup timeout values. This class should
11 * never be instantiated, and only accessed through the {@link #get(String, long)} method.
12 *
13 * These methods are safe to call from any thread, including the UI thread.
14 */
15public final class Timeouts {
16 /** A prefix to use for all keys so to not clobber the global namespace. */
17 private static final String PREFIX = "telecomm.";
18
19 private Timeouts() {}
20
21 /**
22 * Returns the timeout value from Settings or the default value if it hasn't been changed. This
23 * method is safe to call from any thread, including the UI thread.
24 *
25 * @param key Settings key to retrieve.
26 * @param defaultValue Default value, in milliseconds.
27 * @return The timeout value from Settings or the default value if it hasn't been changed.
28 */
29 private static long get(String key, long defaultValue) {
30 return Settings.Secure.getLong(
31 TelecommApp.getInstance().getContentResolver(), PREFIX + key, defaultValue);
32 }
33
34 /**
35 * @return The longest period in milliseconds each {@link CallServiceProvider} lookup cycle is
36 * allowed to span over.
37 */
38 public static long getProviderLookupMs() {
39 return get("provider_lookup_ms", 100);
40 }
41
42 /**
43 * @return The longest period in milliseconds each {@link CallServiceSelector} lookup cycle is
44 * allowed to span over.
45 */
46 public static long getSelectorLookupMs() {
47 return get("selector_lookup_ms", 100);
48 }
49
50 /**
51 * @return How frequently, in milliseconds, to run {@link Switchboard}'s clean-up "tick" cycle.
52 */
53 public static long getTickMs() {
54 return get("tick_ms", 250);
55 }
56
57 /**
58 * Returns the longest period, in milliseconds, each new outgoing call is allowed to wait before
59 * being established. If the call does not connect before this time, abort the call.
60 *
61 * @return The longest period, in milliseconds, each new call is allowed to wait before being
62 * established.
63 */
64 public static long getNewOutgoingCallMs() {
65 return get("new_outgoing_call_ms", 5000);
66 }
67}