blob: 90a01401cc45325a9246afa9a939a09395745610 [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
wangqi153af2f2018-02-15 16:21:49 -0800942 @TargetApi(28)
943 public RttCall getRttCall() {
944 if (!isRttCall()) {
945 return null;
946 }
947 return getTelecomCall().getRttCall();
948 }
949
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700950 public boolean hasReceivedVideoUpgradeRequest() {
951 return VideoUtils.hasReceivedVideoUpgradeRequest(getVideoTech().getSessionModificationState());
952 }
953
954 public boolean hasSentVideoUpgradeRequest() {
955 return VideoUtils.hasSentVideoUpgradeRequest(getVideoTech().getSessionModificationState());
Eric Erfanianccca3152017-02-22 16:32:36 -0800956 }
957
wangqi219b8702018-02-13 09:34:41 -0800958 public boolean hasSentRttUpgradeRequest() {
wangqi219b8702018-02-13 09:34:41 -0800959 return false;
960 }
961
Eric Erfanianccca3152017-02-22 16:32:36 -0800962 /**
963 * Determines if the call handle is an emergency number or not and caches the result to avoid
964 * repeated calls to isEmergencyNumber.
965 */
966 private void updateEmergencyCallState() {
linyuh183cb712017-12-27 17:02:37 -0800967 isEmergencyCall = TelecomCallUtil.isEmergencyCall(telecomCall);
Eric Erfanianccca3152017-02-22 16:32:36 -0800968 }
969
Eric Erfanianccca3152017-02-22 16:32:36 -0800970 public LogState getLogState() {
linyuh183cb712017-12-27 17:02:37 -0800971 return logState;
Eric Erfanianccca3152017-02-22 16:32:36 -0800972 }
973
974 /**
975 * Determines if the call is an external call.
976 *
977 * <p>An external call is one which does not exist locally for the {@link
978 * android.telecom.ConnectionService} it is associated with.
979 *
980 * <p>External calls are only supported in N and higher.
981 *
982 * @return {@code true} if the call is an external call, {@code false} otherwise.
983 */
984 public boolean isExternalCall() {
985 return VERSION.SDK_INT >= VERSION_CODES.N
986 && hasProperty(CallCompat.Details.PROPERTY_IS_EXTERNAL_CALL);
987 }
988
989 /**
Eric Erfanianccca3152017-02-22 16:32:36 -0800990 * Determines if answering this call will cause an ongoing video call to be dropped.
991 *
992 * @return {@code true} if answering this call will drop an ongoing video call, {@code false}
993 * otherwise.
994 */
995 public boolean answeringDisconnectsForegroundVideoCall() {
996 Bundle extras = getExtras();
997 if (extras == null
998 || !extras.containsKey(CallCompat.Details.EXTRA_ANSWERING_DROPS_FOREGROUND_CALL)) {
999 return false;
1000 }
1001 return extras.getBoolean(CallCompat.Details.EXTRA_ANSWERING_DROPS_FOREGROUND_CALL);
1002 }
1003
1004 private void parseCallSpecificAppData() {
1005 if (isExternalCall()) {
1006 return;
1007 }
1008
linyuh183cb712017-12-27 17:02:37 -08001009 logState.callSpecificAppData = CallIntentParser.getCallSpecificAppData(getIntentExtras());
1010 if (logState.callSpecificAppData == null) {
Eric Erfanian8369df02017-05-03 10:27:13 -07001011
linyuh183cb712017-12-27 17:02:37 -08001012 logState.callSpecificAppData =
Eric Erfanian8369df02017-05-03 10:27:13 -07001013 CallSpecificAppData.newBuilder()
1014 .setCallInitiationType(CallInitiationType.Type.EXTERNAL_INITIATION)
1015 .build();
Eric Erfanianccca3152017-02-22 16:32:36 -08001016 }
1017 if (getState() == State.INCOMING) {
linyuh183cb712017-12-27 17:02:37 -08001018 logState.callSpecificAppData =
1019 logState
Eric Erfanian8369df02017-05-03 10:27:13 -07001020 .callSpecificAppData
1021 .toBuilder()
1022 .setCallInitiationType(CallInitiationType.Type.INCOMING_INITIATION)
1023 .build();
Eric Erfanianccca3152017-02-22 16:32:36 -08001024 }
1025 }
1026
1027 @Override
1028 public String toString() {
linyuh183cb712017-12-27 17:02:37 -08001029 if (telecomCall == null) {
Eric Erfanianccca3152017-02-22 16:32:36 -08001030 // This should happen only in testing since otherwise we would never have a null
1031 // Telecom call.
linyuh183cb712017-12-27 17:02:37 -08001032 return String.valueOf(id);
Eric Erfanianccca3152017-02-22 16:32:36 -08001033 }
1034
1035 return String.format(
1036 Locale.US,
1037 "[%s, %s, %s, %s, children:%s, parent:%s, "
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001038 + "conferenceable:%s, videoState:%s, mSessionModificationState:%d, CameraDir:%s]",
linyuh183cb712017-12-27 17:02:37 -08001039 id,
Eric Erfanianccca3152017-02-22 16:32:36 -08001040 State.toString(getState()),
linyuh183cb712017-12-27 17:02:37 -08001041 Details.capabilitiesToString(telecomCall.getDetails().getCallCapabilities()),
1042 Details.propertiesToString(telecomCall.getDetails().getCallProperties()),
1043 childCallIds,
Eric Erfanianccca3152017-02-22 16:32:36 -08001044 getParentId(),
linyuh183cb712017-12-27 17:02:37 -08001045 this.telecomCall.getConferenceableCalls(),
1046 VideoProfile.videoStateToString(telecomCall.getDetails().getVideoState()),
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001047 getVideoTech().getSessionModificationState(),
1048 getCameraDir());
Eric Erfanianccca3152017-02-22 16:32:36 -08001049 }
1050
1051 public String toSimpleString() {
1052 return super.toString();
1053 }
1054
1055 @CallHistoryStatus
1056 public int getCallHistoryStatus() {
linyuh183cb712017-12-27 17:02:37 -08001057 return callHistoryStatus;
Eric Erfanianccca3152017-02-22 16:32:36 -08001058 }
1059
1060 public void setCallHistoryStatus(@CallHistoryStatus int callHistoryStatus) {
linyuh183cb712017-12-27 17:02:37 -08001061 this.callHistoryStatus = callHistoryStatus;
Eric Erfanianccca3152017-02-22 16:32:36 -08001062 }
1063
1064 public boolean didShowCameraPermission() {
1065 return didShowCameraPermission;
1066 }
1067
1068 public void setDidShowCameraPermission(boolean didShow) {
1069 didShowCameraPermission = didShow;
1070 }
1071
Eric Erfanian938468d2017-10-24 14:05:52 -07001072 @Nullable
1073 public Boolean isInGlobalSpamList() {
Eric Erfanianccca3152017-02-22 16:32:36 -08001074 return isInGlobalSpamList;
1075 }
1076
1077 public void setIsInGlobalSpamList(boolean inSpamList) {
1078 isInGlobalSpamList = inSpamList;
1079 }
1080
Eric Erfanian938468d2017-10-24 14:05:52 -07001081 @Nullable
1082 public Boolean isInUserSpamList() {
Eric Erfanianccca3152017-02-22 16:32:36 -08001083 return isInUserSpamList;
1084 }
1085
1086 public void setIsInUserSpamList(boolean inSpamList) {
1087 isInUserSpamList = inSpamList;
1088 }
1089
Eric Erfanian938468d2017-10-24 14:05:52 -07001090 @Nullable
1091 public Boolean isInUserWhiteList() {
Eric Erfanianccca3152017-02-22 16:32:36 -08001092 return isInUserWhiteList;
1093 }
1094
1095 public void setIsInUserWhiteList(boolean inWhiteList) {
1096 isInUserWhiteList = inWhiteList;
1097 }
1098
1099 public boolean isSpam() {
linyuh183cb712017-12-27 17:02:37 -08001100 return isSpam;
Eric Erfanianccca3152017-02-22 16:32:36 -08001101 }
1102
1103 public void setSpam(boolean isSpam) {
linyuh183cb712017-12-27 17:02:37 -08001104 this.isSpam = isSpam;
Eric Erfanianccca3152017-02-22 16:32:36 -08001105 }
1106
1107 public boolean isBlocked() {
linyuh183cb712017-12-27 17:02:37 -08001108 return isBlocked;
Eric Erfanianccca3152017-02-22 16:32:36 -08001109 }
1110
1111 public void setBlockedStatus(boolean isBlocked) {
linyuh183cb712017-12-27 17:02:37 -08001112 this.isBlocked = isBlocked;
Eric Erfanianccca3152017-02-22 16:32:36 -08001113 }
1114
1115 public boolean isRemotelyHeld() {
1116 return isRemotelyHeld;
1117 }
1118
Eric Erfanian2ca43182017-08-31 06:57:16 -07001119 public boolean isMergeInProcess() {
1120 return isMergeInProcess;
1121 }
1122
Eric Erfanianccca3152017-02-22 16:32:36 -08001123 public boolean isIncoming() {
linyuh183cb712017-12-27 17:02:37 -08001124 return logState.isIncoming;
Eric Erfanianccca3152017-02-22 16:32:36 -08001125 }
1126
erfanian2cf2c342017-12-21 12:01:33 -08001127 /**
1128 * Try and determine if the call used assisted dialing.
1129 *
1130 * <p>We will not be able to verify a call underwent assisted dialing until the Platform
1131 * implmentation is complete in P+.
1132 *
1133 * @return a boolean indicating assisted dialing may have been performed
1134 */
Eric Erfanian2ca43182017-08-31 06:57:16 -07001135 public boolean isAssistedDialed() {
1136 if (getIntentExtras() != null) {
erfanian2cf2c342017-12-21 12:01:33 -08001137 // O_MR1 and below uses the existence of USE_ASSISTED_DIALING to indicate assisted dialing
1138 // was used. The Dialer client is responsible for performing assisted dialing before
1139 // placing the outgoing call.
1140 //
1141 // The existence of the assisted dialing extras indicates that assisted dialing took place.
1142 if (getIntentExtras().getBoolean(TelephonyManagerCompat.USE_ASSISTED_DIALING, false)
1143 && getAssistedDialingExtras() != null
1144 && Build.VERSION.SDK_INT <= ConcreteCreator.BUILD_CODE_CEILING) {
1145 return true;
1146 }
1147 }
1148
1149 // Starting in P+ USE_ASSISTED_DIALING indicates that the client requested the platform
1150 // perform assisted dialing. PROPERTY_ASSISTED_DIALING_USED indicates assisted dialing took
1151 // place.
1152 if (hasProperty(TelephonyManagerCompat.PROPERTY_ASSISTED_DIALING_USED)
erfanianf2556612018-01-23 09:55:59 -08001153 && BuildCompat.isAtLeastP()) {
erfanian2cf2c342017-12-21 12:01:33 -08001154 return true;
Eric Erfanian2ca43182017-08-31 06:57:16 -07001155 }
1156 return false;
1157 }
1158
erfanian2cf2c342017-12-21 12:01:33 -08001159 @Nullable
erfaniand0f207f2017-10-11 12:23:29 -07001160 public TransformationInfo getAssistedDialingExtras() {
erfanian2cf2c342017-12-21 12:01:33 -08001161 if (getIntentExtras() == null) {
1162 return null;
erfaniand0f207f2017-10-11 12:23:29 -07001163 }
erfanian2cf2c342017-12-21 12:01:33 -08001164
erfanianf2556612018-01-23 09:55:59 -08001165 if (BuildCompat.isAtLeastP()) {
1166 if (getExtras() == null) {
1167 return null;
1168 }
1169
1170 if (getExtras()
1171 .getParcelable(TelephonyManagerCompat.EXTRA_ASSISTED_DIALING_TRANSFORMATION_INFO)
1172 == null) {
1173 return null;
1174 }
1175
1176 // TODO(erfanian): Use the framework transformation info when we can link against it
1177 return null;
1178 }
1179
erfanian2cf2c342017-12-21 12:01:33 -08001180 if (getIntentExtras().getBundle(TelephonyManagerCompat.ASSISTED_DIALING_EXTRAS) == null) {
1181 return null;
1182 }
1183
erfanianf2556612018-01-23 09:55:59 -08001184 // Used in N-OMR1
erfanian2cf2c342017-12-21 12:01:33 -08001185 return TransformationInfo.newInstanceFromBundle(
1186 getIntentExtras().getBundle(TelephonyManagerCompat.ASSISTED_DIALING_EXTRAS));
erfaniand0f207f2017-10-11 12:23:29 -07001187 }
1188
Eric Erfanianccca3152017-02-22 16:32:36 -08001189 public LatencyReport getLatencyReport() {
linyuh183cb712017-12-27 17:02:37 -08001190 return latencyReport;
Eric Erfanianccca3152017-02-22 16:32:36 -08001191 }
1192
Eric Erfanian2ca43182017-08-31 06:57:16 -07001193 public int getAnswerAndReleaseButtonDisplayedTimes() {
1194 return answerAndReleaseButtonDisplayedTimes;
1195 }
1196
1197 public void increaseAnswerAndReleaseButtonDisplayedTimes() {
1198 answerAndReleaseButtonDisplayedTimes++;
1199 }
1200
1201 public boolean getReleasedByAnsweringSecondCall() {
1202 return releasedByAnsweringSecondCall;
1203 }
1204
1205 public void setReleasedByAnsweringSecondCall(boolean releasedByAnsweringSecondCall) {
1206 this.releasedByAnsweringSecondCall = releasedByAnsweringSecondCall;
1207 }
1208
1209 public int getSecondCallWithoutAnswerAndReleasedButtonTimes() {
1210 return secondCallWithoutAnswerAndReleasedButtonTimes;
1211 }
1212
1213 public void increaseSecondCallWithoutAnswerAndReleasedButtonTimes() {
1214 secondCallWithoutAnswerAndReleasedButtonTimes++;
1215 }
1216
Eric Erfanian8369df02017-05-03 10:27:13 -07001217 @Nullable
1218 public EnrichedCallCapabilities getEnrichedCallCapabilities() {
linyuh183cb712017-12-27 17:02:37 -08001219 return enrichedCallCapabilities;
Eric Erfanian8369df02017-05-03 10:27:13 -07001220 }
1221
1222 public void setEnrichedCallCapabilities(
1223 @Nullable EnrichedCallCapabilities mEnrichedCallCapabilities) {
linyuh183cb712017-12-27 17:02:37 -08001224 this.enrichedCallCapabilities = mEnrichedCallCapabilities;
Eric Erfanian8369df02017-05-03 10:27:13 -07001225 }
1226
1227 @Nullable
1228 public Session getEnrichedCallSession() {
linyuh183cb712017-12-27 17:02:37 -08001229 return enrichedCallSession;
Eric Erfanian8369df02017-05-03 10:27:13 -07001230 }
1231
1232 public void setEnrichedCallSession(@Nullable Session mEnrichedCallSession) {
linyuh183cb712017-12-27 17:02:37 -08001233 this.enrichedCallSession = mEnrichedCallSession;
Eric Erfanian8369df02017-05-03 10:27:13 -07001234 }
1235
Eric Erfanianccca3152017-02-22 16:32:36 -08001236 public void unregisterCallback() {
linyuh183cb712017-12-27 17:02:37 -08001237 telecomCall.unregisterCallback(telecomCallCallback);
Eric Erfanianccca3152017-02-22 16:32:36 -08001238 }
1239
Eric Erfanianccca3152017-02-22 16:32:36 -08001240 public void phoneAccountSelected(PhoneAccountHandle accountHandle, boolean setDefault) {
1241 LogUtil.i(
1242 "DialerCall.phoneAccountSelected",
1243 "accountHandle: %s, setDefault: %b",
1244 accountHandle,
1245 setDefault);
linyuh183cb712017-12-27 17:02:37 -08001246 telecomCall.phoneAccountSelected(accountHandle, setDefault);
Eric Erfanianccca3152017-02-22 16:32:36 -08001247 }
1248
1249 public void disconnect() {
1250 LogUtil.i("DialerCall.disconnect", "");
1251 setState(DialerCall.State.DISCONNECTING);
linyuh183cb712017-12-27 17:02:37 -08001252 for (DialerCallListener listener : listeners) {
Eric Erfanianccca3152017-02-22 16:32:36 -08001253 listener.onDialerCallUpdate();
1254 }
linyuh183cb712017-12-27 17:02:37 -08001255 telecomCall.disconnect();
Eric Erfanianccca3152017-02-22 16:32:36 -08001256 }
1257
1258 public void hold() {
1259 LogUtil.i("DialerCall.hold", "");
linyuh183cb712017-12-27 17:02:37 -08001260 telecomCall.hold();
Eric Erfanianccca3152017-02-22 16:32:36 -08001261 }
1262
1263 public void unhold() {
1264 LogUtil.i("DialerCall.unhold", "");
linyuh183cb712017-12-27 17:02:37 -08001265 telecomCall.unhold();
Eric Erfanianccca3152017-02-22 16:32:36 -08001266 }
1267
1268 public void splitFromConference() {
1269 LogUtil.i("DialerCall.splitFromConference", "");
linyuh183cb712017-12-27 17:02:37 -08001270 telecomCall.splitFromConference();
Eric Erfanianccca3152017-02-22 16:32:36 -08001271 }
1272
1273 public void answer(int videoState) {
1274 LogUtil.i("DialerCall.answer", "videoState: " + videoState);
linyuh183cb712017-12-27 17:02:37 -08001275 telecomCall.answer(videoState);
Eric Erfanianccca3152017-02-22 16:32:36 -08001276 }
1277
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001278 public void answer() {
linyuh183cb712017-12-27 17:02:37 -08001279 answer(telecomCall.getDetails().getVideoState());
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001280 }
1281
Eric Erfanianccca3152017-02-22 16:32:36 -08001282 public void reject(boolean rejectWithMessage, String message) {
1283 LogUtil.i("DialerCall.reject", "");
linyuh183cb712017-12-27 17:02:37 -08001284 telecomCall.reject(rejectWithMessage, message);
Eric Erfanianccca3152017-02-22 16:32:36 -08001285 }
1286
1287 /** Return the string label to represent the call provider */
1288 public String getCallProviderLabel() {
1289 if (callProviderLabel == null) {
1290 PhoneAccount account = getPhoneAccount();
1291 if (account != null && !TextUtils.isEmpty(account.getLabel())) {
wangqi9982f0d2017-10-11 17:46:07 -07001292 if (callCapableAccounts != null && callCapableAccounts.size() > 1) {
Eric Erfanianccca3152017-02-22 16:32:36 -08001293 callProviderLabel = account.getLabel().toString();
1294 }
1295 }
1296 if (callProviderLabel == null) {
1297 callProviderLabel = "";
1298 }
1299 }
1300 return callProviderLabel;
1301 }
1302
1303 private PhoneAccount getPhoneAccount() {
1304 PhoneAccountHandle accountHandle = getAccountHandle();
1305 if (accountHandle == null) {
1306 return null;
1307 }
linyuh183cb712017-12-27 17:02:37 -08001308 return context.getSystemService(TelecomManager.class).getPhoneAccount(accountHandle);
Eric Erfanianccca3152017-02-22 16:32:36 -08001309 }
1310
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001311 public VideoTech getVideoTech() {
roldenburg7bb96232017-10-09 10:32:05 -07001312 if (videoTech == null) {
roldenburg6bd612f2018-01-18 12:57:19 -08001313 videoTech = videoTechManager.getVideoTech(getAccountHandle());
roldenburg7bb96232017-10-09 10:32:05 -07001314
1315 // Only store the first video tech type found to be available during the life of the call.
1316 if (selectedAvailableVideoTechType == com.android.dialer.logging.VideoTech.Type.NONE) {
1317 // Update the video tech.
1318 selectedAvailableVideoTechType = videoTech.getVideoTechType();
1319 }
1320 }
Eric Erfanian2ca43182017-08-31 06:57:16 -07001321 return videoTech;
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001322 }
1323
Eric Erfanianccca3152017-02-22 16:32:36 -08001324 public String getCallbackNumber() {
1325 if (callbackNumber == null) {
1326 // Show the emergency callback number if either:
1327 // 1. This is an emergency call.
1328 // 2. The phone is in Emergency Callback Mode, which means we should show the callback
1329 // number.
1330 boolean showCallbackNumber = hasProperty(Details.PROPERTY_EMERGENCY_CALLBACK_MODE);
1331
1332 if (isEmergencyCall() || showCallbackNumber) {
wangqi339b4f32017-09-18 14:32:09 -07001333 callbackNumber =
linyuh183cb712017-12-27 17:02:37 -08001334 context.getSystemService(TelecomManager.class).getLine1Number(getAccountHandle());
Eric Erfanianccca3152017-02-22 16:32:36 -08001335 }
1336
Eric Erfanianccca3152017-02-22 16:32:36 -08001337 if (callbackNumber == null) {
1338 callbackNumber = "";
1339 }
1340 }
1341 return callbackNumber;
1342 }
1343
wangqi97539352017-09-25 11:15:16 -07001344 public String getSimCountryIso() {
1345 String simCountryIso =
linyuh183cb712017-12-27 17:02:37 -08001346 TelephonyManagerCompat.getTelephonyManagerForPhoneAccountHandle(context, getAccountHandle())
wangqi97539352017-09-25 11:15:16 -07001347 .getSimCountryIso();
1348 if (!TextUtils.isEmpty(simCountryIso)) {
1349 simCountryIso = simCountryIso.toUpperCase(Locale.US);
1350 }
1351 return simCountryIso;
1352 }
1353
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001354 @Override
1355 public void onVideoTechStateChanged() {
1356 update();
1357 }
1358
1359 @Override
1360 public void onSessionModificationStateChanged() {
wangqi9982f0d2017-10-11 17:46:07 -07001361 Trace.beginSection("DialerCall.onSessionModificationStateChanged");
linyuh183cb712017-12-27 17:02:37 -08001362 for (DialerCallListener listener : listeners) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001363 listener.onDialerCallSessionModificationStateChange();
1364 }
wangqi9982f0d2017-10-11 17:46:07 -07001365 Trace.endSection();
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001366 }
1367
1368 @Override
1369 public void onCameraDimensionsChanged(int width, int height) {
1370 InCallVideoCallCallbackNotifier.getInstance().cameraDimensionsChanged(this, width, height);
1371 }
1372
1373 @Override
1374 public void onPeerDimensionsChanged(int width, int height) {
1375 InCallVideoCallCallbackNotifier.getInstance().peerDimensionsChanged(this, width, height);
1376 }
1377
1378 @Override
1379 public void onVideoUpgradeRequestReceived() {
1380 LogUtil.enterBlock("DialerCall.onVideoUpgradeRequestReceived");
1381
linyuh183cb712017-12-27 17:02:37 -08001382 for (DialerCallListener listener : listeners) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001383 listener.onDialerCallUpgradeToVideo();
1384 }
1385
1386 update();
Eric Erfanian8369df02017-05-03 10:27:13 -07001387
linyuh183cb712017-12-27 17:02:37 -08001388 Logger.get(context)
Eric Erfanian8369df02017-05-03 10:27:13 -07001389 .logCallImpression(
1390 DialerImpression.Type.VIDEO_CALL_REQUEST_RECEIVED, getUniqueCallId(), getTimeAddedMs());
1391 }
1392
1393 @Override
1394 public void onUpgradedToVideo(boolean switchToSpeaker) {
1395 LogUtil.enterBlock("DialerCall.onUpgradedToVideo");
1396
1397 if (!switchToSpeaker) {
1398 return;
1399 }
1400
1401 CallAudioState audioState = AudioModeProvider.getInstance().getAudioState();
1402
1403 if (0 != (CallAudioState.ROUTE_BLUETOOTH & audioState.getSupportedRouteMask())) {
1404 LogUtil.e(
1405 "DialerCall.onUpgradedToVideo",
1406 "toggling speakerphone not allowed when bluetooth supported.");
1407 return;
1408 }
1409
1410 if (audioState.getRoute() == CallAudioState.ROUTE_SPEAKER) {
1411 return;
1412 }
1413
1414 TelecomAdapter.getInstance().setAudioRoute(CallAudioState.ROUTE_SPEAKER);
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001415 }
1416
Eric Erfanian2ca43182017-08-31 06:57:16 -07001417 @Override
1418 public void onCapabilitiesUpdated() {
1419 if (getNumber() == null) {
1420 return;
1421 }
1422 EnrichedCallCapabilities capabilities =
linyuh183cb712017-12-27 17:02:37 -08001423 EnrichedCallComponent.get(context).getEnrichedCallManager().getCapabilities(getNumber());
Eric Erfanian2ca43182017-08-31 06:57:16 -07001424 if (capabilities != null) {
1425 setEnrichedCallCapabilities(capabilities);
1426 update();
1427 }
1428 }
1429
1430 @Override
1431 public void onEnrichedCallStateChanged() {
1432 updateEnrichedCallSession();
1433 }
1434
1435 @Override
1436 public void onImpressionLoggingNeeded(DialerImpression.Type impressionType) {
linyuh183cb712017-12-27 17:02:37 -08001437 Logger.get(context).logCallImpression(impressionType, getUniqueCallId(), getTimeAddedMs());
twyendde01c52017-09-22 10:07:31 -07001438 if (impressionType == DialerImpression.Type.LIGHTBRINGER_UPGRADE_REQUESTED) {
1439 if (getLogState().contactLookupResult == Type.NOT_FOUND) {
linyuh183cb712017-12-27 17:02:37 -08001440 Logger.get(context)
twyendde01c52017-09-22 10:07:31 -07001441 .logCallImpression(
1442 DialerImpression.Type.LIGHTBRINGER_NON_CONTACT_UPGRADE_REQUESTED,
1443 getUniqueCallId(),
1444 getTimeAddedMs());
1445 }
1446 }
Eric Erfanian2ca43182017-08-31 06:57:16 -07001447 }
1448
1449 private void updateEnrichedCallSession() {
1450 if (getNumber() == null) {
1451 return;
1452 }
1453 if (getEnrichedCallSession() != null) {
1454 // State changes to existing sessions are currently handled by the UI components (which have
1455 // their own listeners). Someday instead we could remove those and just call update() here and
1456 // have the usual onDialerCallUpdate update the UI.
1457 dispatchOnEnrichedCallSessionUpdate();
1458 return;
1459 }
1460
linyuh183cb712017-12-27 17:02:37 -08001461 EnrichedCallManager manager = EnrichedCallComponent.get(context).getEnrichedCallManager();
Eric Erfanian2ca43182017-08-31 06:57:16 -07001462
1463 Filter filter =
1464 isIncoming()
1465 ? manager.createIncomingCallComposerFilter()
1466 : manager.createOutgoingCallComposerFilter();
1467
1468 Session session = manager.getSession(getUniqueCallId(), getNumber(), filter);
1469 if (session == null) {
1470 return;
1471 }
1472
1473 session.setUniqueDialerCallId(getUniqueCallId());
1474 setEnrichedCallSession(session);
1475
1476 LogUtil.i(
1477 "DialerCall.updateEnrichedCallSession",
1478 "setting session %d's dialer id to %s",
1479 session.getSessionId(),
1480 getUniqueCallId());
1481
1482 dispatchOnEnrichedCallSessionUpdate();
1483 }
1484
1485 private void dispatchOnEnrichedCallSessionUpdate() {
linyuh183cb712017-12-27 17:02:37 -08001486 for (DialerCallListener listener : listeners) {
Eric Erfanian2ca43182017-08-31 06:57:16 -07001487 listener.onEnrichedCallSessionUpdate();
1488 }
1489 }
1490
1491 void onRemovedFromCallList() {
1492 // Ensure we clean up when this call is removed.
linyuh183cb712017-12-27 17:02:37 -08001493 videoTechManager.dispatchRemovedFromCallList();
Eric Erfanian2ca43182017-08-31 06:57:16 -07001494 }
1495
wangqi4d705e52017-09-28 12:23:35 -07001496 public com.android.dialer.logging.VideoTech.Type getSelectedAvailableVideoTechType() {
1497 return selectedAvailableVideoTechType;
yueg457b3972017-09-18 15:11:47 -07001498 }
1499
Android Dialer974fc292018-02-01 16:12:25 -08001500 public void markFeedbackRequested() {
1501 feedbackRequested = true;
1502 }
1503
1504 public boolean isFeedbackRequested() {
1505 return feedbackRequested;
1506 }
1507
Eric Erfanianccca3152017-02-22 16:32:36 -08001508 /**
1509 * Specifies whether a number is in the call history or not. {@link #CALL_HISTORY_STATUS_UNKNOWN}
1510 * means there is no result.
1511 */
1512 @IntDef({
1513 CALL_HISTORY_STATUS_UNKNOWN,
1514 CALL_HISTORY_STATUS_PRESENT,
1515 CALL_HISTORY_STATUS_NOT_PRESENT
1516 })
1517 @Retention(RetentionPolicy.SOURCE)
1518 public @interface CallHistoryStatus {}
1519
1520 /* Defines different states of this call */
1521 public static class State {
1522
1523 public static final int INVALID = 0;
1524 public static final int NEW = 1; /* The call is new. */
1525 public static final int IDLE = 2; /* The call is idle. Nothing active */
1526 public static final int ACTIVE = 3; /* There is an active call */
1527 public static final int INCOMING = 4; /* A normal incoming phone call */
1528 public static final int CALL_WAITING = 5; /* Incoming call while another is active */
1529 public static final int DIALING = 6; /* An outgoing call during dial phase */
1530 public static final int REDIALING = 7; /* Subsequent dialing attempt after a failure */
1531 public static final int ONHOLD = 8; /* An active phone call placed on hold */
1532 public static final int DISCONNECTING = 9; /* A call is being ended. */
1533 public static final int DISCONNECTED = 10; /* State after a call disconnects */
1534 public static final int CONFERENCED = 11; /* DialerCall part of a conference call */
1535 public static final int SELECT_PHONE_ACCOUNT = 12; /* Waiting for account selection */
1536 public static final int CONNECTING = 13; /* Waiting for Telecom broadcast to finish */
1537 public static final int BLOCKED = 14; /* The number was found on the block list */
1538 public static final int PULLING = 15; /* An external call being pulled to the device */
Eric Erfanian2ca43182017-08-31 06:57:16 -07001539 public static final int CALL_PENDING = 16; /* A call is pending on a long process to finish */
Eric Erfanianccca3152017-02-22 16:32:36 -08001540
1541 public static boolean isConnectingOrConnected(int state) {
1542 switch (state) {
1543 case ACTIVE:
1544 case INCOMING:
1545 case CALL_WAITING:
1546 case CONNECTING:
1547 case DIALING:
1548 case PULLING:
1549 case REDIALING:
1550 case ONHOLD:
1551 case CONFERENCED:
1552 return true;
1553 default:
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001554 return false;
Eric Erfanianccca3152017-02-22 16:32:36 -08001555 }
Eric Erfanianccca3152017-02-22 16:32:36 -08001556 }
1557
1558 public static boolean isDialing(int state) {
1559 return state == DIALING || state == PULLING || state == REDIALING;
1560 }
1561
1562 public static String toString(int state) {
1563 switch (state) {
1564 case INVALID:
1565 return "INVALID";
1566 case NEW:
1567 return "NEW";
1568 case IDLE:
1569 return "IDLE";
1570 case ACTIVE:
1571 return "ACTIVE";
1572 case INCOMING:
1573 return "INCOMING";
1574 case CALL_WAITING:
1575 return "CALL_WAITING";
1576 case DIALING:
1577 return "DIALING";
1578 case PULLING:
1579 return "PULLING";
1580 case REDIALING:
1581 return "REDIALING";
1582 case ONHOLD:
1583 return "ONHOLD";
1584 case DISCONNECTING:
1585 return "DISCONNECTING";
1586 case DISCONNECTED:
1587 return "DISCONNECTED";
1588 case CONFERENCED:
1589 return "CONFERENCED";
1590 case SELECT_PHONE_ACCOUNT:
1591 return "SELECT_PHONE_ACCOUNT";
1592 case CONNECTING:
1593 return "CONNECTING";
1594 case BLOCKED:
1595 return "BLOCKED";
1596 default:
1597 return "UNKNOWN";
1598 }
1599 }
1600 }
1601
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001602 /** Camera direction constants */
1603 public static class CameraDirection {
Eric Erfanianccca3152017-02-22 16:32:36 -08001604 public static final int CAMERA_DIRECTION_UNKNOWN = -1;
1605 public static final int CAMERA_DIRECTION_FRONT_FACING = CameraCharacteristics.LENS_FACING_FRONT;
1606 public static final int CAMERA_DIRECTION_BACK_FACING = CameraCharacteristics.LENS_FACING_BACK;
Eric Erfanianccca3152017-02-22 16:32:36 -08001607 }
1608
1609 /**
1610 * Tracks any state variables that is useful for logging. There is some amount of overlap with
1611 * existing call member variables, but this duplication helps to ensure that none of these logging
1612 * variables will interface with/and affect call logic.
1613 */
1614 public static class LogState {
1615
1616 public DisconnectCause disconnectCause;
1617 public boolean isIncoming = false;
Eric Erfanian8369df02017-05-03 10:27:13 -07001618 public ContactLookupResult.Type contactLookupResult =
1619 ContactLookupResult.Type.UNKNOWN_LOOKUP_RESULT_TYPE;
Eric Erfanianccca3152017-02-22 16:32:36 -08001620 public CallSpecificAppData callSpecificAppData;
1621 // If this was a conference call, the total number of calls involved in the conference.
1622 public int conferencedCalls = 0;
1623 public long duration = 0;
1624 public boolean isLogged = false;
1625
Eric Erfanian8369df02017-05-03 10:27:13 -07001626 private static String lookupToString(ContactLookupResult.Type lookupType) {
Eric Erfanianccca3152017-02-22 16:32:36 -08001627 switch (lookupType) {
Eric Erfanian8369df02017-05-03 10:27:13 -07001628 case LOCAL_CONTACT:
Eric Erfanianccca3152017-02-22 16:32:36 -08001629 return "Local";
Eric Erfanian8369df02017-05-03 10:27:13 -07001630 case LOCAL_CACHE:
Eric Erfanianccca3152017-02-22 16:32:36 -08001631 return "Cache";
Eric Erfanian8369df02017-05-03 10:27:13 -07001632 case REMOTE:
Eric Erfanianccca3152017-02-22 16:32:36 -08001633 return "Remote";
Eric Erfanian8369df02017-05-03 10:27:13 -07001634 case EMERGENCY:
Eric Erfanianccca3152017-02-22 16:32:36 -08001635 return "Emergency";
Eric Erfanian8369df02017-05-03 10:27:13 -07001636 case VOICEMAIL:
Eric Erfanianccca3152017-02-22 16:32:36 -08001637 return "Voicemail";
1638 default:
1639 return "Not found";
1640 }
1641 }
1642
1643 private static String initiationToString(CallSpecificAppData callSpecificAppData) {
1644 if (callSpecificAppData == null) {
1645 return "null";
1646 }
Eric Erfanian8369df02017-05-03 10:27:13 -07001647 switch (callSpecificAppData.getCallInitiationType()) {
1648 case INCOMING_INITIATION:
Eric Erfanianccca3152017-02-22 16:32:36 -08001649 return "Incoming";
Eric Erfanian8369df02017-05-03 10:27:13 -07001650 case DIALPAD:
Eric Erfanianccca3152017-02-22 16:32:36 -08001651 return "Dialpad";
Eric Erfanian8369df02017-05-03 10:27:13 -07001652 case SPEED_DIAL:
Eric Erfanianccca3152017-02-22 16:32:36 -08001653 return "Speed Dial";
Eric Erfanian8369df02017-05-03 10:27:13 -07001654 case REMOTE_DIRECTORY:
Eric Erfanianccca3152017-02-22 16:32:36 -08001655 return "Remote Directory";
Eric Erfanian8369df02017-05-03 10:27:13 -07001656 case SMART_DIAL:
Eric Erfanianccca3152017-02-22 16:32:36 -08001657 return "Smart Dial";
Eric Erfanian8369df02017-05-03 10:27:13 -07001658 case REGULAR_SEARCH:
Eric Erfanianccca3152017-02-22 16:32:36 -08001659 return "Regular Search";
Eric Erfanian8369df02017-05-03 10:27:13 -07001660 case CALL_LOG:
Eric Erfanianccca3152017-02-22 16:32:36 -08001661 return "DialerCall Log";
Eric Erfanian8369df02017-05-03 10:27:13 -07001662 case CALL_LOG_FILTER:
Eric Erfanianccca3152017-02-22 16:32:36 -08001663 return "DialerCall Log Filter";
Eric Erfanian8369df02017-05-03 10:27:13 -07001664 case VOICEMAIL_LOG:
Eric Erfanianccca3152017-02-22 16:32:36 -08001665 return "Voicemail Log";
Eric Erfanian8369df02017-05-03 10:27:13 -07001666 case CALL_DETAILS:
Eric Erfanianccca3152017-02-22 16:32:36 -08001667 return "DialerCall Details";
Eric Erfanian8369df02017-05-03 10:27:13 -07001668 case QUICK_CONTACTS:
Eric Erfanianccca3152017-02-22 16:32:36 -08001669 return "Quick Contacts";
Eric Erfanian8369df02017-05-03 10:27:13 -07001670 case EXTERNAL_INITIATION:
Eric Erfanianccca3152017-02-22 16:32:36 -08001671 return "External";
Eric Erfanian8369df02017-05-03 10:27:13 -07001672 case LAUNCHER_SHORTCUT:
Eric Erfanianccca3152017-02-22 16:32:36 -08001673 return "Launcher Shortcut";
1674 default:
Eric Erfanian8369df02017-05-03 10:27:13 -07001675 return "Unknown: " + callSpecificAppData.getCallInitiationType();
Eric Erfanianccca3152017-02-22 16:32:36 -08001676 }
1677 }
1678
1679 @Override
1680 public String toString() {
1681 return String.format(
1682 Locale.US,
1683 "["
1684 + "%s, " // DisconnectCause toString already describes the object type
1685 + "isIncoming: %s, "
1686 + "contactLookup: %s, "
1687 + "callInitiation: %s, "
1688 + "duration: %s"
1689 + "]",
1690 disconnectCause,
1691 isIncoming,
1692 lookupToString(contactLookupResult),
1693 initiationToString(callSpecificAppData),
1694 duration);
1695 }
1696 }
1697
roldenburgd7490db2018-01-09 13:51:29 -08001698 /** Coordinates the available VideoTech implementations for a call. */
1699 @VisibleForTesting
1700 public static class VideoTechManager {
Eric Erfaniand8046e52017-04-06 09:41:50 -07001701 private final Context context;
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001702 private final EmptyVideoTech emptyVideoTech = new EmptyVideoTech();
roldenburgd7490db2018-01-09 13:51:29 -08001703 private final VideoTech rcsVideoShare;
Eric Erfanian90508232017-03-24 09:31:16 -07001704 private final List<VideoTech> videoTechs;
roldenburg7bb96232017-10-09 10:32:05 -07001705 private VideoTech savedTech;
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001706
roldenburgd7490db2018-01-09 13:51:29 -08001707 @VisibleForTesting
1708 public VideoTechManager(DialerCall call) {
linyuh183cb712017-12-27 17:02:37 -08001709 this.context = call.context;
Eric Erfaniand8046e52017-04-06 09:41:50 -07001710
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001711 String phoneNumber = call.getNumber();
Eric Erfaniand8046e52017-04-06 09:41:50 -07001712 phoneNumber = phoneNumber != null ? phoneNumber : "";
Eric Erfanian2ca43182017-08-31 06:57:16 -07001713 phoneNumber = phoneNumber.replaceAll("[^+0-9]", "");
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001714
1715 // Insert order here determines the priority of that video tech option
Eric Erfanian8369df02017-05-03 10:27:13 -07001716 videoTechs = new ArrayList<>();
yueg457b3972017-09-18 15:11:47 -07001717
linyuh183cb712017-12-27 17:02:37 -08001718 videoTechs.add(new ImsVideoTech(Logger.get(call.context), call, call.telecomCall));
Eric Erfanian90508232017-03-24 09:31:16 -07001719
roldenburgd7490db2018-01-09 13:51:29 -08001720 rcsVideoShare =
linyuh183cb712017-12-27 17:02:37 -08001721 EnrichedCallComponent.get(call.context)
Eric Erfanian90508232017-03-24 09:31:16 -07001722 .getRcsVideoShareFactory()
1723 .newRcsVideoShare(
linyuh183cb712017-12-27 17:02:37 -08001724 EnrichedCallComponent.get(call.context).getEnrichedCallManager(),
Eric Erfanian90508232017-03-24 09:31:16 -07001725 call,
Eric Erfaniand8046e52017-04-06 09:41:50 -07001726 phoneNumber);
roldenburg3eca69f2018-01-16 12:07:04 -08001727 videoTechs.add(rcsVideoShare);
Eric Erfaniand8046e52017-04-06 09:41:50 -07001728
1729 videoTechs.add(
roldenburg4f026392017-10-13 18:42:20 -07001730 new DuoVideoTech(
linyuh183cb712017-12-27 17:02:37 -08001731 DuoComponent.get(call.context).getDuo(), call, call.telecomCall, phoneNumber));
roldenburgd7490db2018-01-09 13:51:29 -08001732
1733 savedTech = emptyVideoTech;
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001734 }
1735
roldenburgd7490db2018-01-09 13:51:29 -08001736 @VisibleForTesting
roldenburg6bd612f2018-01-18 12:57:19 -08001737 public VideoTech getVideoTech(PhoneAccountHandle phoneAccountHandle) {
roldenburgd7490db2018-01-09 13:51:29 -08001738 if (savedTech == emptyVideoTech) {
1739 for (VideoTech tech : videoTechs) {
roldenburg6bd612f2018-01-18 12:57:19 -08001740 if (tech.isAvailable(context, phoneAccountHandle)) {
roldenburgd7490db2018-01-09 13:51:29 -08001741 savedTech = tech;
1742 savedTech.becomePrimary();
1743 break;
1744 }
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001745 }
roldenburg6bd612f2018-01-18 12:57:19 -08001746 } else if (savedTech instanceof DuoVideoTech
1747 && rcsVideoShare.isAvailable(context, phoneAccountHandle)) {
roldenburgd7490db2018-01-09 13:51:29 -08001748 // RCS Video Share will become available after the capability exchange which is slower than
1749 // Duo reading local contacts for reachability. If Video Share becomes available and we are
1750 // not in the middle of any session changes, let it take over.
1751 savedTech = rcsVideoShare;
1752 rcsVideoShare.becomePrimary();
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001753 }
1754
roldenburgd7490db2018-01-09 13:51:29 -08001755 return savedTech;
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001756 }
1757
roldenburgd7490db2018-01-09 13:51:29 -08001758 @VisibleForTesting
roldenburg6bd612f2018-01-18 12:57:19 -08001759 public void dispatchCallStateChanged(int newState, PhoneAccountHandle phoneAccountHandle) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001760 for (VideoTech videoTech : videoTechs) {
roldenburg6bd612f2018-01-18 12:57:19 -08001761 videoTech.onCallStateChanged(context, newState, phoneAccountHandle);
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001762 }
1763 }
Eric Erfanian2ca43182017-08-31 06:57:16 -07001764
1765 void dispatchRemovedFromCallList() {
1766 for (VideoTech videoTech : videoTechs) {
1767 videoTech.onRemovedFromCallList();
1768 }
1769 }
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001770 }
1771
Eric Erfanianccca3152017-02-22 16:32:36 -08001772 /** Called when canned text responses have been loaded. */
1773 public interface CannedTextResponsesLoadedListener {
1774 void onCannedTextResponsesLoaded(DialerCall call);
1775 }
1776}