• 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.ColorInt;
21 import android.support.annotation.IntDef;
22 import android.support.annotation.Nullable;
23 import android.telecom.DisconnectCause;
24 import android.text.TextUtils;
25 import com.android.dialer.assisteddialing.TransformationInfo;
26 import com.android.dialer.common.Assert;
27 import com.android.dialer.preferredsim.suggestion.SuggestionProvider;
28 import com.android.incallui.call.state.DialerCallState;
29 import com.android.incallui.videotech.utils.SessionModificationState;
30 import com.google.auto.value.AutoValue;
31 import java.lang.annotation.Retention;
32 import java.lang.annotation.RetentionPolicy;
33 import java.util.Locale;
34 
35 /** State of the primary call. */
36 @AutoValue
37 public abstract class PrimaryCallState {
38 
39   /**
40    * Button state that will be invisible if not supported, visible but invalid if disabled, or
41    * visible if enabled.
42    */
43   @Retention(RetentionPolicy.SOURCE)
44   @IntDef({ButtonState.NOT_SUPPORT, ButtonState.DISABLED, ButtonState.ENABLED})
45   public @interface ButtonState {
46     int NOT_SUPPORT = 0;
47     int DISABLED = 1;
48     int ENABLED = 2;
49   }
50 
state()51   public abstract int state();
52 
isVideoCall()53   public abstract boolean isVideoCall();
54 
55   @SessionModificationState
sessionModificationState()56   public abstract int sessionModificationState();
57 
disconnectCause()58   public abstract DisconnectCause disconnectCause();
59 
60   @Nullable
connectionLabel()61   public abstract String connectionLabel();
62 
primaryColor()63   public abstract @ColorInt int primaryColor();
64 
65   @Nullable
simSuggestionReason()66   public abstract SuggestionProvider.Reason simSuggestionReason();
67 
68   @Nullable
connectionIcon()69   public abstract Drawable connectionIcon();
70 
71   @Nullable
gatewayNumber()72   public abstract String gatewayNumber();
73 
74   @Nullable
callSubject()75   public abstract String callSubject();
76 
77   @Nullable
callbackNumber()78   public abstract String callbackNumber();
79 
isWifi()80   public abstract boolean isWifi();
81 
isConference()82   public abstract boolean isConference();
83 
isWorkCall()84   public abstract boolean isWorkCall();
85 
isHdAttempting()86   public abstract boolean isHdAttempting();
87 
isHdAudioCall()88   public abstract boolean isHdAudioCall();
89 
isForwardedNumber()90   public abstract boolean isForwardedNumber();
91 
shouldShowContactPhoto()92   public abstract boolean shouldShowContactPhoto();
93 
connectTimeMillis()94   public abstract long connectTimeMillis();
95 
isVoiceMailNumber()96   public abstract boolean isVoiceMailNumber();
97 
isRemotelyHeld()98   public abstract boolean isRemotelyHeld();
99 
isBusinessNumber()100   public abstract boolean isBusinessNumber();
101 
supportsCallOnHold()102   public abstract boolean supportsCallOnHold();
103 
swapToSecondaryButtonState()104   public abstract @ButtonState int swapToSecondaryButtonState();
105 
isAssistedDialed()106   public abstract boolean isAssistedDialed();
107 
108   @Nullable
customLabel()109   public abstract String customLabel();
110 
111   @Nullable
assistedDialingExtras()112   public abstract TransformationInfo assistedDialingExtras();
113 
builder()114   public static Builder builder() {
115     return new AutoValue_PrimaryCallState.Builder()
116         .setState(DialerCallState.IDLE)
117         .setIsVideoCall(false)
118         .setSessionModificationState(SessionModificationState.NO_REQUEST)
119         .setDisconnectCause(new DisconnectCause(DisconnectCause.UNKNOWN))
120         .setIsWifi(false)
121         .setIsConference(false)
122         .setIsWorkCall(false)
123         .setIsHdAttempting(false)
124         .setIsHdAudioCall(false)
125         .setIsForwardedNumber(false)
126         .setShouldShowContactPhoto(false)
127         .setConnectTimeMillis(0)
128         .setIsVoiceMailNumber(false)
129         .setIsRemotelyHeld(false)
130         .setIsBusinessNumber(false)
131         .setSupportsCallOnHold(true)
132         .setSwapToSecondaryButtonState(ButtonState.NOT_SUPPORT)
133         .setIsAssistedDialed(false)
134         .setPrimaryColor(0);
135   }
136 
137   /** Builder class for primary call state info. */
138   @AutoValue.Builder
139   public abstract static class Builder {
setState(int state)140     public abstract Builder setState(int state);
141 
setIsVideoCall(boolean isVideoCall)142     public abstract Builder setIsVideoCall(boolean isVideoCall);
143 
setSessionModificationState( @essionModificationState int sessionModificationState)144     public abstract Builder setSessionModificationState(
145         @SessionModificationState int sessionModificationState);
146 
setDisconnectCause(DisconnectCause disconnectCause)147     public abstract Builder setDisconnectCause(DisconnectCause disconnectCause);
148 
setConnectionLabel(String connectionLabel)149     public abstract Builder setConnectionLabel(String connectionLabel);
150 
setSimSuggestionReason(SuggestionProvider.Reason reason)151     public abstract Builder setSimSuggestionReason(SuggestionProvider.Reason reason);
152 
setConnectionIcon(Drawable connectionIcon)153     public abstract Builder setConnectionIcon(Drawable connectionIcon);
154 
setPrimaryColor(@olorInt int color)155     public abstract Builder setPrimaryColor(@ColorInt int color);
156 
setGatewayNumber(String gatewayNumber)157     public abstract Builder setGatewayNumber(String gatewayNumber);
158 
setCallSubject(String callSubject)159     public abstract Builder setCallSubject(String callSubject);
160 
setCallbackNumber(String callbackNumber)161     public abstract Builder setCallbackNumber(String callbackNumber);
162 
setIsWifi(boolean isWifi)163     public abstract Builder setIsWifi(boolean isWifi);
164 
setIsConference(boolean isConference)165     public abstract Builder setIsConference(boolean isConference);
166 
setIsWorkCall(boolean isWorkCall)167     public abstract Builder setIsWorkCall(boolean isWorkCall);
168 
setIsHdAttempting(boolean isHdAttempting)169     public abstract Builder setIsHdAttempting(boolean isHdAttempting);
170 
setIsHdAudioCall(boolean isHdAudioCall)171     public abstract Builder setIsHdAudioCall(boolean isHdAudioCall);
172 
setIsForwardedNumber(boolean isForwardedNumber)173     public abstract Builder setIsForwardedNumber(boolean isForwardedNumber);
174 
setShouldShowContactPhoto(boolean shouldShowContactPhoto)175     public abstract Builder setShouldShowContactPhoto(boolean shouldShowContactPhoto);
176 
setConnectTimeMillis(long connectTimeMillis)177     public abstract Builder setConnectTimeMillis(long connectTimeMillis);
178 
setIsVoiceMailNumber(boolean isVoiceMailNumber)179     public abstract Builder setIsVoiceMailNumber(boolean isVoiceMailNumber);
180 
setIsRemotelyHeld(boolean isRemotelyHeld)181     public abstract Builder setIsRemotelyHeld(boolean isRemotelyHeld);
182 
setIsBusinessNumber(boolean isBusinessNumber)183     public abstract Builder setIsBusinessNumber(boolean isBusinessNumber);
184 
setSupportsCallOnHold(boolean supportsCallOnHold)185     public abstract Builder setSupportsCallOnHold(boolean supportsCallOnHold);
186 
setSwapToSecondaryButtonState( @uttonState int swapToSecondaryButtonState)187     public abstract Builder setSwapToSecondaryButtonState(
188         @ButtonState int swapToSecondaryButtonState);
189 
setIsAssistedDialed(boolean isAssistedDialed)190     public abstract Builder setIsAssistedDialed(boolean isAssistedDialed);
191 
setCustomLabel(String customLabel)192     public abstract Builder setCustomLabel(String customLabel);
193 
setAssistedDialingExtras(TransformationInfo assistedDialingExtras)194     public abstract Builder setAssistedDialingExtras(TransformationInfo assistedDialingExtras);
195 
autoBuild()196     abstract PrimaryCallState autoBuild();
197 
build()198     public PrimaryCallState build() {
199       PrimaryCallState primaryCallState = autoBuild();
200       if (!TextUtils.isEmpty(primaryCallState.customLabel())) {
201         Assert.checkArgument(primaryCallState.state() == DialerCallState.CALL_PENDING);
202       }
203       return primaryCallState;
204     }
205   }
206 
empty()207   public static PrimaryCallState empty() {
208     return PrimaryCallState.builder().build();
209   }
210 
211   @Override
toString()212   public String toString() {
213     return String.format(
214         Locale.US, "PrimaryCallState, state: %d, connectionLabel: %s", state(), connectionLabel());
215   }
216 }
217