blob: a6ec34784c5483edfbb90c1ce690e902dea5f3b0 [file] [log] [blame]
Ben Gilad0407fb22014-01-09 16:18:41 -08001/*
2 * Copyright (C) 2014 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
Ben Gilad9f2bed32013-12-12 17:43:26 -080017package com.android.telecomm;
18
Santos Cordon99c8a6f2014-05-28 18:28:47 -070019import android.content.ContentUris;
20import android.graphics.Bitmap;
21import android.graphics.drawable.Drawable;
Sailesh Nepalce704b92014-03-17 18:31:43 -070022import android.net.Uri;
Sailesh Nepal84fa5f82014-04-02 11:01:11 -070023import android.os.Bundle;
Santos Cordonfd71f4a2014-05-28 13:59:49 -070024import android.os.Handler;
Santos Cordon99c8a6f2014-05-28 18:28:47 -070025import android.provider.ContactsContract.Contacts;
Santos Cordon0b03b4b2014-01-29 18:01:59 -080026import android.telecomm.CallInfo;
Sailesh Nepal84fa5f82014-04-02 11:01:11 -070027import android.telecomm.CallServiceDescriptor;
Santos Cordon0b03b4b2014-01-29 18:01:59 -080028import android.telecomm.CallState;
Yorke Lee33501632014-03-17 19:24:12 -070029import android.telecomm.GatewayInfo;
Ihab Awadff7493a2014-06-10 13:47:44 -070030import android.telecomm.Response;
Santos Cordon766d04f2014-05-06 10:28:25 -070031import android.telecomm.TelecommConstants;
Santos Cordon79ff2bc2014-03-27 15:31:27 -070032import android.telephony.DisconnectCause;
Sailesh Nepal6aca10a2014-03-24 16:11:02 -070033import android.telephony.PhoneNumberUtils;
Santos Cordonfd71f4a2014-05-28 13:59:49 -070034import android.text.TextUtils;
Santos Cordon0b03b4b2014-01-29 18:01:59 -080035
Santos Cordonfd71f4a2014-05-28 13:59:49 -070036import com.android.internal.telephony.CallerInfo;
37import com.android.internal.telephony.CallerInfoAsyncQuery;
38import com.android.internal.telephony.CallerInfoAsyncQuery.OnQueryCompleteListener;
Santos Cordon99c8a6f2014-05-28 18:28:47 -070039
Ihab Awadff7493a2014-06-10 13:47:44 -070040import com.android.internal.telephony.SmsApplication;
Santos Cordon99c8a6f2014-05-28 18:28:47 -070041import com.android.telecomm.ContactsAsyncHelper.OnImageLoadCompleteListener;
Santos Cordon61d0f702014-02-19 02:52:23 -080042import com.google.common.base.Preconditions;
Ihab Awadff7493a2014-06-10 13:47:44 -070043import com.google.common.collect.Sets;
Santos Cordon61d0f702014-02-19 02:52:23 -080044
Ihab Awadff7493a2014-06-10 13:47:44 -070045import java.util.Collections;
Santos Cordona1610702014-06-04 20:22:56 -070046import java.util.LinkedList;
47import java.util.List;
Sailesh Nepal91990782014-03-08 17:45:52 -080048import java.util.Locale;
Ben Gilad61925612014-03-11 19:06:36 -070049import java.util.Set;
Ben Gilad0407fb22014-01-09 16:18:41 -080050
Ben Gilad2495d572014-01-09 17:26:19 -080051/**
52 * Encapsulates all aspects of a given phone call throughout its lifecycle, starting
53 * from the time the call intent was received by Telecomm (vs. the time the call was
54 * connected etc).
55 */
Ben Gilad0407fb22014-01-09 16:18:41 -080056final class Call {
Santos Cordon766d04f2014-05-06 10:28:25 -070057
58 /**
59 * Listener for events on the call.
60 */
61 interface Listener {
62 void onSuccessfulOutgoingCall(Call call);
Ihab Awad0fea3f22014-06-03 18:45:05 -070063 void onFailedOutgoingCall(Call call, boolean isAborted, int errorCode, String errorMsg);
Santos Cordon766d04f2014-05-06 10:28:25 -070064 void onSuccessfulIncomingCall(Call call, CallInfo callInfo);
65 void onFailedIncomingCall(Call call);
Ihab Awadcb387ac2014-05-28 16:49:38 -070066 void onRequestingRingback(Call call, boolean requestingRingback);
Evan Charlton352105c2014-06-03 14:10:54 -070067 void onPostDialWait(Call call, String remaining);
Santos Cordona1610702014-06-04 20:22:56 -070068 void onIsConferenceCapableChanged(Call call, boolean isConferenceCapable);
69 void onExpiredConferenceCall(Call call);
70 void onConfirmedConferenceCall(Call call);
71 void onParentChanged(Call call);
72 void onChildrenChanged(Call call);
Ihab Awadff7493a2014-06-10 13:47:44 -070073 void onCannedSmsResponsesLoaded(Call call);
Santos Cordon766d04f2014-05-06 10:28:25 -070074 }
75
Santos Cordonfd71f4a2014-05-28 13:59:49 -070076 private static final OnQueryCompleteListener sCallerInfoQueryListener =
Santos Cordon99c8a6f2014-05-28 18:28:47 -070077 new OnQueryCompleteListener() {
78 /** ${inheritDoc} */
79 @Override
80 public void onQueryComplete(int token, Object cookie, CallerInfo callerInfo) {
81 if (cookie != null) {
82 ((Call) cookie).setCallerInfo(callerInfo, token);
83 }
Santos Cordonfd71f4a2014-05-28 13:59:49 -070084 }
Santos Cordon99c8a6f2014-05-28 18:28:47 -070085 };
86
87 private static final OnImageLoadCompleteListener sPhotoLoadListener =
88 new OnImageLoadCompleteListener() {
89 /** ${inheritDoc} */
90 @Override
91 public void onImageLoadComplete(
92 int token, Drawable photo, Bitmap photoIcon, Object cookie) {
93 if (cookie != null) {
94 ((Call) cookie).setPhoto(photo, photoIcon, token);
95 }
96 }
97 };
Ben Gilad0407fb22014-01-09 16:18:41 -080098
Sailesh Nepal810735e2014-03-18 18:15:46 -070099 /** True if this is an incoming call. */
100 private final boolean mIsIncoming;
101
Ben Gilad0407fb22014-01-09 16:18:41 -0800102 /**
103 * The time this call was created, typically also the time this call was added to the set
104 * of pending outgoing calls (mPendingOutgoingCalls) that's maintained by the switchboard.
105 * Beyond logging and such, may also be used for bookkeeping and specifically for marking
106 * certain call attempts as failed attempts.
107 */
Sailesh Nepal8c85dee2014-04-07 22:21:40 -0700108 private final long mCreationTimeMillis = System.currentTimeMillis();
109
Santos Cordonfd71f4a2014-05-28 13:59:49 -0700110 /** The gateway information associated with this call. This stores the original call handle
111 * that the user is attempting to connect to via the gateway, the actual handle to dial in
112 * order to connect the call via the gateway, as well as the package name of the gateway
113 * service. */
114 private final GatewayInfo mGatewayInfo;
115
Santos Cordon2174fb52014-05-29 08:22:56 -0700116 private final Handler mHandler = new Handler();
117
Sailesh Nepal8c85dee2014-04-07 22:21:40 -0700118 private long mConnectTimeMillis;
Ben Gilad0407fb22014-01-09 16:18:41 -0800119
Santos Cordon61d0f702014-02-19 02:52:23 -0800120 /** The state of the call. */
121 private CallState mState;
122
123 /** The handle with which to establish this call. */
Sailesh Nepalce704b92014-03-17 18:31:43 -0700124 private Uri mHandle;
Santos Cordon61d0f702014-02-19 02:52:23 -0800125
Ben Gilad0407fb22014-01-09 16:18:41 -0800126 /**
Ben Gilad8e55d1d2014-02-26 16:25:56 -0800127 * The call service which is attempted or already connecting this call.
Santos Cordon681663d2014-01-30 04:32:15 -0800128 */
Santos Cordonc195e362014-02-11 17:05:31 -0800129 private CallServiceWrapper mCallService;
Santos Cordon681663d2014-01-30 04:32:15 -0800130
Ben Gilad8e55d1d2014-02-26 16:25:56 -0800131 /**
Ben Gilad61925612014-03-11 19:06:36 -0700132 * The set of call services that were attempted in the process of placing/switching this call
133 * but turned out unsuitable. Only used in the context of call switching.
134 */
135 private Set<CallServiceWrapper> mIncompatibleCallServices;
136
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700137 private boolean mIsEmergencyCall;
138
Sai Cheemalapatib7157e92014-06-11 17:51:55 -0700139 private boolean mSpeakerphoneOn;
140
Ben Gilad61925612014-03-11 19:06:36 -0700141 /**
Santos Cordon79ff2bc2014-03-27 15:31:27 -0700142 * Disconnect cause for the call. Only valid if the state of the call is DISCONNECTED.
143 * See {@link android.telephony.DisconnectCause}.
144 */
Sailesh Nepal8c85dee2014-04-07 22:21:40 -0700145 private int mDisconnectCause = DisconnectCause.NOT_VALID;
Santos Cordon79ff2bc2014-03-27 15:31:27 -0700146
147 /**
148 * Additional disconnect information provided by the call service.
149 */
150 private String mDisconnectMessage;
151
Sailesh Nepal84fa5f82014-04-02 11:01:11 -0700152 /** Info used by the call services. */
Sailesh Nepal8c85dee2014-04-07 22:21:40 -0700153 private Bundle mExtras = Bundle.EMPTY;
Sailesh Nepal84fa5f82014-04-02 11:01:11 -0700154
155 /** The Uri to dial to perform the handoff. If this is null then handoff is not supported. */
156 private Uri mHandoffHandle;
157
158 /**
159 * References the call that is being handed off. This value is non-null for untracked calls
160 * that are being used to perform a handoff.
161 */
162 private Call mOriginalCall;
163
Santos Cordon79ff2bc2014-03-27 15:31:27 -0700164 /**
Sailesh Nepal8c85dee2014-04-07 22:21:40 -0700165 * The descriptor for the call service that this call is being switched to, null if handoff is
166 * not in progress.
167 */
168 private CallServiceDescriptor mHandoffCallServiceDescriptor;
169
Santos Cordon766d04f2014-05-06 10:28:25 -0700170 /** Set of listeners on this call. */
171 private Set<Listener> mListeners = Sets.newHashSet();
172
Santos Cordon682fe6b2014-05-20 08:56:39 -0700173 private OutgoingCallProcessor mOutgoingCallProcessor;
174
175 // TODO(santoscordon): The repositories should be changed into singleton types.
176 private CallServiceRepository mCallServiceRepository;
Santos Cordon682fe6b2014-05-20 08:56:39 -0700177
Santos Cordonfd71f4a2014-05-28 13:59:49 -0700178 /** Caller information retrieved from the latest contact query. */
179 private CallerInfo mCallerInfo;
180
181 /** The latest token used with a contact info query. */
182 private int mQueryToken = 0;
183
Ihab Awadcb387ac2014-05-28 16:49:38 -0700184 /** Whether this call is requesting that Telecomm play the ringback tone on its behalf. */
185 private boolean mRequestingRingback = false;
186
Santos Cordon2174fb52014-05-29 08:22:56 -0700187 /** Incoming call-info to use when direct-to-voicemail query finishes. */
188 private CallInfo mPendingDirectToVoicemailCallInfo;
189
Santos Cordona1610702014-06-04 20:22:56 -0700190 private boolean mIsConferenceCapable = false;
191
192 private boolean mIsConference = false;
193
194 private Call mParentCall = null;
195
196 private List<Call> mChildCalls = new LinkedList<>();
197
Ihab Awadff7493a2014-06-10 13:47:44 -0700198 /** Set of text message responses allowed for this call, if applicable. */
199 private List<String> mCannedSmsResponses = Collections.EMPTY_LIST;
200
201 /** Whether an attempt has been made to load the text message responses. */
202 private boolean mCannedSmsResponsesLoadingStarted = false;
203
Sailesh Nepal8c85dee2014-04-07 22:21:40 -0700204 /**
Sailesh Nepale59bb192014-04-01 18:33:59 -0700205 * Creates an empty call object.
Sailesh Nepal810735e2014-03-18 18:15:46 -0700206 *
207 * @param isIncoming True if this is an incoming call.
Santos Cordon493e8f22014-02-19 03:15:12 -0800208 */
Santos Cordona1610702014-06-04 20:22:56 -0700209 Call(boolean isIncoming, boolean isConference) {
210 this(null, null, isIncoming, isConference);
Santos Cordon493e8f22014-02-19 03:15:12 -0800211 }
212
213 /**
Ben Gilad0407fb22014-01-09 16:18:41 -0800214 * Persists the specified parameters and initializes the new instance.
215 *
216 * @param handle The handle to dial.
Yorke Lee33501632014-03-17 19:24:12 -0700217 * @param gatewayInfo Gateway information to use for the call.
Sailesh Nepal810735e2014-03-18 18:15:46 -0700218 * @param isIncoming True if this is an incoming call.
Ben Gilad0407fb22014-01-09 16:18:41 -0800219 */
Santos Cordona1610702014-06-04 20:22:56 -0700220 Call(Uri handle, GatewayInfo gatewayInfo, boolean isIncoming, boolean isConference) {
221 mState = isConference ? CallState.ACTIVE : CallState.NEW;
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700222 setHandle(handle);
Yorke Lee33501632014-03-17 19:24:12 -0700223 mGatewayInfo = gatewayInfo;
Sailesh Nepal810735e2014-03-18 18:15:46 -0700224 mIsIncoming = isIncoming;
Santos Cordona1610702014-06-04 20:22:56 -0700225 mIsConference = isConference;
Ihab Awadff7493a2014-06-10 13:47:44 -0700226 maybeLoadCannedSmsResponses();
Ben Gilad0407fb22014-01-09 16:18:41 -0800227 }
228
Santos Cordon766d04f2014-05-06 10:28:25 -0700229 void addListener(Listener listener) {
230 mListeners.add(listener);
231 }
232
233 void removeListener(Listener listener) {
234 mListeners.remove(listener);
235 }
236
Santos Cordon61d0f702014-02-19 02:52:23 -0800237 /** {@inheritDoc} */
238 @Override public String toString() {
Sailesh Nepal4538f012014-04-15 11:40:33 -0700239 String component = null;
240 if (mCallService != null && mCallService.getComponentName() != null) {
241 component = mCallService.getComponentName().flattenToShortString();
242 }
243 return String.format(Locale.US, "[%s, %s, %s]", mState, component, Log.piiHandle(mHandle));
Santos Cordon61d0f702014-02-19 02:52:23 -0800244 }
245
Santos Cordon0b03b4b2014-01-29 18:01:59 -0800246 CallState getState() {
Santos Cordona1610702014-06-04 20:22:56 -0700247 if (mIsConference) {
248 if (!mChildCalls.isEmpty()) {
249 // If we have child calls, just return the child call.
250 return mChildCalls.get(0).getState();
251 }
252 return CallState.ACTIVE;
253 } else {
254 return mState;
255 }
Santos Cordon0b03b4b2014-01-29 18:01:59 -0800256 }
257
258 /**
259 * Sets the call state. Although there exists the notion of appropriate state transitions
260 * (see {@link CallState}), in practice those expectations break down when cellular systems
261 * misbehave and they do this very often. The result is that we do not enforce state transitions
262 * and instead keep the code resilient to unexpected state changes.
263 */
Sailesh Nepal810735e2014-03-18 18:15:46 -0700264 void setState(CallState newState) {
Santos Cordon79ff2bc2014-03-27 15:31:27 -0700265 Preconditions.checkState(newState != CallState.DISCONNECTED ||
266 mDisconnectCause != DisconnectCause.NOT_VALID);
Sailesh Nepal810735e2014-03-18 18:15:46 -0700267 if (mState != newState) {
268 Log.v(this, "setState %s -> %s", mState, newState);
269 mState = newState;
Ihab Awadff7493a2014-06-10 13:47:44 -0700270 maybeLoadCannedSmsResponses();
Sailesh Nepal810735e2014-03-18 18:15:46 -0700271 }
Santos Cordon0b03b4b2014-01-29 18:01:59 -0800272 }
273
Ihab Awadcb387ac2014-05-28 16:49:38 -0700274 void setRequestingRingback(boolean requestingRingback) {
275 mRequestingRingback = requestingRingback;
276 for (Listener l : mListeners) {
277 l.onRequestingRingback(this, mRequestingRingback);
278 }
279 }
280
281 boolean isRequestingRingback() {
282 return mRequestingRingback;
283 }
284
Sailesh Nepalce704b92014-03-17 18:31:43 -0700285 Uri getHandle() {
Ben Gilad0bf5b912014-01-28 17:55:57 -0800286 return mHandle;
287 }
288
Sailesh Nepalce704b92014-03-17 18:31:43 -0700289 void setHandle(Uri handle) {
Santos Cordonfd71f4a2014-05-28 13:59:49 -0700290 if ((mHandle == null && handle != null) || (mHandle != null && !mHandle.equals(handle))) {
291 mHandle = handle;
292 mIsEmergencyCall = mHandle != null && PhoneNumberUtils.isLocalEmergencyNumber(
Yorke Lee66255452014-06-05 08:09:24 -0700293 TelecommApp.getInstance(), mHandle.getSchemeSpecificPart());
Santos Cordonfd71f4a2014-05-28 13:59:49 -0700294 startCallerInfoLookup();
295 }
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700296 }
297
Santos Cordon99c8a6f2014-05-28 18:28:47 -0700298 String getName() {
299 return mCallerInfo == null ? null : mCallerInfo.name;
300 }
301
302 Bitmap getPhotoIcon() {
303 return mCallerInfo == null ? null : mCallerInfo.cachedPhotoIcon;
304 }
305
306 Drawable getPhoto() {
307 return mCallerInfo == null ? null : mCallerInfo.cachedPhoto;
308 }
309
Santos Cordon79ff2bc2014-03-27 15:31:27 -0700310 /**
311 * @param disconnectCause The reason for the disconnection, any of
312 * {@link android.telephony.DisconnectCause}.
313 * @param disconnectMessage Optional call-service-provided message about the disconnect.
314 */
315 void setDisconnectCause(int disconnectCause, String disconnectMessage) {
316 // TODO: Consider combining this method with a setDisconnected() method that is totally
317 // separate from setState.
318 mDisconnectCause = disconnectCause;
319 mDisconnectMessage = disconnectMessage;
320 }
321
322 int getDisconnectCause() {
323 return mDisconnectCause;
324 }
325
326 String getDisconnectMessage() {
327 return mDisconnectMessage;
328 }
329
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700330 boolean isEmergencyCall() {
331 return mIsEmergencyCall;
Santos Cordon61d0f702014-02-19 02:52:23 -0800332 }
333
Yorke Lee33501632014-03-17 19:24:12 -0700334 /**
335 * @return The original handle this call is associated with. In-call services should use this
336 * handle when indicating in their UI the handle that is being called.
337 */
338 public Uri getOriginalHandle() {
339 if (mGatewayInfo != null && !mGatewayInfo.isEmpty()) {
340 return mGatewayInfo.getOriginalHandle();
341 }
342 return getHandle();
343 }
344
345 GatewayInfo getGatewayInfo() {
346 return mGatewayInfo;
347 }
348
Sailesh Nepal810735e2014-03-18 18:15:46 -0700349 boolean isIncoming() {
350 return mIsIncoming;
351 }
352
Ben Gilad0407fb22014-01-09 16:18:41 -0800353 /**
354 * @return The "age" of this call object in milliseconds, which typically also represents the
Sailesh Nepal8c85dee2014-04-07 22:21:40 -0700355 * period since this call was added to the set pending outgoing calls, see
356 * mCreationTimeMillis.
Ben Gilad0407fb22014-01-09 16:18:41 -0800357 */
Sailesh Nepal8c85dee2014-04-07 22:21:40 -0700358 long getAgeMillis() {
359 return System.currentTimeMillis() - mCreationTimeMillis;
Ben Gilad0407fb22014-01-09 16:18:41 -0800360 }
Santos Cordon0b03b4b2014-01-29 18:01:59 -0800361
Yorke Leef98fb572014-03-05 10:56:55 -0800362 /**
363 * @return The time when this call object was created and added to the set of pending outgoing
364 * calls.
365 */
Sailesh Nepal8c85dee2014-04-07 22:21:40 -0700366 long getCreationTimeMillis() {
367 return mCreationTimeMillis;
368 }
369
370 long getConnectTimeMillis() {
371 return mConnectTimeMillis;
372 }
373
374 void setConnectTimeMillis(long connectTimeMillis) {
375 mConnectTimeMillis = connectTimeMillis;
Yorke Leef98fb572014-03-05 10:56:55 -0800376 }
377
Santos Cordona1610702014-06-04 20:22:56 -0700378 boolean isConferenceCapable() {
379 return mIsConferenceCapable;
380 }
381
382 void setIsConferenceCapable(boolean isConferenceCapable) {
383 if (mIsConferenceCapable != isConferenceCapable) {
384 mIsConferenceCapable = isConferenceCapable;
385 for (Listener l : mListeners) {
386 l.onIsConferenceCapableChanged(this, mIsConferenceCapable);
387 }
388 }
389 }
390
391 Call getParentCall() {
392 return mParentCall;
393 }
394
395 List<Call> getChildCalls() {
396 return mChildCalls;
397 }
398
Santos Cordonc195e362014-02-11 17:05:31 -0800399 CallServiceWrapper getCallService() {
Santos Cordon681663d2014-01-30 04:32:15 -0800400 return mCallService;
401 }
402
Santos Cordonc195e362014-02-11 17:05:31 -0800403 void setCallService(CallServiceWrapper callService) {
Sailesh Nepal0e5410a2014-04-04 01:20:58 -0700404 setCallService(callService, null);
405 }
406
407 /**
408 * Changes the call service this call is associated with. If callToReplace is non-null then this
409 * call takes its place within the call service.
410 */
411 void setCallService(CallServiceWrapper callService, Call callToReplace) {
Ben Gilad8e55d1d2014-02-26 16:25:56 -0800412 Preconditions.checkNotNull(callService);
413
Yorke Leeadee12d2014-03-13 12:08:30 -0700414 clearCallService();
Ben Gilad8e55d1d2014-02-26 16:25:56 -0800415
416 callService.incrementAssociatedCallCount();
Santos Cordon681663d2014-01-30 04:32:15 -0800417 mCallService = callService;
Sailesh Nepal0e5410a2014-04-04 01:20:58 -0700418 if (callToReplace == null) {
419 mCallService.addCall(this);
420 } else {
421 mCallService.replaceCall(this, callToReplace);
422 }
Santos Cordon681663d2014-01-30 04:32:15 -0800423 }
424
425 /**
426 * Clears the associated call service.
427 */
428 void clearCallService() {
Yorke Leeadee12d2014-03-13 12:08:30 -0700429 if (mCallService != null) {
Santos Cordonc499c1c2014-04-14 17:13:14 -0700430 CallServiceWrapper callServiceTemp = mCallService;
Yorke Leeadee12d2014-03-13 12:08:30 -0700431 mCallService = null;
Santos Cordonc499c1c2014-04-14 17:13:14 -0700432 callServiceTemp.removeCall(this);
433
434 // Decrementing the count can cause the service to unbind, which itself can trigger the
435 // service-death code. Since the service death code tries to clean up any associated
436 // calls, we need to make sure to remove that information (e.g., removeCall()) before
437 // we decrement. Technically, invoking removeCall() prior to decrementing is all that is
438 // necessary, but cleaning up mCallService prior to triggering an unbind is good to do.
439 // If you change this, make sure to update {@link clearCallServiceSelector} as well.
440 decrementAssociatedCallCount(callServiceTemp);
Yorke Leeadee12d2014-03-13 12:08:30 -0700441 }
Ben Gilad8e55d1d2014-02-26 16:25:56 -0800442 }
443
Ben Gilad8e55d1d2014-02-26 16:25:56 -0800444 /**
Santos Cordon766d04f2014-05-06 10:28:25 -0700445 * Starts the incoming call flow through the switchboard. When switchboard completes, it will
446 * invoke handle[Un]SuccessfulIncomingCall.
447 *
448 * @param descriptor The relevant call-service descriptor.
449 * @param extras The optional extras passed via
450 * {@link TelecommConstants#EXTRA_INCOMING_CALL_EXTRAS}.
451 */
452 void startIncoming(CallServiceDescriptor descriptor, Bundle extras) {
453 Switchboard.getInstance().retrieveIncomingCall(this, descriptor, extras);
454 }
455
Santos Cordon2174fb52014-05-29 08:22:56 -0700456 /**
457 * Takes a verified incoming call and uses the handle to lookup direct-to-voicemail property
458 * from the contacts provider. The call is not yet exposed to the user at this point and
459 * the result of the query will determine if the call is rejected or passed through to the
460 * in-call UI.
461 */
462 void handleVerifiedIncoming(CallInfo callInfo) {
Santos Cordon766d04f2014-05-06 10:28:25 -0700463 Preconditions.checkState(callInfo.getState() == CallState.RINGING);
Santos Cordon2174fb52014-05-29 08:22:56 -0700464
465 // We do not handle incoming calls immediately when they are verified by the call service.
466 // We allow the caller-info-query code to execute first so that we can read the
467 // direct-to-voicemail property before deciding if we want to show the incoming call to the
468 // user or if we want to reject the call.
469 mPendingDirectToVoicemailCallInfo = callInfo;
470
471 // Setting the handle triggers the caller info lookup code.
Santos Cordon766d04f2014-05-06 10:28:25 -0700472 setHandle(callInfo.getHandle());
473
Santos Cordon2174fb52014-05-29 08:22:56 -0700474 // Timeout the direct-to-voicemail lookup execution so that we dont wait too long before
475 // showing the user the incoming call screen.
476 mHandler.postDelayed(new Runnable() {
477 @Override
478 public void run() {
479 processDirectToVoicemail();
480 }
Santos Cordona1610702014-06-04 20:22:56 -0700481 }, Timeouts.getDirectToVoicemailMillis());
Santos Cordon2174fb52014-05-29 08:22:56 -0700482 }
Santos Cordon766d04f2014-05-06 10:28:25 -0700483
Santos Cordon2174fb52014-05-29 08:22:56 -0700484 void processDirectToVoicemail() {
485 if (mPendingDirectToVoicemailCallInfo != null) {
486 if (mCallerInfo != null && mCallerInfo.shouldSendToVoicemail) {
487 Log.i(this, "Directing call to voicemail: %s.", this);
488 // TODO(santoscordon): Once we move State handling from CallsManager to Call, we
489 // will not need to set RINGING state prior to calling reject.
490 setState(CallState.RINGING);
Ihab Awadff7493a2014-06-10 13:47:44 -0700491 reject(false, null);
Santos Cordon2174fb52014-05-29 08:22:56 -0700492 } else {
493 // TODO(santoscordon): Make this class (not CallsManager) responsible for changing
494 // the call state to RINGING.
495
496 // TODO(santoscordon): Replace this with state transition to RINGING.
497 for (Listener l : mListeners) {
498 l.onSuccessfulIncomingCall(this, mPendingDirectToVoicemailCallInfo);
499 }
500 }
501
502 mPendingDirectToVoicemailCallInfo = null;
Santos Cordon766d04f2014-05-06 10:28:25 -0700503 }
504 }
505
506 void handleFailedIncoming() {
507 clearCallService();
508
509 // TODO: Needs more specific disconnect error for this case.
510 setDisconnectCause(DisconnectCause.ERROR_UNSPECIFIED, null);
511 setState(CallState.DISCONNECTED);
512
513 // TODO(santoscordon): Replace this with state transitions related to "connecting".
514 for (Listener l : mListeners) {
515 l.onFailedIncomingCall(this);
516 }
517 }
518
519 /**
Santos Cordon682fe6b2014-05-20 08:56:39 -0700520 * Starts the outgoing call sequence. Upon completion, there should exist an active connection
521 * through a call service (or the call will have failed).
Santos Cordon766d04f2014-05-06 10:28:25 -0700522 */
523 void startOutgoing() {
Santos Cordon682fe6b2014-05-20 08:56:39 -0700524 Preconditions.checkState(mOutgoingCallProcessor == null);
525
526 mOutgoingCallProcessor = new OutgoingCallProcessor(
527 this,
528 Switchboard.getInstance().getCallServiceRepository(),
Santos Cordon682fe6b2014-05-20 08:56:39 -0700529 new AsyncResultCallback<Boolean>() {
530 @Override
Ihab Awad0fea3f22014-06-03 18:45:05 -0700531 public void onResult(Boolean wasCallPlaced, int errorCode, String errorMsg) {
Santos Cordon682fe6b2014-05-20 08:56:39 -0700532 if (wasCallPlaced) {
533 handleSuccessfulOutgoing();
534 } else {
Ihab Awad0fea3f22014-06-03 18:45:05 -0700535 handleFailedOutgoing(
536 mOutgoingCallProcessor.isAborted(), errorCode, errorMsg);
Santos Cordon682fe6b2014-05-20 08:56:39 -0700537 }
538 mOutgoingCallProcessor = null;
539 }
540 });
541 mOutgoingCallProcessor.process();
Santos Cordon766d04f2014-05-06 10:28:25 -0700542 }
543
544 void handleSuccessfulOutgoing() {
545 // TODO(santoscordon): Replace this with state transitions related to "connecting".
546 for (Listener l : mListeners) {
547 l.onSuccessfulOutgoingCall(this);
548 }
549 }
550
Ihab Awad0fea3f22014-06-03 18:45:05 -0700551 void handleFailedOutgoing(boolean isAborted, int errorCode, String errorMsg) {
Santos Cordon766d04f2014-05-06 10:28:25 -0700552 // TODO(santoscordon): Replace this with state transitions related to "connecting".
553 for (Listener l : mListeners) {
Ihab Awad0fea3f22014-06-03 18:45:05 -0700554 l.onFailedOutgoingCall(this, isAborted, errorCode, errorMsg);
Santos Cordon766d04f2014-05-06 10:28:25 -0700555 }
Santos Cordon682fe6b2014-05-20 08:56:39 -0700556
557 clearCallService();
Santos Cordon766d04f2014-05-06 10:28:25 -0700558 }
559
560 /**
Ben Gilad61925612014-03-11 19:06:36 -0700561 * Adds the specified call service to the list of incompatible services. The set is used when
562 * attempting to switch a phone call between call services such that incompatible services can
563 * be avoided.
564 *
565 * @param callService The incompatible call service.
566 */
567 void addIncompatibleCallService(CallServiceWrapper callService) {
568 if (mIncompatibleCallServices == null) {
569 mIncompatibleCallServices = Sets.newHashSet();
570 }
571 mIncompatibleCallServices.add(callService);
572 }
573
574 /**
575 * Checks whether or not the specified callService was identified as incompatible in the
576 * context of this call.
577 *
578 * @param callService The call service to evaluate.
579 * @return True upon incompatible call services and false otherwise.
580 */
581 boolean isIncompatibleCallService(CallServiceWrapper callService) {
582 return mIncompatibleCallServices != null &&
583 mIncompatibleCallServices.contains(callService);
584 }
585
586 /**
Ihab Awad74549ec2014-03-10 15:33:25 -0700587 * Plays the specified DTMF tone.
588 */
589 void playDtmfTone(char digit) {
590 if (mCallService == null) {
591 Log.w(this, "playDtmfTone() request on a call without a call service.");
592 } else {
Sailesh Nepale59bb192014-04-01 18:33:59 -0700593 Log.i(this, "Send playDtmfTone to call service for call %s", this);
594 mCallService.playDtmfTone(this, digit);
Ihab Awad74549ec2014-03-10 15:33:25 -0700595 }
596 }
597
598 /**
599 * Stops playing any currently playing DTMF tone.
600 */
601 void stopDtmfTone() {
602 if (mCallService == null) {
603 Log.w(this, "stopDtmfTone() request on a call without a call service.");
604 } else {
Sailesh Nepale59bb192014-04-01 18:33:59 -0700605 Log.i(this, "Send stopDtmfTone to call service for call %s", this);
606 mCallService.stopDtmfTone(this);
Ihab Awad74549ec2014-03-10 15:33:25 -0700607 }
608 }
609
610 /**
Santos Cordon049b7b62014-01-30 05:34:26 -0800611 * Attempts to disconnect the call through the call service.
612 */
613 void disconnect() {
Santos Cordon766d04f2014-05-06 10:28:25 -0700614 if (mState == CallState.NEW) {
Santos Cordon682fe6b2014-05-20 08:56:39 -0700615 Log.v(this, "Aborting call %s", this);
616 abort();
Santos Cordon74d420b2014-05-07 14:38:47 -0700617 } else if (mState != CallState.ABORTED && mState != CallState.DISCONNECTED) {
Santos Cordon766d04f2014-05-06 10:28:25 -0700618 Preconditions.checkNotNull(mCallService);
619
Sailesh Nepale59bb192014-04-01 18:33:59 -0700620 Log.i(this, "Send disconnect to call service for call: %s", this);
Santos Cordonc195e362014-02-11 17:05:31 -0800621 // The call isn't officially disconnected until the call service confirms that the call
622 // was actually disconnected. Only then is the association between call and call service
623 // severed, see {@link CallsManager#markCallAsDisconnected}.
Sailesh Nepale59bb192014-04-01 18:33:59 -0700624 mCallService.disconnect(this);
Santos Cordon049b7b62014-01-30 05:34:26 -0800625 }
626 }
627
Santos Cordon682fe6b2014-05-20 08:56:39 -0700628 void abort() {
629 if (mOutgoingCallProcessor != null) {
630 mOutgoingCallProcessor.abort();
631 }
632 }
633
Santos Cordon0b03b4b2014-01-29 18:01:59 -0800634 /**
Santos Cordon61d0f702014-02-19 02:52:23 -0800635 * Answers the call if it is ringing.
636 */
637 void answer() {
638 Preconditions.checkNotNull(mCallService);
639
640 // Check to verify that the call is still in the ringing state. A call can change states
641 // between the time the user hits 'answer' and Telecomm receives the command.
642 if (isRinging("answer")) {
643 // At this point, we are asking the call service to answer but we don't assume that
644 // it will work. Instead, we wait until confirmation from the call service that the
645 // call is in a non-RINGING state before changing the UI. See
646 // {@link CallServiceAdapter#setActive} and other set* methods.
Sailesh Nepale59bb192014-04-01 18:33:59 -0700647 mCallService.answer(this);
Santos Cordon61d0f702014-02-19 02:52:23 -0800648 }
649 }
650
651 /**
652 * Rejects the call if it is ringing.
Ihab Awadff7493a2014-06-10 13:47:44 -0700653 *
654 * @param rejectWithMessage Whether to send a text message as part of the call rejection.
655 * @param textMessage An optional text message to send as part of the rejection.
Santos Cordon61d0f702014-02-19 02:52:23 -0800656 */
Ihab Awadff7493a2014-06-10 13:47:44 -0700657 void reject(boolean rejectWithMessage, String textMessage) {
Santos Cordon61d0f702014-02-19 02:52:23 -0800658 Preconditions.checkNotNull(mCallService);
659
660 // Check to verify that the call is still in the ringing state. A call can change states
661 // between the time the user hits 'reject' and Telecomm receives the command.
662 if (isRinging("reject")) {
Sailesh Nepale59bb192014-04-01 18:33:59 -0700663 mCallService.reject(this);
Santos Cordon61d0f702014-02-19 02:52:23 -0800664 }
665 }
666
667 /**
Yorke Leecdf3ebd2014-03-12 18:31:41 -0700668 * Puts the call on hold if it is currently active.
669 */
670 void hold() {
671 Preconditions.checkNotNull(mCallService);
672
673 if (mState == CallState.ACTIVE) {
Sailesh Nepale59bb192014-04-01 18:33:59 -0700674 mCallService.hold(this);
Yorke Leecdf3ebd2014-03-12 18:31:41 -0700675 }
676 }
677
678 /**
679 * Releases the call from hold if it is currently active.
680 */
681 void unhold() {
682 Preconditions.checkNotNull(mCallService);
683
684 if (mState == CallState.ON_HOLD) {
Sailesh Nepale59bb192014-04-01 18:33:59 -0700685 mCallService.unhold(this);
Yorke Leecdf3ebd2014-03-12 18:31:41 -0700686 }
687 }
688
689 /**
Santos Cordon0b03b4b2014-01-29 18:01:59 -0800690 * @return An object containing read-only information about this call.
691 */
Sailesh Nepale59bb192014-04-01 18:33:59 -0700692 CallInfo toCallInfo(String callId) {
Sailesh Nepal84fa5f82014-04-02 11:01:11 -0700693 CallServiceDescriptor descriptor = null;
694 if (mCallService != null) {
695 descriptor = mCallService.getDescriptor();
696 } else if (mOriginalCall != null && mOriginalCall.mCallService != null) {
697 descriptor = mOriginalCall.mCallService.getDescriptor();
698 }
699 return new CallInfo(callId, mState, mHandle, mGatewayInfo, mExtras, descriptor);
Santos Cordon0b03b4b2014-01-29 18:01:59 -0800700 }
701
Sailesh Nepal6aca10a2014-03-24 16:11:02 -0700702 /** Checks if this is a live call or not. */
703 boolean isAlive() {
704 switch (mState) {
705 case NEW:
706 case RINGING:
707 case DISCONNECTED:
708 case ABORTED:
709 return false;
710 default:
711 return true;
712 }
713 }
714
Santos Cordon40f78c22014-04-07 02:11:42 -0700715 boolean isActive() {
716 switch (mState) {
717 case ACTIVE:
718 case POST_DIAL:
719 case POST_DIAL_WAIT:
720 return true;
721 default:
722 return false;
723 }
724 }
725
Sailesh Nepal84fa5f82014-04-02 11:01:11 -0700726 Bundle getExtras() {
727 return mExtras;
728 }
729
730 void setExtras(Bundle extras) {
731 mExtras = extras;
732 }
733
734 Uri getHandoffHandle() {
735 return mHandoffHandle;
736 }
737
738 void setHandoffHandle(Uri handoffHandle) {
739 mHandoffHandle = handoffHandle;
740 }
741
742 Call getOriginalCall() {
743 return mOriginalCall;
744 }
745
746 void setOriginalCall(Call originalCall) {
747 mOriginalCall = originalCall;
748 }
749
Sailesh Nepal8c85dee2014-04-07 22:21:40 -0700750 CallServiceDescriptor getHandoffCallServiceDescriptor() {
751 return mHandoffCallServiceDescriptor;
752 }
753
754 void setHandoffCallServiceDescriptor(CallServiceDescriptor descriptor) {
755 mHandoffCallServiceDescriptor = descriptor;
756 }
757
Santos Cordon5ba7f272014-05-28 13:59:49 -0700758 Uri getRingtone() {
759 return mCallerInfo == null ? null : mCallerInfo.contactRingtoneUri;
760 }
761
Evan Charlton352105c2014-06-03 14:10:54 -0700762 void onPostDialWait(String remaining) {
763 for (Listener l : mListeners) {
764 l.onPostDialWait(this, remaining);
765 }
766 }
767
768 void postDialContinue(boolean proceed) {
769 getCallService().onPostDialContinue(this, proceed);
770 }
771
Santos Cordona1610702014-06-04 20:22:56 -0700772 void conferenceInto(Call conferenceCall) {
773 if (mCallService == null) {
774 Log.w(this, "conference requested on a call without a call service.");
775 } else {
776 mCallService.conference(conferenceCall, this);
777 }
778 }
779
780 void expireConference() {
781 // The conference call expired before we got a confirmation of the conference from the
782 // call service...so start shutting down.
783 clearCallService();
784 for (Listener l : mListeners) {
785 l.onExpiredConferenceCall(this);
786 }
787 }
788
789 void confirmConference() {
790 Log.v(this, "confirming Conf call %s", mListeners);
791 for (Listener l : mListeners) {
792 l.onConfirmedConferenceCall(this);
793 }
794 }
795
796 void splitFromConference() {
797 // TODO(santoscordon): todo
798 }
799
800 void setParentCall(Call parentCall) {
801 if (parentCall == this) {
802 Log.e(this, new Exception(), "setting the parent to self");
803 return;
804 }
805 Preconditions.checkState(parentCall == null || mParentCall == null);
806
807 Call oldParent = mParentCall;
808 if (mParentCall != null) {
809 mParentCall.removeChildCall(this);
810 }
811 mParentCall = parentCall;
812 if (mParentCall != null) {
813 mParentCall.addChildCall(this);
814 }
815
816 for (Listener l : mListeners) {
817 l.onParentChanged(this);
818 }
819 }
820
821 private void addChildCall(Call call) {
822 if (!mChildCalls.contains(call)) {
823 mChildCalls.add(call);
824
825 for (Listener l : mListeners) {
826 l.onChildrenChanged(this);
827 }
828 }
829 }
830
831 private void removeChildCall(Call call) {
832 if (mChildCalls.remove(call)) {
833 for (Listener l : mListeners) {
834 l.onChildrenChanged(this);
835 }
836 }
837 }
838
Santos Cordon0b03b4b2014-01-29 18:01:59 -0800839 /**
Ihab Awadff7493a2014-06-10 13:47:44 -0700840 * Return whether the user can respond to this {@code Call} via an SMS message.
841 *
842 * @return true if the "Respond via SMS" feature should be enabled
843 * for this incoming call.
844 *
845 * The general rule is that we *do* allow "Respond via SMS" except for
846 * the few (relatively rare) cases where we know for sure it won't
847 * work, namely:
848 * - a bogus or blank incoming number
849 * - a call from a SIP address
850 * - a "call presentation" that doesn't allow the number to be revealed
851 *
852 * In all other cases, we allow the user to respond via SMS.
853 *
854 * Note that this behavior isn't perfect; for example we have no way
855 * to detect whether the incoming call is from a landline (with most
856 * networks at least), so we still enable this feature even though
857 * SMSes to that number will silently fail.
858 */
859 boolean isRespondViaSmsCapable() {
860 if (mState != CallState.RINGING) {
861 return false;
862 }
863
864 if (getHandle() == null) {
865 // No incoming number known or call presentation is "PRESENTATION_RESTRICTED", in
866 // other words, the user should not be able to see the incoming phone number.
867 return false;
868 }
869
870 if (PhoneNumberUtils.isUriNumber(getHandle().toString())) {
871 // The incoming number is actually a URI (i.e. a SIP address),
872 // not a regular PSTN phone number, and we can't send SMSes to
873 // SIP addresses.
874 // (TODO: That might still be possible eventually, though. Is
875 // there some SIP-specific equivalent to sending a text message?)
876 return false;
877 }
878
879 // Is there a valid SMS application on the phone?
880 if (SmsApplication.getDefaultRespondViaMessageApplication(TelecommApp.getInstance(),
881 true /*updateIfNeeded*/) == null) {
882 return false;
883 }
884
885 // TODO: with some carriers (in certain countries) you *can* actually
886 // tell whether a given number is a mobile phone or not. So in that
887 // case we could potentially return false here if the incoming call is
888 // from a land line.
889
890 // If none of the above special cases apply, it's OK to enable the
891 // "Respond via SMS" feature.
892 return true;
893 }
894
895 List<String> getCannedSmsResponses() {
896 return mCannedSmsResponses;
897 }
898
899 /**
Santos Cordon61d0f702014-02-19 02:52:23 -0800900 * @return True if the call is ringing, else logs the action name.
901 */
902 private boolean isRinging(String actionName) {
903 if (mState == CallState.RINGING) {
904 return true;
905 }
906
Sailesh Nepalf1c191d2014-03-07 18:17:39 -0800907 Log.i(this, "Request to %s a non-ringing call %s", actionName, this);
Santos Cordon61d0f702014-02-19 02:52:23 -0800908 return false;
909 }
910
Ben Gilad8e55d1d2014-02-26 16:25:56 -0800911 @SuppressWarnings("rawtypes")
912 private void decrementAssociatedCallCount(ServiceBinder binder) {
913 if (binder != null) {
914 binder.decrementAssociatedCallCount();
915 }
916 }
Santos Cordonfd71f4a2014-05-28 13:59:49 -0700917
918 /**
919 * Looks up contact information based on the current handle.
920 */
921 private void startCallerInfoLookup() {
922 String number = mHandle == null ? null : mHandle.getSchemeSpecificPart();
923
924 mQueryToken++; // Updated so that previous queries can no longer set the information.
925 mCallerInfo = null;
926 if (!TextUtils.isEmpty(number)) {
Santos Cordon5ba7f272014-05-28 13:59:49 -0700927 Log.v(this, "Looking up information for: %s.", Log.piiHandle(number));
Santos Cordonfd71f4a2014-05-28 13:59:49 -0700928 CallerInfoAsyncQuery.startQuery(
929 mQueryToken,
930 TelecommApp.getInstance(),
931 number,
932 sCallerInfoQueryListener,
933 this);
934 }
935 }
936
937 /**
Santos Cordon99c8a6f2014-05-28 18:28:47 -0700938 * Saves the specified caller info if the specified token matches that of the last query
Santos Cordonfd71f4a2014-05-28 13:59:49 -0700939 * that was made.
940 *
941 * @param callerInfo The new caller information to set.
942 * @param token The token used with this query.
943 */
944 private void setCallerInfo(CallerInfo callerInfo, int token) {
Santos Cordon99c8a6f2014-05-28 18:28:47 -0700945 Preconditions.checkNotNull(callerInfo);
946
Santos Cordonfd71f4a2014-05-28 13:59:49 -0700947 if (mQueryToken == token) {
948 mCallerInfo = callerInfo;
Santos Cordon5ba7f272014-05-28 13:59:49 -0700949 Log.i(this, "CallerInfo received for %s: %s", Log.piiHandle(mHandle), callerInfo);
Santos Cordon99c8a6f2014-05-28 18:28:47 -0700950
951 if (mCallerInfo.person_id != 0) {
952 Uri personUri =
953 ContentUris.withAppendedId(Contacts.CONTENT_URI, mCallerInfo.person_id);
954 Log.d(this, "Searching person uri %s for call %s", personUri, this);
955 ContactsAsyncHelper.startObtainPhotoAsync(
956 token,
957 TelecommApp.getInstance(),
958 personUri,
959 sPhotoLoadListener,
960 this);
961 }
Santos Cordon2174fb52014-05-29 08:22:56 -0700962
963 processDirectToVoicemail();
Santos Cordon99c8a6f2014-05-28 18:28:47 -0700964 }
965 }
966
967 /**
968 * Saves the specified photo information if the specified token matches that of the last query.
969 *
970 * @param photo The photo as a drawable.
971 * @param photoIcon The photo as a small icon.
972 * @param token The token used with this query.
973 */
974 private void setPhoto(Drawable photo, Bitmap photoIcon, int token) {
975 if (mQueryToken == token) {
976 mCallerInfo.cachedPhoto = photo;
977 mCallerInfo.cachedPhotoIcon = photoIcon;
Santos Cordonfd71f4a2014-05-28 13:59:49 -0700978 }
979 }
Ihab Awadff7493a2014-06-10 13:47:44 -0700980
981 private void maybeLoadCannedSmsResponses() {
982 if (mIsIncoming && isRespondViaSmsCapable() && !mCannedSmsResponsesLoadingStarted) {
983 Log.d(this, "maybeLoadCannedSmsResponses: starting task to load messages");
984 mCannedSmsResponsesLoadingStarted = true;
985 RespondViaSmsManager.getInstance().loadCannedTextMessages(
986 new Response<Void, List<String>>() {
987 @Override
988 public void onResult(Void request, List<String>... result) {
989 if (result.length > 0) {
990 Log.d(this, "maybeLoadCannedSmsResponses: got %s", result[0]);
991 mCannedSmsResponses = result[0];
992 for (Listener l : mListeners) {
993 l.onCannedSmsResponsesLoaded(Call.this);
994 }
995 }
996 }
997
998 @Override
999 public void onError(Void request, int code, String msg) {
1000 Log.w(Call.this, "Error obtaining canned SMS responses: %d %s", code,
1001 msg);
1002 }
1003 }
1004 );
1005 } else {
1006 Log.d(this, "maybeLoadCannedSmsResponses: doing nothing");
1007 }
1008 }
Sai Cheemalapatib7157e92014-06-11 17:51:55 -07001009
1010 /**
1011 * Sets speakerphone option on when call begins.
1012 */
1013 public void setStartWithSpeakerphoneOn(boolean startWithSpeakerphone) {
1014 mSpeakerphoneOn = startWithSpeakerphone;
1015 }
1016
1017 /**
1018 * Returns speakerphone option.
1019 *
1020 * @return Whether or not speakerphone should be set automatically when call begins.
1021 */
1022 public boolean getStartWithSpeakerphoneOn() {
1023 return mSpeakerphoneOn;
1024 }
Ben Gilad9f2bed32013-12-12 17:43:26 -08001025}