1 /* 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 17 package com.android.dialer; 18 19 import com.google.common.annotations.VisibleForTesting; 20 21 import android.graphics.drawable.Drawable; 22 import android.net.Uri; 23 import android.provider.CallLog.Calls; 24 import android.provider.ContactsContract.CommonDataKinds.Phone; 25 import android.telecom.PhoneAccountHandle; 26 27 /** 28 * The details of a phone call to be shown in the UI. 29 */ 30 public class PhoneCallDetails { 31 /** The number of the other party involved in the call. */ 32 public final CharSequence number; 33 /** The number presenting rules set by the network, e.g., {@link Calls#PRESENTATION_ALLOWED} */ 34 public final int numberPresentation; 35 /** 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; 66 /** 67 * The source type of the contact associated with this call. 68 */ 69 public final int sourceType; 70 71 /** 72 * The unique identifier for the account associated with the call. 73 */ 74 public final PhoneAccountHandle accountHandle; 75 /** 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; 83 /** 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, 97 callTypes, date, duration, "", 0, "", null, null, 0, null, 0, null, null); 98 } 99 100 /** Create the details for a call with a number not associated with a contact. */ 101 public PhoneCallDetails(CharSequence number, int numberPresentation, 102 CharSequence formattedNumber, String countryIso, String geocode, 103 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); 108 } 109 110 /** Create the details for a call with a number associated with a contact. */ 111 public PhoneCallDetails(CharSequence number, int numberPresentation, 112 CharSequence formattedNumber, String countryIso, String geocode, 113 int[] callTypes, long date, long duration, CharSequence name, 114 int numberType, CharSequence numberLabel, Uri contactUri, Uri photoUri, 115 int sourceType, PhoneAccountHandle accountHandle, int features, Long dataUsage, 116 String transcription) { 117 this.number = number; 118 this.numberPresentation = numberPresentation; 119 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; 130 this.sourceType = sourceType; 131 this.accountHandle = accountHandle; 132 this.features = features; 133 this.dataUsage = dataUsage; 134 this.transcription = transcription; 135 } 136 } 137