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.os.Parcel; 20 import android.os.Parcelable; 21 import android.support.annotation.Nullable; 22 import com.android.dialer.common.LogUtil; 23 import com.google.auto.value.AutoValue; 24 import java.util.Locale; 25 26 /** Information about the secondary call. */ 27 @AutoValue 28 public abstract class SecondaryInfo implements Parcelable { shouldShow()29 public abstract boolean shouldShow(); 30 31 @Nullable name()32 public abstract String name(); 33 nameIsNumber()34 public abstract boolean nameIsNumber(); 35 36 @Nullable label()37 public abstract String label(); 38 39 @Nullable providerLabel()40 public abstract String providerLabel(); 41 isConference()42 public abstract boolean isConference(); 43 isVideoCall()44 public abstract boolean isVideoCall(); 45 isFullscreen()46 public abstract boolean isFullscreen(); 47 builder()48 public static Builder builder() { 49 return new AutoValue_SecondaryInfo.Builder() 50 .setShouldShow(false) 51 .setNameIsNumber(false) 52 .setIsConference(false) 53 .setIsVideoCall(false) 54 .setIsFullscreen(false); 55 } 56 57 /** Builder class for secondary info. */ 58 @AutoValue.Builder 59 public abstract static class Builder { setShouldShow(boolean shouldShow)60 public abstract Builder setShouldShow(boolean shouldShow); 61 setName(String name)62 public abstract Builder setName(String name); 63 setNameIsNumber(boolean nameIsNumber)64 public abstract Builder setNameIsNumber(boolean nameIsNumber); 65 setLabel(String label)66 public abstract Builder setLabel(String label); 67 setProviderLabel(String providerLabel)68 public abstract Builder setProviderLabel(String providerLabel); 69 setIsConference(boolean isConference)70 public abstract Builder setIsConference(boolean isConference); 71 setIsVideoCall(boolean isVideoCall)72 public abstract Builder setIsVideoCall(boolean isVideoCall); 73 setIsFullscreen(boolean isFullscreen)74 public abstract Builder setIsFullscreen(boolean isFullscreen); 75 build()76 public abstract SecondaryInfo build(); 77 } 78 79 @Override toString()80 public String toString() { 81 return String.format( 82 Locale.US, 83 "SecondaryInfo, show: %b, name: %s, label: %s, " + "providerLabel: %s", 84 shouldShow(), 85 LogUtil.sanitizePii(name()), 86 label(), 87 providerLabel()); 88 } 89 90 public static final Creator<SecondaryInfo> CREATOR = 91 new Creator<SecondaryInfo>() { 92 @Override 93 public SecondaryInfo createFromParcel(Parcel in) { 94 return builder() 95 .setShouldShow(in.readByte() != 0) 96 .setName(in.readString()) 97 .setNameIsNumber(in.readByte() != 0) 98 .setLabel(in.readString()) 99 .setProviderLabel(in.readString()) 100 .setIsConference(in.readByte() != 0) 101 .setIsVideoCall(in.readByte() != 0) 102 .setIsFullscreen(in.readByte() != 0) 103 .build(); 104 } 105 106 @Override 107 public SecondaryInfo[] newArray(int size) { 108 return new SecondaryInfo[size]; 109 } 110 }; 111 112 @Override describeContents()113 public int describeContents() { 114 return 0; 115 } 116 117 @Override writeToParcel(Parcel dest, int flags)118 public void writeToParcel(Parcel dest, int flags) { 119 dest.writeByte((byte) (shouldShow() ? 1 : 0)); 120 dest.writeString(name()); 121 dest.writeByte((byte) (nameIsNumber() ? 1 : 0)); 122 dest.writeString(label()); 123 dest.writeString(providerLabel()); 124 dest.writeByte((byte) (isConference() ? 1 : 0)); 125 dest.writeByte((byte) (isVideoCall() ? 1 : 0)); 126 dest.writeByte((byte) (isFullscreen() ? 1 : 0)); 127 } 128 } 129