Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 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 | |
Tyler Gunn | 7cc70b4 | 2014-09-12 22:17:27 -0700 | [diff] [blame] | 17 | package com.android.server.telecom; |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 18 | |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame^] | 19 | import android.content.Context; |
Andrew Lee | 701dc00 | 2014-09-11 21:29:12 -0700 | [diff] [blame] | 20 | import android.telecom.DisconnectCause; |
Tyler Gunn | 7cc70b4 | 2014-09-12 22:17:27 -0700 | [diff] [blame] | 21 | import android.telecom.ParcelableConnection; |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame^] | 22 | import android.telecom.Phone; |
Tyler Gunn | 7cc70b4 | 2014-09-12 22:17:27 -0700 | [diff] [blame] | 23 | import android.telecom.PhoneAccount; |
| 24 | import android.telecom.PhoneAccountHandle; |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 25 | |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame^] | 26 | // TODO: Needed for move to system service: import com.android.internal.R; |
| 27 | |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 28 | import java.util.ArrayList; |
| 29 | import java.util.Iterator; |
| 30 | import java.util.List; |
Ihab Awad | 293edf2 | 2014-07-24 17:52:29 -0700 | [diff] [blame] | 31 | import java.util.Objects; |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 32 | |
| 33 | /** |
| 34 | * This class creates connections to place new outgoing calls to attached to an existing incoming |
| 35 | * call. In either case, this class cycles through a set of connection services until: |
| 36 | * - a connection service returns a newly created connection in which case the call is displayed |
| 37 | * to the user |
| 38 | * - a connection service cancels the process, in which case the call is aborted |
| 39 | */ |
| 40 | final class CreateConnectionProcessor { |
Ihab Awad | 293edf2 | 2014-07-24 17:52:29 -0700 | [diff] [blame] | 41 | |
| 42 | // Describes information required to attempt to make a phone call |
| 43 | private static class CallAttemptRecord { |
| 44 | // The PhoneAccount describing the target connection service which we will |
| 45 | // contact in order to process an attempt |
Ihab Awad | b78b276 | 2014-07-25 15:16:23 -0700 | [diff] [blame] | 46 | public final PhoneAccountHandle connectionManagerPhoneAccount; |
Ihab Awad | 293edf2 | 2014-07-24 17:52:29 -0700 | [diff] [blame] | 47 | // The PhoneAccount which we will tell the target connection service to use |
| 48 | // for attempting to make the actual phone call |
Ihab Awad | b78b276 | 2014-07-25 15:16:23 -0700 | [diff] [blame] | 49 | public final PhoneAccountHandle targetPhoneAccount; |
Ihab Awad | 293edf2 | 2014-07-24 17:52:29 -0700 | [diff] [blame] | 50 | |
| 51 | public CallAttemptRecord( |
Ihab Awad | b78b276 | 2014-07-25 15:16:23 -0700 | [diff] [blame] | 52 | PhoneAccountHandle connectionManagerPhoneAccount, |
| 53 | PhoneAccountHandle targetPhoneAccount) { |
| 54 | this.connectionManagerPhoneAccount = connectionManagerPhoneAccount; |
| 55 | this.targetPhoneAccount = targetPhoneAccount; |
Ihab Awad | 293edf2 | 2014-07-24 17:52:29 -0700 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | @Override |
| 59 | public String toString() { |
| 60 | return "CallAttemptRecord(" |
Ihab Awad | b78b276 | 2014-07-25 15:16:23 -0700 | [diff] [blame] | 61 | + Objects.toString(connectionManagerPhoneAccount) + "," |
| 62 | + Objects.toString(targetPhoneAccount) + ")"; |
Ihab Awad | 293edf2 | 2014-07-24 17:52:29 -0700 | [diff] [blame] | 63 | } |
Tyler Gunn | 6e6f6d1 | 2014-08-20 15:22:18 -0700 | [diff] [blame] | 64 | |
| 65 | /** |
| 66 | * Determines if this instance of {@code CallAttemptRecord} has the same underlying |
| 67 | * {@code PhoneAccountHandle}s as another instance. |
| 68 | * |
| 69 | * @param obj The other instance to compare against. |
| 70 | * @return {@code True} if the {@code CallAttemptRecord}s are equal. |
| 71 | */ |
| 72 | @Override |
| 73 | public boolean equals(Object obj) { |
| 74 | if (obj instanceof CallAttemptRecord) { |
| 75 | CallAttemptRecord other = (CallAttemptRecord) obj; |
| 76 | return Objects.equals(connectionManagerPhoneAccount, |
| 77 | other.connectionManagerPhoneAccount) && |
| 78 | Objects.equals(targetPhoneAccount, other.targetPhoneAccount); |
| 79 | } |
| 80 | return false; |
| 81 | } |
Ihab Awad | 293edf2 | 2014-07-24 17:52:29 -0700 | [diff] [blame] | 82 | } |
| 83 | |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 84 | private final Call mCall; |
| 85 | private final ConnectionServiceRepository mRepository; |
Ihab Awad | 293edf2 | 2014-07-24 17:52:29 -0700 | [diff] [blame] | 86 | private List<CallAttemptRecord> mAttemptRecords; |
| 87 | private Iterator<CallAttemptRecord> mAttemptRecordIterator; |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 88 | private CreateConnectionResponse mResponse; |
Andrew Lee | 701dc00 | 2014-09-11 21:29:12 -0700 | [diff] [blame] | 89 | private DisconnectCause mLastErrorDisconnectCause; |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame^] | 90 | private final PhoneAccountRegistrar mPhoneAccountRegistrar; |
| 91 | private final Context mContext; |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 92 | |
| 93 | CreateConnectionProcessor( |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame^] | 94 | Call call, ConnectionServiceRepository repository, CreateConnectionResponse response, |
| 95 | PhoneAccountRegistrar phoneAccountRegistrar, Context context) { |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 96 | mCall = call; |
| 97 | mRepository = repository; |
| 98 | mResponse = response; |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame^] | 99 | mPhoneAccountRegistrar = phoneAccountRegistrar; |
| 100 | mContext = context; |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | void process() { |
| 104 | Log.v(this, "process"); |
Ihab Awad | 293edf2 | 2014-07-24 17:52:29 -0700 | [diff] [blame] | 105 | mAttemptRecords = new ArrayList<>(); |
Ihab Awad | b78b276 | 2014-07-25 15:16:23 -0700 | [diff] [blame] | 106 | if (mCall.getTargetPhoneAccount() != null) { |
Sailesh Nepal | 7957f9c | 2014-08-09 17:13:19 -0700 | [diff] [blame] | 107 | mAttemptRecords.add(new CallAttemptRecord( |
| 108 | mCall.getTargetPhoneAccount(), mCall.getTargetPhoneAccount())); |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 109 | } |
Sailesh Nepal | 7957f9c | 2014-08-09 17:13:19 -0700 | [diff] [blame] | 110 | adjustAttemptsForConnectionManager(); |
Ihab Awad | 293edf2 | 2014-07-24 17:52:29 -0700 | [diff] [blame] | 111 | adjustAttemptsForEmergency(); |
| 112 | mAttemptRecordIterator = mAttemptRecords.iterator(); |
Ihab Awad | 69eb0f5 | 2014-07-18 11:20:37 -0700 | [diff] [blame] | 113 | attemptNextPhoneAccount(); |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | void abort() { |
| 117 | Log.v(this, "abort"); |
| 118 | |
| 119 | // Clear the response first to prevent attemptNextConnectionService from attempting any |
| 120 | // more services. |
| 121 | CreateConnectionResponse response = mResponse; |
| 122 | mResponse = null; |
| 123 | |
| 124 | ConnectionServiceWrapper service = mCall.getConnectionService(); |
| 125 | if (service != null) { |
| 126 | service.abort(mCall); |
| 127 | mCall.clearConnectionService(); |
| 128 | } |
| 129 | if (response != null) { |
Andrew Lee | 701dc00 | 2014-09-11 21:29:12 -0700 | [diff] [blame] | 130 | response.handleCreateConnectionFailure(new DisconnectCause(DisconnectCause.LOCAL)); |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 131 | } |
| 132 | } |
| 133 | |
Ihab Awad | 69eb0f5 | 2014-07-18 11:20:37 -0700 | [diff] [blame] | 134 | private void attemptNextPhoneAccount() { |
| 135 | Log.v(this, "attemptNextPhoneAccount"); |
Tyler Gunn | cb59b67 | 2014-08-20 09:02:11 -0700 | [diff] [blame] | 136 | CallAttemptRecord attempt = null; |
| 137 | if (mAttemptRecordIterator.hasNext()) { |
| 138 | attempt = mAttemptRecordIterator.next(); |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 139 | |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame^] | 140 | if (!mPhoneAccountRegistrar.phoneAccountHasPermission( |
| 141 | attempt.connectionManagerPhoneAccount)) { |
Tyler Gunn | cb59b67 | 2014-08-20 09:02:11 -0700 | [diff] [blame] | 142 | Log.w(this, |
| 143 | "Connection mgr does not have BIND_CONNECTION_SERVICE for attempt: %s", |
| 144 | attempt); |
| 145 | attemptNextPhoneAccount(); |
| 146 | return; |
| 147 | } |
| 148 | |
| 149 | // If the target PhoneAccount differs from the ConnectionManager phone acount, ensure it |
| 150 | // also has BIND_CONNECTION_SERVICE permission. |
| 151 | if (!attempt.connectionManagerPhoneAccount.equals(attempt.targetPhoneAccount) && |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame^] | 152 | !mPhoneAccountRegistrar.phoneAccountHasPermission(attempt.targetPhoneAccount)) { |
Tyler Gunn | cb59b67 | 2014-08-20 09:02:11 -0700 | [diff] [blame] | 153 | Log.w(this, |
| 154 | "Target PhoneAccount does not have BIND_CONNECTION_SERVICE for attempt: %s", |
| 155 | attempt); |
| 156 | attemptNextPhoneAccount(); |
| 157 | return; |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | if (mResponse != null && attempt != null) { |
Ihab Awad | 293edf2 | 2014-07-24 17:52:29 -0700 | [diff] [blame] | 162 | Log.i(this, "Trying attempt %s", attempt); |
Evan Charlton | 94d0162 | 2014-07-20 12:32:05 -0700 | [diff] [blame] | 163 | ConnectionServiceWrapper service = |
Ihab Awad | b78b276 | 2014-07-25 15:16:23 -0700 | [diff] [blame] | 164 | mRepository.getService( |
| 165 | attempt.connectionManagerPhoneAccount.getComponentName()); |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 166 | if (service == null) { |
Ihab Awad | 293edf2 | 2014-07-24 17:52:29 -0700 | [diff] [blame] | 167 | Log.i(this, "Found no connection service for attempt %s", attempt); |
Ihab Awad | 69eb0f5 | 2014-07-18 11:20:37 -0700 | [diff] [blame] | 168 | attemptNextPhoneAccount(); |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 169 | } else { |
Ihab Awad | b78b276 | 2014-07-25 15:16:23 -0700 | [diff] [blame] | 170 | mCall.setConnectionManagerPhoneAccount(attempt.connectionManagerPhoneAccount); |
| 171 | mCall.setTargetPhoneAccount(attempt.targetPhoneAccount); |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 172 | mCall.setConnectionService(service); |
| 173 | Log.i(this, "Attempting to call from %s", service.getComponentName()); |
| 174 | service.createConnection(mCall, new Response(service)); |
| 175 | } |
| 176 | } else { |
Ihab Awad | 69eb0f5 | 2014-07-18 11:20:37 -0700 | [diff] [blame] | 177 | Log.v(this, "attemptNextPhoneAccount, no more accounts, failing"); |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 178 | if (mResponse != null) { |
Andrew Lee | 701dc00 | 2014-09-11 21:29:12 -0700 | [diff] [blame] | 179 | mResponse.handleCreateConnectionFailure(mLastErrorDisconnectCause); |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 180 | mResponse = null; |
| 181 | mCall.clearConnectionService(); |
| 182 | } |
| 183 | } |
| 184 | } |
| 185 | |
Sailesh Nepal | 7957f9c | 2014-08-09 17:13:19 -0700 | [diff] [blame] | 186 | private boolean shouldSetConnectionManager() { |
| 187 | if (mAttemptRecords.size() == 0) { |
| 188 | return false; |
Ihab Awad | 293edf2 | 2014-07-24 17:52:29 -0700 | [diff] [blame] | 189 | } |
Ihab Awad | c17294c | 2014-08-04 19:23:37 -0700 | [diff] [blame] | 190 | |
Sailesh Nepal | 7957f9c | 2014-08-09 17:13:19 -0700 | [diff] [blame] | 191 | if (mAttemptRecords.size() > 1) { |
| 192 | Log.d(this, "shouldSetConnectionManager, error, mAttemptRecords should not have more " |
| 193 | + "than 1 record"); |
| 194 | return false; |
| 195 | } |
| 196 | |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame^] | 197 | PhoneAccountHandle connectionManager = mPhoneAccountRegistrar.getSimCallManager(); |
Sailesh Nepal | 7957f9c | 2014-08-09 17:13:19 -0700 | [diff] [blame] | 198 | if (connectionManager == null) { |
| 199 | return false; |
| 200 | } |
| 201 | |
| 202 | PhoneAccountHandle targetPhoneAccountHandle = mAttemptRecords.get(0).targetPhoneAccount; |
| 203 | if (Objects.equals(connectionManager, targetPhoneAccountHandle)) { |
| 204 | return false; |
| 205 | } |
| 206 | |
| 207 | // Connection managers are only allowed to manage SIM subscriptions. |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame^] | 208 | PhoneAccount targetPhoneAccount = mPhoneAccountRegistrar.getPhoneAccount( |
| 209 | targetPhoneAccountHandle); |
Sailesh Nepal | 7957f9c | 2014-08-09 17:13:19 -0700 | [diff] [blame] | 210 | boolean isSimSubscription = (targetPhoneAccount.getCapabilities() & |
| 211 | PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION) != 0; |
| 212 | if (!isSimSubscription) { |
| 213 | return false; |
| 214 | } |
| 215 | |
| 216 | return true; |
| 217 | } |
| 218 | |
| 219 | // If there exists a registered connection manager then use it. |
| 220 | private void adjustAttemptsForConnectionManager() { |
| 221 | if (shouldSetConnectionManager()) { |
| 222 | CallAttemptRecord record = new CallAttemptRecord( |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame^] | 223 | mPhoneAccountRegistrar.getSimCallManager(), |
Sailesh Nepal | 7957f9c | 2014-08-09 17:13:19 -0700 | [diff] [blame] | 224 | mAttemptRecords.get(0).targetPhoneAccount); |
| 225 | Log.v(this, "setConnectionManager, changing %s -> %s", |
| 226 | mAttemptRecords.get(0).targetPhoneAccount, record); |
| 227 | mAttemptRecords.set(0, record); |
| 228 | } else { |
| 229 | Log.v(this, "setConnectionManager, not changing"); |
Ihab Awad | 293edf2 | 2014-07-24 17:52:29 -0700 | [diff] [blame] | 230 | } |
| 231 | } |
| 232 | |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 233 | // If we are possibly attempting to call a local emergency number, ensure that the |
Ihab Awad | 69eb0f5 | 2014-07-18 11:20:37 -0700 | [diff] [blame] | 234 | // plain PSTN connection services are listed, and nothing else. |
Ihab Awad | 293edf2 | 2014-07-24 17:52:29 -0700 | [diff] [blame] | 235 | private void adjustAttemptsForEmergency() { |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame^] | 236 | if (TelephonyUtil.shouldProcessAsEmergency(mContext, mCall.getHandle())) { |
Ihab Awad | 69eb0f5 | 2014-07-18 11:20:37 -0700 | [diff] [blame] | 237 | Log.i(this, "Emergency number detected"); |
Ihab Awad | 293edf2 | 2014-07-24 17:52:29 -0700 | [diff] [blame] | 238 | mAttemptRecords.clear(); |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame^] | 239 | List<PhoneAccount> allAccounts = mPhoneAccountRegistrar.getAllPhoneAccounts(); |
Tyler Gunn | 8e0fef4 | 2014-09-08 18:34:44 -0700 | [diff] [blame] | 240 | // First, add SIM phone accounts which can place emergency calls. |
| 241 | for (PhoneAccount phoneAccount : allAccounts) { |
| 242 | if (phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_PLACE_EMERGENCY_CALLS) && |
| 243 | phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION)) { |
| 244 | Log.i(this, "Will try PSTN account %s for emergency", |
| 245 | phoneAccount.getAccountHandle()); |
Ihab Awad | 293edf2 | 2014-07-24 17:52:29 -0700 | [diff] [blame] | 246 | mAttemptRecords.add( |
| 247 | new CallAttemptRecord( |
Tyler Gunn | 8e0fef4 | 2014-09-08 18:34:44 -0700 | [diff] [blame] | 248 | phoneAccount.getAccountHandle(), |
| 249 | phoneAccount.getAccountHandle())); |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 250 | } |
| 251 | } |
Tyler Gunn | 6e6f6d1 | 2014-08-20 15:22:18 -0700 | [diff] [blame] | 252 | |
Tyler Gunn | 8e0fef4 | 2014-09-08 18:34:44 -0700 | [diff] [blame] | 253 | // Next, add the connection manager account as a backup if it can place emergency calls. |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame^] | 254 | PhoneAccountHandle callManagerHandle = mPhoneAccountRegistrar.getSimCallManager(); |
Tyler Gunn | 8e0fef4 | 2014-09-08 18:34:44 -0700 | [diff] [blame] | 255 | if (callManagerHandle != null) { |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame^] | 256 | PhoneAccount callManager = mPhoneAccountRegistrar |
| 257 | .getPhoneAccount(callManagerHandle); |
Tyler Gunn | 8e0fef4 | 2014-09-08 18:34:44 -0700 | [diff] [blame] | 258 | if (callManager.hasCapabilities(PhoneAccount.CAPABILITY_PLACE_EMERGENCY_CALLS)) { |
| 259 | CallAttemptRecord callAttemptRecord = new CallAttemptRecord(callManagerHandle, |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame^] | 260 | mPhoneAccountRegistrar. |
Tyler Gunn | 8e0fef4 | 2014-09-08 18:34:44 -0700 | [diff] [blame] | 261 | getDefaultOutgoingPhoneAccount(mCall.getHandle().getScheme()) |
| 262 | ); |
Tyler Gunn | 6e6f6d1 | 2014-08-20 15:22:18 -0700 | [diff] [blame] | 263 | |
Tyler Gunn | 8e0fef4 | 2014-09-08 18:34:44 -0700 | [diff] [blame] | 264 | if (!mAttemptRecords.contains(callAttemptRecord)) { |
| 265 | Log.i(this, "Will try Connection Manager account %s for emergency", |
| 266 | callManager); |
| 267 | mAttemptRecords.add(callAttemptRecord); |
| 268 | } |
| 269 | } |
Tyler Gunn | 6e6f6d1 | 2014-08-20 15:22:18 -0700 | [diff] [blame] | 270 | } |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 271 | } |
| 272 | } |
| 273 | |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 274 | private class Response implements CreateConnectionResponse { |
| 275 | private final ConnectionServiceWrapper mService; |
| 276 | |
| 277 | Response(ConnectionServiceWrapper service) { |
| 278 | mService = service; |
| 279 | } |
| 280 | |
| 281 | @Override |
Ihab Awad | 8000845 | 2014-08-23 20:35:44 -0700 | [diff] [blame] | 282 | public void handleCreateConnectionSuccess( |
| 283 | CallIdMapper idMapper, |
| 284 | ParcelableConnection connection) { |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 285 | if (mResponse == null) { |
Ihab Awad | fb5560d | 2014-08-18 09:32:51 -0700 | [diff] [blame] | 286 | // Nobody is listening for this connection attempt any longer; ask the responsible |
| 287 | // ConnectionService to tear down any resources associated with the call |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 288 | mService.abort(mCall); |
| 289 | } else { |
Ihab Awad | fb5560d | 2014-08-18 09:32:51 -0700 | [diff] [blame] | 290 | // Success -- share the good news and remember that we are no longer interested |
| 291 | // in hearing about any more attempts |
Ihab Awad | 8000845 | 2014-08-23 20:35:44 -0700 | [diff] [blame] | 292 | mResponse.handleCreateConnectionSuccess(idMapper, connection); |
Santos Cordon | 72890ce | 2014-07-21 01:32:04 -0700 | [diff] [blame] | 293 | mResponse = null; |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 294 | } |
| 295 | } |
| 296 | |
| 297 | @Override |
Andrew Lee | 701dc00 | 2014-09-11 21:29:12 -0700 | [diff] [blame] | 298 | public void handleCreateConnectionFailure(DisconnectCause errorDisconnectCause) { |
Ihab Awad | fb5560d | 2014-08-18 09:32:51 -0700 | [diff] [blame] | 299 | // Failure of some sort; record the reasons for failure and try again if possible |
Andrew Lee | 701dc00 | 2014-09-11 21:29:12 -0700 | [diff] [blame] | 300 | Log.d(CreateConnectionProcessor.this, "Connection failed: (%s)", errorDisconnectCause); |
| 301 | mLastErrorDisconnectCause = errorDisconnectCause; |
Ihab Awad | 69eb0f5 | 2014-07-18 11:20:37 -0700 | [diff] [blame] | 302 | attemptNextPhoneAccount(); |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 303 | } |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 304 | } |
| 305 | } |