blob: 3511b7ee984685f62e14799f0fcba5e0bf60bbee [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
21final class Call {
22
23 /** The handle with which to establish this call. */
24 private String mHandle;
25
26 /** Additional contact information beyond handle above, optional. */
27 private ContactInfo mContactInfo;
28
29 /**
30 * The time this call was created, typically also the time this call was added to the set
31 * of pending outgoing calls (mPendingOutgoingCalls) that's maintained by the switchboard.
32 * Beyond logging and such, may also be used for bookkeeping and specifically for marking
33 * certain call attempts as failed attempts.
34 */
35 private final Date mCreationTime;
36
37 /**
38 * Persists the specified parameters and initializes the new instance.
39 *
40 * @param handle The handle to dial.
41 * @param contactInfo Information about the entity being called.
42 */
43 public Call(String handle, ContactInfo contactInfo) {
44 mHandle = handle;
45 mContactInfo = contactInfo;
46
47 mCreationTime = new Date();
48 }
49
50 /**
51 * @return The "age" of this call object in milliseconds, which typically also represents the
52 * period since this call was added to the set pending outgoing calls, see mCreationTime.
53 */
54 public long getAgeInMilliseconds() {
55 return new Date().getTime() - mCreationTime.getTime();
56 }
Ben Gilad9f2bed32013-12-12 17:43:26 -080057}