1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.incallui.incall.protocol;
import android.graphics.drawable.Drawable;
import android.support.annotation.IntDef;
import android.support.annotation.Nullable;
import android.telecom.DisconnectCause;
import android.text.TextUtils;
import com.android.dialer.assisteddialing.TransformationInfo;
import com.android.dialer.common.Assert;
import com.android.dialer.preferredsim.suggestion.SuggestionProvider;
import com.android.incallui.call.state.DialerCallState;
import com.android.incallui.videotech.utils.SessionModificationState;
import com.google.auto.value.AutoValue;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Locale;
/** State of the primary call. */
@AutoValue
public abstract class PrimaryCallState {
/**
* Button state that will be invisible if not supported, visible but invalid if disabled, or
* visible if enabled.
*/
@Retention(RetentionPolicy.SOURCE)
@IntDef({ButtonState.NOT_SUPPORT, ButtonState.DISABLED, ButtonState.ENABLED})
public @interface ButtonState {
int NOT_SUPPORT = 0;
int DISABLED = 1;
int ENABLED = 2;
}
public abstract int state();
public abstract boolean isVideoCall();
@SessionModificationState
public abstract int sessionModificationState();
public abstract DisconnectCause disconnectCause();
@Nullable
public abstract String connectionLabel();
@Nullable
public abstract SuggestionProvider.Reason simSuggestionReason();
@Nullable
public abstract Drawable connectionIcon();
@Nullable
public abstract String gatewayNumber();
@Nullable
public abstract String callSubject();
@Nullable
public abstract String callbackNumber();
public abstract boolean isWifi();
public abstract boolean isConference();
public abstract boolean isWorkCall();
public abstract boolean isHdAttempting();
public abstract boolean isHdAudioCall();
public abstract boolean isForwardedNumber();
public abstract boolean shouldShowContactPhoto();
public abstract long connectTimeMillis();
public abstract boolean isVoiceMailNumber();
public abstract boolean isRemotelyHeld();
public abstract boolean isBusinessNumber();
public abstract boolean supportsCallOnHold();
public abstract @ButtonState int swapToSecondaryButtonState();
public abstract boolean isAssistedDialed();
@Nullable
public abstract String customLabel();
@Nullable
public abstract TransformationInfo assistedDialingExtras();
public static Builder builder() {
return new AutoValue_PrimaryCallState.Builder()
.setState(DialerCallState.IDLE)
.setIsVideoCall(false)
.setSessionModificationState(SessionModificationState.NO_REQUEST)
.setDisconnectCause(new DisconnectCause(DisconnectCause.UNKNOWN))
.setIsWifi(false)
.setIsConference(false)
.setIsWorkCall(false)
.setIsHdAttempting(false)
.setIsHdAudioCall(false)
.setIsForwardedNumber(false)
.setShouldShowContactPhoto(false)
.setConnectTimeMillis(0)
.setIsVoiceMailNumber(false)
.setIsRemotelyHeld(false)
.setIsBusinessNumber(false)
.setSupportsCallOnHold(true)
.setSwapToSecondaryButtonState(ButtonState.NOT_SUPPORT)
.setIsAssistedDialed(false);
}
/** Builder class for primary call state info. */
@AutoValue.Builder
public abstract static class Builder {
public abstract Builder setState(int state);
public abstract Builder setIsVideoCall(boolean isVideoCall);
public abstract Builder setSessionModificationState(
@SessionModificationState int sessionModificationState);
public abstract Builder setDisconnectCause(DisconnectCause disconnectCause);
public abstract Builder setConnectionLabel(String connectionLabel);
public abstract Builder setSimSuggestionReason(SuggestionProvider.Reason reason);
public abstract Builder setConnectionIcon(Drawable connectionIcon);
public abstract Builder setGatewayNumber(String gatewayNumber);
public abstract Builder setCallSubject(String callSubject);
public abstract Builder setCallbackNumber(String callbackNumber);
public abstract Builder setIsWifi(boolean isWifi);
public abstract Builder setIsConference(boolean isConference);
public abstract Builder setIsWorkCall(boolean isWorkCall);
public abstract Builder setIsHdAttempting(boolean isHdAttempting);
public abstract Builder setIsHdAudioCall(boolean isHdAudioCall);
public abstract Builder setIsForwardedNumber(boolean isForwardedNumber);
public abstract Builder setShouldShowContactPhoto(boolean shouldShowContactPhoto);
public abstract Builder setConnectTimeMillis(long connectTimeMillis);
public abstract Builder setIsVoiceMailNumber(boolean isVoiceMailNumber);
public abstract Builder setIsRemotelyHeld(boolean isRemotelyHeld);
public abstract Builder setIsBusinessNumber(boolean isBusinessNumber);
public abstract Builder setSupportsCallOnHold(boolean supportsCallOnHold);
public abstract Builder setSwapToSecondaryButtonState(
@ButtonState int swapToSecondaryButtonState);
public abstract Builder setIsAssistedDialed(boolean isAssistedDialed);
public abstract Builder setCustomLabel(String customLabel);
public abstract Builder setAssistedDialingExtras(TransformationInfo assistedDialingExtras);
abstract PrimaryCallState autoBuild();
public PrimaryCallState build() {
PrimaryCallState primaryCallState = autoBuild();
if (!TextUtils.isEmpty(primaryCallState.customLabel())) {
Assert.checkArgument(primaryCallState.state() == DialerCallState.CALL_PENDING);
}
return primaryCallState;
}
}
public static PrimaryCallState empty() {
return PrimaryCallState.builder().build();
}
@Override
public String toString() {
return String.format(
Locale.US, "PrimaryCallState, state: %d, connectionLabel: %s", state(), connectionLabel());
}
}
|