Home | History | Annotate | Download | only in protocol
      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 {
     29   public abstract boolean shouldShow();
     30 
     31   @Nullable
     32   public abstract String name();
     33 
     34   public abstract boolean nameIsNumber();
     35 
     36   @Nullable
     37   public abstract String label();
     38 
     39   @Nullable
     40   public abstract String providerLabel();
     41 
     42   public abstract boolean isConference();
     43 
     44   public abstract boolean isVideoCall();
     45 
     46   public abstract boolean isFullscreen();
     47 
     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 {
     60     public abstract Builder setShouldShow(boolean shouldShow);
     61 
     62     public abstract Builder setName(String name);
     63 
     64     public abstract Builder setNameIsNumber(boolean nameIsNumber);
     65 
     66     public abstract Builder setLabel(String label);
     67 
     68     public abstract Builder setProviderLabel(String providerLabel);
     69 
     70     public abstract Builder setIsConference(boolean isConference);
     71 
     72     public abstract Builder setIsVideoCall(boolean isVideoCall);
     73 
     74     public abstract Builder setIsFullscreen(boolean isFullscreen);
     75 
     76     public abstract SecondaryInfo build();
     77   }
     78 
     79   @Override
     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
    113   public int describeContents() {
    114     return 0;
    115   }
    116 
    117   @Override
    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