1 /* 2 * Copyright (C) 2016 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.incallui.incall.protocol; 18 19 import android.graphics.drawable.Drawable; 20 import android.support.annotation.Nullable; 21 import com.android.dialer.common.LogUtil; 22 import com.android.dialer.multimedia.MultimediaData; 23 import java.util.Locale; 24 25 /** Information about the primary call. */ 26 public class PrimaryInfo { 27 @Nullable public final String number; 28 @Nullable public final String name; 29 public final boolean nameIsNumber; 30 // This is from contacts and shows the type of number. For example, "Mobile". 31 @Nullable public final String label; 32 @Nullable public final String location; 33 @Nullable public final Drawable photo; 34 @ContactPhotoType public final int photoType; 35 public final boolean isSipCall; 36 public final boolean isContactPhotoShown; 37 public final boolean isWorkCall; 38 public final boolean isSpam; 39 public final boolean answeringDisconnectsOngoingCall; 40 public final boolean shouldShowLocation; 41 // Used for consistent LetterTile coloring. 42 @Nullable public final String contactInfoLookupKey; 43 @Nullable public final MultimediaData multimediaData; 44 public final int numberPresentation; 45 46 // TODO: Convert to autovalue. b/34502119 createEmptyPrimaryInfo()47 public static PrimaryInfo createEmptyPrimaryInfo() { 48 return new PrimaryInfo( 49 null, 50 null, 51 false, 52 null, 53 null, 54 null, 55 ContactPhotoType.DEFAULT_PLACEHOLDER, 56 false, 57 false, 58 false, 59 false, 60 false, 61 false, 62 null, 63 null, 64 -1); 65 } 66 PrimaryInfo( @ullable String number, @Nullable String name, boolean nameIsNumber, @Nullable String location, @Nullable String label, @Nullable Drawable photo, @ContactPhotoType int phototType, boolean isSipCall, boolean isContactPhotoShown, boolean isWorkCall, boolean isSpam, boolean answeringDisconnectsOngoingCall, boolean shouldShowLocation, @Nullable String contactInfoLookupKey, @Nullable MultimediaData multimediaData, int numberPresentation)67 public PrimaryInfo( 68 @Nullable String number, 69 @Nullable String name, 70 boolean nameIsNumber, 71 @Nullable String location, 72 @Nullable String label, 73 @Nullable Drawable photo, 74 @ContactPhotoType int phototType, 75 boolean isSipCall, 76 boolean isContactPhotoShown, 77 boolean isWorkCall, 78 boolean isSpam, 79 boolean answeringDisconnectsOngoingCall, 80 boolean shouldShowLocation, 81 @Nullable String contactInfoLookupKey, 82 @Nullable MultimediaData multimediaData, 83 int numberPresentation) { 84 this.number = number; 85 this.name = name; 86 this.nameIsNumber = nameIsNumber; 87 this.location = location; 88 this.label = label; 89 this.photo = photo; 90 this.photoType = phototType; 91 this.isSipCall = isSipCall; 92 this.isContactPhotoShown = isContactPhotoShown; 93 this.isWorkCall = isWorkCall; 94 this.isSpam = isSpam; 95 this.answeringDisconnectsOngoingCall = answeringDisconnectsOngoingCall; 96 this.shouldShowLocation = shouldShowLocation; 97 this.contactInfoLookupKey = contactInfoLookupKey; 98 this.multimediaData = multimediaData; 99 this.numberPresentation = numberPresentation; 100 } 101 102 @Override toString()103 public String toString() { 104 return String.format( 105 Locale.US, 106 "PrimaryInfo, number: %s, name: %s, location: %s, label: %s, " 107 + "photo: %s, photoType: %d, isPhotoVisible: %b", 108 LogUtil.sanitizePhoneNumber(number), 109 LogUtil.sanitizePii(name), 110 LogUtil.sanitizePii(location), 111 label, 112 photo, 113 photoType, 114 isContactPhotoShown); 115 } 116 } 117