Ben Gilad | 0407fb2 | 2014-01-09 16:18:41 -0800 | [diff] [blame] | 1 | /* |
| 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 Gilad | 9f2bed3 | 2013-12-12 17:43:26 -0800 | [diff] [blame] | 17 | package com.android.telecomm; |
| 18 | |
Sailesh Nepal | 9d58de5 | 2014-07-18 14:53:19 -0700 | [diff] [blame] | 19 | import android.app.PendingIntent; |
Santos Cordon | 99c8a6f | 2014-05-28 18:28:47 -0700 | [diff] [blame] | 20 | import android.graphics.Bitmap; |
| 21 | import android.graphics.drawable.Drawable; |
Sailesh Nepal | ce704b9 | 2014-03-17 18:31:43 -0700 | [diff] [blame] | 22 | import android.net.Uri; |
Sailesh Nepal | 84fa5f8 | 2014-04-02 11:01:11 -0700 | [diff] [blame] | 23 | import android.os.Bundle; |
Santos Cordon | fd71f4a | 2014-05-28 13:59:49 -0700 | [diff] [blame] | 24 | import android.os.Handler; |
Santos Cordon | 72890ce | 2014-07-21 01:32:04 -0700 | [diff] [blame] | 25 | import android.telecomm.Connection; |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 26 | import android.telecomm.PhoneCapabilities; |
| 27 | import android.telecomm.PropertyPresentation; |
| 28 | import android.telecomm.CallState; |
Yorke Lee | 3350163 | 2014-03-17 19:24:12 -0700 | [diff] [blame] | 29 | import android.telecomm.GatewayInfo; |
Santos Cordon | 72890ce | 2014-07-21 01:32:04 -0700 | [diff] [blame] | 30 | import android.telecomm.ParcelableConnection; |
Ihab Awad | b78b276 | 2014-07-25 15:16:23 -0700 | [diff] [blame] | 31 | import android.telecomm.PhoneAccount; |
Evan Charlton | 8917637 | 2014-07-19 18:23:09 -0700 | [diff] [blame] | 32 | import android.telecomm.PhoneAccountHandle; |
Ihab Awad | ff7493a | 2014-06-10 13:47:44 -0700 | [diff] [blame] | 33 | import android.telecomm.Response; |
Sailesh Nepal | 35faf8c | 2014-07-08 22:02:34 -0700 | [diff] [blame] | 34 | import android.telecomm.StatusHints; |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 35 | import android.telecomm.VideoProfile; |
Santos Cordon | 79ff2bc | 2014-03-27 15:31:27 -0700 | [diff] [blame] | 36 | import android.telephony.DisconnectCause; |
Sailesh Nepal | 6aca10a | 2014-03-24 16:11:02 -0700 | [diff] [blame] | 37 | import android.telephony.PhoneNumberUtils; |
Santos Cordon | fd71f4a | 2014-05-28 13:59:49 -0700 | [diff] [blame] | 38 | import android.text.TextUtils; |
Santos Cordon | 0b03b4b | 2014-01-29 18:01:59 -0800 | [diff] [blame] | 39 | |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 40 | import com.android.internal.telecomm.IVideoProvider; |
Santos Cordon | fd71f4a | 2014-05-28 13:59:49 -0700 | [diff] [blame] | 41 | import com.android.internal.telephony.CallerInfo; |
| 42 | import com.android.internal.telephony.CallerInfoAsyncQuery; |
| 43 | import com.android.internal.telephony.CallerInfoAsyncQuery.OnQueryCompleteListener; |
Ihab Awad | ff7493a | 2014-06-10 13:47:44 -0700 | [diff] [blame] | 44 | import com.android.internal.telephony.SmsApplication; |
Santos Cordon | 99c8a6f | 2014-05-28 18:28:47 -0700 | [diff] [blame] | 45 | import com.android.telecomm.ContactsAsyncHelper.OnImageLoadCompleteListener; |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 46 | import com.google.common.base.Preconditions; |
| 47 | |
Santos Cordon | 12d6182 | 2014-07-29 16:02:20 -0700 | [diff] [blame] | 48 | import java.util.ArrayList; |
Ihab Awad | ff7493a | 2014-06-10 13:47:44 -0700 | [diff] [blame] | 49 | import java.util.Collections; |
Santos Cordon | a161070 | 2014-06-04 20:22:56 -0700 | [diff] [blame] | 50 | import java.util.LinkedList; |
| 51 | import java.util.List; |
Sailesh Nepal | 9199078 | 2014-03-08 17:45:52 -0800 | [diff] [blame] | 52 | import java.util.Locale; |
Sailesh Nepal | e8ecb98 | 2014-07-11 17:19:42 -0700 | [diff] [blame] | 53 | import java.util.Objects; |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 54 | import java.util.Set; |
Jay Shrauner | a82c8f7 | 2014-08-14 15:49:16 -0700 | [diff] [blame] | 55 | import java.util.concurrent.ConcurrentHashMap; |
Ben Gilad | 0407fb2 | 2014-01-09 16:18:41 -0800 | [diff] [blame] | 56 | |
Ben Gilad | 2495d57 | 2014-01-09 17:26:19 -0800 | [diff] [blame] | 57 | /** |
| 58 | * Encapsulates all aspects of a given phone call throughout its lifecycle, starting |
| 59 | * from the time the call intent was received by Telecomm (vs. the time the call was |
| 60 | * connected etc). |
| 61 | */ |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 62 | final class Call implements CreateConnectionResponse { |
Santos Cordon | 766d04f | 2014-05-06 10:28:25 -0700 | [diff] [blame] | 63 | /** |
| 64 | * Listener for events on the call. |
| 65 | */ |
| 66 | interface Listener { |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 67 | void onSuccessfulOutgoingCall(Call call, int callState); |
Sailesh Nepal | 5a73b03 | 2014-06-25 15:53:21 -0700 | [diff] [blame] | 68 | void onFailedOutgoingCall(Call call, int errorCode, String errorMsg); |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 69 | void onSuccessfulIncomingCall(Call call); |
Santos Cordon | 766d04f | 2014-05-06 10:28:25 -0700 | [diff] [blame] | 70 | void onFailedIncomingCall(Call call); |
Ihab Awad | cb387ac | 2014-05-28 16:49:38 -0700 | [diff] [blame] | 71 | void onRequestingRingback(Call call, boolean requestingRingback); |
Evan Charlton | 352105c | 2014-06-03 14:10:54 -0700 | [diff] [blame] | 72 | void onPostDialWait(Call call, String remaining); |
Sailesh Nepal | e20bc97 | 2014-07-09 21:22:36 -0700 | [diff] [blame] | 73 | void onCallCapabilitiesChanged(Call call); |
Santos Cordon | a161070 | 2014-06-04 20:22:56 -0700 | [diff] [blame] | 74 | void onParentChanged(Call call); |
| 75 | void onChildrenChanged(Call call); |
Ihab Awad | ff7493a | 2014-06-10 13:47:44 -0700 | [diff] [blame] | 76 | void onCannedSmsResponsesLoaded(Call call); |
Andrew Lee | 3bcf935 | 2014-07-23 12:36:05 -0700 | [diff] [blame] | 77 | void onVideoCallProviderChanged(Call call); |
Santos Cordon | 64c7e96 | 2014-07-02 15:15:27 -0700 | [diff] [blame] | 78 | void onCallerInfoChanged(Call call); |
Sailesh Nepal | 7e66957 | 2014-07-08 21:29:12 -0700 | [diff] [blame] | 79 | void onAudioModeIsVoipChanged(Call call); |
Sailesh Nepal | 35faf8c | 2014-07-08 22:02:34 -0700 | [diff] [blame] | 80 | void onStatusHintsChanged(Call call); |
Sailesh Nepal | e8ecb98 | 2014-07-11 17:19:42 -0700 | [diff] [blame] | 81 | void onHandleChanged(Call call); |
| 82 | void onCallerDisplayNameChanged(Call call); |
Andrew Lee | 4a79660 | 2014-07-11 17:23:03 -0700 | [diff] [blame] | 83 | void onVideoStateChanged(Call call); |
Sailesh Nepal | 9d58de5 | 2014-07-18 14:53:19 -0700 | [diff] [blame] | 84 | void onStartActivityFromInCall(Call call, PendingIntent intent); |
Ihab Awad | b78b276 | 2014-07-25 15:16:23 -0700 | [diff] [blame] | 85 | void onTargetPhoneAccountChanged(Call call); |
| 86 | void onConnectionManagerPhoneAccountChanged(Call call); |
Santos Cordon | 12d6182 | 2014-07-29 16:02:20 -0700 | [diff] [blame] | 87 | void onPhoneAccountChanged(Call call); |
| 88 | void onConferenceableCallsChanged(Call call); |
Santos Cordon | 64c7e96 | 2014-07-02 15:15:27 -0700 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | abstract static class ListenerBase implements Listener { |
| 92 | @Override |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 93 | public void onSuccessfulOutgoingCall(Call call, int callState) {} |
Santos Cordon | 64c7e96 | 2014-07-02 15:15:27 -0700 | [diff] [blame] | 94 | @Override |
| 95 | public void onFailedOutgoingCall(Call call, int errorCode, String errorMsg) {} |
| 96 | @Override |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 97 | public void onSuccessfulIncomingCall(Call call) {} |
Santos Cordon | 64c7e96 | 2014-07-02 15:15:27 -0700 | [diff] [blame] | 98 | @Override |
| 99 | public void onFailedIncomingCall(Call call) {} |
| 100 | @Override |
| 101 | public void onRequestingRingback(Call call, boolean requestingRingback) {} |
| 102 | @Override |
| 103 | public void onPostDialWait(Call call, String remaining) {} |
| 104 | @Override |
Sailesh Nepal | e20bc97 | 2014-07-09 21:22:36 -0700 | [diff] [blame] | 105 | public void onCallCapabilitiesChanged(Call call) {} |
Santos Cordon | 64c7e96 | 2014-07-02 15:15:27 -0700 | [diff] [blame] | 106 | @Override |
Santos Cordon | 64c7e96 | 2014-07-02 15:15:27 -0700 | [diff] [blame] | 107 | public void onParentChanged(Call call) {} |
| 108 | @Override |
| 109 | public void onChildrenChanged(Call call) {} |
| 110 | @Override |
| 111 | public void onCannedSmsResponsesLoaded(Call call) {} |
| 112 | @Override |
Andrew Lee | 3bcf935 | 2014-07-23 12:36:05 -0700 | [diff] [blame] | 113 | public void onVideoCallProviderChanged(Call call) {} |
Santos Cordon | 64c7e96 | 2014-07-02 15:15:27 -0700 | [diff] [blame] | 114 | @Override |
Santos Cordon | 64c7e96 | 2014-07-02 15:15:27 -0700 | [diff] [blame] | 115 | public void onCallerInfoChanged(Call call) {} |
Sailesh Nepal | 7e66957 | 2014-07-08 21:29:12 -0700 | [diff] [blame] | 116 | @Override |
| 117 | public void onAudioModeIsVoipChanged(Call call) {} |
Sailesh Nepal | 35faf8c | 2014-07-08 22:02:34 -0700 | [diff] [blame] | 118 | @Override |
| 119 | public void onStatusHintsChanged(Call call) {} |
Sailesh Nepal | e8ecb98 | 2014-07-11 17:19:42 -0700 | [diff] [blame] | 120 | @Override |
| 121 | public void onHandleChanged(Call call) {} |
| 122 | @Override |
| 123 | public void onCallerDisplayNameChanged(Call call) {} |
Andrew Lee | 4a79660 | 2014-07-11 17:23:03 -0700 | [diff] [blame] | 124 | @Override |
| 125 | public void onVideoStateChanged(Call call) {} |
Sailesh Nepal | 9d58de5 | 2014-07-18 14:53:19 -0700 | [diff] [blame] | 126 | @Override |
| 127 | public void onStartActivityFromInCall(Call call, PendingIntent intent) {} |
Ihab Awad | 69eb0f5 | 2014-07-18 11:20:37 -0700 | [diff] [blame] | 128 | @Override |
Ihab Awad | b78b276 | 2014-07-25 15:16:23 -0700 | [diff] [blame] | 129 | public void onTargetPhoneAccountChanged(Call call) {} |
| 130 | @Override |
| 131 | public void onConnectionManagerPhoneAccountChanged(Call call) {} |
Santos Cordon | 12d6182 | 2014-07-29 16:02:20 -0700 | [diff] [blame] | 132 | @Override |
| 133 | public void onPhoneAccountChanged(Call call) {} |
| 134 | @Override |
| 135 | public void onConferenceableCallsChanged(Call call) {} |
Santos Cordon | 766d04f | 2014-05-06 10:28:25 -0700 | [diff] [blame] | 136 | } |
| 137 | |
Santos Cordon | fd71f4a | 2014-05-28 13:59:49 -0700 | [diff] [blame] | 138 | private static final OnQueryCompleteListener sCallerInfoQueryListener = |
Santos Cordon | 99c8a6f | 2014-05-28 18:28:47 -0700 | [diff] [blame] | 139 | new OnQueryCompleteListener() { |
| 140 | /** ${inheritDoc} */ |
| 141 | @Override |
| 142 | public void onQueryComplete(int token, Object cookie, CallerInfo callerInfo) { |
| 143 | if (cookie != null) { |
| 144 | ((Call) cookie).setCallerInfo(callerInfo, token); |
| 145 | } |
Santos Cordon | fd71f4a | 2014-05-28 13:59:49 -0700 | [diff] [blame] | 146 | } |
Santos Cordon | 99c8a6f | 2014-05-28 18:28:47 -0700 | [diff] [blame] | 147 | }; |
| 148 | |
| 149 | private static final OnImageLoadCompleteListener sPhotoLoadListener = |
| 150 | new OnImageLoadCompleteListener() { |
| 151 | /** ${inheritDoc} */ |
| 152 | @Override |
| 153 | public void onImageLoadComplete( |
| 154 | int token, Drawable photo, Bitmap photoIcon, Object cookie) { |
| 155 | if (cookie != null) { |
| 156 | ((Call) cookie).setPhoto(photo, photoIcon, token); |
| 157 | } |
| 158 | } |
| 159 | }; |
Ben Gilad | 0407fb2 | 2014-01-09 16:18:41 -0800 | [diff] [blame] | 160 | |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 161 | private final Runnable mDirectToVoicemailRunnable = new Runnable() { |
| 162 | @Override |
| 163 | public void run() { |
| 164 | processDirectToVoicemail(); |
| 165 | } |
| 166 | }; |
| 167 | |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 168 | /** True if this is an incoming call. */ |
| 169 | private final boolean mIsIncoming; |
| 170 | |
Ben Gilad | 0407fb2 | 2014-01-09 16:18:41 -0800 | [diff] [blame] | 171 | /** |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 172 | * The time this call was created. Beyond logging and such, may also be used for bookkeeping |
| 173 | * and specifically for marking certain call attempts as failed attempts. |
Ben Gilad | 0407fb2 | 2014-01-09 16:18:41 -0800 | [diff] [blame] | 174 | */ |
Sailesh Nepal | 8c85dee | 2014-04-07 22:21:40 -0700 | [diff] [blame] | 175 | private final long mCreationTimeMillis = System.currentTimeMillis(); |
| 176 | |
Santos Cordon | fd71f4a | 2014-05-28 13:59:49 -0700 | [diff] [blame] | 177 | /** The gateway information associated with this call. This stores the original call handle |
| 178 | * that the user is attempting to connect to via the gateway, the actual handle to dial in |
| 179 | * order to connect the call via the gateway, as well as the package name of the gateway |
| 180 | * service. */ |
Nancy Chen | 0d3076c | 2014-07-30 14:45:44 -0700 | [diff] [blame] | 181 | private GatewayInfo mGatewayInfo; |
Santos Cordon | fd71f4a | 2014-05-28 13:59:49 -0700 | [diff] [blame] | 182 | |
Ihab Awad | b78b276 | 2014-07-25 15:16:23 -0700 | [diff] [blame] | 183 | private PhoneAccountHandle mConnectionManagerPhoneAccountHandle; |
| 184 | |
| 185 | private PhoneAccountHandle mTargetPhoneAccountHandle; |
Nancy Chen | 77d2d0e | 2014-06-24 12:06:03 -0700 | [diff] [blame] | 186 | |
Santos Cordon | 2174fb5 | 2014-05-29 08:22:56 -0700 | [diff] [blame] | 187 | private final Handler mHandler = new Handler(); |
| 188 | |
Santos Cordon | 12d6182 | 2014-07-29 16:02:20 -0700 | [diff] [blame] | 189 | private final List<Call> mConferenceableCalls = new ArrayList<>(); |
| 190 | |
| 191 | private PhoneAccountHandle mPhoneAccountHandle; |
| 192 | |
Sailesh Nepal | 8c85dee | 2014-04-07 22:21:40 -0700 | [diff] [blame] | 193 | private long mConnectTimeMillis; |
Ben Gilad | 0407fb2 | 2014-01-09 16:18:41 -0800 | [diff] [blame] | 194 | |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 195 | /** The state of the call. */ |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 196 | private int mState; |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 197 | |
| 198 | /** The handle with which to establish this call. */ |
Sailesh Nepal | ce704b9 | 2014-03-17 18:31:43 -0700 | [diff] [blame] | 199 | private Uri mHandle; |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 200 | |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 201 | /** The {@link PropertyPresentation} that controls how the handle is shown. */ |
Sailesh Nepal | e8ecb98 | 2014-07-11 17:19:42 -0700 | [diff] [blame] | 202 | private int mHandlePresentation; |
| 203 | |
| 204 | /** The caller display name (CNAP) set by the connection service. */ |
| 205 | private String mCallerDisplayName; |
| 206 | |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 207 | /** The {@link PropertyPresentation} that controls how the caller display name is shown. */ |
Sailesh Nepal | e8ecb98 | 2014-07-11 17:19:42 -0700 | [diff] [blame] | 208 | private int mCallerDisplayNamePresentation; |
| 209 | |
Ben Gilad | 0407fb2 | 2014-01-09 16:18:41 -0800 | [diff] [blame] | 210 | /** |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 211 | * The connection service which is attempted or already connecting this call. |
Santos Cordon | 681663d | 2014-01-30 04:32:15 -0800 | [diff] [blame] | 212 | */ |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 213 | private ConnectionServiceWrapper mConnectionService; |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 214 | |
Sailesh Nepal | 6aca10a | 2014-03-24 16:11:02 -0700 | [diff] [blame] | 215 | private boolean mIsEmergencyCall; |
| 216 | |
Sai Cheemalapati | b7157e9 | 2014-06-11 17:51:55 -0700 | [diff] [blame] | 217 | private boolean mSpeakerphoneOn; |
| 218 | |
Tyler Gunn | 0a388fc | 2014-07-17 12:21:17 -0700 | [diff] [blame] | 219 | /** |
| 220 | * Tracks the video states which were applicable over the duration of a call. |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 221 | * See {@link VideoProfile} for a list of valid video states. |
Tyler Gunn | 0a388fc | 2014-07-17 12:21:17 -0700 | [diff] [blame] | 222 | */ |
| 223 | private int mVideoStateHistory; |
| 224 | |
Tyler Gunn | c4abd91 | 2014-07-08 14:22:10 -0700 | [diff] [blame] | 225 | private int mVideoState; |
| 226 | |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 227 | /** |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 228 | * Disconnect cause for the call. Only valid if the state of the call is STATE_DISCONNECTED. |
Santos Cordon | 79ff2bc | 2014-03-27 15:31:27 -0700 | [diff] [blame] | 229 | * See {@link android.telephony.DisconnectCause}. |
| 230 | */ |
Sailesh Nepal | 8c85dee | 2014-04-07 22:21:40 -0700 | [diff] [blame] | 231 | private int mDisconnectCause = DisconnectCause.NOT_VALID; |
Santos Cordon | 79ff2bc | 2014-03-27 15:31:27 -0700 | [diff] [blame] | 232 | |
| 233 | /** |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 234 | * Additional disconnect information provided by the connection service. |
Santos Cordon | 79ff2bc | 2014-03-27 15:31:27 -0700 | [diff] [blame] | 235 | */ |
| 236 | private String mDisconnectMessage; |
| 237 | |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 238 | /** Info used by the connection services. */ |
Sailesh Nepal | 8c85dee | 2014-04-07 22:21:40 -0700 | [diff] [blame] | 239 | private Bundle mExtras = Bundle.EMPTY; |
Sailesh Nepal | 84fa5f8 | 2014-04-02 11:01:11 -0700 | [diff] [blame] | 240 | |
Jay Shrauner | a82c8f7 | 2014-08-14 15:49:16 -0700 | [diff] [blame] | 241 | /** Set of listeners on this call. |
| 242 | * |
| 243 | * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is |
| 244 | * load factor before resizing, 1 means we only expect a single thread to |
| 245 | * access the map so make only a single shard |
| 246 | */ |
| 247 | private final Set<Listener> mListeners = Collections.newSetFromMap( |
| 248 | new ConcurrentHashMap<Listener, Boolean>(8, 0.9f, 1)); |
Santos Cordon | 766d04f | 2014-05-06 10:28:25 -0700 | [diff] [blame] | 249 | |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 250 | private CreateConnectionProcessor mCreateConnectionProcessor; |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 251 | |
Santos Cordon | fd71f4a | 2014-05-28 13:59:49 -0700 | [diff] [blame] | 252 | /** Caller information retrieved from the latest contact query. */ |
| 253 | private CallerInfo mCallerInfo; |
| 254 | |
| 255 | /** The latest token used with a contact info query. */ |
| 256 | private int mQueryToken = 0; |
| 257 | |
Ihab Awad | cb387ac | 2014-05-28 16:49:38 -0700 | [diff] [blame] | 258 | /** Whether this call is requesting that Telecomm play the ringback tone on its behalf. */ |
| 259 | private boolean mRequestingRingback = false; |
| 260 | |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 261 | /** Whether direct-to-voicemail query is pending. */ |
| 262 | private boolean mDirectToVoicemailQueryPending; |
Santos Cordon | 2174fb5 | 2014-05-29 08:22:56 -0700 | [diff] [blame] | 263 | |
Sailesh Nepal | e20bc97 | 2014-07-09 21:22:36 -0700 | [diff] [blame] | 264 | private int mCallCapabilities; |
Santos Cordon | a161070 | 2014-06-04 20:22:56 -0700 | [diff] [blame] | 265 | |
| 266 | private boolean mIsConference = false; |
| 267 | |
| 268 | private Call mParentCall = null; |
| 269 | |
| 270 | private List<Call> mChildCalls = new LinkedList<>(); |
| 271 | |
Ihab Awad | ff7493a | 2014-06-10 13:47:44 -0700 | [diff] [blame] | 272 | /** Set of text message responses allowed for this call, if applicable. */ |
| 273 | private List<String> mCannedSmsResponses = Collections.EMPTY_LIST; |
| 274 | |
| 275 | /** Whether an attempt has been made to load the text message responses. */ |
| 276 | private boolean mCannedSmsResponsesLoadingStarted = false; |
| 277 | |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 278 | private IVideoProvider mVideoProvider; |
Nancy Chen | a65d41f | 2014-06-24 12:06:03 -0700 | [diff] [blame] | 279 | |
Sailesh Nepal | 7e66957 | 2014-07-08 21:29:12 -0700 | [diff] [blame] | 280 | private boolean mAudioModeIsVoip; |
Sailesh Nepal | 35faf8c | 2014-07-08 22:02:34 -0700 | [diff] [blame] | 281 | private StatusHints mStatusHints; |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 282 | private final ConnectionServiceRepository mRepository; |
Sailesh Nepal | 7e66957 | 2014-07-08 21:29:12 -0700 | [diff] [blame] | 283 | |
Sailesh Nepal | 8c85dee | 2014-04-07 22:21:40 -0700 | [diff] [blame] | 284 | /** |
Ben Gilad | 0407fb2 | 2014-01-09 16:18:41 -0800 | [diff] [blame] | 285 | * Persists the specified parameters and initializes the new instance. |
| 286 | * |
| 287 | * @param handle The handle to dial. |
Yorke Lee | 3350163 | 2014-03-17 19:24:12 -0700 | [diff] [blame] | 288 | * @param gatewayInfo Gateway information to use for the call. |
Ihab Awad | b78b276 | 2014-07-25 15:16:23 -0700 | [diff] [blame] | 289 | * @param connectionManagerPhoneAccountHandle Account to use for the service managing the call. |
| 290 | * This account must be one that was registered with the |
| 291 | * {@link PhoneAccount#CAPABILITY_CONNECTION_MANAGER} flag. |
| 292 | * @param targetPhoneAccountHandle Account information to use for the call. This account must be |
| 293 | * one that was registered with the {@link PhoneAccount#CAPABILITY_CALL_PROVIDER} flag. |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 294 | * @param isIncoming True if this is an incoming call. |
Ben Gilad | 0407fb2 | 2014-01-09 16:18:41 -0800 | [diff] [blame] | 295 | */ |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 296 | Call( |
| 297 | ConnectionServiceRepository repository, |
| 298 | Uri handle, |
| 299 | GatewayInfo gatewayInfo, |
Ihab Awad | b78b276 | 2014-07-25 15:16:23 -0700 | [diff] [blame] | 300 | PhoneAccountHandle connectionManagerPhoneAccountHandle, |
| 301 | PhoneAccountHandle targetPhoneAccountHandle, |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 302 | boolean isIncoming, |
| 303 | boolean isConference) { |
Santos Cordon | a161070 | 2014-06-04 20:22:56 -0700 | [diff] [blame] | 304 | mState = isConference ? CallState.ACTIVE : CallState.NEW; |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 305 | mRepository = repository; |
Nancy Chen | 0d3076c | 2014-07-30 14:45:44 -0700 | [diff] [blame] | 306 | setHandle(handle); |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 307 | setHandle(handle, PropertyPresentation.ALLOWED); |
Yorke Lee | 3350163 | 2014-03-17 19:24:12 -0700 | [diff] [blame] | 308 | mGatewayInfo = gatewayInfo; |
Ihab Awad | b78b276 | 2014-07-25 15:16:23 -0700 | [diff] [blame] | 309 | mConnectionManagerPhoneAccountHandle = connectionManagerPhoneAccountHandle; |
| 310 | mTargetPhoneAccountHandle = targetPhoneAccountHandle; |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 311 | mIsIncoming = isIncoming; |
Santos Cordon | a161070 | 2014-06-04 20:22:56 -0700 | [diff] [blame] | 312 | mIsConference = isConference; |
Ihab Awad | ff7493a | 2014-06-10 13:47:44 -0700 | [diff] [blame] | 313 | maybeLoadCannedSmsResponses(); |
Ben Gilad | 0407fb2 | 2014-01-09 16:18:41 -0800 | [diff] [blame] | 314 | } |
| 315 | |
Santos Cordon | 766d04f | 2014-05-06 10:28:25 -0700 | [diff] [blame] | 316 | void addListener(Listener listener) { |
| 317 | mListeners.add(listener); |
| 318 | } |
| 319 | |
| 320 | void removeListener(Listener listener) { |
Jay Shrauner | a82c8f7 | 2014-08-14 15:49:16 -0700 | [diff] [blame] | 321 | if (listener != null) { |
| 322 | mListeners.remove(listener); |
| 323 | } |
Santos Cordon | 766d04f | 2014-05-06 10:28:25 -0700 | [diff] [blame] | 324 | } |
| 325 | |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 326 | /** {@inheritDoc} */ |
Santos Cordon | 12d6182 | 2014-07-29 16:02:20 -0700 | [diff] [blame] | 327 | @Override |
| 328 | public String toString() { |
Sailesh Nepal | 4538f01 | 2014-04-15 11:40:33 -0700 | [diff] [blame] | 329 | String component = null; |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 330 | if (mConnectionService != null && mConnectionService.getComponentName() != null) { |
| 331 | component = mConnectionService.getComponentName().flattenToShortString(); |
Sailesh Nepal | 4538f01 | 2014-04-15 11:40:33 -0700 | [diff] [blame] | 332 | } |
Tyler Gunn | 0a388fc | 2014-07-17 12:21:17 -0700 | [diff] [blame] | 333 | |
| 334 | return String.format(Locale.US, "[%s, %s, %s, %d]", mState, component, |
| 335 | Log.piiHandle(mHandle), getVideoState()); |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 336 | } |
| 337 | |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 338 | int getState() { |
Santos Cordon | 0fbe632 | 2014-08-14 04:04:25 -0700 | [diff] [blame] | 339 | return mState; |
Santos Cordon | 0b03b4b | 2014-01-29 18:01:59 -0800 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | /** |
| 343 | * Sets the call state. Although there exists the notion of appropriate state transitions |
| 344 | * (see {@link CallState}), in practice those expectations break down when cellular systems |
| 345 | * misbehave and they do this very often. The result is that we do not enforce state transitions |
| 346 | * and instead keep the code resilient to unexpected state changes. |
| 347 | */ |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 348 | void setState(int newState) { |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 349 | if (mState != newState) { |
| 350 | Log.v(this, "setState %s -> %s", mState, newState); |
| 351 | mState = newState; |
Ihab Awad | ff7493a | 2014-06-10 13:47:44 -0700 | [diff] [blame] | 352 | maybeLoadCannedSmsResponses(); |
Santos Cordon | 672321e | 2014-08-21 14:38:58 -0700 | [diff] [blame] | 353 | |
| 354 | if (mState == CallState.DISCONNECTED) { |
| 355 | fixParentAfterDisconnect(); |
| 356 | } |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 357 | } |
Santos Cordon | 0b03b4b | 2014-01-29 18:01:59 -0800 | [diff] [blame] | 358 | } |
| 359 | |
Ihab Awad | cb387ac | 2014-05-28 16:49:38 -0700 | [diff] [blame] | 360 | void setRequestingRingback(boolean requestingRingback) { |
| 361 | mRequestingRingback = requestingRingback; |
| 362 | for (Listener l : mListeners) { |
| 363 | l.onRequestingRingback(this, mRequestingRingback); |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | boolean isRequestingRingback() { |
| 368 | return mRequestingRingback; |
| 369 | } |
| 370 | |
Santos Cordon | 672321e | 2014-08-21 14:38:58 -0700 | [diff] [blame] | 371 | boolean isConference() { |
| 372 | return mIsConference; |
| 373 | } |
| 374 | |
Sailesh Nepal | ce704b9 | 2014-03-17 18:31:43 -0700 | [diff] [blame] | 375 | Uri getHandle() { |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 376 | return mHandle; |
| 377 | } |
| 378 | |
Sailesh Nepal | e8ecb98 | 2014-07-11 17:19:42 -0700 | [diff] [blame] | 379 | int getHandlePresentation() { |
| 380 | return mHandlePresentation; |
| 381 | } |
| 382 | |
Nancy Chen | 0d3076c | 2014-07-30 14:45:44 -0700 | [diff] [blame] | 383 | |
| 384 | void setHandle(Uri handle) { |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 385 | setHandle(handle, PropertyPresentation.ALLOWED); |
Nancy Chen | 0d3076c | 2014-07-30 14:45:44 -0700 | [diff] [blame] | 386 | } |
| 387 | |
Sailesh Nepal | e8ecb98 | 2014-07-11 17:19:42 -0700 | [diff] [blame] | 388 | void setHandle(Uri handle, int presentation) { |
| 389 | if (!Objects.equals(handle, mHandle) || presentation != mHandlePresentation) { |
Santos Cordon | fd71f4a | 2014-05-28 13:59:49 -0700 | [diff] [blame] | 390 | mHandle = handle; |
Sailesh Nepal | e8ecb98 | 2014-07-11 17:19:42 -0700 | [diff] [blame] | 391 | mHandlePresentation = presentation; |
Santos Cordon | fd71f4a | 2014-05-28 13:59:49 -0700 | [diff] [blame] | 392 | mIsEmergencyCall = mHandle != null && PhoneNumberUtils.isLocalEmergencyNumber( |
Yorke Lee | 6625545 | 2014-06-05 08:09:24 -0700 | [diff] [blame] | 393 | TelecommApp.getInstance(), mHandle.getSchemeSpecificPart()); |
Santos Cordon | fd71f4a | 2014-05-28 13:59:49 -0700 | [diff] [blame] | 394 | startCallerInfoLookup(); |
Sailesh Nepal | e8ecb98 | 2014-07-11 17:19:42 -0700 | [diff] [blame] | 395 | for (Listener l : mListeners) { |
| 396 | l.onHandleChanged(this); |
| 397 | } |
| 398 | } |
| 399 | } |
| 400 | |
| 401 | String getCallerDisplayName() { |
| 402 | return mCallerDisplayName; |
| 403 | } |
| 404 | |
| 405 | int getCallerDisplayNamePresentation() { |
| 406 | return mCallerDisplayNamePresentation; |
| 407 | } |
| 408 | |
| 409 | void setCallerDisplayName(String callerDisplayName, int presentation) { |
| 410 | if (!TextUtils.equals(callerDisplayName, mCallerDisplayName) || |
| 411 | presentation != mCallerDisplayNamePresentation) { |
| 412 | mCallerDisplayName = callerDisplayName; |
| 413 | mCallerDisplayNamePresentation = presentation; |
| 414 | for (Listener l : mListeners) { |
| 415 | l.onCallerDisplayNameChanged(this); |
| 416 | } |
Santos Cordon | fd71f4a | 2014-05-28 13:59:49 -0700 | [diff] [blame] | 417 | } |
Sailesh Nepal | 6aca10a | 2014-03-24 16:11:02 -0700 | [diff] [blame] | 418 | } |
| 419 | |
Santos Cordon | 99c8a6f | 2014-05-28 18:28:47 -0700 | [diff] [blame] | 420 | String getName() { |
| 421 | return mCallerInfo == null ? null : mCallerInfo.name; |
| 422 | } |
| 423 | |
| 424 | Bitmap getPhotoIcon() { |
| 425 | return mCallerInfo == null ? null : mCallerInfo.cachedPhotoIcon; |
| 426 | } |
| 427 | |
| 428 | Drawable getPhoto() { |
| 429 | return mCallerInfo == null ? null : mCallerInfo.cachedPhoto; |
| 430 | } |
| 431 | |
Santos Cordon | 79ff2bc | 2014-03-27 15:31:27 -0700 | [diff] [blame] | 432 | /** |
| 433 | * @param disconnectCause The reason for the disconnection, any of |
| 434 | * {@link android.telephony.DisconnectCause}. |
Sailesh Nepal | 905dfba | 2014-07-14 08:20:41 -0700 | [diff] [blame] | 435 | * @param disconnectMessage Optional message about the disconnect. |
Santos Cordon | 79ff2bc | 2014-03-27 15:31:27 -0700 | [diff] [blame] | 436 | */ |
| 437 | void setDisconnectCause(int disconnectCause, String disconnectMessage) { |
| 438 | // TODO: Consider combining this method with a setDisconnected() method that is totally |
| 439 | // separate from setState. |
| 440 | mDisconnectCause = disconnectCause; |
| 441 | mDisconnectMessage = disconnectMessage; |
| 442 | } |
| 443 | |
| 444 | int getDisconnectCause() { |
| 445 | return mDisconnectCause; |
| 446 | } |
| 447 | |
| 448 | String getDisconnectMessage() { |
| 449 | return mDisconnectMessage; |
| 450 | } |
| 451 | |
Sailesh Nepal | 6aca10a | 2014-03-24 16:11:02 -0700 | [diff] [blame] | 452 | boolean isEmergencyCall() { |
| 453 | return mIsEmergencyCall; |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 454 | } |
| 455 | |
Yorke Lee | 3350163 | 2014-03-17 19:24:12 -0700 | [diff] [blame] | 456 | /** |
| 457 | * @return The original handle this call is associated with. In-call services should use this |
| 458 | * handle when indicating in their UI the handle that is being called. |
| 459 | */ |
| 460 | public Uri getOriginalHandle() { |
| 461 | if (mGatewayInfo != null && !mGatewayInfo.isEmpty()) { |
| 462 | return mGatewayInfo.getOriginalHandle(); |
| 463 | } |
| 464 | return getHandle(); |
| 465 | } |
| 466 | |
| 467 | GatewayInfo getGatewayInfo() { |
| 468 | return mGatewayInfo; |
| 469 | } |
| 470 | |
Nancy Chen | 0d3076c | 2014-07-30 14:45:44 -0700 | [diff] [blame] | 471 | void setGatewayInfo(GatewayInfo gatewayInfo) { |
| 472 | mGatewayInfo = gatewayInfo; |
| 473 | } |
| 474 | |
Ihab Awad | b78b276 | 2014-07-25 15:16:23 -0700 | [diff] [blame] | 475 | PhoneAccountHandle getConnectionManagerPhoneAccount() { |
| 476 | return mConnectionManagerPhoneAccountHandle; |
Nancy Chen | 77d2d0e | 2014-06-24 12:06:03 -0700 | [diff] [blame] | 477 | } |
| 478 | |
Ihab Awad | b78b276 | 2014-07-25 15:16:23 -0700 | [diff] [blame] | 479 | void setConnectionManagerPhoneAccount(PhoneAccountHandle accountHandle) { |
| 480 | if (!Objects.equals(mConnectionManagerPhoneAccountHandle, accountHandle)) { |
| 481 | mConnectionManagerPhoneAccountHandle = accountHandle; |
Ihab Awad | 69eb0f5 | 2014-07-18 11:20:37 -0700 | [diff] [blame] | 482 | for (Listener l : mListeners) { |
Ihab Awad | b78b276 | 2014-07-25 15:16:23 -0700 | [diff] [blame] | 483 | l.onConnectionManagerPhoneAccountChanged(this); |
| 484 | } |
| 485 | } |
| 486 | |
| 487 | } |
| 488 | |
| 489 | PhoneAccountHandle getTargetPhoneAccount() { |
| 490 | return mTargetPhoneAccountHandle; |
| 491 | } |
| 492 | |
| 493 | void setTargetPhoneAccount(PhoneAccountHandle accountHandle) { |
| 494 | if (!Objects.equals(mTargetPhoneAccountHandle, accountHandle)) { |
| 495 | mTargetPhoneAccountHandle = accountHandle; |
| 496 | for (Listener l : mListeners) { |
| 497 | l.onTargetPhoneAccountChanged(this); |
Ihab Awad | 69eb0f5 | 2014-07-18 11:20:37 -0700 | [diff] [blame] | 498 | } |
| 499 | } |
Nancy Chen | 53ceedc | 2014-07-08 18:56:51 -0700 | [diff] [blame] | 500 | } |
| 501 | |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 502 | boolean isIncoming() { |
| 503 | return mIsIncoming; |
| 504 | } |
| 505 | |
Ben Gilad | 0407fb2 | 2014-01-09 16:18:41 -0800 | [diff] [blame] | 506 | /** |
| 507 | * @return The "age" of this call object in milliseconds, which typically also represents the |
Sailesh Nepal | 8c85dee | 2014-04-07 22:21:40 -0700 | [diff] [blame] | 508 | * period since this call was added to the set pending outgoing calls, see |
| 509 | * mCreationTimeMillis. |
Ben Gilad | 0407fb2 | 2014-01-09 16:18:41 -0800 | [diff] [blame] | 510 | */ |
Sailesh Nepal | 8c85dee | 2014-04-07 22:21:40 -0700 | [diff] [blame] | 511 | long getAgeMillis() { |
| 512 | return System.currentTimeMillis() - mCreationTimeMillis; |
Ben Gilad | 0407fb2 | 2014-01-09 16:18:41 -0800 | [diff] [blame] | 513 | } |
Santos Cordon | 0b03b4b | 2014-01-29 18:01:59 -0800 | [diff] [blame] | 514 | |
Yorke Lee | f98fb57 | 2014-03-05 10:56:55 -0800 | [diff] [blame] | 515 | /** |
| 516 | * @return The time when this call object was created and added to the set of pending outgoing |
| 517 | * calls. |
| 518 | */ |
Sailesh Nepal | 8c85dee | 2014-04-07 22:21:40 -0700 | [diff] [blame] | 519 | long getCreationTimeMillis() { |
| 520 | return mCreationTimeMillis; |
| 521 | } |
| 522 | |
| 523 | long getConnectTimeMillis() { |
| 524 | return mConnectTimeMillis; |
| 525 | } |
| 526 | |
| 527 | void setConnectTimeMillis(long connectTimeMillis) { |
| 528 | mConnectTimeMillis = connectTimeMillis; |
Yorke Lee | f98fb57 | 2014-03-05 10:56:55 -0800 | [diff] [blame] | 529 | } |
| 530 | |
Sailesh Nepal | e20bc97 | 2014-07-09 21:22:36 -0700 | [diff] [blame] | 531 | int getCallCapabilities() { |
| 532 | return mCallCapabilities; |
Santos Cordon | a161070 | 2014-06-04 20:22:56 -0700 | [diff] [blame] | 533 | } |
| 534 | |
Sailesh Nepal | e20bc97 | 2014-07-09 21:22:36 -0700 | [diff] [blame] | 535 | void setCallCapabilities(int callCapabilities) { |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 536 | Log.v(this, "setCallCapabilities: %s", PhoneCapabilities.toString(callCapabilities)); |
Sailesh Nepal | e20bc97 | 2014-07-09 21:22:36 -0700 | [diff] [blame] | 537 | if (mCallCapabilities != callCapabilities) { |
Santos Cordon | 12d6182 | 2014-07-29 16:02:20 -0700 | [diff] [blame] | 538 | mCallCapabilities = callCapabilities; |
Santos Cordon | a161070 | 2014-06-04 20:22:56 -0700 | [diff] [blame] | 539 | for (Listener l : mListeners) { |
Sailesh Nepal | e20bc97 | 2014-07-09 21:22:36 -0700 | [diff] [blame] | 540 | l.onCallCapabilitiesChanged(this); |
Santos Cordon | a161070 | 2014-06-04 20:22:56 -0700 | [diff] [blame] | 541 | } |
| 542 | } |
| 543 | } |
| 544 | |
| 545 | Call getParentCall() { |
| 546 | return mParentCall; |
| 547 | } |
| 548 | |
| 549 | List<Call> getChildCalls() { |
| 550 | return mChildCalls; |
| 551 | } |
| 552 | |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 553 | ConnectionServiceWrapper getConnectionService() { |
| 554 | return mConnectionService; |
Santos Cordon | 681663d | 2014-01-30 04:32:15 -0800 | [diff] [blame] | 555 | } |
| 556 | |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 557 | void setConnectionService(ConnectionServiceWrapper service) { |
| 558 | Preconditions.checkNotNull(service); |
| 559 | |
| 560 | clearConnectionService(); |
| 561 | |
| 562 | service.incrementAssociatedCallCount(); |
| 563 | mConnectionService = service; |
| 564 | mConnectionService.addCall(this); |
Sailesh Nepal | 0e5410a | 2014-04-04 01:20:58 -0700 | [diff] [blame] | 565 | } |
| 566 | |
| 567 | /** |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 568 | * Clears the associated connection service. |
Sailesh Nepal | 0e5410a | 2014-04-04 01:20:58 -0700 | [diff] [blame] | 569 | */ |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 570 | void clearConnectionService() { |
| 571 | if (mConnectionService != null) { |
| 572 | ConnectionServiceWrapper serviceTemp = mConnectionService; |
| 573 | mConnectionService = null; |
| 574 | serviceTemp.removeCall(this); |
Santos Cordon | c499c1c | 2014-04-14 17:13:14 -0700 | [diff] [blame] | 575 | |
| 576 | // Decrementing the count can cause the service to unbind, which itself can trigger the |
| 577 | // service-death code. Since the service death code tries to clean up any associated |
| 578 | // calls, we need to make sure to remove that information (e.g., removeCall()) before |
| 579 | // we decrement. Technically, invoking removeCall() prior to decrementing is all that is |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 580 | // necessary, but cleaning up mConnectionService prior to triggering an unbind is good |
| 581 | // to do. |
| 582 | decrementAssociatedCallCount(serviceTemp); |
Yorke Lee | adee12d | 2014-03-13 12:08:30 -0700 | [diff] [blame] | 583 | } |
Ben Gilad | 8e55d1d | 2014-02-26 16:25:56 -0800 | [diff] [blame] | 584 | } |
| 585 | |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 586 | private void processDirectToVoicemail() { |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 587 | if (mDirectToVoicemailQueryPending) { |
Santos Cordon | 2174fb5 | 2014-05-29 08:22:56 -0700 | [diff] [blame] | 588 | if (mCallerInfo != null && mCallerInfo.shouldSendToVoicemail) { |
| 589 | Log.i(this, "Directing call to voicemail: %s.", this); |
Santos Cordon | df39986 | 2014-08-06 04:39:15 -0700 | [diff] [blame] | 590 | // TODO: Once we move State handling from CallsManager to Call, we |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 591 | // will not need to set STATE_RINGING state prior to calling reject. |
Santos Cordon | 2174fb5 | 2014-05-29 08:22:56 -0700 | [diff] [blame] | 592 | setState(CallState.RINGING); |
Ihab Awad | ff7493a | 2014-06-10 13:47:44 -0700 | [diff] [blame] | 593 | reject(false, null); |
Santos Cordon | 2174fb5 | 2014-05-29 08:22:56 -0700 | [diff] [blame] | 594 | } else { |
Santos Cordon | df39986 | 2014-08-06 04:39:15 -0700 | [diff] [blame] | 595 | // TODO: Make this class (not CallsManager) responsible for changing |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 596 | // the call state to STATE_RINGING. |
Santos Cordon | 2174fb5 | 2014-05-29 08:22:56 -0700 | [diff] [blame] | 597 | |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 598 | // TODO: Replace this with state transition to STATE_RINGING. |
Santos Cordon | 2174fb5 | 2014-05-29 08:22:56 -0700 | [diff] [blame] | 599 | for (Listener l : mListeners) { |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 600 | l.onSuccessfulIncomingCall(this); |
Santos Cordon | 2174fb5 | 2014-05-29 08:22:56 -0700 | [diff] [blame] | 601 | } |
| 602 | } |
| 603 | |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 604 | mDirectToVoicemailQueryPending = false; |
Santos Cordon | 766d04f | 2014-05-06 10:28:25 -0700 | [diff] [blame] | 605 | } |
| 606 | } |
| 607 | |
Santos Cordon | 766d04f | 2014-05-06 10:28:25 -0700 | [diff] [blame] | 608 | /** |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 609 | * Starts the create connection sequence. Upon completion, there should exist an active |
| 610 | * connection through a connection service (or the call will have failed). |
Santos Cordon | 766d04f | 2014-05-06 10:28:25 -0700 | [diff] [blame] | 611 | */ |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 612 | void startCreateConnection() { |
| 613 | Preconditions.checkState(mCreateConnectionProcessor == null); |
| 614 | mCreateConnectionProcessor = new CreateConnectionProcessor(this, mRepository, this); |
| 615 | mCreateConnectionProcessor.process(); |
Santos Cordon | 766d04f | 2014-05-06 10:28:25 -0700 | [diff] [blame] | 616 | } |
| 617 | |
Sailesh Nepal | 5a73b03 | 2014-06-25 15:53:21 -0700 | [diff] [blame] | 618 | @Override |
Ihab Awad | 8000845 | 2014-08-23 20:35:44 -0700 | [diff] [blame] | 619 | public void handleCreateConnectionSuccess( |
| 620 | CallIdMapper idMapper, |
| 621 | ParcelableConnection connection) { |
Santos Cordon | 12d6182 | 2014-07-29 16:02:20 -0700 | [diff] [blame] | 622 | Log.v(this, "handleCreateConnectionSuccessful %s", connection); |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 623 | mCreateConnectionProcessor = null; |
Ihab Awad | b78b276 | 2014-07-25 15:16:23 -0700 | [diff] [blame] | 624 | setTargetPhoneAccount(connection.getPhoneAccount()); |
Santos Cordon | 72890ce | 2014-07-21 01:32:04 -0700 | [diff] [blame] | 625 | setHandle(connection.getHandle(), connection.getHandlePresentation()); |
| 626 | setCallerDisplayName( |
| 627 | connection.getCallerDisplayName(), connection.getCallerDisplayNamePresentation()); |
Yorke Lee | b2920b3 | 2014-08-20 13:30:08 -0700 | [diff] [blame] | 628 | setCallCapabilities(connection.getCapabilities()); |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 629 | setVideoProvider(connection.getVideoProvider()); |
Tyler Gunn | b1a95a7 | 2014-07-23 14:08:19 -0700 | [diff] [blame] | 630 | setVideoState(connection.getVideoState()); |
Sailesh Nepal | 604a4fe | 2014-08-14 18:03:43 -0700 | [diff] [blame] | 631 | setRequestingRingback(connection.isRequestingRingback()); |
| 632 | setAudioModeIsVoip(connection.getAudioModeIsVoip()); |
| 633 | setStatusHints(connection.getStatusHints()); |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 634 | |
Ihab Awad | 8000845 | 2014-08-23 20:35:44 -0700 | [diff] [blame] | 635 | mConferenceableCalls.clear(); |
| 636 | for (String id : connection.getConferenceableConnectionIds()) { |
| 637 | mConferenceableCalls.add(idMapper.getCall(id)); |
| 638 | } |
| 639 | |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 640 | if (mIsIncoming) { |
| 641 | // We do not handle incoming calls immediately when they are verified by the connection |
| 642 | // service. We allow the caller-info-query code to execute first so that we can read the |
| 643 | // direct-to-voicemail property before deciding if we want to show the incoming call to |
| 644 | // the user or if we want to reject the call. |
| 645 | mDirectToVoicemailQueryPending = true; |
| 646 | |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 647 | // Timeout the direct-to-voicemail lookup execution so that we dont wait too long before |
| 648 | // showing the user the incoming call screen. |
| 649 | mHandler.postDelayed(mDirectToVoicemailRunnable, Timeouts.getDirectToVoicemailMillis()); |
| 650 | } else { |
| 651 | for (Listener l : mListeners) { |
Tyler Gunn | cde2e50 | 2014-08-12 14:35:58 -0700 | [diff] [blame] | 652 | l.onSuccessfulOutgoingCall(this, |
| 653 | getStateFromConnectionState(connection.getState())); |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 654 | } |
Santos Cordon | 766d04f | 2014-05-06 10:28:25 -0700 | [diff] [blame] | 655 | } |
| 656 | } |
| 657 | |
Sailesh Nepal | 5a73b03 | 2014-06-25 15:53:21 -0700 | [diff] [blame] | 658 | @Override |
Ihab Awad | fb5560d | 2014-08-18 09:32:51 -0700 | [diff] [blame] | 659 | public void handleCreateConnectionFailure(int code, String msg) { |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 660 | mCreateConnectionProcessor = null; |
Ihab Awad | fb5560d | 2014-08-18 09:32:51 -0700 | [diff] [blame] | 661 | clearConnectionService(); |
| 662 | setDisconnectCause(code, msg); |
| 663 | CallsManager.getInstance().markCallAsDisconnected(this, code, msg); |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 664 | |
Ihab Awad | fb5560d | 2014-08-18 09:32:51 -0700 | [diff] [blame] | 665 | if (mIsIncoming) { |
Jay Shrauner | a82c8f7 | 2014-08-14 15:49:16 -0700 | [diff] [blame] | 666 | for (Listener listener : mListeners) { |
| 667 | listener.onFailedIncomingCall(this); |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 668 | } |
| 669 | } else { |
Jay Shrauner | a82c8f7 | 2014-08-14 15:49:16 -0700 | [diff] [blame] | 670 | for (Listener listener : mListeners) { |
| 671 | listener.onFailedOutgoingCall(this, code, msg); |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 672 | } |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 673 | } |
Santos Cordon | 766d04f | 2014-05-06 10:28:25 -0700 | [diff] [blame] | 674 | } |
| 675 | |
| 676 | /** |
Ihab Awad | 74549ec | 2014-03-10 15:33:25 -0700 | [diff] [blame] | 677 | * Plays the specified DTMF tone. |
| 678 | */ |
| 679 | void playDtmfTone(char digit) { |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 680 | if (mConnectionService == null) { |
| 681 | Log.w(this, "playDtmfTone() request on a call without a connection service."); |
Ihab Awad | 74549ec | 2014-03-10 15:33:25 -0700 | [diff] [blame] | 682 | } else { |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 683 | Log.i(this, "Send playDtmfTone to connection service for call %s", this); |
| 684 | mConnectionService.playDtmfTone(this, digit); |
Ihab Awad | 74549ec | 2014-03-10 15:33:25 -0700 | [diff] [blame] | 685 | } |
| 686 | } |
| 687 | |
| 688 | /** |
| 689 | * Stops playing any currently playing DTMF tone. |
| 690 | */ |
| 691 | void stopDtmfTone() { |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 692 | if (mConnectionService == null) { |
Jay Shrauner | fd4d7b5 | 2014-08-14 14:14:43 -0700 | [diff] [blame] | 693 | Log.w(this, "stopDtmfTone() request on a call without a connection service."); |
Ihab Awad | 74549ec | 2014-03-10 15:33:25 -0700 | [diff] [blame] | 694 | } else { |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 695 | Log.i(this, "Send stopDtmfTone to connection service for call %s", this); |
| 696 | mConnectionService.stopDtmfTone(this); |
Ihab Awad | 74549ec | 2014-03-10 15:33:25 -0700 | [diff] [blame] | 697 | } |
| 698 | } |
| 699 | |
| 700 | /** |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 701 | * Attempts to disconnect the call through the connection service. |
Santos Cordon | 049b7b6 | 2014-01-30 05:34:26 -0800 | [diff] [blame] | 702 | */ |
| 703 | void disconnect() { |
Jay Shrauner | fd4d7b5 | 2014-08-14 14:14:43 -0700 | [diff] [blame] | 704 | if (mState == CallState.NEW || mState == CallState.PRE_DIAL_WAIT || |
| 705 | mState == CallState.CONNECTING) { |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 706 | Log.v(this, "Aborting call %s", this); |
| 707 | abort(); |
Santos Cordon | 74d420b | 2014-05-07 14:38:47 -0700 | [diff] [blame] | 708 | } else if (mState != CallState.ABORTED && mState != CallState.DISCONNECTED) { |
Jay Shrauner | fd4d7b5 | 2014-08-14 14:14:43 -0700 | [diff] [blame] | 709 | if (mConnectionService == null) { |
| 710 | Log.e(this, new Exception(), "disconnect() request on a call without a" |
| 711 | + " connection service."); |
| 712 | } else { |
| 713 | Log.i(this, "Send disconnect to connection service for call: %s", this); |
| 714 | // The call isn't officially disconnected until the connection service |
| 715 | // confirms that the call was actually disconnected. Only then is the |
| 716 | // association between call and connection service severed, see |
| 717 | // {@link CallsManager#markCallAsDisconnected}. |
| 718 | mConnectionService.disconnect(this); |
| 719 | } |
Santos Cordon | 049b7b6 | 2014-01-30 05:34:26 -0800 | [diff] [blame] | 720 | } |
| 721 | } |
| 722 | |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 723 | void abort() { |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 724 | if (mCreateConnectionProcessor != null) { |
| 725 | mCreateConnectionProcessor.abort(); |
Yorke Lee | 43df90f | 2014-08-20 10:56:09 -0700 | [diff] [blame] | 726 | } else if (mState == CallState.NEW || mState == CallState.PRE_DIAL_WAIT |
| 727 | || mState == CallState.CONNECTING) { |
| 728 | handleCreateConnectionFailure(DisconnectCause.OUTGOING_CANCELED, null); |
Santos Cordon | 2d0b331 | 2014-08-15 15:04:17 -0700 | [diff] [blame] | 729 | } else { |
| 730 | Log.v(this, "Cannot abort a call which isn't either PRE_DIAL_WAIT or CONNECTING"); |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 731 | } |
| 732 | } |
| 733 | |
Santos Cordon | 0b03b4b | 2014-01-29 18:01:59 -0800 | [diff] [blame] | 734 | /** |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 735 | * Answers the call if it is ringing. |
Andrew Lee | 38931d0 | 2014-07-16 10:17:36 -0700 | [diff] [blame] | 736 | * |
| 737 | * @param videoState The video state in which to answer the call. |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 738 | */ |
Andrew Lee | 38931d0 | 2014-07-16 10:17:36 -0700 | [diff] [blame] | 739 | void answer(int videoState) { |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 740 | Preconditions.checkNotNull(mConnectionService); |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 741 | |
| 742 | // Check to verify that the call is still in the ringing state. A call can change states |
| 743 | // between the time the user hits 'answer' and Telecomm receives the command. |
| 744 | if (isRinging("answer")) { |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 745 | // At this point, we are asking the connection service to answer but we don't assume |
| 746 | // that it will work. Instead, we wait until confirmation from the connectino service |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 747 | // that the call is in a non-STATE_RINGING state before changing the UI. See |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 748 | // {@link ConnectionServiceAdapter#setActive} and other set* methods. |
Andrew Lee | 38931d0 | 2014-07-16 10:17:36 -0700 | [diff] [blame] | 749 | mConnectionService.answer(this, videoState); |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 750 | } |
| 751 | } |
| 752 | |
| 753 | /** |
| 754 | * Rejects the call if it is ringing. |
Ihab Awad | ff7493a | 2014-06-10 13:47:44 -0700 | [diff] [blame] | 755 | * |
| 756 | * @param rejectWithMessage Whether to send a text message as part of the call rejection. |
| 757 | * @param textMessage An optional text message to send as part of the rejection. |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 758 | */ |
Ihab Awad | ff7493a | 2014-06-10 13:47:44 -0700 | [diff] [blame] | 759 | void reject(boolean rejectWithMessage, String textMessage) { |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 760 | Preconditions.checkNotNull(mConnectionService); |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 761 | |
| 762 | // Check to verify that the call is still in the ringing state. A call can change states |
| 763 | // between the time the user hits 'reject' and Telecomm receives the command. |
| 764 | if (isRinging("reject")) { |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 765 | mConnectionService.reject(this); |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 766 | } |
| 767 | } |
| 768 | |
| 769 | /** |
Yorke Lee | cdf3ebd | 2014-03-12 18:31:41 -0700 | [diff] [blame] | 770 | * Puts the call on hold if it is currently active. |
| 771 | */ |
| 772 | void hold() { |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 773 | Preconditions.checkNotNull(mConnectionService); |
Yorke Lee | cdf3ebd | 2014-03-12 18:31:41 -0700 | [diff] [blame] | 774 | |
| 775 | if (mState == CallState.ACTIVE) { |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 776 | mConnectionService.hold(this); |
Yorke Lee | cdf3ebd | 2014-03-12 18:31:41 -0700 | [diff] [blame] | 777 | } |
| 778 | } |
| 779 | |
| 780 | /** |
| 781 | * Releases the call from hold if it is currently active. |
| 782 | */ |
| 783 | void unhold() { |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 784 | Preconditions.checkNotNull(mConnectionService); |
Yorke Lee | cdf3ebd | 2014-03-12 18:31:41 -0700 | [diff] [blame] | 785 | |
| 786 | if (mState == CallState.ON_HOLD) { |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 787 | mConnectionService.unhold(this); |
Yorke Lee | cdf3ebd | 2014-03-12 18:31:41 -0700 | [diff] [blame] | 788 | } |
| 789 | } |
| 790 | |
Sailesh Nepal | 6aca10a | 2014-03-24 16:11:02 -0700 | [diff] [blame] | 791 | /** Checks if this is a live call or not. */ |
| 792 | boolean isAlive() { |
| 793 | switch (mState) { |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 794 | case CallState.NEW: |
| 795 | case CallState.RINGING: |
| 796 | case CallState.DISCONNECTED: |
| 797 | case CallState.ABORTED: |
Sailesh Nepal | 6aca10a | 2014-03-24 16:11:02 -0700 | [diff] [blame] | 798 | return false; |
| 799 | default: |
| 800 | return true; |
| 801 | } |
| 802 | } |
| 803 | |
Santos Cordon | 40f78c2 | 2014-04-07 02:11:42 -0700 | [diff] [blame] | 804 | boolean isActive() { |
Ihab Awad | 84bfe47 | 2014-07-13 17:11:57 -0700 | [diff] [blame] | 805 | return mState == CallState.ACTIVE; |
Santos Cordon | 40f78c2 | 2014-04-07 02:11:42 -0700 | [diff] [blame] | 806 | } |
| 807 | |
Sailesh Nepal | 84fa5f8 | 2014-04-02 11:01:11 -0700 | [diff] [blame] | 808 | Bundle getExtras() { |
| 809 | return mExtras; |
| 810 | } |
| 811 | |
| 812 | void setExtras(Bundle extras) { |
| 813 | mExtras = extras; |
| 814 | } |
| 815 | |
Santos Cordon | 5ba7f27 | 2014-05-28 13:59:49 -0700 | [diff] [blame] | 816 | Uri getRingtone() { |
| 817 | return mCallerInfo == null ? null : mCallerInfo.contactRingtoneUri; |
| 818 | } |
| 819 | |
Evan Charlton | 352105c | 2014-06-03 14:10:54 -0700 | [diff] [blame] | 820 | void onPostDialWait(String remaining) { |
| 821 | for (Listener l : mListeners) { |
| 822 | l.onPostDialWait(this, remaining); |
| 823 | } |
| 824 | } |
| 825 | |
| 826 | void postDialContinue(boolean proceed) { |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 827 | mConnectionService.onPostDialContinue(this, proceed); |
Evan Charlton | 352105c | 2014-06-03 14:10:54 -0700 | [diff] [blame] | 828 | } |
| 829 | |
Sailesh Nepal | 77da19e | 2014-07-02 21:31:16 -0700 | [diff] [blame] | 830 | void phoneAccountClicked() { |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 831 | mConnectionService.onPhoneAccountClicked(this); |
Sailesh Nepal | 77da19e | 2014-07-02 21:31:16 -0700 | [diff] [blame] | 832 | } |
| 833 | |
Santos Cordon | 0fbe632 | 2014-08-14 04:04:25 -0700 | [diff] [blame] | 834 | void conferenceWith(Call otherCall) { |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 835 | if (mConnectionService == null) { |
| 836 | Log.w(this, "conference requested on a call without a connection service."); |
Santos Cordon | a161070 | 2014-06-04 20:22:56 -0700 | [diff] [blame] | 837 | } else { |
Santos Cordon | 0fbe632 | 2014-08-14 04:04:25 -0700 | [diff] [blame] | 838 | mConnectionService.conference(this, otherCall); |
Santos Cordon | a161070 | 2014-06-04 20:22:56 -0700 | [diff] [blame] | 839 | } |
| 840 | } |
| 841 | |
| 842 | void splitFromConference() { |
Santos Cordon | 672321e | 2014-08-21 14:38:58 -0700 | [diff] [blame] | 843 | if (mConnectionService == null) { |
| 844 | Log.w(this, "splitting from conference call without a connection service"); |
| 845 | } else { |
| 846 | mConnectionService.splitFromConference(this); |
| 847 | } |
Santos Cordon | a161070 | 2014-06-04 20:22:56 -0700 | [diff] [blame] | 848 | } |
| 849 | |
| 850 | void setParentCall(Call parentCall) { |
| 851 | if (parentCall == this) { |
| 852 | Log.e(this, new Exception(), "setting the parent to self"); |
| 853 | return; |
| 854 | } |
Santos Cordon | 0fbe632 | 2014-08-14 04:04:25 -0700 | [diff] [blame] | 855 | if (parentCall == mParentCall) { |
| 856 | // nothing to do |
| 857 | return; |
| 858 | } |
Santos Cordon | a161070 | 2014-06-04 20:22:56 -0700 | [diff] [blame] | 859 | Preconditions.checkState(parentCall == null || mParentCall == null); |
| 860 | |
| 861 | Call oldParent = mParentCall; |
| 862 | if (mParentCall != null) { |
| 863 | mParentCall.removeChildCall(this); |
| 864 | } |
| 865 | mParentCall = parentCall; |
| 866 | if (mParentCall != null) { |
| 867 | mParentCall.addChildCall(this); |
| 868 | } |
| 869 | |
| 870 | for (Listener l : mListeners) { |
| 871 | l.onParentChanged(this); |
| 872 | } |
| 873 | } |
| 874 | |
Santos Cordon | 12d6182 | 2014-07-29 16:02:20 -0700 | [diff] [blame] | 875 | void setConferenceableCalls(List<Call> conferenceableCalls) { |
| 876 | mConferenceableCalls.clear(); |
| 877 | mConferenceableCalls.addAll(conferenceableCalls); |
| 878 | } |
| 879 | |
| 880 | List<Call> getConferenceableCalls() { |
| 881 | return mConferenceableCalls; |
| 882 | } |
| 883 | |
Santos Cordon | a161070 | 2014-06-04 20:22:56 -0700 | [diff] [blame] | 884 | private void addChildCall(Call call) { |
| 885 | if (!mChildCalls.contains(call)) { |
| 886 | mChildCalls.add(call); |
| 887 | |
| 888 | for (Listener l : mListeners) { |
| 889 | l.onChildrenChanged(this); |
| 890 | } |
| 891 | } |
| 892 | } |
| 893 | |
| 894 | private void removeChildCall(Call call) { |
| 895 | if (mChildCalls.remove(call)) { |
| 896 | for (Listener l : mListeners) { |
| 897 | l.onChildrenChanged(this); |
| 898 | } |
| 899 | } |
| 900 | } |
| 901 | |
Santos Cordon | 0b03b4b | 2014-01-29 18:01:59 -0800 | [diff] [blame] | 902 | /** |
Ihab Awad | ff7493a | 2014-06-10 13:47:44 -0700 | [diff] [blame] | 903 | * Return whether the user can respond to this {@code Call} via an SMS message. |
| 904 | * |
| 905 | * @return true if the "Respond via SMS" feature should be enabled |
| 906 | * for this incoming call. |
| 907 | * |
| 908 | * The general rule is that we *do* allow "Respond via SMS" except for |
| 909 | * the few (relatively rare) cases where we know for sure it won't |
| 910 | * work, namely: |
| 911 | * - a bogus or blank incoming number |
| 912 | * - a call from a SIP address |
| 913 | * - a "call presentation" that doesn't allow the number to be revealed |
| 914 | * |
| 915 | * In all other cases, we allow the user to respond via SMS. |
| 916 | * |
| 917 | * Note that this behavior isn't perfect; for example we have no way |
| 918 | * to detect whether the incoming call is from a landline (with most |
| 919 | * networks at least), so we still enable this feature even though |
| 920 | * SMSes to that number will silently fail. |
| 921 | */ |
| 922 | boolean isRespondViaSmsCapable() { |
| 923 | if (mState != CallState.RINGING) { |
| 924 | return false; |
| 925 | } |
| 926 | |
| 927 | if (getHandle() == null) { |
| 928 | // No incoming number known or call presentation is "PRESENTATION_RESTRICTED", in |
| 929 | // other words, the user should not be able to see the incoming phone number. |
| 930 | return false; |
| 931 | } |
| 932 | |
| 933 | if (PhoneNumberUtils.isUriNumber(getHandle().toString())) { |
| 934 | // The incoming number is actually a URI (i.e. a SIP address), |
| 935 | // not a regular PSTN phone number, and we can't send SMSes to |
| 936 | // SIP addresses. |
| 937 | // (TODO: That might still be possible eventually, though. Is |
| 938 | // there some SIP-specific equivalent to sending a text message?) |
| 939 | return false; |
| 940 | } |
| 941 | |
| 942 | // Is there a valid SMS application on the phone? |
| 943 | if (SmsApplication.getDefaultRespondViaMessageApplication(TelecommApp.getInstance(), |
| 944 | true /*updateIfNeeded*/) == null) { |
| 945 | return false; |
| 946 | } |
| 947 | |
| 948 | // TODO: with some carriers (in certain countries) you *can* actually |
| 949 | // tell whether a given number is a mobile phone or not. So in that |
| 950 | // case we could potentially return false here if the incoming call is |
| 951 | // from a land line. |
| 952 | |
| 953 | // If none of the above special cases apply, it's OK to enable the |
| 954 | // "Respond via SMS" feature. |
| 955 | return true; |
| 956 | } |
| 957 | |
| 958 | List<String> getCannedSmsResponses() { |
| 959 | return mCannedSmsResponses; |
| 960 | } |
| 961 | |
| 962 | /** |
Santos Cordon | 672321e | 2014-08-21 14:38:58 -0700 | [diff] [blame] | 963 | * We need to make sure that before we move a call to the disconnected state, it no |
| 964 | * longer has any parent/child relationships. We want to do this to ensure that the InCall |
| 965 | * Service always has the right data in the right order. We also want to do it in telecomm so |
| 966 | * that the insurance policy lives in the framework side of things. |
| 967 | */ |
| 968 | private void fixParentAfterDisconnect() { |
| 969 | setParentCall(null); |
| 970 | } |
| 971 | |
| 972 | /** |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 973 | * @return True if the call is ringing, else logs the action name. |
| 974 | */ |
| 975 | private boolean isRinging(String actionName) { |
| 976 | if (mState == CallState.RINGING) { |
| 977 | return true; |
| 978 | } |
| 979 | |
Sailesh Nepal | f1c191d | 2014-03-07 18:17:39 -0800 | [diff] [blame] | 980 | Log.i(this, "Request to %s a non-ringing call %s", actionName, this); |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 981 | return false; |
| 982 | } |
| 983 | |
Ben Gilad | 8e55d1d | 2014-02-26 16:25:56 -0800 | [diff] [blame] | 984 | @SuppressWarnings("rawtypes") |
| 985 | private void decrementAssociatedCallCount(ServiceBinder binder) { |
| 986 | if (binder != null) { |
| 987 | binder.decrementAssociatedCallCount(); |
| 988 | } |
| 989 | } |
Santos Cordon | fd71f4a | 2014-05-28 13:59:49 -0700 | [diff] [blame] | 990 | |
| 991 | /** |
| 992 | * Looks up contact information based on the current handle. |
| 993 | */ |
| 994 | private void startCallerInfoLookup() { |
| 995 | String number = mHandle == null ? null : mHandle.getSchemeSpecificPart(); |
| 996 | |
| 997 | mQueryToken++; // Updated so that previous queries can no longer set the information. |
| 998 | mCallerInfo = null; |
| 999 | if (!TextUtils.isEmpty(number)) { |
Santos Cordon | 5ba7f27 | 2014-05-28 13:59:49 -0700 | [diff] [blame] | 1000 | Log.v(this, "Looking up information for: %s.", Log.piiHandle(number)); |
Santos Cordon | fd71f4a | 2014-05-28 13:59:49 -0700 | [diff] [blame] | 1001 | CallerInfoAsyncQuery.startQuery( |
| 1002 | mQueryToken, |
| 1003 | TelecommApp.getInstance(), |
| 1004 | number, |
| 1005 | sCallerInfoQueryListener, |
| 1006 | this); |
| 1007 | } |
| 1008 | } |
| 1009 | |
| 1010 | /** |
Santos Cordon | 99c8a6f | 2014-05-28 18:28:47 -0700 | [diff] [blame] | 1011 | * Saves the specified caller info if the specified token matches that of the last query |
Santos Cordon | fd71f4a | 2014-05-28 13:59:49 -0700 | [diff] [blame] | 1012 | * that was made. |
| 1013 | * |
| 1014 | * @param callerInfo The new caller information to set. |
| 1015 | * @param token The token used with this query. |
| 1016 | */ |
| 1017 | private void setCallerInfo(CallerInfo callerInfo, int token) { |
Santos Cordon | 99c8a6f | 2014-05-28 18:28:47 -0700 | [diff] [blame] | 1018 | Preconditions.checkNotNull(callerInfo); |
| 1019 | |
Santos Cordon | fd71f4a | 2014-05-28 13:59:49 -0700 | [diff] [blame] | 1020 | if (mQueryToken == token) { |
| 1021 | mCallerInfo = callerInfo; |
Santos Cordon | 5ba7f27 | 2014-05-28 13:59:49 -0700 | [diff] [blame] | 1022 | Log.i(this, "CallerInfo received for %s: %s", Log.piiHandle(mHandle), callerInfo); |
Santos Cordon | 99c8a6f | 2014-05-28 18:28:47 -0700 | [diff] [blame] | 1023 | |
Makoto Onuki | a1662d0 | 2014-07-10 15:31:59 -0700 | [diff] [blame] | 1024 | if (mCallerInfo.contactDisplayPhotoUri != null) { |
| 1025 | Log.d(this, "Searching person uri %s for call %s", |
| 1026 | mCallerInfo.contactDisplayPhotoUri, this); |
Santos Cordon | 99c8a6f | 2014-05-28 18:28:47 -0700 | [diff] [blame] | 1027 | ContactsAsyncHelper.startObtainPhotoAsync( |
| 1028 | token, |
| 1029 | TelecommApp.getInstance(), |
Makoto Onuki | a1662d0 | 2014-07-10 15:31:59 -0700 | [diff] [blame] | 1030 | mCallerInfo.contactDisplayPhotoUri, |
Santos Cordon | 99c8a6f | 2014-05-28 18:28:47 -0700 | [diff] [blame] | 1031 | sPhotoLoadListener, |
| 1032 | this); |
Makoto Onuki | a1662d0 | 2014-07-10 15:31:59 -0700 | [diff] [blame] | 1033 | // Do not call onCallerInfoChanged yet in this case. We call it in setPhoto(). |
Santos Cordon | 64c7e96 | 2014-07-02 15:15:27 -0700 | [diff] [blame] | 1034 | } else { |
| 1035 | for (Listener l : mListeners) { |
| 1036 | l.onCallerInfoChanged(this); |
| 1037 | } |
Santos Cordon | 99c8a6f | 2014-05-28 18:28:47 -0700 | [diff] [blame] | 1038 | } |
Santos Cordon | 2174fb5 | 2014-05-29 08:22:56 -0700 | [diff] [blame] | 1039 | |
| 1040 | processDirectToVoicemail(); |
Santos Cordon | 99c8a6f | 2014-05-28 18:28:47 -0700 | [diff] [blame] | 1041 | } |
| 1042 | } |
| 1043 | |
Yorke Lee | 6f3f7af | 2014-07-11 10:59:46 -0700 | [diff] [blame] | 1044 | CallerInfo getCallerInfo() { |
| 1045 | return mCallerInfo; |
| 1046 | } |
| 1047 | |
Santos Cordon | 99c8a6f | 2014-05-28 18:28:47 -0700 | [diff] [blame] | 1048 | /** |
| 1049 | * Saves the specified photo information if the specified token matches that of the last query. |
| 1050 | * |
| 1051 | * @param photo The photo as a drawable. |
| 1052 | * @param photoIcon The photo as a small icon. |
| 1053 | * @param token The token used with this query. |
| 1054 | */ |
| 1055 | private void setPhoto(Drawable photo, Bitmap photoIcon, int token) { |
| 1056 | if (mQueryToken == token) { |
| 1057 | mCallerInfo.cachedPhoto = photo; |
| 1058 | mCallerInfo.cachedPhotoIcon = photoIcon; |
Santos Cordon | 64c7e96 | 2014-07-02 15:15:27 -0700 | [diff] [blame] | 1059 | |
| 1060 | for (Listener l : mListeners) { |
| 1061 | l.onCallerInfoChanged(this); |
| 1062 | } |
Santos Cordon | fd71f4a | 2014-05-28 13:59:49 -0700 | [diff] [blame] | 1063 | } |
| 1064 | } |
Ihab Awad | ff7493a | 2014-06-10 13:47:44 -0700 | [diff] [blame] | 1065 | |
| 1066 | private void maybeLoadCannedSmsResponses() { |
| 1067 | if (mIsIncoming && isRespondViaSmsCapable() && !mCannedSmsResponsesLoadingStarted) { |
| 1068 | Log.d(this, "maybeLoadCannedSmsResponses: starting task to load messages"); |
| 1069 | mCannedSmsResponsesLoadingStarted = true; |
| 1070 | RespondViaSmsManager.getInstance().loadCannedTextMessages( |
| 1071 | new Response<Void, List<String>>() { |
| 1072 | @Override |
| 1073 | public void onResult(Void request, List<String>... result) { |
| 1074 | if (result.length > 0) { |
| 1075 | Log.d(this, "maybeLoadCannedSmsResponses: got %s", result[0]); |
| 1076 | mCannedSmsResponses = result[0]; |
| 1077 | for (Listener l : mListeners) { |
| 1078 | l.onCannedSmsResponsesLoaded(Call.this); |
| 1079 | } |
| 1080 | } |
| 1081 | } |
| 1082 | |
| 1083 | @Override |
| 1084 | public void onError(Void request, int code, String msg) { |
| 1085 | Log.w(Call.this, "Error obtaining canned SMS responses: %d %s", code, |
| 1086 | msg); |
| 1087 | } |
| 1088 | } |
| 1089 | ); |
| 1090 | } else { |
| 1091 | Log.d(this, "maybeLoadCannedSmsResponses: doing nothing"); |
| 1092 | } |
| 1093 | } |
Sai Cheemalapati | b7157e9 | 2014-06-11 17:51:55 -0700 | [diff] [blame] | 1094 | |
| 1095 | /** |
| 1096 | * Sets speakerphone option on when call begins. |
| 1097 | */ |
| 1098 | public void setStartWithSpeakerphoneOn(boolean startWithSpeakerphone) { |
| 1099 | mSpeakerphoneOn = startWithSpeakerphone; |
| 1100 | } |
| 1101 | |
| 1102 | /** |
| 1103 | * Returns speakerphone option. |
| 1104 | * |
| 1105 | * @return Whether or not speakerphone should be set automatically when call begins. |
| 1106 | */ |
| 1107 | public boolean getStartWithSpeakerphoneOn() { |
| 1108 | return mSpeakerphoneOn; |
| 1109 | } |
Andrew Lee | e9a7765 | 2014-06-26 13:07:57 -0700 | [diff] [blame] | 1110 | |
| 1111 | /** |
Andrew Lee | 3bcf935 | 2014-07-23 12:36:05 -0700 | [diff] [blame] | 1112 | * Sets a video call provider for the call. |
Andrew Lee | e9a7765 | 2014-06-26 13:07:57 -0700 | [diff] [blame] | 1113 | */ |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 1114 | public void setVideoProvider(IVideoProvider videoProvider) { |
| 1115 | mVideoProvider = videoProvider; |
Nancy Chen | a65d41f | 2014-06-24 12:06:03 -0700 | [diff] [blame] | 1116 | for (Listener l : mListeners) { |
Andrew Lee | 3bcf935 | 2014-07-23 12:36:05 -0700 | [diff] [blame] | 1117 | l.onVideoCallProviderChanged(Call.this); |
Nancy Chen | a65d41f | 2014-06-24 12:06:03 -0700 | [diff] [blame] | 1118 | } |
| 1119 | } |
| 1120 | |
| 1121 | /** |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 1122 | * @return Return the {@link Connection.VideoProvider} binder. |
Nancy Chen | a65d41f | 2014-06-24 12:06:03 -0700 | [diff] [blame] | 1123 | */ |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 1124 | public IVideoProvider getVideoProvider() { |
| 1125 | return mVideoProvider; |
Andrew Lee | e9a7765 | 2014-06-26 13:07:57 -0700 | [diff] [blame] | 1126 | } |
Tyler Gunn | e19cc00 | 2014-07-01 11:32:53 -0700 | [diff] [blame] | 1127 | |
| 1128 | /** |
Tyler Gunn | c4abd91 | 2014-07-08 14:22:10 -0700 | [diff] [blame] | 1129 | * The current video state for the call. |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 1130 | * Valid values: see {@link VideoProfile.VideoState}. |
Tyler Gunn | c4abd91 | 2014-07-08 14:22:10 -0700 | [diff] [blame] | 1131 | */ |
| 1132 | public int getVideoState() { |
| 1133 | return mVideoState; |
| 1134 | } |
| 1135 | |
| 1136 | /** |
Tyler Gunn | 0a388fc | 2014-07-17 12:21:17 -0700 | [diff] [blame] | 1137 | * Returns the video states which were applicable over the duration of a call. |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 1138 | * See {@link VideoProfile} for a list of valid video states. |
Tyler Gunn | 0a388fc | 2014-07-17 12:21:17 -0700 | [diff] [blame] | 1139 | * |
| 1140 | * @return The video states applicable over the duration of the call. |
| 1141 | */ |
| 1142 | public int getVideoStateHistory() { |
| 1143 | return mVideoStateHistory; |
| 1144 | } |
| 1145 | |
| 1146 | /** |
| 1147 | * Determines the current video state for the call. |
| 1148 | * For an outgoing call determines the desired video state for the call. |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 1149 | * Valid values: see {@link VideoProfile.VideoState} |
Tyler Gunn | c4abd91 | 2014-07-08 14:22:10 -0700 | [diff] [blame] | 1150 | * |
Tyler Gunn | 0a388fc | 2014-07-17 12:21:17 -0700 | [diff] [blame] | 1151 | * @param videoState The video state for the call. |
Tyler Gunn | c4abd91 | 2014-07-08 14:22:10 -0700 | [diff] [blame] | 1152 | */ |
| 1153 | public void setVideoState(int videoState) { |
Tyler Gunn | 0a388fc | 2014-07-17 12:21:17 -0700 | [diff] [blame] | 1154 | // Track which video states were applicable over the duration of the call. |
| 1155 | mVideoStateHistory = mVideoStateHistory | videoState; |
| 1156 | |
Tyler Gunn | c4abd91 | 2014-07-08 14:22:10 -0700 | [diff] [blame] | 1157 | mVideoState = videoState; |
Andrew Lee | 4a79660 | 2014-07-11 17:23:03 -0700 | [diff] [blame] | 1158 | for (Listener l : mListeners) { |
| 1159 | l.onVideoStateChanged(this); |
| 1160 | } |
Tyler Gunn | c4abd91 | 2014-07-08 14:22:10 -0700 | [diff] [blame] | 1161 | } |
Sailesh Nepal | 7e66957 | 2014-07-08 21:29:12 -0700 | [diff] [blame] | 1162 | |
| 1163 | public boolean getAudioModeIsVoip() { |
| 1164 | return mAudioModeIsVoip; |
| 1165 | } |
| 1166 | |
| 1167 | public void setAudioModeIsVoip(boolean audioModeIsVoip) { |
| 1168 | mAudioModeIsVoip = audioModeIsVoip; |
| 1169 | for (Listener l : mListeners) { |
Sailesh Nepal | 35faf8c | 2014-07-08 22:02:34 -0700 | [diff] [blame] | 1170 | l.onAudioModeIsVoipChanged(this); |
| 1171 | } |
| 1172 | } |
| 1173 | |
| 1174 | public StatusHints getStatusHints() { |
| 1175 | return mStatusHints; |
| 1176 | } |
| 1177 | |
| 1178 | public void setStatusHints(StatusHints statusHints) { |
| 1179 | mStatusHints = statusHints; |
| 1180 | for (Listener l : mListeners) { |
| 1181 | l.onStatusHintsChanged(this); |
Sailesh Nepal | 7e66957 | 2014-07-08 21:29:12 -0700 | [diff] [blame] | 1182 | } |
| 1183 | } |
Sailesh Nepal | 9d58de5 | 2014-07-18 14:53:19 -0700 | [diff] [blame] | 1184 | |
| 1185 | public void startActivityFromInCall(PendingIntent intent) { |
| 1186 | if (intent.isActivity()) { |
| 1187 | for (Listener l : mListeners) { |
| 1188 | l.onStartActivityFromInCall(this, intent); |
| 1189 | } |
| 1190 | } else { |
| 1191 | Log.w(this, "startActivityFromInCall, activity intent required"); |
| 1192 | } |
| 1193 | } |
Santos Cordon | 72890ce | 2014-07-21 01:32:04 -0700 | [diff] [blame] | 1194 | |
Santos Cordon | 0fbe632 | 2014-08-14 04:04:25 -0700 | [diff] [blame] | 1195 | static int getStateFromConnectionState(int state) { |
Santos Cordon | 72890ce | 2014-07-21 01:32:04 -0700 | [diff] [blame] | 1196 | switch (state) { |
Ihab Awad | a02bef5 | 2014-08-13 18:18:42 -0700 | [diff] [blame] | 1197 | case Connection.STATE_INITIALIZING: |
| 1198 | return CallState.CONNECTING; |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 1199 | case Connection.STATE_ACTIVE: |
Santos Cordon | 72890ce | 2014-07-21 01:32:04 -0700 | [diff] [blame] | 1200 | return CallState.ACTIVE; |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 1201 | case Connection.STATE_DIALING: |
Santos Cordon | 72890ce | 2014-07-21 01:32:04 -0700 | [diff] [blame] | 1202 | return CallState.DIALING; |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 1203 | case Connection.STATE_DISCONNECTED: |
Santos Cordon | 72890ce | 2014-07-21 01:32:04 -0700 | [diff] [blame] | 1204 | return CallState.DISCONNECTED; |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 1205 | case Connection.STATE_HOLDING: |
Santos Cordon | 72890ce | 2014-07-21 01:32:04 -0700 | [diff] [blame] | 1206 | return CallState.ON_HOLD; |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 1207 | case Connection.STATE_NEW: |
Santos Cordon | 72890ce | 2014-07-21 01:32:04 -0700 | [diff] [blame] | 1208 | return CallState.NEW; |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 1209 | case Connection.STATE_RINGING: |
Santos Cordon | 72890ce | 2014-07-21 01:32:04 -0700 | [diff] [blame] | 1210 | return CallState.RINGING; |
| 1211 | } |
| 1212 | return CallState.DISCONNECTED; |
| 1213 | } |
Ben Gilad | 9f2bed3 | 2013-12-12 17:43:26 -0800 | [diff] [blame] | 1214 | } |