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