blob: ef72cd037083d1c4efc72621a01722928a362d10 [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
Ben Gilad0bf5b912014-01-28 17:55:57 -080028 /**
29 * Unique identifier for the call as a UUID string.
30 */
31 private final String mId;
32
Ben Gilad0407fb22014-01-09 16:18:41 -080033 /** The handle with which to establish this call. */
Ben Gilad0bf5b912014-01-28 17:55:57 -080034 private final String mHandle;
Ben Gilad0407fb22014-01-09 16:18:41 -080035
36 /** Additional contact information beyond handle above, optional. */
Ben Gilad0bf5b912014-01-28 17:55:57 -080037 private final ContactInfo mContactInfo;
Ben Gilad0407fb22014-01-09 16:18:41 -080038
39 /**
40 * The time this call was created, typically also the time this call was added to the set
41 * of pending outgoing calls (mPendingOutgoingCalls) that's maintained by the switchboard.
42 * Beyond logging and such, may also be used for bookkeeping and specifically for marking
43 * certain call attempts as failed attempts.
44 */
45 private final Date mCreationTime;
46
47 /**
48 * Persists the specified parameters and initializes the new instance.
49 *
50 * @param handle The handle to dial.
51 * @param contactInfo Information about the entity being called.
52 */
Ben Gilad0bf5b912014-01-28 17:55:57 -080053 Call(String handle, ContactInfo contactInfo) {
54 // TODO(gilad): Pass this in etc.
55 mId = "dummy";
56
Ben Gilad0407fb22014-01-09 16:18:41 -080057 mHandle = handle;
58 mContactInfo = contactInfo;
59
60 mCreationTime = new Date();
61 }
62
Ben Gilad0bf5b912014-01-28 17:55:57 -080063 String getId() {
64 return mId;
65 }
66
67 String getHandle() {
68 return mHandle;
69 }
70
71 ContactInfo getContactInfo() {
72 return mContactInfo;
73 }
74
Ben Gilad0407fb22014-01-09 16:18:41 -080075 /**
76 * @return The "age" of this call object in milliseconds, which typically also represents the
77 * period since this call was added to the set pending outgoing calls, see mCreationTime.
78 */
Ben Gilad0bf5b912014-01-28 17:55:57 -080079 long getAgeInMilliseconds() {
Ben Gilad0407fb22014-01-09 16:18:41 -080080 return new Date().getTime() - mCreationTime.getTime();
81 }
Ben Gilad9f2bed32013-12-12 17:43:26 -080082}