blob: a969158fef0e1f714c5dcb3e5f83ac1595f34e74 [file] [log] [blame]
Ben Gilad0407fb22014-01-09 16:18:41 -08001/*
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 */
16
Ben Gilad9f2bed32013-12-12 17:43:26 -080017package com.android.telecomm;
18
Ben Gilad0407fb22014-01-09 16:18:41 -080019import java.util.Date;
20
Ben Gilad2495d572014-01-09 17:26:19 -080021/**
22 * Encapsulates all aspects of a given phone call throughout its lifecycle, starting
23 * from the time the call intent was received by Telecomm (vs. the time the call was
24 * connected etc).
25 */
Ben Gilad0407fb22014-01-09 16:18:41 -080026final class Call {
27
28 /** The handle with which to establish this call. */
29 private String mHandle;
30
31 /** Additional contact information beyond handle above, optional. */
32 private ContactInfo mContactInfo;
33
34 /**
35 * The time this call was created, typically also the time this call was added to the set
36 * of pending outgoing calls (mPendingOutgoingCalls) that's maintained by the switchboard.
37 * Beyond logging and such, may also be used for bookkeeping and specifically for marking
38 * certain call attempts as failed attempts.
39 */
40 private final Date mCreationTime;
41
42 /**
43 * Persists the specified parameters and initializes the new instance.
44 *
45 * @param handle The handle to dial.
46 * @param contactInfo Information about the entity being called.
47 */
48 public Call(String handle, ContactInfo contactInfo) {
49 mHandle = handle;
50 mContactInfo = contactInfo;
51
52 mCreationTime = new Date();
53 }
54
55 /**
56 * @return The "age" of this call object in milliseconds, which typically also represents the
57 * period since this call was added to the set pending outgoing calls, see mCreationTime.
58 */
59 public long getAgeInMilliseconds() {
60 return new Date().getTime() - mCreationTime.getTime();
61 }
Ben Gilad9f2bed32013-12-12 17:43:26 -080062}