blob: ec9657ed801042f1d4123859d7b3473d257811d6 [file] [log] [blame]
Chiao Cheng94b10b52012-08-17 16:59:12 -07001/*
2 * Copyright (C) 2011 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
17package com.android.dialer;
18
Yorke Lee8cd94232014-07-23 14:05:31 -070019import com.google.common.annotations.VisibleForTesting;
20
Nancy Chen87ba4892014-06-11 17:56:07 -070021import android.graphics.drawable.Drawable;
Chiao Cheng94b10b52012-08-17 16:59:12 -070022import android.net.Uri;
23import android.provider.CallLog.Calls;
24import android.provider.ContactsContract.CommonDataKinds.Phone;
Nancy Chene80d6222014-10-08 20:17:55 -070025import android.telecom.PhoneAccountHandle;
Chiao Cheng94b10b52012-08-17 16:59:12 -070026
27/**
28 * The details of a phone call to be shown in the UI.
29 */
30public class PhoneCallDetails {
31 /** The number of the other party involved in the call. */
32 public final CharSequence number;
Jay Shrauner719a7ad2013-05-30 15:41:13 -070033 /** The number presenting rules set by the network, e.g., {@link Calls#PRESENTATION_ALLOWED} */
34 public final int numberPresentation;
Chiao Cheng94b10b52012-08-17 16:59:12 -070035 /** The formatted version of {@link #number}. */
36 public final CharSequence formattedNumber;
37 /** The country corresponding with the phone number. */
38 public final String countryIso;
39 /** The geocoded location for the phone number. */
40 public final String geocode;
41 /**
42 * The type of calls, as defined in the call log table, e.g., {@link Calls#INCOMING_TYPE}.
43 * <p>
44 * There might be multiple types if this represents a set of entries grouped together.
45 */
46 public final int[] callTypes;
47 /** The date of the call, in milliseconds since the epoch. */
48 public final long date;
49 /** The duration of the call in milliseconds, or 0 for missed calls. */
50 public final long duration;
51 /** The name of the contact, or the empty string. */
52 public final CharSequence name;
53 /** The type of phone, e.g., {@link Phone#TYPE_HOME}, 0 if not available. */
54 public final int numberType;
55 /** The custom label associated with the phone number in the contact, or the empty string. */
56 public final CharSequence numberLabel;
57 /** The URI of the contact associated with this phone call. */
58 public final Uri contactUri;
59 /**
60 * The photo URI of the picture of the contact that is associated with this phone call or
61 * null if there is none.
62 * <p>
63 * This is meant to store the high-res photo only.
64 */
65 public final Uri photoUri;
Yorke Lee56cb0ef2014-02-21 10:02:18 -080066 /**
67 * The source type of the contact associated with this call.
68 */
69 public final int sourceType;
Nancy Chene80d6222014-10-08 20:17:55 -070070
Nancy Chen87ba4892014-06-11 17:56:07 -070071 /**
Nancy Chen19702632014-07-25 13:23:16 -070072 * The unique identifier for the account associated with the call.
73 */
Nancy Chene80d6222014-10-08 20:17:55 -070074 public final PhoneAccountHandle accountHandle;
Tyler Gunn8b0e8582014-07-10 12:28:43 -070075 /**
76 * Features applicable to this call.
77 */
78 public final int features;
79 /**
80 * Total data usage for this call.
81 */
82 public final Long dataUsage;
Yorke Lee8cd94232014-07-23 14:05:31 -070083 /**
84 * Voicemail transcription
85 */
86 public final String transcription;
87
88 /**
89 * Create the details for a call, with empty defaults specified for extra fields that are
90 * not necessary for testing.
91 */
92 @VisibleForTesting
93 public PhoneCallDetails(CharSequence number, int numberPresentation,
94 CharSequence formattedNumber, String countryIso, String geocode,
95 int[] callTypes, long date, long duration) {
96 this (number, numberPresentation, formattedNumber, countryIso, geocode,
Nancy Chene80d6222014-10-08 20:17:55 -070097 callTypes, date, duration, "", 0, "", null, null, 0, null, 0, null, null);
Yorke Lee8cd94232014-07-23 14:05:31 -070098 }
Chiao Cheng94b10b52012-08-17 16:59:12 -070099
100 /** Create the details for a call with a number not associated with a contact. */
Jay Shrauner719a7ad2013-05-30 15:41:13 -0700101 public PhoneCallDetails(CharSequence number, int numberPresentation,
102 CharSequence formattedNumber, String countryIso, String geocode,
Nancy Chene80d6222014-10-08 20:17:55 -0700103 int[] callTypes, long date, long duration,
104 PhoneAccountHandle accountHandle, int features, Long dataUsage, String transcription) {
105 this(number, numberPresentation, formattedNumber, countryIso, geocode, callTypes, date,
106 duration, "", 0, "", null, null, 0, accountHandle, features, dataUsage,
107 transcription);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700108 }
109
110 /** Create the details for a call with a number associated with a contact. */
Jay Shrauner719a7ad2013-05-30 15:41:13 -0700111 public PhoneCallDetails(CharSequence number, int numberPresentation,
112 CharSequence formattedNumber, String countryIso, String geocode,
113 int[] callTypes, long date, long duration, CharSequence name,
Nancy Chene80d6222014-10-08 20:17:55 -0700114 int numberType, CharSequence numberLabel, Uri contactUri, Uri photoUri,
115 int sourceType, PhoneAccountHandle accountHandle, int features, Long dataUsage,
116 String transcription) {
Chiao Cheng94b10b52012-08-17 16:59:12 -0700117 this.number = number;
Jay Shrauner719a7ad2013-05-30 15:41:13 -0700118 this.numberPresentation = numberPresentation;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700119 this.formattedNumber = formattedNumber;
120 this.countryIso = countryIso;
121 this.geocode = geocode;
122 this.callTypes = callTypes;
123 this.date = date;
124 this.duration = duration;
125 this.name = name;
126 this.numberType = numberType;
127 this.numberLabel = numberLabel;
128 this.contactUri = contactUri;
129 this.photoUri = photoUri;
Yorke Lee56cb0ef2014-02-21 10:02:18 -0800130 this.sourceType = sourceType;
Nancy Chene80d6222014-10-08 20:17:55 -0700131 this.accountHandle = accountHandle;
Tyler Gunn8b0e8582014-07-10 12:28:43 -0700132 this.features = features;
133 this.dataUsage = dataUsage;
Yorke Lee8cd94232014-07-23 14:05:31 -0700134 this.transcription = transcription;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700135 }
136}