blob: 378806183de52f788a07acdb42a916223f3061d3 [file] [log] [blame]
Eric Erfanianccca3152017-02-22 16:32:36 -08001/*
2 * Copyright (C) 2013 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
17package com.android.incallui.call;
18
wangqi9982f0d2017-10-11 17:46:07 -070019import android.Manifest.permission;
wangqi8d407a02018-02-15 15:32:52 -080020import android.annotation.TargetApi;
Eric Erfanianccca3152017-02-22 16:32:36 -080021import android.content.Context;
22import android.hardware.camera2.CameraCharacteristics;
23import android.net.Uri;
erfanian2cf2c342017-12-21 12:01:33 -080024import android.os.Build;
Eric Erfanianccca3152017-02-22 16:32:36 -080025import android.os.Build.VERSION;
26import android.os.Build.VERSION_CODES;
27import android.os.Bundle;
28import android.os.Trace;
29import android.support.annotation.IntDef;
Eric Erfaniand5e47f62017-03-15 14:41:07 -070030import android.support.annotation.NonNull;
Eric Erfanianccca3152017-02-22 16:32:36 -080031import android.support.annotation.Nullable;
twyendde01c52017-09-22 10:07:31 -070032import android.support.annotation.VisibleForTesting;
wangqif4ba3452018-01-09 11:26:29 -080033import android.support.v4.os.BuildCompat;
Eric Erfanianccca3152017-02-22 16:32:36 -080034import android.telecom.Call;
35import android.telecom.Call.Details;
wangqi219b8702018-02-13 09:34:41 -080036import android.telecom.Call.RttCall;
Eric Erfanian8369df02017-05-03 10:27:13 -070037import android.telecom.CallAudioState;
Eric Erfanianccca3152017-02-22 16:32:36 -080038import android.telecom.Connection;
39import android.telecom.DisconnectCause;
40import android.telecom.GatewayInfo;
41import android.telecom.InCallService.VideoCall;
42import android.telecom.PhoneAccount;
43import android.telecom.PhoneAccountHandle;
44import android.telecom.StatusHints;
45import android.telecom.TelecomManager;
46import android.telecom.VideoProfile;
Eric Erfanianccca3152017-02-22 16:32:36 -080047import android.text.TextUtils;
48import com.android.contacts.common.compat.CallCompat;
Eric Erfanianccca3152017-02-22 16:32:36 -080049import com.android.contacts.common.compat.telecom.TelecomManagerCompat;
erfanian2cf2c342017-12-21 12:01:33 -080050import com.android.dialer.assisteddialing.ConcreteCreator;
erfaniand0f207f2017-10-11 12:23:29 -070051import com.android.dialer.assisteddialing.TransformationInfo;
Eric Erfanian8369df02017-05-03 10:27:13 -070052import com.android.dialer.callintent.CallInitiationType;
Eric Erfanianccca3152017-02-22 16:32:36 -080053import com.android.dialer.callintent.CallIntentParser;
Eric Erfanian8369df02017-05-03 10:27:13 -070054import com.android.dialer.callintent.CallSpecificAppData;
Eric Erfanianccca3152017-02-22 16:32:36 -080055import com.android.dialer.common.Assert;
Eric Erfanianccca3152017-02-22 16:32:36 -080056import com.android.dialer.common.LogUtil;
Eric Erfanian2ca43182017-08-31 06:57:16 -070057import com.android.dialer.compat.telephony.TelephonyManagerCompat;
58import com.android.dialer.configprovider.ConfigProviderBindings;
roldenburg4f026392017-10-13 18:42:20 -070059import com.android.dialer.duo.DuoComponent;
Eric Erfanian8369df02017-05-03 10:27:13 -070060import com.android.dialer.enrichedcall.EnrichedCallCapabilities;
Eric Erfaniand5e47f62017-03-15 14:41:07 -070061import com.android.dialer.enrichedcall.EnrichedCallComponent;
Eric Erfanian2ca43182017-08-31 06:57:16 -070062import com.android.dialer.enrichedcall.EnrichedCallManager;
63import com.android.dialer.enrichedcall.EnrichedCallManager.CapabilitiesListener;
64import com.android.dialer.enrichedcall.EnrichedCallManager.Filter;
65import com.android.dialer.enrichedcall.EnrichedCallManager.StateChangedListener;
Eric Erfanian8369df02017-05-03 10:27:13 -070066import com.android.dialer.enrichedcall.Session;
wangqi9982f0d2017-10-11 17:46:07 -070067import com.android.dialer.location.GeoUtil;
Eric Erfanian8369df02017-05-03 10:27:13 -070068import com.android.dialer.logging.ContactLookupResult;
twyendde01c52017-09-22 10:07:31 -070069import com.android.dialer.logging.ContactLookupResult.Type;
Eric Erfanian8369df02017-05-03 10:27:13 -070070import com.android.dialer.logging.DialerImpression;
71import com.android.dialer.logging.Logger;
twyena4745bd2017-12-12 18:40:11 -080072import com.android.dialer.telecom.TelecomCallUtil;
wangqi9982f0d2017-10-11 17:46:07 -070073import com.android.dialer.telecom.TelecomUtil;
Eric Erfanianc857f902017-05-15 14:05:33 -070074import com.android.dialer.theme.R;
wangqi9982f0d2017-10-11 17:46:07 -070075import com.android.dialer.util.PermissionsUtil;
Eric Erfanian8369df02017-05-03 10:27:13 -070076import com.android.incallui.audiomode.AudioModeProvider;
Eric Erfanianccca3152017-02-22 16:32:36 -080077import com.android.incallui.latencyreport.LatencyReport;
Eric Erfaniand5e47f62017-03-15 14:41:07 -070078import com.android.incallui.videotech.VideoTech;
79import com.android.incallui.videotech.VideoTech.VideoTechListener;
roldenburg4f026392017-10-13 18:42:20 -070080import com.android.incallui.videotech.duo.DuoVideoTech;
Eric Erfaniand5e47f62017-03-15 14:41:07 -070081import com.android.incallui.videotech.empty.EmptyVideoTech;
82import com.android.incallui.videotech.ims.ImsVideoTech;
Eric Erfanian90508232017-03-24 09:31:16 -070083import com.android.incallui.videotech.utils.VideoUtils;
Eric Erfanianccca3152017-02-22 16:32:36 -080084import java.lang.annotation.Retention;
85import java.lang.annotation.RetentionPolicy;
86import java.util.ArrayList;
87import java.util.List;
88import java.util.Locale;
89import java.util.Objects;
90import java.util.UUID;
91import java.util.concurrent.CopyOnWriteArrayList;
92import java.util.concurrent.TimeUnit;
93
94/** Describes a single call and its state. */
Eric Erfanian2ca43182017-08-31 06:57:16 -070095public class DialerCall implements VideoTechListener, StateChangedListener, CapabilitiesListener {
Eric Erfanianccca3152017-02-22 16:32:36 -080096
97 public static final int CALL_HISTORY_STATUS_UNKNOWN = 0;
98 public static final int CALL_HISTORY_STATUS_PRESENT = 1;
99 public static final int CALL_HISTORY_STATUS_NOT_PRESENT = 2;
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700100
101 // Hard coded property for {@code Call}. Upstreamed change from Motorola.
Eric Erfanian938468d2017-10-24 14:05:52 -0700102 // TODO(a bug): Move it to Telecom in framework.
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700103 public static final int PROPERTY_CODEC_KNOWN = 0x04000000;
104
Eric Erfanianccca3152017-02-22 16:32:36 -0800105 private static final String ID_PREFIX = "DialerCall_";
106 private static final String CONFIG_EMERGENCY_CALLBACK_WINDOW_MILLIS =
107 "emergency_callback_window_millis";
linyuh183cb712017-12-27 17:02:37 -0800108 private static int idCounter = 0;
Eric Erfanianccca3152017-02-22 16:32:36 -0800109
110 /**
Eric Erfanianc857f902017-05-15 14:05:33 -0700111 * A counter used to append to restricted/private/hidden calls so that users can identify them in
112 * a conversation. This value is reset in {@link CallList#onCallRemoved(Context, Call)} when there
113 * are no live calls.
114 */
linyuh183cb712017-12-27 17:02:37 -0800115 private static int hiddenCounter;
Eric Erfanianc857f902017-05-15 14:05:33 -0700116
117 /**
Eric Erfanianccca3152017-02-22 16:32:36 -0800118 * The unique call ID for every call. This will help us to identify each call and allow us the
119 * ability to stitch impressions to calls if needed.
120 */
121 private final String uniqueCallId = UUID.randomUUID().toString();
122
linyuh183cb712017-12-27 17:02:37 -0800123 private final Call telecomCall;
124 private final LatencyReport latencyReport;
125 private final String id;
126 private final int hiddenId;
127 private final List<String> childCallIds = new ArrayList<>();
128 private final LogState logState = new LogState();
129 private final Context context;
130 private final DialerCallDelegate dialerCallDelegate;
131 private final List<DialerCallListener> listeners = new CopyOnWriteArrayList<>();
132 private final List<CannedTextResponsesLoadedListener> cannedTextResponsesLoadedListeners =
Eric Erfanianccca3152017-02-22 16:32:36 -0800133 new CopyOnWriteArrayList<>();
linyuh183cb712017-12-27 17:02:37 -0800134 private final VideoTechManager videoTechManager;
Eric Erfanianccca3152017-02-22 16:32:36 -0800135
linyuh183cb712017-12-27 17:02:37 -0800136 private boolean isEmergencyCall;
137 private Uri handle;
138 private int state = State.INVALID;
139 private DisconnectCause disconnectCause;
Eric Erfanianccca3152017-02-22 16:32:36 -0800140
141 private boolean hasShownWiFiToLteHandoverToast;
142 private boolean doNotShowDialogForHandoffToWifiFailure;
143
linyuh183cb712017-12-27 17:02:37 -0800144 private String childNumber;
145 private String lastForwardedNumber;
wangqif4ba3452018-01-09 11:26:29 -0800146 private boolean isCallForwarded;
linyuh183cb712017-12-27 17:02:37 -0800147 private String callSubject;
148 private PhoneAccountHandle phoneAccountHandle;
149 @CallHistoryStatus private int callHistoryStatus = CALL_HISTORY_STATUS_UNKNOWN;
150 private boolean isSpam;
151 private boolean isBlocked;
Eric Erfanian938468d2017-10-24 14:05:52 -0700152
153 @Nullable private Boolean isInUserSpamList;
154
155 @Nullable private Boolean isInUserWhiteList;
156
157 @Nullable private Boolean isInGlobalSpamList;
Eric Erfanianccca3152017-02-22 16:32:36 -0800158 private boolean didShowCameraPermission;
159 private String callProviderLabel;
160 private String callbackNumber;
linyuh183cb712017-12-27 17:02:37 -0800161 private int cameraDirection = CameraDirection.CAMERA_DIRECTION_UNKNOWN;
162 private EnrichedCallCapabilities enrichedCallCapabilities;
163 private Session enrichedCallSession;
Eric Erfanianccca3152017-02-22 16:32:36 -0800164
Eric Erfanian2ca43182017-08-31 06:57:16 -0700165 private int answerAndReleaseButtonDisplayedTimes = 0;
166 private boolean releasedByAnsweringSecondCall = false;
167 // Times when a second call is received but AnswerAndRelease button is not shown
168 // since it's not supported.
169 private int secondCallWithoutAnswerAndReleasedButtonTimes = 0;
roldenburg7bb96232017-10-09 10:32:05 -0700170 private VideoTech videoTech;
Eric Erfanian2ca43182017-08-31 06:57:16 -0700171
wangqi4d705e52017-09-28 12:23:35 -0700172 private com.android.dialer.logging.VideoTech.Type selectedAvailableVideoTechType =
173 com.android.dialer.logging.VideoTech.Type.NONE;
wangqi9982f0d2017-10-11 17:46:07 -0700174 private boolean isVoicemailNumber;
175 private List<PhoneAccountHandle> callCapableAccounts;
176 private String countryIso;
yueg457b3972017-09-18 15:11:47 -0700177
Android Dialer974fc292018-02-01 16:12:25 -0800178 private volatile boolean feedbackRequested = false;
179
Eric Erfanianccca3152017-02-22 16:32:36 -0800180 public static String getNumberFromHandle(Uri handle) {
181 return handle == null ? "" : handle.getSchemeSpecificPart();
182 }
183
184 /**
185 * Whether the call is put on hold by remote party. This is different than the {@link
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700186 * State#ONHOLD} state which indicates that the call is being held locally on the device.
Eric Erfanianccca3152017-02-22 16:32:36 -0800187 */
188 private boolean isRemotelyHeld;
189
Eric Erfanian2ca43182017-08-31 06:57:16 -0700190 /** Indicates whether this call is currently in the process of being merged into a conference. */
191 private boolean isMergeInProcess;
192
Eric Erfanianccca3152017-02-22 16:32:36 -0800193 /**
194 * Indicates whether the phone account associated with this call supports specifying a call
195 * subject.
196 */
linyuh183cb712017-12-27 17:02:37 -0800197 private boolean isCallSubjectSupported;
Eric Erfanianccca3152017-02-22 16:32:36 -0800198
linyuh183cb712017-12-27 17:02:37 -0800199 private final Call.Callback telecomCallCallback =
Eric Erfanianccca3152017-02-22 16:32:36 -0800200 new Call.Callback() {
201 @Override
202 public void onStateChanged(Call call, int newState) {
203 LogUtil.v("TelecomCallCallback.onStateChanged", "call=" + call + " newState=" + newState);
204 update();
205 }
206
207 @Override
208 public void onParentChanged(Call call, Call newParent) {
209 LogUtil.v(
210 "TelecomCallCallback.onParentChanged", "call=" + call + " newParent=" + newParent);
211 update();
212 }
213
214 @Override
215 public void onChildrenChanged(Call call, List<Call> children) {
216 update();
217 }
218
219 @Override
220 public void onDetailsChanged(Call call, Call.Details details) {
Eric Erfanian2ca43182017-08-31 06:57:16 -0700221 LogUtil.v(
222 "TelecomCallCallback.onDetailsChanged", " call=" + call + " details=" + details);
Eric Erfanianccca3152017-02-22 16:32:36 -0800223 update();
224 }
225
226 @Override
227 public void onCannedTextResponsesLoaded(Call call, List<String> cannedTextResponses) {
228 LogUtil.v(
Eric Erfanian2ca43182017-08-31 06:57:16 -0700229 "TelecomCallCallback.onCannedTextResponsesLoaded",
Eric Erfanianccca3152017-02-22 16:32:36 -0800230 "call=" + call + " cannedTextResponses=" + cannedTextResponses);
linyuh183cb712017-12-27 17:02:37 -0800231 for (CannedTextResponsesLoadedListener listener : cannedTextResponsesLoadedListeners) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800232 listener.onCannedTextResponsesLoaded(DialerCall.this);
233 }
234 }
235
236 @Override
237 public void onPostDialWait(Call call, String remainingPostDialSequence) {
238 LogUtil.v(
Eric Erfanian2ca43182017-08-31 06:57:16 -0700239 "TelecomCallCallback.onPostDialWait",
Eric Erfanianccca3152017-02-22 16:32:36 -0800240 "call=" + call + " remainingPostDialSequence=" + remainingPostDialSequence);
241 update();
242 }
243
244 @Override
245 public void onVideoCallChanged(Call call, VideoCall videoCall) {
246 LogUtil.v(
Eric Erfanian2ca43182017-08-31 06:57:16 -0700247 "TelecomCallCallback.onVideoCallChanged", "call=" + call + " videoCall=" + videoCall);
Eric Erfanianccca3152017-02-22 16:32:36 -0800248 update();
249 }
250
251 @Override
252 public void onCallDestroyed(Call call) {
Eric Erfanian2ca43182017-08-31 06:57:16 -0700253 LogUtil.v("TelecomCallCallback.onCallDestroyed", "call=" + call);
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700254 unregisterCallback();
Eric Erfanianccca3152017-02-22 16:32:36 -0800255 }
256
257 @Override
258 public void onConferenceableCallsChanged(Call call, List<Call> conferenceableCalls) {
259 LogUtil.v(
Eric Erfanian2ca43182017-08-31 06:57:16 -0700260 "TelecomCallCallback.onConferenceableCallsChanged",
Eric Erfanianccca3152017-02-22 16:32:36 -0800261 "call %s, conferenceable calls: %d",
262 call,
263 conferenceableCalls.size());
264 update();
265 }
266
267 @Override
wangqi219b8702018-02-13 09:34:41 -0800268 public void onRttModeChanged(Call call, int mode) {
269 LogUtil.v("TelecomCallCallback.onRttModeChanged", "mode=%d", mode);
270 }
271
272 @Override
273 public void onRttRequest(Call call, int id) {
274 LogUtil.v("TelecomCallCallback.onRttRequest", "id=%d", id);
275 }
276
277 @Override
278 public void onRttInitiationFailure(Call call, int reason) {
279 LogUtil.v("TelecomCallCallback.onRttInitiationFailure", "reason=%d", reason);
280 update();
281 }
282
283 @Override
284 public void onRttStatusChanged(Call call, boolean enabled, RttCall rttCall) {
285 LogUtil.v("TelecomCallCallback.onRttStatusChanged", "enabled=%b", enabled);
286 update();
287 }
288
289 @Override
Eric Erfanianccca3152017-02-22 16:32:36 -0800290 public void onConnectionEvent(android.telecom.Call call, String event, Bundle extras) {
291 LogUtil.v(
Eric Erfanian2ca43182017-08-31 06:57:16 -0700292 "TelecomCallCallback.onConnectionEvent",
Eric Erfanianccca3152017-02-22 16:32:36 -0800293 "Call: " + call + ", Event: " + event + ", Extras: " + extras);
294 switch (event) {
295 // The Previous attempt to Merge two calls together has failed in Telecom. We must
296 // now update the UI to possibly re-enable the Merge button based on the number of
297 // currently conferenceable calls available or Connection Capabilities.
298 case android.telecom.Connection.EVENT_CALL_MERGE_FAILED:
299 update();
300 break;
301 case TelephonyManagerCompat.EVENT_HANDOVER_VIDEO_FROM_WIFI_TO_LTE:
302 notifyWiFiToLteHandover();
303 break;
304 case TelephonyManagerCompat.EVENT_HANDOVER_TO_WIFI_FAILED:
305 notifyHandoverToWifiFailed();
306 break;
307 case TelephonyManagerCompat.EVENT_CALL_REMOTELY_HELD:
308 isRemotelyHeld = true;
309 update();
310 break;
311 case TelephonyManagerCompat.EVENT_CALL_REMOTELY_UNHELD:
312 isRemotelyHeld = false;
313 update();
314 break;
Eric Erfanianc857f902017-05-15 14:05:33 -0700315 case TelephonyManagerCompat.EVENT_NOTIFY_INTERNATIONAL_CALL_ON_WFC:
316 notifyInternationalCallOnWifi();
317 break;
Eric Erfanian2ca43182017-08-31 06:57:16 -0700318 case TelephonyManagerCompat.EVENT_MERGE_START:
319 LogUtil.i("DialerCall.onConnectionEvent", "merge start");
320 isMergeInProcess = true;
321 break;
322 case TelephonyManagerCompat.EVENT_MERGE_COMPLETE:
323 LogUtil.i("DialerCall.onConnectionEvent", "merge complete");
324 isMergeInProcess = false;
325 break;
wangqif4ba3452018-01-09 11:26:29 -0800326 case TelephonyManagerCompat.EVENT_CALL_FORWARDED:
327 // Only handle this event for P+ since it's unreliable pre-P.
328 if (BuildCompat.isAtLeastP()) {
329 isCallForwarded = true;
330 update();
331 }
332 break;
Eric Erfanianccca3152017-02-22 16:32:36 -0800333 default:
334 break;
335 }
336 }
337 };
Eric Erfanianc857f902017-05-15 14:05:33 -0700338
linyuh183cb712017-12-27 17:02:37 -0800339 private long timeAddedMs;
Eric Erfanianccca3152017-02-22 16:32:36 -0800340
341 public DialerCall(
342 Context context,
343 DialerCallDelegate dialerCallDelegate,
344 Call telecomCall,
345 LatencyReport latencyReport,
346 boolean registerCallback) {
347 Assert.isNotNull(context);
linyuh183cb712017-12-27 17:02:37 -0800348 this.context = context;
349 this.dialerCallDelegate = dialerCallDelegate;
350 this.telecomCall = telecomCall;
351 this.latencyReport = latencyReport;
352 id = ID_PREFIX + Integer.toString(idCounter++);
Eric Erfanianccca3152017-02-22 16:32:36 -0800353
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700354 // Must be after assigning mTelecomCall
linyuh183cb712017-12-27 17:02:37 -0800355 videoTechManager = new VideoTechManager(this);
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700356
357 updateFromTelecomCall();
Eric Erfanianc857f902017-05-15 14:05:33 -0700358 if (isHiddenNumber() && TextUtils.isEmpty(getNumber())) {
linyuh183cb712017-12-27 17:02:37 -0800359 hiddenId = ++hiddenCounter;
Eric Erfanianc857f902017-05-15 14:05:33 -0700360 } else {
linyuh183cb712017-12-27 17:02:37 -0800361 hiddenId = 0;
Eric Erfanianc857f902017-05-15 14:05:33 -0700362 }
Eric Erfanianccca3152017-02-22 16:32:36 -0800363
364 if (registerCallback) {
linyuh183cb712017-12-27 17:02:37 -0800365 this.telecomCall.registerCallback(telecomCallCallback);
Eric Erfanianccca3152017-02-22 16:32:36 -0800366 }
367
linyuh183cb712017-12-27 17:02:37 -0800368 timeAddedMs = System.currentTimeMillis();
Eric Erfanianccca3152017-02-22 16:32:36 -0800369 parseCallSpecificAppData();
Eric Erfanian2ca43182017-08-31 06:57:16 -0700370
371 updateEnrichedCallSession();
Eric Erfanianccca3152017-02-22 16:32:36 -0800372 }
373
twyendde01c52017-09-22 10:07:31 -0700374 /** Test only constructor to avoid initializing dependencies. */
375 @VisibleForTesting
376 DialerCall(Context context) {
linyuh183cb712017-12-27 17:02:37 -0800377 this.context = context;
378 telecomCall = null;
379 latencyReport = null;
380 id = null;
381 hiddenId = 0;
382 dialerCallDelegate = null;
383 videoTechManager = null;
twyendde01c52017-09-22 10:07:31 -0700384 }
385
Eric Erfanianccca3152017-02-22 16:32:36 -0800386 private static int translateState(int state) {
387 switch (state) {
388 case Call.STATE_NEW:
389 case Call.STATE_CONNECTING:
390 return DialerCall.State.CONNECTING;
391 case Call.STATE_SELECT_PHONE_ACCOUNT:
392 return DialerCall.State.SELECT_PHONE_ACCOUNT;
393 case Call.STATE_DIALING:
394 return DialerCall.State.DIALING;
395 case Call.STATE_PULLING_CALL:
396 return DialerCall.State.PULLING;
397 case Call.STATE_RINGING:
398 return DialerCall.State.INCOMING;
399 case Call.STATE_ACTIVE:
400 return DialerCall.State.ACTIVE;
401 case Call.STATE_HOLDING:
402 return DialerCall.State.ONHOLD;
403 case Call.STATE_DISCONNECTED:
404 return DialerCall.State.DISCONNECTED;
405 case Call.STATE_DISCONNECTING:
406 return DialerCall.State.DISCONNECTING;
407 default:
408 return DialerCall.State.INVALID;
409 }
410 }
411
412 public static boolean areSame(DialerCall call1, DialerCall call2) {
413 if (call1 == null && call2 == null) {
414 return true;
415 } else if (call1 == null || call2 == null) {
416 return false;
417 }
418
419 // otherwise compare call Ids
420 return call1.getId().equals(call2.getId());
421 }
422
Eric Erfanianccca3152017-02-22 16:32:36 -0800423 public void addListener(DialerCallListener listener) {
424 Assert.isMainThread();
linyuh183cb712017-12-27 17:02:37 -0800425 listeners.add(listener);
Eric Erfanianccca3152017-02-22 16:32:36 -0800426 }
427
428 public void removeListener(DialerCallListener listener) {
429 Assert.isMainThread();
linyuh183cb712017-12-27 17:02:37 -0800430 listeners.remove(listener);
Eric Erfanianccca3152017-02-22 16:32:36 -0800431 }
432
433 public void addCannedTextResponsesLoadedListener(CannedTextResponsesLoadedListener listener) {
434 Assert.isMainThread();
linyuh183cb712017-12-27 17:02:37 -0800435 cannedTextResponsesLoadedListeners.add(listener);
Eric Erfanianccca3152017-02-22 16:32:36 -0800436 }
437
438 public void removeCannedTextResponsesLoadedListener(CannedTextResponsesLoadedListener listener) {
439 Assert.isMainThread();
linyuh183cb712017-12-27 17:02:37 -0800440 cannedTextResponsesLoadedListeners.remove(listener);
Eric Erfanianccca3152017-02-22 16:32:36 -0800441 }
442
443 public void notifyWiFiToLteHandover() {
444 LogUtil.i("DialerCall.notifyWiFiToLteHandover", "");
linyuh183cb712017-12-27 17:02:37 -0800445 for (DialerCallListener listener : listeners) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800446 listener.onWiFiToLteHandover();
447 }
448 }
449
450 public void notifyHandoverToWifiFailed() {
451 LogUtil.i("DialerCall.notifyHandoverToWifiFailed", "");
linyuh183cb712017-12-27 17:02:37 -0800452 for (DialerCallListener listener : listeners) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800453 listener.onHandoverToWifiFailure();
454 }
455 }
456
Eric Erfanianc857f902017-05-15 14:05:33 -0700457 public void notifyInternationalCallOnWifi() {
458 LogUtil.enterBlock("DialerCall.notifyInternationalCallOnWifi");
linyuh183cb712017-12-27 17:02:37 -0800459 for (DialerCallListener dialerCallListener : listeners) {
Eric Erfanianc857f902017-05-15 14:05:33 -0700460 dialerCallListener.onInternationalCallOnWifi();
461 }
462 }
463
Eric Erfanianccca3152017-02-22 16:32:36 -0800464 /* package-private */ Call getTelecomCall() {
linyuh183cb712017-12-27 17:02:37 -0800465 return telecomCall;
Eric Erfanianccca3152017-02-22 16:32:36 -0800466 }
Android Dialer974fc292018-02-01 16:12:25 -0800467
Eric Erfanianccca3152017-02-22 16:32:36 -0800468 public StatusHints getStatusHints() {
linyuh183cb712017-12-27 17:02:37 -0800469 return telecomCall.getDetails().getStatusHints();
Eric Erfanianccca3152017-02-22 16:32:36 -0800470 }
471
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700472 public int getCameraDir() {
linyuh183cb712017-12-27 17:02:37 -0800473 return cameraDirection;
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700474 }
475
476 public void setCameraDir(int cameraDir) {
477 if (cameraDir == CameraDirection.CAMERA_DIRECTION_FRONT_FACING
478 || cameraDir == CameraDirection.CAMERA_DIRECTION_BACK_FACING) {
linyuh183cb712017-12-27 17:02:37 -0800479 cameraDirection = cameraDir;
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700480 } else {
linyuh183cb712017-12-27 17:02:37 -0800481 cameraDirection = CameraDirection.CAMERA_DIRECTION_UNKNOWN;
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700482 }
Eric Erfanianccca3152017-02-22 16:32:36 -0800483 }
484
Eric Erfanian2ca43182017-08-31 06:57:16 -0700485 public boolean wasParentCall() {
linyuh183cb712017-12-27 17:02:37 -0800486 return logState.conferencedCalls != 0;
Eric Erfanian2ca43182017-08-31 06:57:16 -0700487 }
488
wangqi9982f0d2017-10-11 17:46:07 -0700489 public boolean isVoiceMailNumber() {
490 return isVoicemailNumber;
491 }
492
493 public List<PhoneAccountHandle> getCallCapableAccounts() {
494 return callCapableAccounts;
495 }
496
497 public String getCountryIso() {
498 return countryIso;
499 }
500
501 private void updateIsVoiceMailNumber() {
502 if (getHandle() != null && PhoneAccount.SCHEME_VOICEMAIL.equals(getHandle().getScheme())) {
503 isVoicemailNumber = true;
504 }
505
linyuh183cb712017-12-27 17:02:37 -0800506 if (!PermissionsUtil.hasPermission(context, permission.READ_PHONE_STATE)) {
wangqi9982f0d2017-10-11 17:46:07 -0700507 isVoicemailNumber = false;
508 }
509
linyuh183cb712017-12-27 17:02:37 -0800510 isVoicemailNumber = TelecomUtil.isVoicemailNumber(context, getAccountHandle(), getNumber());
wangqi9982f0d2017-10-11 17:46:07 -0700511 }
512
Eric Erfanianccca3152017-02-22 16:32:36 -0800513 private void update() {
Eric Erfanian2ca43182017-08-31 06:57:16 -0700514 Trace.beginSection("DialerCall.update");
Eric Erfanianccca3152017-02-22 16:32:36 -0800515 int oldState = getState();
roldenburg7bb96232017-10-09 10:32:05 -0700516 // Clear any cache here that could potentially change on update.
517 videoTech = null;
Eric Erfanianccca3152017-02-22 16:32:36 -0800518 // We want to potentially register a video call callback here.
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700519 updateFromTelecomCall();
Eric Erfanianccca3152017-02-22 16:32:36 -0800520 if (oldState != getState() && getState() == DialerCall.State.DISCONNECTED) {
linyuh183cb712017-12-27 17:02:37 -0800521 for (DialerCallListener listener : listeners) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800522 listener.onDialerCallDisconnect();
523 }
linyuh183cb712017-12-27 17:02:37 -0800524 EnrichedCallComponent.get(context)
Eric Erfanian2ca43182017-08-31 06:57:16 -0700525 .getEnrichedCallManager()
526 .unregisterCapabilitiesListener(this);
linyuh183cb712017-12-27 17:02:37 -0800527 EnrichedCallComponent.get(context)
Eric Erfanian2ca43182017-08-31 06:57:16 -0700528 .getEnrichedCallManager()
529 .unregisterStateChangedListener(this);
Eric Erfanianccca3152017-02-22 16:32:36 -0800530 } else {
linyuh183cb712017-12-27 17:02:37 -0800531 for (DialerCallListener listener : listeners) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800532 listener.onDialerCallUpdate();
533 }
534 }
535 Trace.endSection();
536 }
537
wangqi9982f0d2017-10-11 17:46:07 -0700538 @SuppressWarnings("MissingPermission")
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700539 private void updateFromTelecomCall() {
Eric Erfanian2ca43182017-08-31 06:57:16 -0700540 Trace.beginSection("DialerCall.updateFromTelecomCall");
linyuh183cb712017-12-27 17:02:37 -0800541 LogUtil.v("DialerCall.updateFromTelecomCall", telecomCall.toString());
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700542
roldenburg6bd612f2018-01-18 12:57:19 -0800543 videoTechManager.dispatchCallStateChanged(telecomCall.getState(), getAccountHandle());
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700544
linyuh183cb712017-12-27 17:02:37 -0800545 final int translatedState = translateState(telecomCall.getState());
546 if (state != State.BLOCKED) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800547 setState(translatedState);
linyuh183cb712017-12-27 17:02:37 -0800548 setDisconnectCause(telecomCall.getDetails().getDisconnectCause());
Eric Erfanianccca3152017-02-22 16:32:36 -0800549 }
550
linyuh183cb712017-12-27 17:02:37 -0800551 childCallIds.clear();
552 final int numChildCalls = telecomCall.getChildren().size();
Eric Erfanianccca3152017-02-22 16:32:36 -0800553 for (int i = 0; i < numChildCalls; i++) {
linyuh183cb712017-12-27 17:02:37 -0800554 childCallIds.add(
555 dialerCallDelegate
556 .getDialerCallFromTelecomCall(telecomCall.getChildren().get(i))
Eric Erfanianccca3152017-02-22 16:32:36 -0800557 .getId());
558 }
559
560 // The number of conferenced calls can change over the course of the call, so use the
561 // maximum number of conferenced child calls as the metric for conference call usage.
linyuh183cb712017-12-27 17:02:37 -0800562 logState.conferencedCalls = Math.max(numChildCalls, logState.conferencedCalls);
Eric Erfanianccca3152017-02-22 16:32:36 -0800563
linyuh183cb712017-12-27 17:02:37 -0800564 updateFromCallExtras(telecomCall.getDetails().getExtras());
Eric Erfanianccca3152017-02-22 16:32:36 -0800565
566 // If the handle of the call has changed, update state for the call determining if it is an
567 // emergency call.
linyuh183cb712017-12-27 17:02:37 -0800568 Uri newHandle = telecomCall.getDetails().getHandle();
569 if (!Objects.equals(handle, newHandle)) {
570 handle = newHandle;
Eric Erfanianccca3152017-02-22 16:32:36 -0800571 updateEmergencyCallState();
572 }
573
linyuh183cb712017-12-27 17:02:37 -0800574 TelecomManager telecomManager = context.getSystemService(TelecomManager.class);
Eric Erfanianccca3152017-02-22 16:32:36 -0800575 // If the phone account handle of the call is set, cache capability bit indicating whether
576 // the phone account supports call subjects.
linyuh183cb712017-12-27 17:02:37 -0800577 PhoneAccountHandle newPhoneAccountHandle = telecomCall.getDetails().getAccountHandle();
578 if (!Objects.equals(phoneAccountHandle, newPhoneAccountHandle)) {
579 phoneAccountHandle = newPhoneAccountHandle;
Eric Erfanianccca3152017-02-22 16:32:36 -0800580
linyuh183cb712017-12-27 17:02:37 -0800581 if (phoneAccountHandle != null) {
582 PhoneAccount phoneAccount = telecomManager.getPhoneAccount(phoneAccountHandle);
Eric Erfanianccca3152017-02-22 16:32:36 -0800583 if (phoneAccount != null) {
linyuh183cb712017-12-27 17:02:37 -0800584 isCallSubjectSupported =
Eric Erfanianccca3152017-02-22 16:32:36 -0800585 phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_CALL_SUBJECT);
586 }
587 }
588 }
linyuh183cb712017-12-27 17:02:37 -0800589 if (PermissionsUtil.hasPermission(context, permission.READ_PHONE_STATE)) {
wangqi9982f0d2017-10-11 17:46:07 -0700590 updateIsVoiceMailNumber();
591 callCapableAccounts = telecomManager.getCallCapablePhoneAccounts();
linyuh183cb712017-12-27 17:02:37 -0800592 countryIso = GeoUtil.getCurrentCountryIso(context);
wangqi9982f0d2017-10-11 17:46:07 -0700593 }
Eric Erfanian2ca43182017-08-31 06:57:16 -0700594 Trace.endSection();
Eric Erfanianccca3152017-02-22 16:32:36 -0800595 }
596
597 /**
598 * Tests corruption of the {@code callExtras} bundle by calling {@link
599 * Bundle#containsKey(String)}. If the bundle is corrupted a {@link IllegalArgumentException} will
600 * be thrown and caught by this function.
601 *
602 * @param callExtras the bundle to verify
603 * @return {@code true} if the bundle is corrupted, {@code false} otherwise.
604 */
605 protected boolean areCallExtrasCorrupted(Bundle callExtras) {
606 /**
Eric Erfanian938468d2017-10-24 14:05:52 -0700607 * There's currently a bug in Telephony service (a bug) that could corrupt the extras
Eric Erfanianccca3152017-02-22 16:32:36 -0800608 * bundle, resulting in a IllegalArgumentException while validating data under {@link
609 * Bundle#containsKey(String)}.
610 */
611 try {
612 callExtras.containsKey(Connection.EXTRA_CHILD_ADDRESS);
613 return false;
614 } catch (IllegalArgumentException e) {
615 LogUtil.e(
616 "DialerCall.areCallExtrasCorrupted", "callExtras is corrupted, ignoring exception", e);
617 return true;
618 }
619 }
620
621 protected void updateFromCallExtras(Bundle callExtras) {
622 if (callExtras == null || areCallExtrasCorrupted(callExtras)) {
623 /**
624 * If the bundle is corrupted, abandon information update as a work around. These are not
625 * critical for the dialer to function.
626 */
627 return;
628 }
629 // Check for a change in the child address and notify any listeners.
630 if (callExtras.containsKey(Connection.EXTRA_CHILD_ADDRESS)) {
631 String childNumber = callExtras.getString(Connection.EXTRA_CHILD_ADDRESS);
linyuh183cb712017-12-27 17:02:37 -0800632 if (!Objects.equals(childNumber, this.childNumber)) {
633 this.childNumber = childNumber;
634 for (DialerCallListener listener : listeners) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800635 listener.onDialerCallChildNumberChange();
636 }
637 }
638 }
639
640 // Last forwarded number comes in as an array of strings. We want to choose the
641 // last item in the array. The forwarding numbers arrive independently of when the
642 // call is originally set up, so we need to notify the the UI of the change.
643 if (callExtras.containsKey(Connection.EXTRA_LAST_FORWARDED_NUMBER)) {
644 ArrayList<String> lastForwardedNumbers =
645 callExtras.getStringArrayList(Connection.EXTRA_LAST_FORWARDED_NUMBER);
646
647 if (lastForwardedNumbers != null) {
648 String lastForwardedNumber = null;
649 if (!lastForwardedNumbers.isEmpty()) {
650 lastForwardedNumber = lastForwardedNumbers.get(lastForwardedNumbers.size() - 1);
651 }
652
linyuh183cb712017-12-27 17:02:37 -0800653 if (!Objects.equals(lastForwardedNumber, this.lastForwardedNumber)) {
654 this.lastForwardedNumber = lastForwardedNumber;
655 for (DialerCallListener listener : listeners) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800656 listener.onDialerCallLastForwardedNumberChange();
657 }
658 }
659 }
660 }
661
662 // DialerCall subject is present in the extras at the start of call, so we do not need to
663 // notify any other listeners of this.
664 if (callExtras.containsKey(Connection.EXTRA_CALL_SUBJECT)) {
665 String callSubject = callExtras.getString(Connection.EXTRA_CALL_SUBJECT);
linyuh183cb712017-12-27 17:02:37 -0800666 if (!Objects.equals(this.callSubject, callSubject)) {
667 this.callSubject = callSubject;
Eric Erfanianccca3152017-02-22 16:32:36 -0800668 }
669 }
670 }
671
Eric Erfanianccca3152017-02-22 16:32:36 -0800672 public String getId() {
linyuh183cb712017-12-27 17:02:37 -0800673 return id;
Eric Erfanianccca3152017-02-22 16:32:36 -0800674 }
675
Eric Erfanianc857f902017-05-15 14:05:33 -0700676 /**
677 * @return name appended with a number if the number is restricted/unknown and the user has
678 * received more than one restricted/unknown call.
679 */
680 @Nullable
681 public String updateNameIfRestricted(@Nullable String name) {
linyuh183cb712017-12-27 17:02:37 -0800682 if (name != null && isHiddenNumber() && hiddenId != 0 && hiddenCounter > 1) {
683 return context.getString(R.string.unknown_counter, name, hiddenId);
Eric Erfanianc857f902017-05-15 14:05:33 -0700684 }
685 return name;
686 }
687
688 public static void clearRestrictedCount() {
linyuh183cb712017-12-27 17:02:37 -0800689 hiddenCounter = 0;
Eric Erfanianc857f902017-05-15 14:05:33 -0700690 }
691
692 private boolean isHiddenNumber() {
693 return getNumberPresentation() == TelecomManager.PRESENTATION_RESTRICTED
694 || getNumberPresentation() == TelecomManager.PRESENTATION_UNKNOWN;
695 }
696
Eric Erfanianccca3152017-02-22 16:32:36 -0800697 public boolean hasShownWiFiToLteHandoverToast() {
698 return hasShownWiFiToLteHandoverToast;
699 }
700
701 public void setHasShownWiFiToLteHandoverToast() {
702 hasShownWiFiToLteHandoverToast = true;
703 }
704
705 public boolean showWifiHandoverAlertAsToast() {
706 return doNotShowDialogForHandoffToWifiFailure;
707 }
708
709 public void setDoNotShowDialogForHandoffToWifiFailure(boolean bool) {
710 doNotShowDialogForHandoffToWifiFailure = bool;
711 }
712
713 public long getTimeAddedMs() {
linyuh183cb712017-12-27 17:02:37 -0800714 return timeAddedMs;
Eric Erfanianccca3152017-02-22 16:32:36 -0800715 }
716
717 @Nullable
718 public String getNumber() {
linyuh183cb712017-12-27 17:02:37 -0800719 return TelecomCallUtil.getNumber(telecomCall);
Eric Erfanianccca3152017-02-22 16:32:36 -0800720 }
721
722 public void blockCall() {
linyuh183cb712017-12-27 17:02:37 -0800723 telecomCall.reject(false, null);
Eric Erfanianccca3152017-02-22 16:32:36 -0800724 setState(State.BLOCKED);
725 }
726
727 @Nullable
728 public Uri getHandle() {
linyuh183cb712017-12-27 17:02:37 -0800729 return telecomCall == null ? null : telecomCall.getDetails().getHandle();
Eric Erfanianccca3152017-02-22 16:32:36 -0800730 }
731
732 public boolean isEmergencyCall() {
linyuh183cb712017-12-27 17:02:37 -0800733 return isEmergencyCall;
Eric Erfanianccca3152017-02-22 16:32:36 -0800734 }
735
736 public boolean isPotentialEmergencyCallback() {
737 // The property PROPERTY_EMERGENCY_CALLBACK_MODE is only set for CDMA calls when the system
738 // is actually in emergency callback mode (ie data is disabled).
739 if (hasProperty(Details.PROPERTY_EMERGENCY_CALLBACK_MODE)) {
740 return true;
741 }
742 // We want to treat any incoming call that arrives a short time after an outgoing emergency call
743 // as a potential emergency callback.
744 if (getExtras() != null
745 && getExtras().getLong(TelecomManagerCompat.EXTRA_LAST_EMERGENCY_CALLBACK_TIME_MILLIS, 0)
746 > 0) {
747 long lastEmergencyCallMillis =
748 getExtras().getLong(TelecomManagerCompat.EXTRA_LAST_EMERGENCY_CALLBACK_TIME_MILLIS, 0);
749 if (isInEmergencyCallbackWindow(lastEmergencyCallMillis)) {
750 return true;
751 }
752 }
753 return false;
754 }
755
756 boolean isInEmergencyCallbackWindow(long timestampMillis) {
757 long emergencyCallbackWindowMillis =
linyuh183cb712017-12-27 17:02:37 -0800758 ConfigProviderBindings.get(context)
Eric Erfanianccca3152017-02-22 16:32:36 -0800759 .getLong(CONFIG_EMERGENCY_CALLBACK_WINDOW_MILLIS, TimeUnit.MINUTES.toMillis(5));
760 return System.currentTimeMillis() - timestampMillis < emergencyCallbackWindowMillis;
761 }
762
763 public int getState() {
linyuh183cb712017-12-27 17:02:37 -0800764 if (telecomCall != null && telecomCall.getParent() != null) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800765 return State.CONFERENCED;
766 } else {
linyuh183cb712017-12-27 17:02:37 -0800767 return state;
Eric Erfanianccca3152017-02-22 16:32:36 -0800768 }
769 }
770
yueg265089a2017-10-06 14:35:15 -0700771 public int getNonConferenceState() {
linyuh183cb712017-12-27 17:02:37 -0800772 return state;
yueg265089a2017-10-06 14:35:15 -0700773 }
774
Eric Erfanianccca3152017-02-22 16:32:36 -0800775 public void setState(int state) {
Eric Erfanian2ca43182017-08-31 06:57:16 -0700776 if (state == State.INCOMING) {
linyuh183cb712017-12-27 17:02:37 -0800777 logState.isIncoming = true;
Eric Erfanian2ca43182017-08-31 06:57:16 -0700778 } else if (state == State.DISCONNECTED) {
779 long newDuration =
Eric Erfanianccca3152017-02-22 16:32:36 -0800780 getConnectTimeMillis() == 0 ? 0 : System.currentTimeMillis() - getConnectTimeMillis();
linyuh183cb712017-12-27 17:02:37 -0800781 if (this.state != state) {
782 logState.duration = newDuration;
Eric Erfanian2ca43182017-08-31 06:57:16 -0700783 } else {
784 LogUtil.i(
785 "DialerCall.setState",
786 "ignoring state transition from DISCONNECTED to DISCONNECTED."
787 + " Duration would have changed from %s to %s",
linyuh183cb712017-12-27 17:02:37 -0800788 logState.duration,
Eric Erfanian2ca43182017-08-31 06:57:16 -0700789 newDuration);
790 }
Eric Erfanianccca3152017-02-22 16:32:36 -0800791 }
linyuh183cb712017-12-27 17:02:37 -0800792 this.state = state;
Eric Erfanianccca3152017-02-22 16:32:36 -0800793 }
794
795 public int getNumberPresentation() {
linyuh183cb712017-12-27 17:02:37 -0800796 return telecomCall == null ? -1 : telecomCall.getDetails().getHandlePresentation();
Eric Erfanianccca3152017-02-22 16:32:36 -0800797 }
798
799 public int getCnapNamePresentation() {
linyuh183cb712017-12-27 17:02:37 -0800800 return telecomCall == null ? -1 : telecomCall.getDetails().getCallerDisplayNamePresentation();
Eric Erfanianccca3152017-02-22 16:32:36 -0800801 }
802
803 @Nullable
804 public String getCnapName() {
linyuh183cb712017-12-27 17:02:37 -0800805 return telecomCall == null ? null : getTelecomCall().getDetails().getCallerDisplayName();
Eric Erfanianccca3152017-02-22 16:32:36 -0800806 }
807
808 public Bundle getIntentExtras() {
linyuh183cb712017-12-27 17:02:37 -0800809 return telecomCall.getDetails().getIntentExtras();
Eric Erfanianccca3152017-02-22 16:32:36 -0800810 }
811
812 @Nullable
813 public Bundle getExtras() {
linyuh183cb712017-12-27 17:02:37 -0800814 return telecomCall == null ? null : telecomCall.getDetails().getExtras();
Eric Erfanianccca3152017-02-22 16:32:36 -0800815 }
816
817 /** @return The child number for the call, or {@code null} if none specified. */
818 public String getChildNumber() {
linyuh183cb712017-12-27 17:02:37 -0800819 return childNumber;
Eric Erfanianccca3152017-02-22 16:32:36 -0800820 }
821
822 /** @return The last forwarded number for the call, or {@code null} if none specified. */
823 public String getLastForwardedNumber() {
linyuh183cb712017-12-27 17:02:37 -0800824 return lastForwardedNumber;
Eric Erfanianccca3152017-02-22 16:32:36 -0800825 }
826
wangqif4ba3452018-01-09 11:26:29 -0800827 public boolean isCallForwarded() {
828 return isCallForwarded;
829 }
830
Eric Erfanianccca3152017-02-22 16:32:36 -0800831 /** @return The call subject, or {@code null} if none specified. */
832 public String getCallSubject() {
linyuh183cb712017-12-27 17:02:37 -0800833 return callSubject;
Eric Erfanianccca3152017-02-22 16:32:36 -0800834 }
835
836 /**
837 * @return {@code true} if the call's phone account supports call subjects, {@code false}
838 * otherwise.
839 */
840 public boolean isCallSubjectSupported() {
linyuh183cb712017-12-27 17:02:37 -0800841 return isCallSubjectSupported;
Eric Erfanianccca3152017-02-22 16:32:36 -0800842 }
843
844 /** Returns call disconnect cause, defined by {@link DisconnectCause}. */
845 public DisconnectCause getDisconnectCause() {
linyuh183cb712017-12-27 17:02:37 -0800846 if (state == State.DISCONNECTED || state == State.IDLE) {
847 return disconnectCause;
Eric Erfanianccca3152017-02-22 16:32:36 -0800848 }
849
850 return new DisconnectCause(DisconnectCause.UNKNOWN);
851 }
852
853 public void setDisconnectCause(DisconnectCause disconnectCause) {
linyuh183cb712017-12-27 17:02:37 -0800854 this.disconnectCause = disconnectCause;
855 logState.disconnectCause = this.disconnectCause;
Eric Erfanianccca3152017-02-22 16:32:36 -0800856 }
857
858 /** Returns the possible text message responses. */
859 public List<String> getCannedSmsResponses() {
linyuh183cb712017-12-27 17:02:37 -0800860 return telecomCall.getCannedTextResponses();
Eric Erfanianccca3152017-02-22 16:32:36 -0800861 }
862
863 /** Checks if the call supports the given set of capabilities supplied as a bit mask. */
864 public boolean can(int capabilities) {
linyuh183cb712017-12-27 17:02:37 -0800865 int supportedCapabilities = telecomCall.getDetails().getCallCapabilities();
Eric Erfanianccca3152017-02-22 16:32:36 -0800866
867 if ((capabilities & Call.Details.CAPABILITY_MERGE_CONFERENCE) != 0) {
868 // We allow you to merge if the capabilities allow it or if it is a call with
869 // conferenceable calls.
linyuh183cb712017-12-27 17:02:37 -0800870 if (telecomCall.getConferenceableCalls().isEmpty()
Eric Erfanianccca3152017-02-22 16:32:36 -0800871 && ((Call.Details.CAPABILITY_MERGE_CONFERENCE & supportedCapabilities) == 0)) {
872 // Cannot merge calls if there are no calls to merge with.
873 return false;
874 }
875 capabilities &= ~Call.Details.CAPABILITY_MERGE_CONFERENCE;
876 }
877 return (capabilities == (capabilities & supportedCapabilities));
878 }
879
880 public boolean hasProperty(int property) {
linyuh183cb712017-12-27 17:02:37 -0800881 return telecomCall.getDetails().hasProperty(property);
Eric Erfanianccca3152017-02-22 16:32:36 -0800882 }
883
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700884 @NonNull
Eric Erfanianccca3152017-02-22 16:32:36 -0800885 public String getUniqueCallId() {
886 return uniqueCallId;
887 }
888
889 /** Gets the time when the call first became active. */
890 public long getConnectTimeMillis() {
linyuh183cb712017-12-27 17:02:37 -0800891 return telecomCall.getDetails().getConnectTimeMillis();
Eric Erfanianccca3152017-02-22 16:32:36 -0800892 }
893
894 public boolean isConferenceCall() {
895 return hasProperty(Call.Details.PROPERTY_CONFERENCE);
896 }
897
898 @Nullable
899 public GatewayInfo getGatewayInfo() {
linyuh183cb712017-12-27 17:02:37 -0800900 return telecomCall == null ? null : telecomCall.getDetails().getGatewayInfo();
Eric Erfanianccca3152017-02-22 16:32:36 -0800901 }
902
903 @Nullable
904 public PhoneAccountHandle getAccountHandle() {
linyuh183cb712017-12-27 17:02:37 -0800905 return telecomCall == null ? null : telecomCall.getDetails().getAccountHandle();
Eric Erfanianccca3152017-02-22 16:32:36 -0800906 }
907
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700908 /** @return The {@link VideoCall} instance associated with the {@link Call}. */
Eric Erfanianccca3152017-02-22 16:32:36 -0800909 public VideoCall getVideoCall() {
linyuh183cb712017-12-27 17:02:37 -0800910 return telecomCall == null ? null : telecomCall.getVideoCall();
Eric Erfanianccca3152017-02-22 16:32:36 -0800911 }
912
913 public List<String> getChildCallIds() {
linyuh183cb712017-12-27 17:02:37 -0800914 return childCallIds;
Eric Erfanianccca3152017-02-22 16:32:36 -0800915 }
916
917 public String getParentId() {
linyuh183cb712017-12-27 17:02:37 -0800918 Call parentCall = telecomCall.getParent();
Eric Erfanianccca3152017-02-22 16:32:36 -0800919 if (parentCall != null) {
linyuh183cb712017-12-27 17:02:37 -0800920 return dialerCallDelegate.getDialerCallFromTelecomCall(parentCall).getId();
Eric Erfanianccca3152017-02-22 16:32:36 -0800921 }
922 return null;
923 }
924
925 public int getVideoState() {
linyuh183cb712017-12-27 17:02:37 -0800926 return telecomCall.getDetails().getVideoState();
Eric Erfanianccca3152017-02-22 16:32:36 -0800927 }
928
929 public boolean isVideoCall() {
roldenburg2cec3802017-10-11 16:26:51 -0700930 return getVideoTech().isTransmittingOrReceiving() || VideoProfile.isVideo(getVideoState());
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700931 }
932
wangqi8d407a02018-02-15 15:32:52 -0800933 @TargetApi(28)
wangqi219b8702018-02-13 09:34:41 -0800934 public boolean isRttCall() {
935 if (BuildCompat.isAtLeastP()) {
936 return getTelecomCall().isRttActive();
937 } else {
938 return false;
939 }
940 }
941
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700942 public boolean hasReceivedVideoUpgradeRequest() {
943 return VideoUtils.hasReceivedVideoUpgradeRequest(getVideoTech().getSessionModificationState());
944 }
945
946 public boolean hasSentVideoUpgradeRequest() {
947 return VideoUtils.hasSentVideoUpgradeRequest(getVideoTech().getSessionModificationState());
Eric Erfanianccca3152017-02-22 16:32:36 -0800948 }
949
wangqi219b8702018-02-13 09:34:41 -0800950 public boolean hasSentRttUpgradeRequest() {
951 // TODO(wangqi): Implement this.
952 return false;
953 }
954
Eric Erfanianccca3152017-02-22 16:32:36 -0800955 /**
956 * Determines if the call handle is an emergency number or not and caches the result to avoid
957 * repeated calls to isEmergencyNumber.
958 */
959 private void updateEmergencyCallState() {
linyuh183cb712017-12-27 17:02:37 -0800960 isEmergencyCall = TelecomCallUtil.isEmergencyCall(telecomCall);
Eric Erfanianccca3152017-02-22 16:32:36 -0800961 }
962
Eric Erfanianccca3152017-02-22 16:32:36 -0800963 public LogState getLogState() {
linyuh183cb712017-12-27 17:02:37 -0800964 return logState;
Eric Erfanianccca3152017-02-22 16:32:36 -0800965 }
966
967 /**
968 * Determines if the call is an external call.
969 *
970 * <p>An external call is one which does not exist locally for the {@link
971 * android.telecom.ConnectionService} it is associated with.
972 *
973 * <p>External calls are only supported in N and higher.
974 *
975 * @return {@code true} if the call is an external call, {@code false} otherwise.
976 */
977 public boolean isExternalCall() {
978 return VERSION.SDK_INT >= VERSION_CODES.N
979 && hasProperty(CallCompat.Details.PROPERTY_IS_EXTERNAL_CALL);
980 }
981
982 /**
Eric Erfanianccca3152017-02-22 16:32:36 -0800983 * Determines if answering this call will cause an ongoing video call to be dropped.
984 *
985 * @return {@code true} if answering this call will drop an ongoing video call, {@code false}
986 * otherwise.
987 */
988 public boolean answeringDisconnectsForegroundVideoCall() {
989 Bundle extras = getExtras();
990 if (extras == null
991 || !extras.containsKey(CallCompat.Details.EXTRA_ANSWERING_DROPS_FOREGROUND_CALL)) {
992 return false;
993 }
994 return extras.getBoolean(CallCompat.Details.EXTRA_ANSWERING_DROPS_FOREGROUND_CALL);
995 }
996
997 private void parseCallSpecificAppData() {
998 if (isExternalCall()) {
999 return;
1000 }
1001
linyuh183cb712017-12-27 17:02:37 -08001002 logState.callSpecificAppData = CallIntentParser.getCallSpecificAppData(getIntentExtras());
1003 if (logState.callSpecificAppData == null) {
Eric Erfanian8369df02017-05-03 10:27:13 -07001004
linyuh183cb712017-12-27 17:02:37 -08001005 logState.callSpecificAppData =
Eric Erfanian8369df02017-05-03 10:27:13 -07001006 CallSpecificAppData.newBuilder()
1007 .setCallInitiationType(CallInitiationType.Type.EXTERNAL_INITIATION)
1008 .build();
Eric Erfanianccca3152017-02-22 16:32:36 -08001009 }
1010 if (getState() == State.INCOMING) {
linyuh183cb712017-12-27 17:02:37 -08001011 logState.callSpecificAppData =
1012 logState
Eric Erfanian8369df02017-05-03 10:27:13 -07001013 .callSpecificAppData
1014 .toBuilder()
1015 .setCallInitiationType(CallInitiationType.Type.INCOMING_INITIATION)
1016 .build();
Eric Erfanianccca3152017-02-22 16:32:36 -08001017 }
1018 }
1019
1020 @Override
1021 public String toString() {
linyuh183cb712017-12-27 17:02:37 -08001022 if (telecomCall == null) {
Eric Erfanianccca3152017-02-22 16:32:36 -08001023 // This should happen only in testing since otherwise we would never have a null
1024 // Telecom call.
linyuh183cb712017-12-27 17:02:37 -08001025 return String.valueOf(id);
Eric Erfanianccca3152017-02-22 16:32:36 -08001026 }
1027
1028 return String.format(
1029 Locale.US,
1030 "[%s, %s, %s, %s, children:%s, parent:%s, "
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001031 + "conferenceable:%s, videoState:%s, mSessionModificationState:%d, CameraDir:%s]",
linyuh183cb712017-12-27 17:02:37 -08001032 id,
Eric Erfanianccca3152017-02-22 16:32:36 -08001033 State.toString(getState()),
linyuh183cb712017-12-27 17:02:37 -08001034 Details.capabilitiesToString(telecomCall.getDetails().getCallCapabilities()),
1035 Details.propertiesToString(telecomCall.getDetails().getCallProperties()),
1036 childCallIds,
Eric Erfanianccca3152017-02-22 16:32:36 -08001037 getParentId(),
linyuh183cb712017-12-27 17:02:37 -08001038 this.telecomCall.getConferenceableCalls(),
1039 VideoProfile.videoStateToString(telecomCall.getDetails().getVideoState()),
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001040 getVideoTech().getSessionModificationState(),
1041 getCameraDir());
Eric Erfanianccca3152017-02-22 16:32:36 -08001042 }
1043
1044 public String toSimpleString() {
1045 return super.toString();
1046 }
1047
1048 @CallHistoryStatus
1049 public int getCallHistoryStatus() {
linyuh183cb712017-12-27 17:02:37 -08001050 return callHistoryStatus;
Eric Erfanianccca3152017-02-22 16:32:36 -08001051 }
1052
1053 public void setCallHistoryStatus(@CallHistoryStatus int callHistoryStatus) {
linyuh183cb712017-12-27 17:02:37 -08001054 this.callHistoryStatus = callHistoryStatus;
Eric Erfanianccca3152017-02-22 16:32:36 -08001055 }
1056
1057 public boolean didShowCameraPermission() {
1058 return didShowCameraPermission;
1059 }
1060
1061 public void setDidShowCameraPermission(boolean didShow) {
1062 didShowCameraPermission = didShow;
1063 }
1064
Eric Erfanian938468d2017-10-24 14:05:52 -07001065 @Nullable
1066 public Boolean isInGlobalSpamList() {
Eric Erfanianccca3152017-02-22 16:32:36 -08001067 return isInGlobalSpamList;
1068 }
1069
1070 public void setIsInGlobalSpamList(boolean inSpamList) {
1071 isInGlobalSpamList = inSpamList;
1072 }
1073
Eric Erfanian938468d2017-10-24 14:05:52 -07001074 @Nullable
1075 public Boolean isInUserSpamList() {
Eric Erfanianccca3152017-02-22 16:32:36 -08001076 return isInUserSpamList;
1077 }
1078
1079 public void setIsInUserSpamList(boolean inSpamList) {
1080 isInUserSpamList = inSpamList;
1081 }
1082
Eric Erfanian938468d2017-10-24 14:05:52 -07001083 @Nullable
1084 public Boolean isInUserWhiteList() {
Eric Erfanianccca3152017-02-22 16:32:36 -08001085 return isInUserWhiteList;
1086 }
1087
1088 public void setIsInUserWhiteList(boolean inWhiteList) {
1089 isInUserWhiteList = inWhiteList;
1090 }
1091
1092 public boolean isSpam() {
linyuh183cb712017-12-27 17:02:37 -08001093 return isSpam;
Eric Erfanianccca3152017-02-22 16:32:36 -08001094 }
1095
1096 public void setSpam(boolean isSpam) {
linyuh183cb712017-12-27 17:02:37 -08001097 this.isSpam = isSpam;
Eric Erfanianccca3152017-02-22 16:32:36 -08001098 }
1099
1100 public boolean isBlocked() {
linyuh183cb712017-12-27 17:02:37 -08001101 return isBlocked;
Eric Erfanianccca3152017-02-22 16:32:36 -08001102 }
1103
1104 public void setBlockedStatus(boolean isBlocked) {
linyuh183cb712017-12-27 17:02:37 -08001105 this.isBlocked = isBlocked;
Eric Erfanianccca3152017-02-22 16:32:36 -08001106 }
1107
1108 public boolean isRemotelyHeld() {
1109 return isRemotelyHeld;
1110 }
1111
Eric Erfanian2ca43182017-08-31 06:57:16 -07001112 public boolean isMergeInProcess() {
1113 return isMergeInProcess;
1114 }
1115
Eric Erfanianccca3152017-02-22 16:32:36 -08001116 public boolean isIncoming() {
linyuh183cb712017-12-27 17:02:37 -08001117 return logState.isIncoming;
Eric Erfanianccca3152017-02-22 16:32:36 -08001118 }
1119
erfanian2cf2c342017-12-21 12:01:33 -08001120 /**
1121 * Try and determine if the call used assisted dialing.
1122 *
1123 * <p>We will not be able to verify a call underwent assisted dialing until the Platform
1124 * implmentation is complete in P+.
1125 *
1126 * @return a boolean indicating assisted dialing may have been performed
1127 */
Eric Erfanian2ca43182017-08-31 06:57:16 -07001128 public boolean isAssistedDialed() {
1129 if (getIntentExtras() != null) {
erfanian2cf2c342017-12-21 12:01:33 -08001130 // O_MR1 and below uses the existence of USE_ASSISTED_DIALING to indicate assisted dialing
1131 // was used. The Dialer client is responsible for performing assisted dialing before
1132 // placing the outgoing call.
1133 //
1134 // The existence of the assisted dialing extras indicates that assisted dialing took place.
1135 if (getIntentExtras().getBoolean(TelephonyManagerCompat.USE_ASSISTED_DIALING, false)
1136 && getAssistedDialingExtras() != null
1137 && Build.VERSION.SDK_INT <= ConcreteCreator.BUILD_CODE_CEILING) {
1138 return true;
1139 }
1140 }
1141
1142 // Starting in P+ USE_ASSISTED_DIALING indicates that the client requested the platform
1143 // perform assisted dialing. PROPERTY_ASSISTED_DIALING_USED indicates assisted dialing took
1144 // place.
1145 if (hasProperty(TelephonyManagerCompat.PROPERTY_ASSISTED_DIALING_USED)
erfanianf2556612018-01-23 09:55:59 -08001146 && BuildCompat.isAtLeastP()) {
erfanian2cf2c342017-12-21 12:01:33 -08001147 return true;
Eric Erfanian2ca43182017-08-31 06:57:16 -07001148 }
1149 return false;
1150 }
1151
erfanian2cf2c342017-12-21 12:01:33 -08001152 @Nullable
erfaniand0f207f2017-10-11 12:23:29 -07001153 public TransformationInfo getAssistedDialingExtras() {
erfanian2cf2c342017-12-21 12:01:33 -08001154 if (getIntentExtras() == null) {
1155 return null;
erfaniand0f207f2017-10-11 12:23:29 -07001156 }
erfanian2cf2c342017-12-21 12:01:33 -08001157
erfanianf2556612018-01-23 09:55:59 -08001158 if (BuildCompat.isAtLeastP()) {
1159 if (getExtras() == null) {
1160 return null;
1161 }
1162
1163 if (getExtras()
1164 .getParcelable(TelephonyManagerCompat.EXTRA_ASSISTED_DIALING_TRANSFORMATION_INFO)
1165 == null) {
1166 return null;
1167 }
1168
1169 // TODO(erfanian): Use the framework transformation info when we can link against it
1170 return null;
1171 }
1172
erfanian2cf2c342017-12-21 12:01:33 -08001173 if (getIntentExtras().getBundle(TelephonyManagerCompat.ASSISTED_DIALING_EXTRAS) == null) {
1174 return null;
1175 }
1176
erfanianf2556612018-01-23 09:55:59 -08001177 // Used in N-OMR1
erfanian2cf2c342017-12-21 12:01:33 -08001178 return TransformationInfo.newInstanceFromBundle(
1179 getIntentExtras().getBundle(TelephonyManagerCompat.ASSISTED_DIALING_EXTRAS));
erfaniand0f207f2017-10-11 12:23:29 -07001180 }
1181
Eric Erfanianccca3152017-02-22 16:32:36 -08001182 public LatencyReport getLatencyReport() {
linyuh183cb712017-12-27 17:02:37 -08001183 return latencyReport;
Eric Erfanianccca3152017-02-22 16:32:36 -08001184 }
1185
Eric Erfanian2ca43182017-08-31 06:57:16 -07001186 public int getAnswerAndReleaseButtonDisplayedTimes() {
1187 return answerAndReleaseButtonDisplayedTimes;
1188 }
1189
1190 public void increaseAnswerAndReleaseButtonDisplayedTimes() {
1191 answerAndReleaseButtonDisplayedTimes++;
1192 }
1193
1194 public boolean getReleasedByAnsweringSecondCall() {
1195 return releasedByAnsweringSecondCall;
1196 }
1197
1198 public void setReleasedByAnsweringSecondCall(boolean releasedByAnsweringSecondCall) {
1199 this.releasedByAnsweringSecondCall = releasedByAnsweringSecondCall;
1200 }
1201
1202 public int getSecondCallWithoutAnswerAndReleasedButtonTimes() {
1203 return secondCallWithoutAnswerAndReleasedButtonTimes;
1204 }
1205
1206 public void increaseSecondCallWithoutAnswerAndReleasedButtonTimes() {
1207 secondCallWithoutAnswerAndReleasedButtonTimes++;
1208 }
1209
Eric Erfanian8369df02017-05-03 10:27:13 -07001210 @Nullable
1211 public EnrichedCallCapabilities getEnrichedCallCapabilities() {
linyuh183cb712017-12-27 17:02:37 -08001212 return enrichedCallCapabilities;
Eric Erfanian8369df02017-05-03 10:27:13 -07001213 }
1214
1215 public void setEnrichedCallCapabilities(
1216 @Nullable EnrichedCallCapabilities mEnrichedCallCapabilities) {
linyuh183cb712017-12-27 17:02:37 -08001217 this.enrichedCallCapabilities = mEnrichedCallCapabilities;
Eric Erfanian8369df02017-05-03 10:27:13 -07001218 }
1219
1220 @Nullable
1221 public Session getEnrichedCallSession() {
linyuh183cb712017-12-27 17:02:37 -08001222 return enrichedCallSession;
Eric Erfanian8369df02017-05-03 10:27:13 -07001223 }
1224
1225 public void setEnrichedCallSession(@Nullable Session mEnrichedCallSession) {
linyuh183cb712017-12-27 17:02:37 -08001226 this.enrichedCallSession = mEnrichedCallSession;
Eric Erfanian8369df02017-05-03 10:27:13 -07001227 }
1228
Eric Erfanianccca3152017-02-22 16:32:36 -08001229 public void unregisterCallback() {
linyuh183cb712017-12-27 17:02:37 -08001230 telecomCall.unregisterCallback(telecomCallCallback);
Eric Erfanianccca3152017-02-22 16:32:36 -08001231 }
1232
Eric Erfanianccca3152017-02-22 16:32:36 -08001233 public void phoneAccountSelected(PhoneAccountHandle accountHandle, boolean setDefault) {
1234 LogUtil.i(
1235 "DialerCall.phoneAccountSelected",
1236 "accountHandle: %s, setDefault: %b",
1237 accountHandle,
1238 setDefault);
linyuh183cb712017-12-27 17:02:37 -08001239 telecomCall.phoneAccountSelected(accountHandle, setDefault);
Eric Erfanianccca3152017-02-22 16:32:36 -08001240 }
1241
1242 public void disconnect() {
1243 LogUtil.i("DialerCall.disconnect", "");
1244 setState(DialerCall.State.DISCONNECTING);
linyuh183cb712017-12-27 17:02:37 -08001245 for (DialerCallListener listener : listeners) {
Eric Erfanianccca3152017-02-22 16:32:36 -08001246 listener.onDialerCallUpdate();
1247 }
linyuh183cb712017-12-27 17:02:37 -08001248 telecomCall.disconnect();
Eric Erfanianccca3152017-02-22 16:32:36 -08001249 }
1250
1251 public void hold() {
1252 LogUtil.i("DialerCall.hold", "");
linyuh183cb712017-12-27 17:02:37 -08001253 telecomCall.hold();
Eric Erfanianccca3152017-02-22 16:32:36 -08001254 }
1255
1256 public void unhold() {
1257 LogUtil.i("DialerCall.unhold", "");
linyuh183cb712017-12-27 17:02:37 -08001258 telecomCall.unhold();
Eric Erfanianccca3152017-02-22 16:32:36 -08001259 }
1260
1261 public void splitFromConference() {
1262 LogUtil.i("DialerCall.splitFromConference", "");
linyuh183cb712017-12-27 17:02:37 -08001263 telecomCall.splitFromConference();
Eric Erfanianccca3152017-02-22 16:32:36 -08001264 }
1265
1266 public void answer(int videoState) {
1267 LogUtil.i("DialerCall.answer", "videoState: " + videoState);
linyuh183cb712017-12-27 17:02:37 -08001268 telecomCall.answer(videoState);
Eric Erfanianccca3152017-02-22 16:32:36 -08001269 }
1270
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001271 public void answer() {
linyuh183cb712017-12-27 17:02:37 -08001272 answer(telecomCall.getDetails().getVideoState());
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001273 }
1274
Eric Erfanianccca3152017-02-22 16:32:36 -08001275 public void reject(boolean rejectWithMessage, String message) {
1276 LogUtil.i("DialerCall.reject", "");
linyuh183cb712017-12-27 17:02:37 -08001277 telecomCall.reject(rejectWithMessage, message);
Eric Erfanianccca3152017-02-22 16:32:36 -08001278 }
1279
1280 /** Return the string label to represent the call provider */
1281 public String getCallProviderLabel() {
1282 if (callProviderLabel == null) {
1283 PhoneAccount account = getPhoneAccount();
1284 if (account != null && !TextUtils.isEmpty(account.getLabel())) {
wangqi9982f0d2017-10-11 17:46:07 -07001285 if (callCapableAccounts != null && callCapableAccounts.size() > 1) {
Eric Erfanianccca3152017-02-22 16:32:36 -08001286 callProviderLabel = account.getLabel().toString();
1287 }
1288 }
1289 if (callProviderLabel == null) {
1290 callProviderLabel = "";
1291 }
1292 }
1293 return callProviderLabel;
1294 }
1295
1296 private PhoneAccount getPhoneAccount() {
1297 PhoneAccountHandle accountHandle = getAccountHandle();
1298 if (accountHandle == null) {
1299 return null;
1300 }
linyuh183cb712017-12-27 17:02:37 -08001301 return context.getSystemService(TelecomManager.class).getPhoneAccount(accountHandle);
Eric Erfanianccca3152017-02-22 16:32:36 -08001302 }
1303
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001304 public VideoTech getVideoTech() {
roldenburg7bb96232017-10-09 10:32:05 -07001305 if (videoTech == null) {
roldenburg6bd612f2018-01-18 12:57:19 -08001306 videoTech = videoTechManager.getVideoTech(getAccountHandle());
roldenburg7bb96232017-10-09 10:32:05 -07001307
1308 // Only store the first video tech type found to be available during the life of the call.
1309 if (selectedAvailableVideoTechType == com.android.dialer.logging.VideoTech.Type.NONE) {
1310 // Update the video tech.
1311 selectedAvailableVideoTechType = videoTech.getVideoTechType();
1312 }
1313 }
Eric Erfanian2ca43182017-08-31 06:57:16 -07001314 return videoTech;
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001315 }
1316
Eric Erfanianccca3152017-02-22 16:32:36 -08001317 public String getCallbackNumber() {
1318 if (callbackNumber == null) {
1319 // Show the emergency callback number if either:
1320 // 1. This is an emergency call.
1321 // 2. The phone is in Emergency Callback Mode, which means we should show the callback
1322 // number.
1323 boolean showCallbackNumber = hasProperty(Details.PROPERTY_EMERGENCY_CALLBACK_MODE);
1324
1325 if (isEmergencyCall() || showCallbackNumber) {
wangqi339b4f32017-09-18 14:32:09 -07001326 callbackNumber =
linyuh183cb712017-12-27 17:02:37 -08001327 context.getSystemService(TelecomManager.class).getLine1Number(getAccountHandle());
Eric Erfanianccca3152017-02-22 16:32:36 -08001328 }
1329
Eric Erfanianccca3152017-02-22 16:32:36 -08001330 if (callbackNumber == null) {
1331 callbackNumber = "";
1332 }
1333 }
1334 return callbackNumber;
1335 }
1336
wangqi97539352017-09-25 11:15:16 -07001337 public String getSimCountryIso() {
1338 String simCountryIso =
linyuh183cb712017-12-27 17:02:37 -08001339 TelephonyManagerCompat.getTelephonyManagerForPhoneAccountHandle(context, getAccountHandle())
wangqi97539352017-09-25 11:15:16 -07001340 .getSimCountryIso();
1341 if (!TextUtils.isEmpty(simCountryIso)) {
1342 simCountryIso = simCountryIso.toUpperCase(Locale.US);
1343 }
1344 return simCountryIso;
1345 }
1346
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001347 @Override
1348 public void onVideoTechStateChanged() {
1349 update();
1350 }
1351
1352 @Override
1353 public void onSessionModificationStateChanged() {
wangqi9982f0d2017-10-11 17:46:07 -07001354 Trace.beginSection("DialerCall.onSessionModificationStateChanged");
linyuh183cb712017-12-27 17:02:37 -08001355 for (DialerCallListener listener : listeners) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001356 listener.onDialerCallSessionModificationStateChange();
1357 }
wangqi9982f0d2017-10-11 17:46:07 -07001358 Trace.endSection();
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001359 }
1360
1361 @Override
1362 public void onCameraDimensionsChanged(int width, int height) {
1363 InCallVideoCallCallbackNotifier.getInstance().cameraDimensionsChanged(this, width, height);
1364 }
1365
1366 @Override
1367 public void onPeerDimensionsChanged(int width, int height) {
1368 InCallVideoCallCallbackNotifier.getInstance().peerDimensionsChanged(this, width, height);
1369 }
1370
1371 @Override
1372 public void onVideoUpgradeRequestReceived() {
1373 LogUtil.enterBlock("DialerCall.onVideoUpgradeRequestReceived");
1374
linyuh183cb712017-12-27 17:02:37 -08001375 for (DialerCallListener listener : listeners) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001376 listener.onDialerCallUpgradeToVideo();
1377 }
1378
1379 update();
Eric Erfanian8369df02017-05-03 10:27:13 -07001380
linyuh183cb712017-12-27 17:02:37 -08001381 Logger.get(context)
Eric Erfanian8369df02017-05-03 10:27:13 -07001382 .logCallImpression(
1383 DialerImpression.Type.VIDEO_CALL_REQUEST_RECEIVED, getUniqueCallId(), getTimeAddedMs());
1384 }
1385
1386 @Override
1387 public void onUpgradedToVideo(boolean switchToSpeaker) {
1388 LogUtil.enterBlock("DialerCall.onUpgradedToVideo");
1389
1390 if (!switchToSpeaker) {
1391 return;
1392 }
1393
1394 CallAudioState audioState = AudioModeProvider.getInstance().getAudioState();
1395
1396 if (0 != (CallAudioState.ROUTE_BLUETOOTH & audioState.getSupportedRouteMask())) {
1397 LogUtil.e(
1398 "DialerCall.onUpgradedToVideo",
1399 "toggling speakerphone not allowed when bluetooth supported.");
1400 return;
1401 }
1402
1403 if (audioState.getRoute() == CallAudioState.ROUTE_SPEAKER) {
1404 return;
1405 }
1406
1407 TelecomAdapter.getInstance().setAudioRoute(CallAudioState.ROUTE_SPEAKER);
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001408 }
1409
Eric Erfanian2ca43182017-08-31 06:57:16 -07001410 @Override
1411 public void onCapabilitiesUpdated() {
1412 if (getNumber() == null) {
1413 return;
1414 }
1415 EnrichedCallCapabilities capabilities =
linyuh183cb712017-12-27 17:02:37 -08001416 EnrichedCallComponent.get(context).getEnrichedCallManager().getCapabilities(getNumber());
Eric Erfanian2ca43182017-08-31 06:57:16 -07001417 if (capabilities != null) {
1418 setEnrichedCallCapabilities(capabilities);
1419 update();
1420 }
1421 }
1422
1423 @Override
1424 public void onEnrichedCallStateChanged() {
1425 updateEnrichedCallSession();
1426 }
1427
1428 @Override
1429 public void onImpressionLoggingNeeded(DialerImpression.Type impressionType) {
linyuh183cb712017-12-27 17:02:37 -08001430 Logger.get(context).logCallImpression(impressionType, getUniqueCallId(), getTimeAddedMs());
twyendde01c52017-09-22 10:07:31 -07001431 if (impressionType == DialerImpression.Type.LIGHTBRINGER_UPGRADE_REQUESTED) {
1432 if (getLogState().contactLookupResult == Type.NOT_FOUND) {
linyuh183cb712017-12-27 17:02:37 -08001433 Logger.get(context)
twyendde01c52017-09-22 10:07:31 -07001434 .logCallImpression(
1435 DialerImpression.Type.LIGHTBRINGER_NON_CONTACT_UPGRADE_REQUESTED,
1436 getUniqueCallId(),
1437 getTimeAddedMs());
1438 }
1439 }
Eric Erfanian2ca43182017-08-31 06:57:16 -07001440 }
1441
1442 private void updateEnrichedCallSession() {
1443 if (getNumber() == null) {
1444 return;
1445 }
1446 if (getEnrichedCallSession() != null) {
1447 // State changes to existing sessions are currently handled by the UI components (which have
1448 // their own listeners). Someday instead we could remove those and just call update() here and
1449 // have the usual onDialerCallUpdate update the UI.
1450 dispatchOnEnrichedCallSessionUpdate();
1451 return;
1452 }
1453
linyuh183cb712017-12-27 17:02:37 -08001454 EnrichedCallManager manager = EnrichedCallComponent.get(context).getEnrichedCallManager();
Eric Erfanian2ca43182017-08-31 06:57:16 -07001455
1456 Filter filter =
1457 isIncoming()
1458 ? manager.createIncomingCallComposerFilter()
1459 : manager.createOutgoingCallComposerFilter();
1460
1461 Session session = manager.getSession(getUniqueCallId(), getNumber(), filter);
1462 if (session == null) {
1463 return;
1464 }
1465
1466 session.setUniqueDialerCallId(getUniqueCallId());
1467 setEnrichedCallSession(session);
1468
1469 LogUtil.i(
1470 "DialerCall.updateEnrichedCallSession",
1471 "setting session %d's dialer id to %s",
1472 session.getSessionId(),
1473 getUniqueCallId());
1474
1475 dispatchOnEnrichedCallSessionUpdate();
1476 }
1477
1478 private void dispatchOnEnrichedCallSessionUpdate() {
linyuh183cb712017-12-27 17:02:37 -08001479 for (DialerCallListener listener : listeners) {
Eric Erfanian2ca43182017-08-31 06:57:16 -07001480 listener.onEnrichedCallSessionUpdate();
1481 }
1482 }
1483
1484 void onRemovedFromCallList() {
1485 // Ensure we clean up when this call is removed.
linyuh183cb712017-12-27 17:02:37 -08001486 videoTechManager.dispatchRemovedFromCallList();
Eric Erfanian2ca43182017-08-31 06:57:16 -07001487 }
1488
wangqi4d705e52017-09-28 12:23:35 -07001489 public com.android.dialer.logging.VideoTech.Type getSelectedAvailableVideoTechType() {
1490 return selectedAvailableVideoTechType;
yueg457b3972017-09-18 15:11:47 -07001491 }
1492
Android Dialer974fc292018-02-01 16:12:25 -08001493 public void markFeedbackRequested() {
1494 feedbackRequested = true;
1495 }
1496
1497 public boolean isFeedbackRequested() {
1498 return feedbackRequested;
1499 }
1500
Eric Erfanianccca3152017-02-22 16:32:36 -08001501 /**
1502 * Specifies whether a number is in the call history or not. {@link #CALL_HISTORY_STATUS_UNKNOWN}
1503 * means there is no result.
1504 */
1505 @IntDef({
1506 CALL_HISTORY_STATUS_UNKNOWN,
1507 CALL_HISTORY_STATUS_PRESENT,
1508 CALL_HISTORY_STATUS_NOT_PRESENT
1509 })
1510 @Retention(RetentionPolicy.SOURCE)
1511 public @interface CallHistoryStatus {}
1512
1513 /* Defines different states of this call */
1514 public static class State {
1515
1516 public static final int INVALID = 0;
1517 public static final int NEW = 1; /* The call is new. */
1518 public static final int IDLE = 2; /* The call is idle. Nothing active */
1519 public static final int ACTIVE = 3; /* There is an active call */
1520 public static final int INCOMING = 4; /* A normal incoming phone call */
1521 public static final int CALL_WAITING = 5; /* Incoming call while another is active */
1522 public static final int DIALING = 6; /* An outgoing call during dial phase */
1523 public static final int REDIALING = 7; /* Subsequent dialing attempt after a failure */
1524 public static final int ONHOLD = 8; /* An active phone call placed on hold */
1525 public static final int DISCONNECTING = 9; /* A call is being ended. */
1526 public static final int DISCONNECTED = 10; /* State after a call disconnects */
1527 public static final int CONFERENCED = 11; /* DialerCall part of a conference call */
1528 public static final int SELECT_PHONE_ACCOUNT = 12; /* Waiting for account selection */
1529 public static final int CONNECTING = 13; /* Waiting for Telecom broadcast to finish */
1530 public static final int BLOCKED = 14; /* The number was found on the block list */
1531 public static final int PULLING = 15; /* An external call being pulled to the device */
Eric Erfanian2ca43182017-08-31 06:57:16 -07001532 public static final int CALL_PENDING = 16; /* A call is pending on a long process to finish */
Eric Erfanianccca3152017-02-22 16:32:36 -08001533
1534 public static boolean isConnectingOrConnected(int state) {
1535 switch (state) {
1536 case ACTIVE:
1537 case INCOMING:
1538 case CALL_WAITING:
1539 case CONNECTING:
1540 case DIALING:
1541 case PULLING:
1542 case REDIALING:
1543 case ONHOLD:
1544 case CONFERENCED:
1545 return true;
1546 default:
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001547 return false;
Eric Erfanianccca3152017-02-22 16:32:36 -08001548 }
Eric Erfanianccca3152017-02-22 16:32:36 -08001549 }
1550
1551 public static boolean isDialing(int state) {
1552 return state == DIALING || state == PULLING || state == REDIALING;
1553 }
1554
1555 public static String toString(int state) {
1556 switch (state) {
1557 case INVALID:
1558 return "INVALID";
1559 case NEW:
1560 return "NEW";
1561 case IDLE:
1562 return "IDLE";
1563 case ACTIVE:
1564 return "ACTIVE";
1565 case INCOMING:
1566 return "INCOMING";
1567 case CALL_WAITING:
1568 return "CALL_WAITING";
1569 case DIALING:
1570 return "DIALING";
1571 case PULLING:
1572 return "PULLING";
1573 case REDIALING:
1574 return "REDIALING";
1575 case ONHOLD:
1576 return "ONHOLD";
1577 case DISCONNECTING:
1578 return "DISCONNECTING";
1579 case DISCONNECTED:
1580 return "DISCONNECTED";
1581 case CONFERENCED:
1582 return "CONFERENCED";
1583 case SELECT_PHONE_ACCOUNT:
1584 return "SELECT_PHONE_ACCOUNT";
1585 case CONNECTING:
1586 return "CONNECTING";
1587 case BLOCKED:
1588 return "BLOCKED";
1589 default:
1590 return "UNKNOWN";
1591 }
1592 }
1593 }
1594
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001595 /** Camera direction constants */
1596 public static class CameraDirection {
Eric Erfanianccca3152017-02-22 16:32:36 -08001597 public static final int CAMERA_DIRECTION_UNKNOWN = -1;
1598 public static final int CAMERA_DIRECTION_FRONT_FACING = CameraCharacteristics.LENS_FACING_FRONT;
1599 public static final int CAMERA_DIRECTION_BACK_FACING = CameraCharacteristics.LENS_FACING_BACK;
Eric Erfanianccca3152017-02-22 16:32:36 -08001600 }
1601
1602 /**
1603 * Tracks any state variables that is useful for logging. There is some amount of overlap with
1604 * existing call member variables, but this duplication helps to ensure that none of these logging
1605 * variables will interface with/and affect call logic.
1606 */
1607 public static class LogState {
1608
1609 public DisconnectCause disconnectCause;
1610 public boolean isIncoming = false;
Eric Erfanian8369df02017-05-03 10:27:13 -07001611 public ContactLookupResult.Type contactLookupResult =
1612 ContactLookupResult.Type.UNKNOWN_LOOKUP_RESULT_TYPE;
Eric Erfanianccca3152017-02-22 16:32:36 -08001613 public CallSpecificAppData callSpecificAppData;
1614 // If this was a conference call, the total number of calls involved in the conference.
1615 public int conferencedCalls = 0;
1616 public long duration = 0;
1617 public boolean isLogged = false;
1618
Eric Erfanian8369df02017-05-03 10:27:13 -07001619 private static String lookupToString(ContactLookupResult.Type lookupType) {
Eric Erfanianccca3152017-02-22 16:32:36 -08001620 switch (lookupType) {
Eric Erfanian8369df02017-05-03 10:27:13 -07001621 case LOCAL_CONTACT:
Eric Erfanianccca3152017-02-22 16:32:36 -08001622 return "Local";
Eric Erfanian8369df02017-05-03 10:27:13 -07001623 case LOCAL_CACHE:
Eric Erfanianccca3152017-02-22 16:32:36 -08001624 return "Cache";
Eric Erfanian8369df02017-05-03 10:27:13 -07001625 case REMOTE:
Eric Erfanianccca3152017-02-22 16:32:36 -08001626 return "Remote";
Eric Erfanian8369df02017-05-03 10:27:13 -07001627 case EMERGENCY:
Eric Erfanianccca3152017-02-22 16:32:36 -08001628 return "Emergency";
Eric Erfanian8369df02017-05-03 10:27:13 -07001629 case VOICEMAIL:
Eric Erfanianccca3152017-02-22 16:32:36 -08001630 return "Voicemail";
1631 default:
1632 return "Not found";
1633 }
1634 }
1635
1636 private static String initiationToString(CallSpecificAppData callSpecificAppData) {
1637 if (callSpecificAppData == null) {
1638 return "null";
1639 }
Eric Erfanian8369df02017-05-03 10:27:13 -07001640 switch (callSpecificAppData.getCallInitiationType()) {
1641 case INCOMING_INITIATION:
Eric Erfanianccca3152017-02-22 16:32:36 -08001642 return "Incoming";
Eric Erfanian8369df02017-05-03 10:27:13 -07001643 case DIALPAD:
Eric Erfanianccca3152017-02-22 16:32:36 -08001644 return "Dialpad";
Eric Erfanian8369df02017-05-03 10:27:13 -07001645 case SPEED_DIAL:
Eric Erfanianccca3152017-02-22 16:32:36 -08001646 return "Speed Dial";
Eric Erfanian8369df02017-05-03 10:27:13 -07001647 case REMOTE_DIRECTORY:
Eric Erfanianccca3152017-02-22 16:32:36 -08001648 return "Remote Directory";
Eric Erfanian8369df02017-05-03 10:27:13 -07001649 case SMART_DIAL:
Eric Erfanianccca3152017-02-22 16:32:36 -08001650 return "Smart Dial";
Eric Erfanian8369df02017-05-03 10:27:13 -07001651 case REGULAR_SEARCH:
Eric Erfanianccca3152017-02-22 16:32:36 -08001652 return "Regular Search";
Eric Erfanian8369df02017-05-03 10:27:13 -07001653 case CALL_LOG:
Eric Erfanianccca3152017-02-22 16:32:36 -08001654 return "DialerCall Log";
Eric Erfanian8369df02017-05-03 10:27:13 -07001655 case CALL_LOG_FILTER:
Eric Erfanianccca3152017-02-22 16:32:36 -08001656 return "DialerCall Log Filter";
Eric Erfanian8369df02017-05-03 10:27:13 -07001657 case VOICEMAIL_LOG:
Eric Erfanianccca3152017-02-22 16:32:36 -08001658 return "Voicemail Log";
Eric Erfanian8369df02017-05-03 10:27:13 -07001659 case CALL_DETAILS:
Eric Erfanianccca3152017-02-22 16:32:36 -08001660 return "DialerCall Details";
Eric Erfanian8369df02017-05-03 10:27:13 -07001661 case QUICK_CONTACTS:
Eric Erfanianccca3152017-02-22 16:32:36 -08001662 return "Quick Contacts";
Eric Erfanian8369df02017-05-03 10:27:13 -07001663 case EXTERNAL_INITIATION:
Eric Erfanianccca3152017-02-22 16:32:36 -08001664 return "External";
Eric Erfanian8369df02017-05-03 10:27:13 -07001665 case LAUNCHER_SHORTCUT:
Eric Erfanianccca3152017-02-22 16:32:36 -08001666 return "Launcher Shortcut";
1667 default:
Eric Erfanian8369df02017-05-03 10:27:13 -07001668 return "Unknown: " + callSpecificAppData.getCallInitiationType();
Eric Erfanianccca3152017-02-22 16:32:36 -08001669 }
1670 }
1671
1672 @Override
1673 public String toString() {
1674 return String.format(
1675 Locale.US,
1676 "["
1677 + "%s, " // DisconnectCause toString already describes the object type
1678 + "isIncoming: %s, "
1679 + "contactLookup: %s, "
1680 + "callInitiation: %s, "
1681 + "duration: %s"
1682 + "]",
1683 disconnectCause,
1684 isIncoming,
1685 lookupToString(contactLookupResult),
1686 initiationToString(callSpecificAppData),
1687 duration);
1688 }
1689 }
1690
roldenburgd7490db2018-01-09 13:51:29 -08001691 /** Coordinates the available VideoTech implementations for a call. */
1692 @VisibleForTesting
1693 public static class VideoTechManager {
Eric Erfaniand8046e52017-04-06 09:41:50 -07001694 private final Context context;
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001695 private final EmptyVideoTech emptyVideoTech = new EmptyVideoTech();
roldenburgd7490db2018-01-09 13:51:29 -08001696 private final VideoTech rcsVideoShare;
Eric Erfanian90508232017-03-24 09:31:16 -07001697 private final List<VideoTech> videoTechs;
roldenburg7bb96232017-10-09 10:32:05 -07001698 private VideoTech savedTech;
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001699
roldenburgd7490db2018-01-09 13:51:29 -08001700 @VisibleForTesting
1701 public VideoTechManager(DialerCall call) {
linyuh183cb712017-12-27 17:02:37 -08001702 this.context = call.context;
Eric Erfaniand8046e52017-04-06 09:41:50 -07001703
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001704 String phoneNumber = call.getNumber();
Eric Erfaniand8046e52017-04-06 09:41:50 -07001705 phoneNumber = phoneNumber != null ? phoneNumber : "";
Eric Erfanian2ca43182017-08-31 06:57:16 -07001706 phoneNumber = phoneNumber.replaceAll("[^+0-9]", "");
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001707
1708 // Insert order here determines the priority of that video tech option
Eric Erfanian8369df02017-05-03 10:27:13 -07001709 videoTechs = new ArrayList<>();
yueg457b3972017-09-18 15:11:47 -07001710
linyuh183cb712017-12-27 17:02:37 -08001711 videoTechs.add(new ImsVideoTech(Logger.get(call.context), call, call.telecomCall));
Eric Erfanian90508232017-03-24 09:31:16 -07001712
roldenburgd7490db2018-01-09 13:51:29 -08001713 rcsVideoShare =
linyuh183cb712017-12-27 17:02:37 -08001714 EnrichedCallComponent.get(call.context)
Eric Erfanian90508232017-03-24 09:31:16 -07001715 .getRcsVideoShareFactory()
1716 .newRcsVideoShare(
linyuh183cb712017-12-27 17:02:37 -08001717 EnrichedCallComponent.get(call.context).getEnrichedCallManager(),
Eric Erfanian90508232017-03-24 09:31:16 -07001718 call,
Eric Erfaniand8046e52017-04-06 09:41:50 -07001719 phoneNumber);
roldenburg3eca69f2018-01-16 12:07:04 -08001720 videoTechs.add(rcsVideoShare);
Eric Erfaniand8046e52017-04-06 09:41:50 -07001721
1722 videoTechs.add(
roldenburg4f026392017-10-13 18:42:20 -07001723 new DuoVideoTech(
linyuh183cb712017-12-27 17:02:37 -08001724 DuoComponent.get(call.context).getDuo(), call, call.telecomCall, phoneNumber));
roldenburgd7490db2018-01-09 13:51:29 -08001725
1726 savedTech = emptyVideoTech;
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001727 }
1728
roldenburgd7490db2018-01-09 13:51:29 -08001729 @VisibleForTesting
roldenburg6bd612f2018-01-18 12:57:19 -08001730 public VideoTech getVideoTech(PhoneAccountHandle phoneAccountHandle) {
roldenburgd7490db2018-01-09 13:51:29 -08001731 if (savedTech == emptyVideoTech) {
1732 for (VideoTech tech : videoTechs) {
roldenburg6bd612f2018-01-18 12:57:19 -08001733 if (tech.isAvailable(context, phoneAccountHandle)) {
roldenburgd7490db2018-01-09 13:51:29 -08001734 savedTech = tech;
1735 savedTech.becomePrimary();
1736 break;
1737 }
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001738 }
roldenburg6bd612f2018-01-18 12:57:19 -08001739 } else if (savedTech instanceof DuoVideoTech
1740 && rcsVideoShare.isAvailable(context, phoneAccountHandle)) {
roldenburgd7490db2018-01-09 13:51:29 -08001741 // RCS Video Share will become available after the capability exchange which is slower than
1742 // Duo reading local contacts for reachability. If Video Share becomes available and we are
1743 // not in the middle of any session changes, let it take over.
1744 savedTech = rcsVideoShare;
1745 rcsVideoShare.becomePrimary();
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001746 }
1747
roldenburgd7490db2018-01-09 13:51:29 -08001748 return savedTech;
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001749 }
1750
roldenburgd7490db2018-01-09 13:51:29 -08001751 @VisibleForTesting
roldenburg6bd612f2018-01-18 12:57:19 -08001752 public void dispatchCallStateChanged(int newState, PhoneAccountHandle phoneAccountHandle) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001753 for (VideoTech videoTech : videoTechs) {
roldenburg6bd612f2018-01-18 12:57:19 -08001754 videoTech.onCallStateChanged(context, newState, phoneAccountHandle);
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001755 }
1756 }
Eric Erfanian2ca43182017-08-31 06:57:16 -07001757
1758 void dispatchRemovedFromCallList() {
1759 for (VideoTech videoTech : videoTechs) {
1760 videoTech.onRemovedFromCallList();
1761 }
1762 }
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001763 }
1764
Eric Erfanianccca3152017-02-22 16:32:36 -08001765 /** Called when canned text responses have been loaded. */
1766 public interface CannedTextResponsesLoadedListener {
1767 void onCannedTextResponsesLoaded(DialerCall call);
1768 }
1769}