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.net.Uri; 21 import android.support.annotation.Nullable; 22 import com.android.dialer.common.LogUtil; 23 import com.android.dialer.multimedia.MultimediaData; 24 import com.google.auto.value.AutoValue; 25 import java.util.Locale; 26 27 /** Information about the primary call. */ 28 @AutoValue 29 public abstract class PrimaryInfo { 30 @Nullable number()31 public abstract String number(); 32 33 @Nullable name()34 public abstract String name(); 35 nameIsNumber()36 public abstract boolean nameIsNumber(); 37 // This is from contacts and shows the type of number. For example, "Mobile". 38 @Nullable label()39 public abstract String label(); 40 41 @Nullable location()42 public abstract String location(); 43 44 @Nullable photo()45 public abstract Drawable photo(); 46 47 @Nullable photoUri()48 public abstract Uri photoUri(); 49 50 @ContactPhotoType photoType()51 public abstract int photoType(); 52 isSipCall()53 public abstract boolean isSipCall(); 54 isContactPhotoShown()55 public abstract boolean isContactPhotoShown(); 56 isWorkCall()57 public abstract boolean isWorkCall(); 58 isSpam()59 public abstract boolean isSpam(); 60 isLocalContact()61 public abstract boolean isLocalContact(); 62 answeringDisconnectsOngoingCall()63 public abstract boolean answeringDisconnectsOngoingCall(); 64 shouldShowLocation()65 public abstract boolean shouldShowLocation(); 66 // Used for consistent LetterTile coloring. 67 @Nullable contactInfoLookupKey()68 public abstract String contactInfoLookupKey(); 69 70 @Nullable multimediaData()71 public abstract MultimediaData multimediaData(); 72 showInCallButtonGrid()73 public abstract boolean showInCallButtonGrid(); 74 numberPresentation()75 public abstract int numberPresentation(); 76 builder()77 public static Builder builder() { 78 return new AutoValue_PrimaryInfo.Builder(); 79 } 80 81 /** Builder class for primary call info. */ 82 @AutoValue.Builder 83 public abstract static class Builder { setNumber(String number)84 public abstract Builder setNumber(String number); 85 setName(String name)86 public abstract Builder setName(String name); 87 setNameIsNumber(boolean nameIsNumber)88 public abstract Builder setNameIsNumber(boolean nameIsNumber); 89 setLabel(String label)90 public abstract Builder setLabel(String label); 91 setLocation(String location)92 public abstract Builder setLocation(String location); 93 setPhoto(Drawable photo)94 public abstract Builder setPhoto(Drawable photo); 95 setPhotoUri(Uri photoUri)96 public abstract Builder setPhotoUri(Uri photoUri); 97 setPhotoType(@ontactPhotoType int photoType)98 public abstract Builder setPhotoType(@ContactPhotoType int photoType); 99 setIsSipCall(boolean isSipCall)100 public abstract Builder setIsSipCall(boolean isSipCall); 101 setIsContactPhotoShown(boolean isContactPhotoShown)102 public abstract Builder setIsContactPhotoShown(boolean isContactPhotoShown); 103 setIsWorkCall(boolean isWorkCall)104 public abstract Builder setIsWorkCall(boolean isWorkCall); 105 setIsSpam(boolean isSpam)106 public abstract Builder setIsSpam(boolean isSpam); 107 setIsLocalContact(boolean isLocalContact)108 public abstract Builder setIsLocalContact(boolean isLocalContact); 109 setAnsweringDisconnectsOngoingCall( boolean answeringDisconnectsOngoingCall)110 public abstract Builder setAnsweringDisconnectsOngoingCall( 111 boolean answeringDisconnectsOngoingCall); 112 setShouldShowLocation(boolean shouldShowLocation)113 public abstract Builder setShouldShowLocation(boolean shouldShowLocation); 114 setContactInfoLookupKey(String contactInfoLookupKey)115 public abstract Builder setContactInfoLookupKey(String contactInfoLookupKey); 116 setMultimediaData(MultimediaData multimediaData)117 public abstract Builder setMultimediaData(MultimediaData multimediaData); 118 setShowInCallButtonGrid(boolean showInCallButtonGrid)119 public abstract Builder setShowInCallButtonGrid(boolean showInCallButtonGrid); 120 setNumberPresentation(int numberPresentation)121 public abstract Builder setNumberPresentation(int numberPresentation); 122 build()123 public abstract PrimaryInfo build(); 124 } 125 empty()126 public static PrimaryInfo empty() { 127 return PrimaryInfo.builder() 128 .setNameIsNumber(false) 129 .setPhotoType(ContactPhotoType.DEFAULT_PLACEHOLDER) 130 .setIsSipCall(false) 131 .setIsContactPhotoShown(false) 132 .setIsWorkCall(false) 133 .setIsSpam(false) 134 .setIsLocalContact(false) 135 .setAnsweringDisconnectsOngoingCall(false) 136 .setShouldShowLocation(false) 137 .setShowInCallButtonGrid(true) 138 .setNumberPresentation(-1) 139 .build(); 140 } 141 142 @Override toString()143 public String toString() { 144 return String.format( 145 Locale.US, 146 "PrimaryInfo, number: %s, name: %s, location: %s, label: %s, " 147 + "photo: %s, photoType: %d, isPhotoVisible: %b, MultimediaData: %s", 148 LogUtil.sanitizePhoneNumber(number()), 149 LogUtil.sanitizePii(name()), 150 LogUtil.sanitizePii(location()), 151 label(), 152 photo(), 153 photoType(), 154 isContactPhotoShown(), 155 multimediaData()); 156 } 157 } 158