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.graphics.drawable.Drawable;
     20 import android.telecom.DisconnectCause;
     21 import com.android.incallui.call.DialerCall;
     22 import com.android.incallui.videotech.utils.SessionModificationState;
     23 import java.util.Locale;
     24 
     25 /** State of the primary call. */
     26 public class PrimaryCallState {
     27   public final int state;
     28   public final boolean isVideoCall;
     29   @SessionModificationState public final int sessionModificationState;
     30   public final DisconnectCause disconnectCause;
     31   public final String connectionLabel;
     32   public final Drawable connectionIcon;
     33   public final String gatewayNumber;
     34   public final String callSubject;
     35   public final String callbackNumber;
     36   public final boolean isWifi;
     37   public final boolean isConference;
     38   public final boolean isWorkCall;
     39   public final boolean isHdAttempting;
     40   public final boolean isHdAudioCall;
     41   public final boolean isForwardedNumber;
     42   public final boolean shouldShowContactPhoto;
     43   public final long connectTimeMillis;
     44   public final boolean isVoiceMailNumber;
     45   public final boolean isRemotelyHeld;
     46   public final boolean isBusinessNumber;
     47   public final boolean supportsCallOnHold;
     48 
     49   // TODO: Convert to autovalue. b/34502119
     50   public static PrimaryCallState createEmptyPrimaryCallState() {
     51     return new PrimaryCallState(
     52         DialerCall.State.IDLE,
     53         false, /* isVideoCall */
     54         SessionModificationState.NO_REQUEST,
     55         new DisconnectCause(DisconnectCause.UNKNOWN),
     56         null, /* connectionLabel */
     57         null, /* connectionIcon */
     58         null, /* gatewayNumber */
     59         null, /* callSubject */
     60         null, /* callbackNumber */
     61         false /* isWifi */,
     62         false /* isConference */,
     63         false /* isWorkCall */,
     64         false /* isHdAttempting */,
     65         false /* isHdAudioCall */,
     66         false /* isForwardedNumber */,
     67         false /* shouldShowContactPhoto */,
     68         0,
     69         false /* isVoiceMailNumber */,
     70         false /* isRemotelyHeld */,
     71         false /* isBusinessNumber */,
     72         true /* supportsCallOnHold */);
     73   }
     74 
     75   public PrimaryCallState(
     76       int state,
     77       boolean isVideoCall,
     78       @SessionModificationState int sessionModificationState,
     79       DisconnectCause disconnectCause,
     80       String connectionLabel,
     81       Drawable connectionIcon,
     82       String gatewayNumber,
     83       String callSubject,
     84       String callbackNumber,
     85       boolean isWifi,
     86       boolean isConference,
     87       boolean isWorkCall,
     88       boolean isHdAttempting,
     89       boolean isHdAudioCall,
     90       boolean isForwardedNumber,
     91       boolean shouldShowContactPhoto,
     92       long connectTimeMillis,
     93       boolean isVoiceMailNumber,
     94       boolean isRemotelyHeld,
     95       boolean isBusinessNumber,
     96       boolean supportsCallOnHold) {
     97     this.state = state;
     98     this.isVideoCall = isVideoCall;
     99     this.sessionModificationState = sessionModificationState;
    100     this.disconnectCause = disconnectCause;
    101     this.connectionLabel = connectionLabel;
    102     this.connectionIcon = connectionIcon;
    103     this.gatewayNumber = gatewayNumber;
    104     this.callSubject = callSubject;
    105     this.callbackNumber = callbackNumber;
    106     this.isWifi = isWifi;
    107     this.isConference = isConference;
    108     this.isWorkCall = isWorkCall;
    109     this.isHdAttempting = isHdAttempting;
    110     this.isHdAudioCall = isHdAudioCall;
    111     this.isForwardedNumber = isForwardedNumber;
    112     this.shouldShowContactPhoto = shouldShowContactPhoto;
    113     this.connectTimeMillis = connectTimeMillis;
    114     this.isVoiceMailNumber = isVoiceMailNumber;
    115     this.isRemotelyHeld = isRemotelyHeld;
    116     this.isBusinessNumber = isBusinessNumber;
    117     this.supportsCallOnHold = supportsCallOnHold;
    118   }
    119 
    120   @Override
    121   public String toString() {
    122     return String.format(
    123         Locale.US, "PrimaryCallState, state: %d, connectionLabel: %s", state, connectionLabel);
    124   }
    125 }
    126