Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.phone; |
| 18 | |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 19 | import android.os.AsyncResult; |
| 20 | import android.os.Handler; |
| 21 | import android.os.Message; |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 22 | import android.os.SystemProperties; |
Christine Chen | af2fd0a | 2013-09-13 16:27:40 -0700 | [diff] [blame] | 23 | import android.telephony.PhoneNumberUtils; |
Santos Cordon | e38b1ff | 2013-08-07 12:12:16 -0700 | [diff] [blame] | 24 | import android.text.TextUtils; |
| 25 | import android.util.Log; |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 26 | |
Santos Cordon | a3d0514 | 2013-07-29 11:25:17 -0700 | [diff] [blame] | 27 | import com.android.internal.telephony.CallManager; |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 28 | import com.android.internal.telephony.Connection; |
Santos Cordon | eead6ec | 2013-08-07 22:16:33 -0700 | [diff] [blame] | 29 | import com.android.internal.telephony.Phone; |
Santos Cordon | a3d0514 | 2013-07-29 11:25:17 -0700 | [diff] [blame] | 30 | import com.android.internal.telephony.PhoneConstants; |
Santos Cordon | a5d5db8 | 2013-09-15 13:00:34 -0700 | [diff] [blame] | 31 | import com.android.internal.telephony.TelephonyCapabilities; |
| 32 | import com.android.internal.telephony.cdma.CdmaCallWaitingNotification; |
Santos Cordon | 69a6919 | 2013-08-22 14:25:42 -0700 | [diff] [blame] | 33 | import com.android.phone.CallGatewayManager.RawGatewayInfo; |
Santos Cordon | 995c816 | 2013-07-29 09:22:22 -0700 | [diff] [blame] | 34 | import com.android.services.telephony.common.Call; |
Santos Cordon | 26e7b24 | 2013-08-07 21:15:45 -0700 | [diff] [blame] | 35 | import com.android.services.telephony.common.Call.Capabilities; |
Santos Cordon | a3d0514 | 2013-07-29 11:25:17 -0700 | [diff] [blame] | 36 | import com.android.services.telephony.common.Call.State; |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 37 | |
Yorke Lee | 814da30 | 2013-08-30 16:01:07 -0700 | [diff] [blame] | 38 | import com.google.android.collect.Maps; |
Santos Cordon | 2500858 | 2013-11-12 13:39:40 -0800 | [diff] [blame] | 39 | import com.google.android.collect.Sets; |
Yorke Lee | 814da30 | 2013-08-30 16:01:07 -0700 | [diff] [blame] | 40 | import com.google.common.base.Preconditions; |
| 41 | import com.google.common.collect.ImmutableMap; |
| 42 | import com.google.common.collect.ImmutableSortedSet; |
Santos Cordon | ad1ed6d | 2013-09-16 03:04:23 -0700 | [diff] [blame] | 43 | import com.google.common.collect.Lists; |
Yorke Lee | 814da30 | 2013-08-30 16:01:07 -0700 | [diff] [blame] | 44 | |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 45 | import java.util.ArrayList; |
Santos Cordon | ad1ed6d | 2013-09-16 03:04:23 -0700 | [diff] [blame] | 46 | import java.util.Collections; |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 47 | import java.util.HashMap; |
| 48 | import java.util.List; |
Santos Cordon | 249efd0 | 2013-08-05 03:33:56 -0700 | [diff] [blame] | 49 | import java.util.Map.Entry; |
Santos Cordon | 2500858 | 2013-11-12 13:39:40 -0800 | [diff] [blame] | 50 | import java.util.Set; |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 51 | import java.util.concurrent.atomic.AtomicInteger; |
| 52 | |
| 53 | /** |
| 54 | * Creates a Call model from Call state and data received from the telephony |
| 55 | * layer. The telephony layer maintains 3 conceptual objects: Phone, Call, |
| 56 | * Connection. |
| 57 | * |
| 58 | * Phone represents the radio and there is an implementation per technology |
| 59 | * type such as GSMPhone, SipPhone, CDMAPhone, etc. Generally, we will only ever |
| 60 | * deal with one instance of this object for the lifetime of this class. |
| 61 | * |
| 62 | * There are 3 Call instances that exist for the lifetime of this class which |
| 63 | * are created by CallTracker. The three are RingingCall, ForegroundCall, and |
| 64 | * BackgroundCall. |
| 65 | * |
| 66 | * A Connection most closely resembles what the layperson would consider a call. |
| 67 | * A Connection is created when a user dials and it is "owned" by one of the |
| 68 | * three Call instances. Which of the three Calls owns the Connection changes |
| 69 | * as the Connection goes between ACTIVE, HOLD, RINGING, and other states. |
| 70 | * |
| 71 | * This class models a new Call class from Connection objects received from |
| 72 | * the telephony layer. We use Connection references as identifiers for a call; |
| 73 | * new reference = new call. |
| 74 | * |
Christine Chen | 91db67d | 2013-09-18 12:01:11 -0700 | [diff] [blame] | 75 | * TODO: Create a new Call class to replace the simple call Id ints |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 76 | * being used currently. |
| 77 | * |
| 78 | * The new Call models are parcellable for transfer via the CallHandlerService |
| 79 | * API. |
| 80 | */ |
| 81 | public class CallModeler extends Handler { |
| 82 | |
| 83 | private static final String TAG = CallModeler.class.getSimpleName(); |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 84 | private static final boolean DBG = |
| 85 | (PhoneGlobals.DBG_LEVEL >= 1) && (SystemProperties.getInt("ro.debuggable", 0) == 1); |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 86 | |
| 87 | private static final int CALL_ID_START_VALUE = 1; |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 88 | |
Santos Cordon | 998f42b | 2013-08-02 16:13:12 -0700 | [diff] [blame] | 89 | private final CallStateMonitor mCallStateMonitor; |
| 90 | private final CallManager mCallManager; |
Santos Cordon | 69a6919 | 2013-08-22 14:25:42 -0700 | [diff] [blame] | 91 | private final CallGatewayManager mCallGatewayManager; |
Santos Cordon | 998f42b | 2013-08-02 16:13:12 -0700 | [diff] [blame] | 92 | private final HashMap<Connection, Call> mCallMap = Maps.newHashMap(); |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 93 | private final HashMap<Connection, Call> mConfCallMap = Maps.newHashMap(); |
Santos Cordon | 998f42b | 2013-08-02 16:13:12 -0700 | [diff] [blame] | 94 | private final AtomicInteger mNextCallId = new AtomicInteger(CALL_ID_START_VALUE); |
Christine Chen | daf7bf6 | 2013-08-05 19:12:31 -0700 | [diff] [blame] | 95 | private final ArrayList<Listener> mListeners = new ArrayList<Listener>(); |
Santos Cordon | a5d5db8 | 2013-09-15 13:00:34 -0700 | [diff] [blame] | 96 | private Connection mCdmaIncomingConnection; |
Santos Cordon | ad1ed6d | 2013-09-16 03:04:23 -0700 | [diff] [blame] | 97 | private Connection mCdmaOutgoingConnection; |
Sailesh Nepal | 1eaf22b | 2014-02-22 17:00:49 -0800 | [diff] [blame^] | 98 | // TODO(sail): Temporary flag to disable sending telephony updates when Telecomm is being used. |
| 99 | private boolean mShouldDisableUpdates; |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 100 | |
Christine Chen | ee09a49 | 2013-08-06 16:02:29 -0700 | [diff] [blame] | 101 | public CallModeler(CallStateMonitor callStateMonitor, CallManager callManager, |
Santos Cordon | 69a6919 | 2013-08-22 14:25:42 -0700 | [diff] [blame] | 102 | CallGatewayManager callGatewayManager) { |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 103 | mCallStateMonitor = callStateMonitor; |
Santos Cordon | a3d0514 | 2013-07-29 11:25:17 -0700 | [diff] [blame] | 104 | mCallManager = callManager; |
Santos Cordon | 69a6919 | 2013-08-22 14:25:42 -0700 | [diff] [blame] | 105 | mCallGatewayManager = callGatewayManager; |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 106 | |
| 107 | mCallStateMonitor.addListener(this); |
| 108 | } |
| 109 | |
Sailesh Nepal | 1eaf22b | 2014-02-22 17:00:49 -0800 | [diff] [blame^] | 110 | public void setShouldDisableUpdates(boolean shouldDisableUpdates) { |
| 111 | Log.i(TAG, "setShouldDisableUpdates " + mShouldDisableUpdates + " -> " + |
| 112 | shouldDisableUpdates); |
| 113 | mShouldDisableUpdates = shouldDisableUpdates; |
| 114 | } |
| 115 | |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 116 | @Override |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 117 | public void handleMessage(Message msg) { |
| 118 | switch(msg.what) { |
| 119 | case CallStateMonitor.PHONE_NEW_RINGING_CONNECTION: |
Christine Chen | fb0cc2b | 2013-09-16 14:21:29 -0700 | [diff] [blame] | 120 | // We let the CallNotifier handle the new ringing connection first. When the custom |
| 121 | // ringtone and send_to_voicemail settings are retrieved, CallNotifier will directly |
| 122 | // call CallModeler's onNewRingingConnection. |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 123 | break; |
| 124 | case CallStateMonitor.PHONE_DISCONNECT: |
Santos Cordon | a5d5db8 | 2013-09-15 13:00:34 -0700 | [diff] [blame] | 125 | onDisconnect((Connection) ((AsyncResult) msg.obj).result); |
Santos Cordon | 995c816 | 2013-07-29 09:22:22 -0700 | [diff] [blame] | 126 | break; |
Santos Cordon | 54fdb59 | 2013-09-19 05:16:18 -0700 | [diff] [blame] | 127 | case CallStateMonitor.PHONE_UNKNOWN_CONNECTION_APPEARED: |
| 128 | // fall through |
Santos Cordon | 995c816 | 2013-07-29 09:22:22 -0700 | [diff] [blame] | 129 | case CallStateMonitor.PHONE_STATE_CHANGED: |
| 130 | onPhoneStateChanged((AsyncResult) msg.obj); |
| 131 | break; |
Chiao Cheng | 3f015c9 | 2013-09-06 15:56:27 -0700 | [diff] [blame] | 132 | case CallStateMonitor.PHONE_ON_DIAL_CHARS: |
| 133 | onPostDialChars((AsyncResult) msg.obj, (char) msg.arg1); |
| 134 | break; |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 135 | default: |
| 136 | break; |
| 137 | } |
| 138 | } |
| 139 | |
Christine Chen | daf7bf6 | 2013-08-05 19:12:31 -0700 | [diff] [blame] | 140 | public void addListener(Listener listener) { |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 141 | Preconditions.checkNotNull(listener); |
Christine Chen | daf7bf6 | 2013-08-05 19:12:31 -0700 | [diff] [blame] | 142 | Preconditions.checkNotNull(mListeners); |
Christine Chen | 4748abd | 2013-08-07 15:44:15 -0700 | [diff] [blame] | 143 | if (!mListeners.contains(listener)) { |
| 144 | mListeners.add(listener); |
| 145 | } |
Santos Cordon | 998f42b | 2013-08-02 16:13:12 -0700 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | public List<Call> getFullList() { |
Santos Cordon | ad1ed6d | 2013-09-16 03:04:23 -0700 | [diff] [blame] | 149 | final List<Call> calls = |
| 150 | Lists.newArrayListWithCapacity(mCallMap.size() + mConfCallMap.size()); |
| 151 | calls.addAll(mCallMap.values()); |
| 152 | calls.addAll(mConfCallMap.values()); |
| 153 | return calls; |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 154 | } |
| 155 | |
Santos Cordon | 249efd0 | 2013-08-05 03:33:56 -0700 | [diff] [blame] | 156 | public CallResult getCallWithId(int callId) { |
| 157 | // max 8 connections, so this should be fast even through we are traversing the entire map. |
| 158 | for (Entry<Connection, Call> entry : mCallMap.entrySet()) { |
| 159 | if (entry.getValue().getCallId() == callId) { |
| 160 | return new CallResult(entry.getValue(), entry.getKey()); |
| 161 | } |
| 162 | } |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 163 | |
| 164 | for (Entry<Connection, Call> entry : mConfCallMap.entrySet()) { |
| 165 | if (entry.getValue().getCallId() == callId) { |
Christine Chen | 6905020 | 2013-09-14 15:36:35 -0700 | [diff] [blame] | 166 | return new CallResult(entry.getValue(), entry.getKey()); |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 167 | } |
| 168 | } |
Santos Cordon | 249efd0 | 2013-08-05 03:33:56 -0700 | [diff] [blame] | 169 | return null; |
| 170 | } |
| 171 | |
Santos Cordon | af763a1 | 2013-08-19 20:04:58 -0700 | [diff] [blame] | 172 | public boolean hasLiveCall() { |
| 173 | return hasLiveCallInternal(mCallMap) || |
| 174 | hasLiveCallInternal(mConfCallMap); |
| 175 | } |
| 176 | |
Santos Cordon | a5d5db8 | 2013-09-15 13:00:34 -0700 | [diff] [blame] | 177 | public void onCdmaCallWaiting(CdmaCallWaitingNotification callWaitingInfo) { |
| 178 | // We dont get the traditional onIncomingCall notification for cdma call waiting, |
| 179 | // but the Connection does actually exist. We need to find it in the set of ringing calls |
| 180 | // and pass it through our normal incoming logic. |
| 181 | final com.android.internal.telephony.Call teleCall = |
| 182 | mCallManager.getFirstActiveRingingCall(); |
| 183 | |
| 184 | if (teleCall.getState() == com.android.internal.telephony.Call.State.WAITING) { |
| 185 | Connection connection = teleCall.getLatestConnection(); |
| 186 | |
| 187 | if (connection != null) { |
| 188 | String number = connection.getAddress(); |
| 189 | if (number != null && number.equals(callWaitingInfo.number)) { |
| 190 | Call call = onNewRingingConnection(connection); |
| 191 | mCdmaIncomingConnection = connection; |
| 192 | return; |
| 193 | } |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | Log.e(TAG, "CDMA Call waiting notification without a matching connection."); |
| 198 | } |
| 199 | |
| 200 | public void onCdmaCallWaitingReject() { |
| 201 | // Cdma call was rejected... |
| 202 | if (mCdmaIncomingConnection != null) { |
| 203 | onDisconnect(mCdmaIncomingConnection); |
| 204 | mCdmaIncomingConnection = null; |
| 205 | } else { |
| 206 | Log.e(TAG, "CDMA Call waiting rejection without an incoming call."); |
| 207 | } |
| 208 | } |
| 209 | |
Santos Cordon | ad1ed6d | 2013-09-16 03:04:23 -0700 | [diff] [blame] | 210 | /** |
| 211 | * CDMA Calls have no sense of "dialing" state. For outgoing calls 3way calls we want to |
| 212 | * mimick this state so that the the UI can notify the user that there is a "dialing" |
| 213 | * call. |
| 214 | */ |
| 215 | public void setCdmaOutgoing3WayCall(Connection connection) { |
| 216 | boolean wasSet = mCdmaOutgoingConnection != null; |
| 217 | |
| 218 | mCdmaOutgoingConnection = connection; |
| 219 | |
| 220 | // If we reset the connection, that mean we can now tell the user that the call is actually |
| 221 | // part of the conference call and move it out of the dialing state. To do this, issue a |
| 222 | // new update completely. |
| 223 | if (wasSet && mCdmaOutgoingConnection == null) { |
| 224 | onPhoneStateChanged(null); |
| 225 | } |
| 226 | } |
| 227 | |
Santos Cordon | af763a1 | 2013-08-19 20:04:58 -0700 | [diff] [blame] | 228 | private boolean hasLiveCallInternal(HashMap<Connection, Call> map) { |
| 229 | for (Call call : map.values()) { |
| 230 | final int state = call.getState(); |
| 231 | if (state == Call.State.ACTIVE || |
| 232 | state == Call.State.CALL_WAITING || |
| 233 | state == Call.State.CONFERENCED || |
| 234 | state == Call.State.DIALING || |
Santos Cordon | ce02f3a | 2013-09-19 01:58:42 -0700 | [diff] [blame] | 235 | state == Call.State.REDIALING || |
Santos Cordon | af763a1 | 2013-08-19 20:04:58 -0700 | [diff] [blame] | 236 | state == Call.State.INCOMING || |
Christine Chen | 3e0f041 | 2013-09-18 20:33:49 -0700 | [diff] [blame] | 237 | state == Call.State.ONHOLD || |
| 238 | state == Call.State.DISCONNECTING) { |
Santos Cordon | af763a1 | 2013-08-19 20:04:58 -0700 | [diff] [blame] | 239 | return true; |
| 240 | } |
| 241 | } |
| 242 | return false; |
| 243 | } |
| 244 | |
Santos Cordon | 2b73bd6 | 2013-08-27 14:53:43 -0700 | [diff] [blame] | 245 | public boolean hasOutstandingActiveOrDialingCall() { |
| 246 | return hasOutstandingActiveOrDialingCallInternal(mCallMap) || |
| 247 | hasOutstandingActiveOrDialingCallInternal(mConfCallMap); |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 248 | } |
| 249 | |
Santos Cordon | 2b73bd6 | 2013-08-27 14:53:43 -0700 | [diff] [blame] | 250 | private static boolean hasOutstandingActiveOrDialingCallInternal( |
| 251 | HashMap<Connection, Call> map) { |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 252 | for (Call call : map.values()) { |
| 253 | final int state = call.getState(); |
Santos Cordon | ce02f3a | 2013-09-19 01:58:42 -0700 | [diff] [blame] | 254 | if (state == Call.State.ACTIVE || Call.State.isDialing(state)) { |
Santos Cordon | 2eaff90 | 2013-08-05 04:37:55 -0700 | [diff] [blame] | 255 | return true; |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | return false; |
| 260 | } |
| 261 | |
Chiao Cheng | 3f015c9 | 2013-09-06 15:56:27 -0700 | [diff] [blame] | 262 | |
| 263 | /** |
| 264 | * Handles the POST_ON_DIAL_CHARS message from the Phone (see our call to |
| 265 | * mPhone.setOnPostDialCharacter() above.) |
| 266 | * |
| 267 | * TODO: NEED TO TEST THIS SEQUENCE now that we no longer handle "dialable" key events here in |
| 268 | * the InCallScreen: we do directly to the Dialer UI instead. Similarly, we may now need to go |
| 269 | * directly to the Dialer to handle POST_ON_DIAL_CHARS too. |
| 270 | */ |
| 271 | private void onPostDialChars(AsyncResult r, char ch) { |
| 272 | final Connection c = (Connection) r.result; |
| 273 | |
| 274 | if (c != null) { |
| 275 | final Connection.PostDialState state = (Connection.PostDialState) r.userObj; |
| 276 | |
| 277 | switch (state) { |
Chiao Cheng | 3f015c9 | 2013-09-06 15:56:27 -0700 | [diff] [blame] | 278 | case WAIT: |
| 279 | final Call call = getCallFromMap(mCallMap, c, false); |
| 280 | if (call == null) { |
| 281 | Log.i(TAG, "Call no longer exists. Skipping onPostDialWait()."); |
Sailesh Nepal | 1eaf22b | 2014-02-22 17:00:49 -0800 | [diff] [blame^] | 282 | } else if (!mShouldDisableUpdates) { |
Chiao Cheng | 3f015c9 | 2013-09-06 15:56:27 -0700 | [diff] [blame] | 283 | for (Listener mListener : mListeners) { |
Yorke Lee | de41f67 | 2013-09-19 13:46:55 -0700 | [diff] [blame] | 284 | mListener.onPostDialAction(state, call.getCallId(), |
| 285 | c.getRemainingPostDialString(), ch); |
Chiao Cheng | 3f015c9 | 2013-09-06 15:56:27 -0700 | [diff] [blame] | 286 | } |
| 287 | } |
| 288 | break; |
Chiao Cheng | 3f015c9 | 2013-09-06 15:56:27 -0700 | [diff] [blame] | 289 | default: |
Yorke Lee | de41f67 | 2013-09-19 13:46:55 -0700 | [diff] [blame] | 290 | // This is primarily to cause the DTMFTonePlayer to play local tones. |
| 291 | // Other listeners simply perform no-ops. |
Sailesh Nepal | 1eaf22b | 2014-02-22 17:00:49 -0800 | [diff] [blame^] | 292 | if (!mShouldDisableUpdates) { |
| 293 | for (Listener mListener : mListeners) { |
| 294 | mListener.onPostDialAction(state, 0, "", ch); |
| 295 | } |
Yorke Lee | de41f67 | 2013-09-19 13:46:55 -0700 | [diff] [blame] | 296 | } |
Chiao Cheng | 3f015c9 | 2013-09-06 15:56:27 -0700 | [diff] [blame] | 297 | break; |
| 298 | } |
| 299 | } |
| 300 | } |
| 301 | |
Christine Chen | fb0cc2b | 2013-09-16 14:21:29 -0700 | [diff] [blame] | 302 | /* package */ Call onNewRingingConnection(Connection conn) { |
Santos Cordon | 2b73bd6 | 2013-08-27 14:53:43 -0700 | [diff] [blame] | 303 | Log.i(TAG, "onNewRingingConnection"); |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 304 | final Call call = getCallFromMap(mCallMap, conn, true); |
Santos Cordon | e38b1ff | 2013-08-07 12:12:16 -0700 | [diff] [blame] | 305 | |
Christine Chen | fb0cc2b | 2013-09-16 14:21:29 -0700 | [diff] [blame] | 306 | if (call != null) { |
| 307 | updateCallFromConnection(call, conn, false); |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 308 | |
Sailesh Nepal | 1eaf22b | 2014-02-22 17:00:49 -0800 | [diff] [blame^] | 309 | if (!mShouldDisableUpdates) { |
| 310 | for (int i = 0; i < mListeners.size(); ++i) { |
| 311 | mListeners.get(i).onIncoming(call); |
| 312 | } |
Christine Chen | ee09a49 | 2013-08-06 16:02:29 -0700 | [diff] [blame] | 313 | } |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 314 | } |
Santos Cordon | a5d5db8 | 2013-09-15 13:00:34 -0700 | [diff] [blame] | 315 | |
Santos Cordon | 24a92b3 | 2013-09-26 16:48:14 -0700 | [diff] [blame] | 316 | PhoneGlobals.getInstance().updateWakeState(); |
Santos Cordon | a5d5db8 | 2013-09-15 13:00:34 -0700 | [diff] [blame] | 317 | return call; |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 318 | } |
| 319 | |
Santos Cordon | a5d5db8 | 2013-09-15 13:00:34 -0700 | [diff] [blame] | 320 | private void onDisconnect(Connection conn) { |
Santos Cordon | 2b73bd6 | 2013-08-27 14:53:43 -0700 | [diff] [blame] | 321 | Log.i(TAG, "onDisconnect"); |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 322 | final Call call = getCallFromMap(mCallMap, conn, false); |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 323 | |
Santos Cordon | 995c816 | 2013-07-29 09:22:22 -0700 | [diff] [blame] | 324 | if (call != null) { |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 325 | final boolean wasConferenced = call.getState() == State.CONFERENCED; |
| 326 | |
| 327 | updateCallFromConnection(call, conn, false); |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 328 | |
Sailesh Nepal | 1eaf22b | 2014-02-22 17:00:49 -0800 | [diff] [blame^] | 329 | if (!mShouldDisableUpdates) { |
| 330 | for (int i = 0; i < mListeners.size(); ++i) { |
| 331 | mListeners.get(i).onDisconnect(call); |
| 332 | } |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 333 | } |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 334 | |
| 335 | // If it was a conferenced call, we need to run the entire update |
| 336 | // to make the proper changes to parent conference calls. |
| 337 | if (wasConferenced) { |
| 338 | onPhoneStateChanged(null); |
| 339 | } |
| 340 | |
| 341 | mCallMap.remove(conn); |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 342 | } |
Santos Cordon | 24a92b3 | 2013-09-26 16:48:14 -0700 | [diff] [blame] | 343 | |
Christine Chen | 6af50e6 | 2013-09-26 15:05:57 -0700 | [diff] [blame] | 344 | mCallManager.clearDisconnected(); |
Santos Cordon | 24a92b3 | 2013-09-26 16:48:14 -0700 | [diff] [blame] | 345 | PhoneGlobals.getInstance().updateWakeState(); |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 346 | } |
| 347 | |
Santos Cordon | a3d0514 | 2013-07-29 11:25:17 -0700 | [diff] [blame] | 348 | /** |
| 349 | * Called when the phone state changes. |
Santos Cordon | a3d0514 | 2013-07-29 11:25:17 -0700 | [diff] [blame] | 350 | */ |
Santos Cordon | 995c816 | 2013-07-29 09:22:22 -0700 | [diff] [blame] | 351 | private void onPhoneStateChanged(AsyncResult r) { |
Santos Cordon | 2b73bd6 | 2013-08-27 14:53:43 -0700 | [diff] [blame] | 352 | Log.i(TAG, "onPhoneStateChanged: "); |
Santos Cordon | 998f42b | 2013-08-02 16:13:12 -0700 | [diff] [blame] | 353 | final List<Call> updatedCalls = Lists.newArrayList(); |
| 354 | doUpdate(false, updatedCalls); |
| 355 | |
Sailesh Nepal | 1eaf22b | 2014-02-22 17:00:49 -0800 | [diff] [blame^] | 356 | if (updatedCalls.size() > 0 && !mShouldDisableUpdates) { |
Santos Cordon | 71d5c6e | 2013-09-05 21:34:33 -0700 | [diff] [blame] | 357 | for (int i = 0; i < mListeners.size(); ++i) { |
| 358 | mListeners.get(i).onUpdate(updatedCalls); |
| 359 | } |
Santos Cordon | 998f42b | 2013-08-02 16:13:12 -0700 | [diff] [blame] | 360 | } |
Santos Cordon | 24a92b3 | 2013-09-26 16:48:14 -0700 | [diff] [blame] | 361 | |
| 362 | PhoneGlobals.getInstance().updateWakeState(); |
Santos Cordon | 998f42b | 2013-08-02 16:13:12 -0700 | [diff] [blame] | 363 | } |
| 364 | |
Santos Cordon | 998f42b | 2013-08-02 16:13:12 -0700 | [diff] [blame] | 365 | /** |
| 366 | * Go through the Calls from CallManager and return the list of calls that were updated. |
Santos Cordon | 2500858 | 2013-11-12 13:39:40 -0800 | [diff] [blame] | 367 | * Method also finds any orphaned Calls (Connection objects no longer returned by telephony as |
| 368 | * either ringing, foreground, or background). For each orphaned call, it sets the call state |
| 369 | * to IDLE and adds it to the list of calls to update. |
| 370 | * |
| 371 | * @param fullUpdate Add all calls to out parameter including those that have no updates. |
| 372 | * @param out List to populate with Calls that have been updated. |
Santos Cordon | 998f42b | 2013-08-02 16:13:12 -0700 | [diff] [blame] | 373 | */ |
| 374 | private void doUpdate(boolean fullUpdate, List<Call> out) { |
Santos Cordon | a3d0514 | 2013-07-29 11:25:17 -0700 | [diff] [blame] | 375 | final List<com.android.internal.telephony.Call> telephonyCalls = Lists.newArrayList(); |
| 376 | telephonyCalls.addAll(mCallManager.getRingingCalls()); |
| 377 | telephonyCalls.addAll(mCallManager.getForegroundCalls()); |
| 378 | telephonyCalls.addAll(mCallManager.getBackgroundCalls()); |
| 379 | |
Santos Cordon | 2500858 | 2013-11-12 13:39:40 -0800 | [diff] [blame] | 380 | // orphanedConnections starts out including all connections we know about. |
| 381 | // As we iterate through the connections we get from the telephony layer we |
| 382 | // prune this Set down to only the connections we have but telephony no longer |
| 383 | // recognizes. |
| 384 | final Set<Connection> orphanedConnections = Sets.newHashSet(); |
| 385 | orphanedConnections.addAll(mCallMap.keySet()); |
| 386 | orphanedConnections.addAll(mConfCallMap.keySet()); |
| 387 | |
Santos Cordon | a3d0514 | 2013-07-29 11:25:17 -0700 | [diff] [blame] | 388 | // Cycle through all the Connections on all the Calls. Update our Call objects |
| 389 | // to reflect any new state and send the updated Call objects to the handler service. |
| 390 | for (com.android.internal.telephony.Call telephonyCall : telephonyCalls) { |
Santos Cordon | a3d0514 | 2013-07-29 11:25:17 -0700 | [diff] [blame] | 391 | |
| 392 | for (Connection connection : telephonyCall.getConnections()) { |
Christine Chen | 3e0f041 | 2013-09-18 20:33:49 -0700 | [diff] [blame] | 393 | if (DBG) Log.d(TAG, "connection: " + connection + connection.getState()); |
Santos Cordon | a5d5db8 | 2013-09-15 13:00:34 -0700 | [diff] [blame] | 394 | |
Santos Cordon | 2500858 | 2013-11-12 13:39:40 -0800 | [diff] [blame] | 395 | if (orphanedConnections.contains(connection)) { |
| 396 | orphanedConnections.remove(connection); |
| 397 | } |
| 398 | |
Santos Cordon | 12a03aa | 2013-09-12 23:34:05 -0700 | [diff] [blame] | 399 | // We only send updates for live calls which are not incoming (ringing). |
| 400 | // Disconnected and incoming calls are handled by onDisconnect and |
| 401 | // onNewRingingConnection. |
Christine Chen | df19e45 | 2013-09-25 17:21:23 -0700 | [diff] [blame] | 402 | final boolean shouldUpdate = |
Christine Chen | 3e0f041 | 2013-09-18 20:33:49 -0700 | [diff] [blame] | 403 | connection.getState() != |
| 404 | com.android.internal.telephony.Call.State.DISCONNECTED && |
| 405 | connection.getState() != |
| 406 | com.android.internal.telephony.Call.State.IDLE && |
Santos Cordon | 71d5c6e | 2013-09-05 21:34:33 -0700 | [diff] [blame] | 407 | !connection.getState().isRinging(); |
| 408 | |
Christine Chen | df19e45 | 2013-09-25 17:21:23 -0700 | [diff] [blame] | 409 | final boolean isDisconnecting = connection.getState() == |
| 410 | com.android.internal.telephony.Call.State.DISCONNECTING; |
| 411 | |
| 412 | // For disconnecting calls, we still need to send the update to the UI but we do |
| 413 | // not create a new call if the call did not exist. |
| 414 | final boolean shouldCreate = shouldUpdate && !isDisconnecting; |
| 415 | |
Santos Cordon | 71d5c6e | 2013-09-05 21:34:33 -0700 | [diff] [blame] | 416 | // New connections return a Call with INVALID state, which does not translate to |
Santos Cordon | e38b1ff | 2013-08-07 12:12:16 -0700 | [diff] [blame] | 417 | // a state in the internal.telephony.Call object. This ensures that staleness |
| 418 | // check below fails and we always add the item to the update list if it is new. |
Christine Chen | df19e45 | 2013-09-25 17:21:23 -0700 | [diff] [blame] | 419 | final Call call = getCallFromMap(mCallMap, connection, shouldCreate /* create */); |
Santos Cordon | 71d5c6e | 2013-09-05 21:34:33 -0700 | [diff] [blame] | 420 | |
Santos Cordon | 12a03aa | 2013-09-12 23:34:05 -0700 | [diff] [blame] | 421 | if (call == null || !shouldUpdate) { |
Santos Cordon | a5d5db8 | 2013-09-15 13:00:34 -0700 | [diff] [blame] | 422 | if (DBG) Log.d(TAG, "update skipped"); |
Santos Cordon | 71d5c6e | 2013-09-05 21:34:33 -0700 | [diff] [blame] | 423 | continue; |
| 424 | } |
Santos Cordon | a3d0514 | 2013-07-29 11:25:17 -0700 | [diff] [blame] | 425 | |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 426 | boolean changed = updateCallFromConnection(call, connection, false); |
Santos Cordon | 2b73bd6 | 2013-08-27 14:53:43 -0700 | [diff] [blame] | 427 | |
Santos Cordon | e38b1ff | 2013-08-07 12:12:16 -0700 | [diff] [blame] | 428 | if (fullUpdate || changed) { |
Santos Cordon | 998f42b | 2013-08-02 16:13:12 -0700 | [diff] [blame] | 429 | out.add(call); |
Santos Cordon | a3d0514 | 2013-07-29 11:25:17 -0700 | [diff] [blame] | 430 | } |
| 431 | } |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 432 | |
| 433 | // We do a second loop to address conference call scenarios. We do this as a separate |
| 434 | // loop to ensure all child calls are up to date before we start updating the parent |
| 435 | // conference calls. |
| 436 | for (Connection connection : telephonyCall.getConnections()) { |
| 437 | updateForConferenceCalls(connection, out); |
| 438 | } |
Santos Cordon | 2500858 | 2013-11-12 13:39:40 -0800 | [diff] [blame] | 439 | } |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 440 | |
Santos Cordon | 2500858 | 2013-11-12 13:39:40 -0800 | [diff] [blame] | 441 | // Iterate through orphaned connections, set them to idle, and remove |
| 442 | // them from our internal structures. |
| 443 | for (Connection orphanedConnection : orphanedConnections) { |
| 444 | if (mCallMap.containsKey(orphanedConnection)) { |
| 445 | final Call call = mCallMap.get(orphanedConnection); |
| 446 | call.setState(Call.State.IDLE); |
| 447 | out.add(call); |
| 448 | |
| 449 | mCallMap.remove(orphanedConnection); |
| 450 | } |
| 451 | |
| 452 | if (mConfCallMap.containsKey(orphanedConnection)) { |
| 453 | final Call call = mCallMap.get(orphanedConnection); |
| 454 | call.setState(Call.State.IDLE); |
| 455 | out.add(call); |
| 456 | |
| 457 | mConfCallMap.remove(orphanedConnection); |
| 458 | } |
Santos Cordon | a3d0514 | 2013-07-29 11:25:17 -0700 | [diff] [blame] | 459 | } |
Santos Cordon | a3d0514 | 2013-07-29 11:25:17 -0700 | [diff] [blame] | 460 | } |
| 461 | |
Santos Cordon | e38b1ff | 2013-08-07 12:12:16 -0700 | [diff] [blame] | 462 | /** |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 463 | * Checks to see if the connection is the first connection in a conference call. |
| 464 | * If it is a conference call, we will create a new Conference Call object or |
| 465 | * update the existing conference call object for that connection. |
| 466 | * If it is not a conference call but a previous associated conference call still exists, |
| 467 | * we mark it as idle and remove it from the map. |
| 468 | * In both cases above, we add the Calls to be updated to the UI. |
| 469 | * @param connection The connection object to check. |
| 470 | * @param updatedCalls List of 'updated' calls that will be sent to the UI. |
| 471 | */ |
| 472 | private boolean updateForConferenceCalls(Connection connection, List<Call> updatedCalls) { |
| 473 | // We consider this connection a conference connection if the call it |
Yorke Lee | cd3f969 | 2013-09-14 13:51:27 -0700 | [diff] [blame] | 474 | // belongs to is a multiparty call AND it is the first live connection. |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 475 | final boolean isConferenceCallConnection = isPartOfLiveConferenceCall(connection) && |
Yorke Lee | cd3f969 | 2013-09-14 13:51:27 -0700 | [diff] [blame] | 476 | getEarliestLiveConnection(connection.getCall()) == connection; |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 477 | |
| 478 | boolean changed = false; |
| 479 | |
| 480 | // If this connection is the main connection for the conference call, then create or update |
| 481 | // a Call object for that conference call. |
| 482 | if (isConferenceCallConnection) { |
| 483 | final Call confCall = getCallFromMap(mConfCallMap, connection, true); |
| 484 | changed = updateCallFromConnection(confCall, connection, true); |
| 485 | |
| 486 | if (changed) { |
| 487 | updatedCalls.add(confCall); |
| 488 | } |
| 489 | |
| 490 | if (DBG) Log.d(TAG, "Updating a conference call: " + confCall); |
| 491 | |
| 492 | // It is possible that through a conference call split, there may be lingering conference |
| 493 | // calls where this connection was the main connection. We clean those up here. |
| 494 | } else { |
| 495 | final Call oldConfCall = getCallFromMap(mConfCallMap, connection, false); |
| 496 | |
| 497 | // We found a conference call for this connection, which is no longer a conference call. |
| 498 | // Kill it! |
| 499 | if (oldConfCall != null) { |
| 500 | if (DBG) Log.d(TAG, "Cleaning up an old conference call: " + oldConfCall); |
| 501 | mConfCallMap.remove(connection); |
| 502 | oldConfCall.setState(State.IDLE); |
| 503 | changed = true; |
| 504 | |
| 505 | // add to the list of calls to update |
| 506 | updatedCalls.add(oldConfCall); |
| 507 | } |
| 508 | } |
| 509 | |
| 510 | return changed; |
| 511 | } |
| 512 | |
Yorke Lee | cd3f969 | 2013-09-14 13:51:27 -0700 | [diff] [blame] | 513 | private Connection getEarliestLiveConnection(com.android.internal.telephony.Call call) { |
| 514 | final List<Connection> connections = call.getConnections(); |
| 515 | final int size = connections.size(); |
| 516 | Connection earliestConn = null; |
| 517 | long earliestTime = Long.MAX_VALUE; |
| 518 | for (int i = 0; i < size; i++) { |
| 519 | final Connection connection = connections.get(i); |
| 520 | if (!connection.isAlive()) continue; |
| 521 | final long time = connection.getCreateTime(); |
| 522 | if (time < earliestTime) { |
| 523 | earliestTime = time; |
| 524 | earliestConn = connection; |
| 525 | } |
| 526 | } |
| 527 | return earliestConn; |
| 528 | } |
| 529 | |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 530 | /** |
Santos Cordon | 69a6919 | 2013-08-22 14:25:42 -0700 | [diff] [blame] | 531 | * Sets the new call state onto the call and performs some additional logic |
| 532 | * associated with setting the state. |
| 533 | */ |
| 534 | private void setNewState(Call call, int newState, Connection connection) { |
| 535 | Preconditions.checkState(call.getState() != newState); |
| 536 | |
| 537 | // When starting an outgoing call, we need to grab gateway information |
| 538 | // for the call, if available, and set it. |
| 539 | final RawGatewayInfo info = mCallGatewayManager.getGatewayInfo(connection); |
| 540 | |
Santos Cordon | ce02f3a | 2013-09-19 01:58:42 -0700 | [diff] [blame] | 541 | if (Call.State.isDialing(newState)) { |
Santos Cordon | 69a6919 | 2013-08-22 14:25:42 -0700 | [diff] [blame] | 542 | if (!info.isEmpty()) { |
| 543 | call.setGatewayNumber(info.getFormattedGatewayNumber()); |
| 544 | call.setGatewayPackage(info.packageName); |
| 545 | } |
| 546 | } else if (!Call.State.isConnected(newState)) { |
| 547 | mCallGatewayManager.clearGatewayData(connection); |
| 548 | } |
| 549 | |
| 550 | call.setState(newState); |
| 551 | } |
| 552 | |
| 553 | /** |
Santos Cordon | e38b1ff | 2013-08-07 12:12:16 -0700 | [diff] [blame] | 554 | * Updates the Call properties to match the state of the connection object |
| 555 | * that it represents. |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 556 | * @param call The call object to update. |
| 557 | * @param connection The connection object from which to update call. |
| 558 | * @param isForConference There are slight differences in how we populate data for conference |
| 559 | * calls. This boolean tells us which method to use. |
Santos Cordon | e38b1ff | 2013-08-07 12:12:16 -0700 | [diff] [blame] | 560 | */ |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 561 | private boolean updateCallFromConnection(Call call, Connection connection, |
| 562 | boolean isForConference) { |
Santos Cordon | e38b1ff | 2013-08-07 12:12:16 -0700 | [diff] [blame] | 563 | boolean changed = false; |
| 564 | |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 565 | final int newState = translateStateFromTelephony(connection, isForConference); |
Santos Cordon | e38b1ff | 2013-08-07 12:12:16 -0700 | [diff] [blame] | 566 | |
| 567 | if (call.getState() != newState) { |
Santos Cordon | 69a6919 | 2013-08-22 14:25:42 -0700 | [diff] [blame] | 568 | setNewState(call, newState, connection); |
Santos Cordon | e38b1ff | 2013-08-07 12:12:16 -0700 | [diff] [blame] | 569 | changed = true; |
| 570 | } |
| 571 | |
Sailesh Nepal | d1e6815 | 2013-12-12 19:08:02 -0800 | [diff] [blame] | 572 | final boolean isWifiCall = connection.getCall().getPhone().getPhoneType() == |
| 573 | PhoneConstants.PHONE_TYPE_THIRD_PARTY; |
| 574 | if (call.isWifiCall() != isWifiCall) { |
| 575 | call.setIsWifiCall(isWifiCall); |
| 576 | changed = true; |
| 577 | } |
| 578 | |
Santos Cordon | e38b1ff | 2013-08-07 12:12:16 -0700 | [diff] [blame] | 579 | final Call.DisconnectCause newDisconnectCause = |
| 580 | translateDisconnectCauseFromTelephony(connection.getDisconnectCause()); |
| 581 | if (call.getDisconnectCause() != newDisconnectCause) { |
| 582 | call.setDisconnectCause(newDisconnectCause); |
| 583 | changed = true; |
| 584 | } |
| 585 | |
Santos Cordon | bbe8ecf | 2013-08-13 15:26:18 -0700 | [diff] [blame] | 586 | final long oldConnectTime = call.getConnectTime(); |
| 587 | if (oldConnectTime != connection.getConnectTime()) { |
| 588 | call.setConnectTime(connection.getConnectTime()); |
| 589 | changed = true; |
| 590 | } |
| 591 | |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 592 | if (!isForConference) { |
Santos Cordon | 69a6919 | 2013-08-22 14:25:42 -0700 | [diff] [blame] | 593 | // Number |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 594 | final String oldNumber = call.getNumber(); |
Santos Cordon | 69a6919 | 2013-08-22 14:25:42 -0700 | [diff] [blame] | 595 | String newNumber = connection.getAddress(); |
| 596 | RawGatewayInfo info = mCallGatewayManager.getGatewayInfo(connection); |
| 597 | if (!info.isEmpty()) { |
| 598 | newNumber = info.trueNumber; |
| 599 | } |
| 600 | if (TextUtils.isEmpty(oldNumber) || !oldNumber.equals(newNumber)) { |
| 601 | call.setNumber(newNumber); |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 602 | changed = true; |
| 603 | } |
| 604 | |
Santos Cordon | 69a6919 | 2013-08-22 14:25:42 -0700 | [diff] [blame] | 605 | // Number presentation |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 606 | final int newNumberPresentation = connection.getNumberPresentation(); |
| 607 | if (call.getNumberPresentation() != newNumberPresentation) { |
| 608 | call.setNumberPresentation(newNumberPresentation); |
| 609 | changed = true; |
| 610 | } |
| 611 | |
Santos Cordon | 69a6919 | 2013-08-22 14:25:42 -0700 | [diff] [blame] | 612 | // Name |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 613 | final String oldCnapName = call.getCnapName(); |
| 614 | if (TextUtils.isEmpty(oldCnapName) || !oldCnapName.equals(connection.getCnapName())) { |
| 615 | call.setCnapName(connection.getCnapName()); |
| 616 | changed = true; |
| 617 | } |
Santos Cordon | 69a6919 | 2013-08-22 14:25:42 -0700 | [diff] [blame] | 618 | |
| 619 | // Name Presentation |
| 620 | final int newCnapNamePresentation = connection.getCnapNamePresentation(); |
| 621 | if (call.getCnapNamePresentation() != newCnapNamePresentation) { |
| 622 | call.setCnapNamePresentation(newCnapNamePresentation); |
| 623 | changed = true; |
| 624 | } |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 625 | } else { |
| 626 | |
| 627 | // update the list of children by: |
| 628 | // 1) Saving the old set |
| 629 | // 2) Removing all children |
| 630 | // 3) Adding the correct children into the Call |
| 631 | // 4) Comparing the new children set with the old children set |
| 632 | ImmutableSortedSet<Integer> oldSet = call.getChildCallIds(); |
| 633 | call.removeAllChildren(); |
| 634 | |
| 635 | if (connection.getCall() != null) { |
| 636 | for (Connection childConn : connection.getCall().getConnections()) { |
| 637 | final Call childCall = getCallFromMap(mCallMap, childConn, false); |
| 638 | if (childCall != null && childConn.isAlive()) { |
| 639 | call.addChildId(childCall.getCallId()); |
| 640 | } |
| 641 | } |
| 642 | } |
Christine Chen | 4527702 | 2013-09-05 10:55:37 -0700 | [diff] [blame] | 643 | changed |= !oldSet.equals(call.getChildCallIds()); |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 644 | } |
| 645 | |
Santos Cordon | eead6ec | 2013-08-07 22:16:33 -0700 | [diff] [blame] | 646 | /** |
| 647 | * !!! Uses values from connection and call collected above so this part must be last !!! |
| 648 | */ |
Santos Cordon | ad1ed6d | 2013-09-16 03:04:23 -0700 | [diff] [blame] | 649 | final int newCapabilities = getCapabilitiesFor(connection, call, isForConference); |
Santos Cordon | 26e7b24 | 2013-08-07 21:15:45 -0700 | [diff] [blame] | 650 | if (call.getCapabilities() != newCapabilities) { |
| 651 | call.setCapabilities(newCapabilities); |
| 652 | changed = true; |
| 653 | } |
| 654 | |
Santos Cordon | e38b1ff | 2013-08-07 12:12:16 -0700 | [diff] [blame] | 655 | return changed; |
| 656 | } |
| 657 | |
Santos Cordon | 26e7b24 | 2013-08-07 21:15:45 -0700 | [diff] [blame] | 658 | /** |
| 659 | * Returns a mask of capabilities for the connection such as merge, hold, etc. |
| 660 | */ |
Santos Cordon | ad1ed6d | 2013-09-16 03:04:23 -0700 | [diff] [blame] | 661 | private int getCapabilitiesFor(Connection connection, Call call, boolean isForConference) { |
Santos Cordon | eead6ec | 2013-08-07 22:16:33 -0700 | [diff] [blame] | 662 | final boolean callIsActive = (call.getState() == Call.State.ACTIVE); |
| 663 | final Phone phone = connection.getCall().getPhone(); |
| 664 | |
Santos Cordon | eead6ec | 2013-08-07 22:16:33 -0700 | [diff] [blame] | 665 | boolean canAddCall = false; |
| 666 | boolean canMergeCall = false; |
| 667 | boolean canSwapCall = false; |
Yorke Lee | 814da30 | 2013-08-30 16:01:07 -0700 | [diff] [blame] | 668 | boolean canRespondViaText = false; |
Christine Chen | af2fd0a | 2013-09-13 16:27:40 -0700 | [diff] [blame] | 669 | boolean canMute = false; |
| 670 | |
| 671 | final boolean supportHold = PhoneUtils.okToSupportHold(mCallManager); |
Christine Chen | 94853bc | 2013-09-17 16:53:33 -0700 | [diff] [blame] | 672 | final boolean canHold = (supportHold ? PhoneUtils.okToHoldCall(mCallManager) : false); |
Santos Cordon | ad1ed6d | 2013-09-16 03:04:23 -0700 | [diff] [blame] | 673 | final boolean genericConf = isForConference && |
Sailesh Nepal | d1e6815 | 2013-12-12 19:08:02 -0800 | [diff] [blame] | 674 | (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA); |
Santos Cordon | eead6ec | 2013-08-07 22:16:33 -0700 | [diff] [blame] | 675 | |
| 676 | // only applies to active calls |
| 677 | if (callIsActive) { |
Santos Cordon | eead6ec | 2013-08-07 22:16:33 -0700 | [diff] [blame] | 678 | canMergeCall = PhoneUtils.okToMergeCalls(mCallManager); |
| 679 | canSwapCall = PhoneUtils.okToSwapCalls(mCallManager); |
| 680 | } |
| 681 | |
Christine Chen | af2fd0a | 2013-09-13 16:27:40 -0700 | [diff] [blame] | 682 | canAddCall = PhoneUtils.okToAddCall(mCallManager); |
| 683 | |
| 684 | // "Mute": only enabled when the foreground call is ACTIVE. |
| 685 | // (It's meaningless while on hold, or while DIALING/ALERTING.) |
| 686 | // It's also explicitly disabled during emergency calls or if |
| 687 | // emergency callback mode (ECM) is active. |
| 688 | boolean isEmergencyCall = false; |
| 689 | if (connection != null) { |
| 690 | isEmergencyCall = PhoneNumberUtils.isLocalEmergencyNumber(connection.getAddress(), |
| 691 | phone.getContext()); |
| 692 | } |
| 693 | boolean isECM = PhoneUtils.isPhoneInEcm(phone); |
| 694 | if (isEmergencyCall || isECM) { // disable "Mute" item |
| 695 | canMute = false; |
| 696 | } else { |
| 697 | canMute = callIsActive; |
| 698 | } |
| 699 | |
Yorke Lee | 814da30 | 2013-08-30 16:01:07 -0700 | [diff] [blame] | 700 | canRespondViaText = RejectWithTextMessageManager.allowRespondViaSmsForCall(call, |
| 701 | connection); |
| 702 | |
Santos Cordon | eead6ec | 2013-08-07 22:16:33 -0700 | [diff] [blame] | 703 | // special rules section! |
| 704 | // CDMA always has Add |
| 705 | if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) { |
| 706 | canAddCall = true; |
Santos Cordon | eead6ec | 2013-08-07 22:16:33 -0700 | [diff] [blame] | 707 | } |
| 708 | |
Santos Cordon | 26e7b24 | 2013-08-07 21:15:45 -0700 | [diff] [blame] | 709 | int retval = 0x0; |
Santos Cordon | eead6ec | 2013-08-07 22:16:33 -0700 | [diff] [blame] | 710 | if (canHold) { |
Santos Cordon | 26e7b24 | 2013-08-07 21:15:45 -0700 | [diff] [blame] | 711 | retval |= Capabilities.HOLD; |
| 712 | } |
Christine Chen | af2fd0a | 2013-09-13 16:27:40 -0700 | [diff] [blame] | 713 | if (supportHold) { |
| 714 | retval |= Capabilities.SUPPORT_HOLD; |
| 715 | } |
Santos Cordon | eead6ec | 2013-08-07 22:16:33 -0700 | [diff] [blame] | 716 | if (canAddCall) { |
| 717 | retval |= Capabilities.ADD_CALL; |
| 718 | } |
| 719 | if (canMergeCall) { |
| 720 | retval |= Capabilities.MERGE_CALLS; |
| 721 | } |
| 722 | if (canSwapCall) { |
| 723 | retval |= Capabilities.SWAP_CALLS; |
| 724 | } |
Yorke Lee | 814da30 | 2013-08-30 16:01:07 -0700 | [diff] [blame] | 725 | if (canRespondViaText) { |
| 726 | retval |= Capabilities.RESPOND_VIA_TEXT; |
| 727 | } |
Christine Chen | af2fd0a | 2013-09-13 16:27:40 -0700 | [diff] [blame] | 728 | if (canMute) { |
| 729 | retval |= Capabilities.MUTE; |
| 730 | } |
Santos Cordon | ad1ed6d | 2013-09-16 03:04:23 -0700 | [diff] [blame] | 731 | if (genericConf) { |
| 732 | retval |= Capabilities.GENERIC_CONFERENCE; |
| 733 | } |
Yorke Lee | 814da30 | 2013-08-30 16:01:07 -0700 | [diff] [blame] | 734 | |
Santos Cordon | 26e7b24 | 2013-08-07 21:15:45 -0700 | [diff] [blame] | 735 | return retval; |
| 736 | } |
| 737 | |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 738 | /** |
| 739 | * Returns true if the Connection is part of a multiparty call. |
| 740 | * We do this by checking the isMultiparty() method of the telephony.Call object and also |
| 741 | * checking to see if more than one of it's children is alive. |
| 742 | */ |
| 743 | private boolean isPartOfLiveConferenceCall(Connection connection) { |
| 744 | if (connection.getCall() != null && connection.getCall().isMultiparty()) { |
| 745 | int count = 0; |
| 746 | for (Connection currConn : connection.getCall().getConnections()) { |
Santos Cordon | ad1ed6d | 2013-09-16 03:04:23 -0700 | [diff] [blame] | 747 | |
| 748 | // Only count connections which are alive and never cound the special |
| 749 | // "dialing" 3way call for CDMA calls. |
| 750 | if (currConn.isAlive() && currConn != mCdmaOutgoingConnection) { |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 751 | count++; |
| 752 | if (count >= 2) { |
| 753 | return true; |
| 754 | } |
| 755 | } |
| 756 | } |
| 757 | } |
| 758 | return false; |
| 759 | } |
| 760 | |
| 761 | private int translateStateFromTelephony(Connection connection, boolean isForConference) { |
| 762 | |
Santos Cordon | ce02f3a | 2013-09-19 01:58:42 -0700 | [diff] [blame] | 763 | com.android.internal.telephony.Call.State connState = connection.getState(); |
| 764 | |
Santos Cordon | ad1ed6d | 2013-09-16 03:04:23 -0700 | [diff] [blame] | 765 | // For the "fake" outgoing CDMA call, we need to always treat it as an outgoing call. |
| 766 | if (mCdmaOutgoingConnection == connection) { |
Santos Cordon | ce02f3a | 2013-09-19 01:58:42 -0700 | [diff] [blame] | 767 | connState = com.android.internal.telephony.Call.State.DIALING; |
Santos Cordon | ad1ed6d | 2013-09-16 03:04:23 -0700 | [diff] [blame] | 768 | } |
| 769 | |
Santos Cordon | a3d0514 | 2013-07-29 11:25:17 -0700 | [diff] [blame] | 770 | int retval = State.IDLE; |
Santos Cordon | ce02f3a | 2013-09-19 01:58:42 -0700 | [diff] [blame] | 771 | switch (connState) { |
Santos Cordon | a3d0514 | 2013-07-29 11:25:17 -0700 | [diff] [blame] | 772 | case ACTIVE: |
| 773 | retval = State.ACTIVE; |
| 774 | break; |
| 775 | case INCOMING: |
| 776 | retval = State.INCOMING; |
| 777 | break; |
| 778 | case DIALING: |
| 779 | case ALERTING: |
Santos Cordon | ce02f3a | 2013-09-19 01:58:42 -0700 | [diff] [blame] | 780 | if (PhoneGlobals.getInstance().notifier.getIsCdmaRedialCall()) { |
| 781 | retval = State.REDIALING; |
| 782 | } else { |
| 783 | retval = State.DIALING; |
| 784 | } |
Santos Cordon | a3d0514 | 2013-07-29 11:25:17 -0700 | [diff] [blame] | 785 | break; |
| 786 | case WAITING: |
| 787 | retval = State.CALL_WAITING; |
| 788 | break; |
| 789 | case HOLDING: |
| 790 | retval = State.ONHOLD; |
| 791 | break; |
Santos Cordon | e38b1ff | 2013-08-07 12:12:16 -0700 | [diff] [blame] | 792 | case DISCONNECTING: |
Christine Chen | 3e0f041 | 2013-09-18 20:33:49 -0700 | [diff] [blame] | 793 | retval = State.DISCONNECTING; |
| 794 | break; |
| 795 | case DISCONNECTED: |
Santos Cordon | e38b1ff | 2013-08-07 12:12:16 -0700 | [diff] [blame] | 796 | retval = State.DISCONNECTED; |
Santos Cordon | a3d0514 | 2013-07-29 11:25:17 -0700 | [diff] [blame] | 797 | default: |
| 798 | } |
| 799 | |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 800 | // If we are dealing with a potential child call (not the parent conference call), |
| 801 | // the check to see if we have to set the state to CONFERENCED. |
| 802 | if (!isForConference) { |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 803 | // if the connection is part of a multiparty call, and it is live, |
| 804 | // annotate it with CONFERENCED state instead. |
| 805 | if (isPartOfLiveConferenceCall(connection) && connection.isAlive()) { |
| 806 | return State.CONFERENCED; |
| 807 | } |
| 808 | } |
| 809 | |
Santos Cordon | a3d0514 | 2013-07-29 11:25:17 -0700 | [diff] [blame] | 810 | return retval; |
Santos Cordon | 995c816 | 2013-07-29 09:22:22 -0700 | [diff] [blame] | 811 | } |
| 812 | |
Santos Cordon | e38b1ff | 2013-08-07 12:12:16 -0700 | [diff] [blame] | 813 | private final ImmutableMap<Connection.DisconnectCause, Call.DisconnectCause> CAUSE_MAP = |
| 814 | ImmutableMap.<Connection.DisconnectCause, Call.DisconnectCause>builder() |
| 815 | .put(Connection.DisconnectCause.BUSY, Call.DisconnectCause.BUSY) |
| 816 | .put(Connection.DisconnectCause.CALL_BARRED, Call.DisconnectCause.CALL_BARRED) |
| 817 | .put(Connection.DisconnectCause.CDMA_ACCESS_BLOCKED, |
| 818 | Call.DisconnectCause.CDMA_ACCESS_BLOCKED) |
| 819 | .put(Connection.DisconnectCause.CDMA_ACCESS_FAILURE, |
| 820 | Call.DisconnectCause.CDMA_ACCESS_FAILURE) |
| 821 | .put(Connection.DisconnectCause.CDMA_DROP, Call.DisconnectCause.CDMA_DROP) |
| 822 | .put(Connection.DisconnectCause.CDMA_INTERCEPT, Call.DisconnectCause.CDMA_INTERCEPT) |
| 823 | .put(Connection.DisconnectCause.CDMA_LOCKED_UNTIL_POWER_CYCLE, |
| 824 | Call.DisconnectCause.CDMA_LOCKED_UNTIL_POWER_CYCLE) |
| 825 | .put(Connection.DisconnectCause.CDMA_NOT_EMERGENCY, |
| 826 | Call.DisconnectCause.CDMA_NOT_EMERGENCY) |
| 827 | .put(Connection.DisconnectCause.CDMA_PREEMPTED, Call.DisconnectCause.CDMA_PREEMPTED) |
| 828 | .put(Connection.DisconnectCause.CDMA_REORDER, Call.DisconnectCause.CDMA_REORDER) |
| 829 | .put(Connection.DisconnectCause.CDMA_RETRY_ORDER, |
| 830 | Call.DisconnectCause.CDMA_RETRY_ORDER) |
| 831 | .put(Connection.DisconnectCause.CDMA_SO_REJECT, Call.DisconnectCause.CDMA_SO_REJECT) |
| 832 | .put(Connection.DisconnectCause.CONGESTION, Call.DisconnectCause.CONGESTION) |
| 833 | .put(Connection.DisconnectCause.CS_RESTRICTED, Call.DisconnectCause.CS_RESTRICTED) |
| 834 | .put(Connection.DisconnectCause.CS_RESTRICTED_EMERGENCY, |
| 835 | Call.DisconnectCause.CS_RESTRICTED_EMERGENCY) |
| 836 | .put(Connection.DisconnectCause.CS_RESTRICTED_NORMAL, |
| 837 | Call.DisconnectCause.CS_RESTRICTED_NORMAL) |
| 838 | .put(Connection.DisconnectCause.ERROR_UNSPECIFIED, |
| 839 | Call.DisconnectCause.ERROR_UNSPECIFIED) |
| 840 | .put(Connection.DisconnectCause.FDN_BLOCKED, Call.DisconnectCause.FDN_BLOCKED) |
| 841 | .put(Connection.DisconnectCause.ICC_ERROR, Call.DisconnectCause.ICC_ERROR) |
| 842 | .put(Connection.DisconnectCause.INCOMING_MISSED, |
| 843 | Call.DisconnectCause.INCOMING_MISSED) |
| 844 | .put(Connection.DisconnectCause.INCOMING_REJECTED, |
| 845 | Call.DisconnectCause.INCOMING_REJECTED) |
| 846 | .put(Connection.DisconnectCause.INVALID_CREDENTIALS, |
| 847 | Call.DisconnectCause.INVALID_CREDENTIALS) |
| 848 | .put(Connection.DisconnectCause.INVALID_NUMBER, |
| 849 | Call.DisconnectCause.INVALID_NUMBER) |
| 850 | .put(Connection.DisconnectCause.LIMIT_EXCEEDED, Call.DisconnectCause.LIMIT_EXCEEDED) |
| 851 | .put(Connection.DisconnectCause.LOCAL, Call.DisconnectCause.LOCAL) |
| 852 | .put(Connection.DisconnectCause.LOST_SIGNAL, Call.DisconnectCause.LOST_SIGNAL) |
| 853 | .put(Connection.DisconnectCause.MMI, Call.DisconnectCause.MMI) |
| 854 | .put(Connection.DisconnectCause.NORMAL, Call.DisconnectCause.NORMAL) |
| 855 | .put(Connection.DisconnectCause.NOT_DISCONNECTED, |
| 856 | Call.DisconnectCause.NOT_DISCONNECTED) |
| 857 | .put(Connection.DisconnectCause.NUMBER_UNREACHABLE, |
| 858 | Call.DisconnectCause.NUMBER_UNREACHABLE) |
| 859 | .put(Connection.DisconnectCause.OUT_OF_NETWORK, Call.DisconnectCause.OUT_OF_NETWORK) |
| 860 | .put(Connection.DisconnectCause.OUT_OF_SERVICE, Call.DisconnectCause.OUT_OF_SERVICE) |
| 861 | .put(Connection.DisconnectCause.POWER_OFF, Call.DisconnectCause.POWER_OFF) |
| 862 | .put(Connection.DisconnectCause.SERVER_ERROR, Call.DisconnectCause.SERVER_ERROR) |
| 863 | .put(Connection.DisconnectCause.SERVER_UNREACHABLE, |
| 864 | Call.DisconnectCause.SERVER_UNREACHABLE) |
| 865 | .put(Connection.DisconnectCause.TIMED_OUT, Call.DisconnectCause.TIMED_OUT) |
| 866 | .put(Connection.DisconnectCause.UNOBTAINABLE_NUMBER, |
| 867 | Call.DisconnectCause.UNOBTAINABLE_NUMBER) |
| 868 | .build(); |
| 869 | |
| 870 | private Call.DisconnectCause translateDisconnectCauseFromTelephony( |
| 871 | Connection.DisconnectCause causeSource) { |
| 872 | |
| 873 | if (CAUSE_MAP.containsKey(causeSource)) { |
| 874 | return CAUSE_MAP.get(causeSource); |
| 875 | } |
| 876 | |
| 877 | return Call.DisconnectCause.UNKNOWN; |
| 878 | } |
| 879 | |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 880 | /** |
Santos Cordon | e38b1ff | 2013-08-07 12:12:16 -0700 | [diff] [blame] | 881 | * Gets an existing callId for a connection, or creates one if none exists. |
| 882 | * This function does NOT set any of the Connection data onto the Call class. |
| 883 | * A separate call to updateCallFromConnection must be made for that purpose. |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 884 | */ |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 885 | private Call getCallFromMap(HashMap<Connection, Call> map, Connection conn, |
| 886 | boolean createIfMissing) { |
Santos Cordon | 995c816 | 2013-07-29 09:22:22 -0700 | [diff] [blame] | 887 | Call call = null; |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 888 | |
| 889 | // Find the call id or create if missing and requested. |
| 890 | if (conn != null) { |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 891 | if (map.containsKey(conn)) { |
| 892 | call = map.get(conn); |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 893 | } else if (createIfMissing) { |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 894 | call = createNewCall(); |
| 895 | map.put(conn, call); |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 896 | } |
| 897 | } |
Santos Cordon | 995c816 | 2013-07-29 09:22:22 -0700 | [diff] [blame] | 898 | return call; |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 899 | } |
| 900 | |
| 901 | /** |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 902 | * Creates a brand new connection for the call. |
| 903 | */ |
| 904 | private Call createNewCall() { |
| 905 | int callId; |
| 906 | int newNextCallId; |
| 907 | do { |
| 908 | callId = mNextCallId.get(); |
| 909 | |
| 910 | // protect against overflow |
| 911 | newNextCallId = (callId == Integer.MAX_VALUE ? |
| 912 | CALL_ID_START_VALUE : callId + 1); |
| 913 | |
| 914 | // Keep looping if the change was not atomic OR the value is already taken. |
| 915 | // The call to containsValue() is linear, however, most devices support a |
| 916 | // maximum of 7 connections so it's not expensive. |
| 917 | } while (!mNextCallId.compareAndSet(callId, newNextCallId)); |
| 918 | |
| 919 | return new Call(callId); |
| 920 | } |
| 921 | |
| 922 | /** |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 923 | * Listener interface for changes to Calls. |
| 924 | */ |
| 925 | public interface Listener { |
Santos Cordon | 995c816 | 2013-07-29 09:22:22 -0700 | [diff] [blame] | 926 | void onDisconnect(Call call); |
Chiao Cheng | 6c6b272 | 2013-08-22 18:35:54 -0700 | [diff] [blame] | 927 | void onIncoming(Call call); |
| 928 | void onUpdate(List<Call> calls); |
Yorke Lee | de41f67 | 2013-09-19 13:46:55 -0700 | [diff] [blame] | 929 | void onPostDialAction(Connection.PostDialState state, int callId, String remainingChars, |
| 930 | char c); |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 931 | } |
Santos Cordon | 249efd0 | 2013-08-05 03:33:56 -0700 | [diff] [blame] | 932 | |
| 933 | /** |
| 934 | * Result class for accessing a call by connection. |
| 935 | */ |
| 936 | public static class CallResult { |
| 937 | public Call mCall; |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 938 | public Call mActionableCall; |
Santos Cordon | 249efd0 | 2013-08-05 03:33:56 -0700 | [diff] [blame] | 939 | public Connection mConnection; |
| 940 | |
| 941 | private CallResult(Call call, Connection connection) { |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 942 | this(call, call, connection); |
| 943 | } |
| 944 | |
| 945 | private CallResult(Call call, Call actionableCall, Connection connection) { |
Santos Cordon | 249efd0 | 2013-08-05 03:33:56 -0700 | [diff] [blame] | 946 | mCall = call; |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 947 | mActionableCall = actionableCall; |
Santos Cordon | 249efd0 | 2013-08-05 03:33:56 -0700 | [diff] [blame] | 948 | mConnection = connection; |
| 949 | } |
| 950 | |
| 951 | public Call getCall() { |
| 952 | return mCall; |
| 953 | } |
| 954 | |
Santos Cordon | 4ad64cd | 2013-08-15 00:36:14 -0700 | [diff] [blame] | 955 | // The call that should be used for call actions like hanging up. |
| 956 | public Call getActionableCall() { |
| 957 | return mActionableCall; |
| 958 | } |
| 959 | |
Santos Cordon | 249efd0 | 2013-08-05 03:33:56 -0700 | [diff] [blame] | 960 | public Connection getConnection() { |
| 961 | return mConnection; |
| 962 | } |
| 963 | } |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 964 | } |