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 17 package com.android.server.telecom; 18 19 import android.app.AppOpsManager; 20 21 import android.app.Activity; 22 import android.app.BroadcastOptions; 23 import android.content.BroadcastReceiver; 24 import android.content.Context; 25 import android.content.Intent; 26 import android.content.res.Resources; 27 import android.net.Uri; 28 import android.os.Bundle; 29 import android.os.Trace; 30 import android.os.UserHandle; 31 import android.telecom.GatewayInfo; 32 import android.telecom.Log; 33 import android.telecom.PhoneAccount; 34 import android.telecom.PhoneAccountHandle; 35 import android.telecom.TelecomManager; 36 import android.telecom.VideoProfile; 37 import android.telephony.DisconnectCause; 38 import android.telephony.TelephonyManager; 39 import android.text.TextUtils; 40 41 import com.android.internal.annotations.VisibleForTesting; 42 import com.android.server.telecom.callredirection.CallRedirectionProcessor; 43 44 // TODO: Needed for move to system service: import com.android.internal.R; 45 46 /** 47 * OutgoingCallIntentBroadcaster receives CALL and CALL_PRIVILEGED Intents, and broadcasts the 48 * ACTION_NEW_OUTGOING_CALL intent. ACTION_NEW_OUTGOING_CALL is an ordered broadcast intent which 49 * contains the phone number being dialed. Applications can use this intent to (1) see which numbers 50 * are being dialed, (2) redirect a call (change the number being dialed), or (3) prevent a call 51 * from being placed. 52 * 53 * After the other applications have had a chance to see the ACTION_NEW_OUTGOING_CALL intent, it 54 * finally reaches the {@link NewOutgoingCallBroadcastIntentReceiver}. 55 * 56 * Calls where no number is present (like for a CDMA "empty flash" or a nonexistent voicemail 57 * number) are exempt from being broadcast. 58 * 59 * Calls to emergency numbers are still broadcast for informative purposes. The call is placed 60 * prior to sending ACTION_NEW_OUTGOING_CALL and cannot be redirected nor prevented. 61 */ 62 @VisibleForTesting 63 public class NewOutgoingCallIntentBroadcaster { 64 /** 65 * Legacy string constants used to retrieve gateway provider extras from intents. These still 66 * need to be copied from the source call intent to the destination intent in order to 67 * support third party gateway providers that are still using old string constants in 68 * Telephony. 69 */ 70 public static final String EXTRA_GATEWAY_PROVIDER_PACKAGE = 71 "com.android.phone.extra.GATEWAY_PROVIDER_PACKAGE"; 72 public static final String EXTRA_GATEWAY_URI = "com.android.phone.extra.GATEWAY_URI"; 73 74 private final CallsManager mCallsManager; 75 private Call mCall; 76 private final Intent mIntent; 77 private final Context mContext; 78 private final PhoneNumberUtilsAdapter mPhoneNumberUtilsAdapter; 79 private final TelecomSystem.SyncRoot mLock; 80 private final DefaultDialerCache mDefaultDialerCache; 81 82 /* 83 * Whether or not the outgoing call intent originated from the default phone application. If 84 * so, it will be allowed to make emergency calls, even with the ACTION_CALL intent. 85 */ 86 private final boolean mIsDefaultOrSystemPhoneApp; 87 88 public static class CallDisposition { 89 // True for certain types of numbers that are not intended to be intercepted or modified 90 // by third parties (e.g. emergency numbers). 91 public boolean callImmediately = false; 92 // True for all managed calls, false for self-managed calls. 93 public boolean sendBroadcast = true; 94 // True for requesting call redirection, false for not requesting it. 95 public boolean requestRedirection = true; 96 public int disconnectCause = DisconnectCause.NOT_DISCONNECTED; 97 String number; 98 Uri callingAddress; 99 } 100 101 @VisibleForTesting NewOutgoingCallIntentBroadcaster(Context context, CallsManager callsManager, Intent intent, PhoneNumberUtilsAdapter phoneNumberUtilsAdapter, boolean isDefaultPhoneApp, DefaultDialerCache defaultDialerCache)102 public NewOutgoingCallIntentBroadcaster(Context context, CallsManager callsManager, 103 Intent intent, PhoneNumberUtilsAdapter phoneNumberUtilsAdapter, 104 boolean isDefaultPhoneApp, DefaultDialerCache defaultDialerCache) { 105 mContext = context; 106 mCallsManager = callsManager; 107 mIntent = intent; 108 mPhoneNumberUtilsAdapter = phoneNumberUtilsAdapter; 109 mIsDefaultOrSystemPhoneApp = isDefaultPhoneApp; 110 mLock = mCallsManager.getLock(); 111 mDefaultDialerCache = defaultDialerCache; 112 } 113 114 /** 115 * Processes the result of the outgoing call broadcast intent, and performs callbacks to 116 * the OutgoingCallIntentBroadcasterListener as necessary. 117 */ 118 public class NewOutgoingCallBroadcastIntentReceiver extends BroadcastReceiver { 119 120 @Override onReceive(Context context, Intent intent)121 public void onReceive(Context context, Intent intent) { 122 try { 123 Log.startSession("NOCBIR.oR"); 124 Trace.beginSection("onReceiveNewOutgoingCallBroadcast"); 125 synchronized (mLock) { 126 Log.v(this, "onReceive: %s", intent); 127 128 // Once the NEW_OUTGOING_CALL broadcast is finished, the resultData is 129 // used as the actual number to call. (If null, no call will be placed.) 130 String resultNumber = getResultData(); 131 Log.i(this, "Received new-outgoing-call-broadcast for %s with data %s", mCall, 132 Log.pii(resultNumber)); 133 134 boolean endEarly = false; 135 long disconnectTimeout = 136 Timeouts.getNewOutgoingCallCancelMillis(mContext.getContentResolver()); 137 if (resultNumber == null) { 138 Log.v(this, "Call cancelled (null number), returning..."); 139 disconnectTimeout = getDisconnectTimeoutFromApp( 140 getResultExtras(false), disconnectTimeout); 141 endEarly = true; 142 } else if (isPotentialEmergencyNumber(resultNumber)) { 143 Log.w(this, "Cannot modify outgoing call to emergency number %s.", 144 resultNumber); 145 disconnectTimeout = 0; 146 endEarly = true; 147 } 148 149 if (endEarly) { 150 if (mCall != null) { 151 mCall.disconnect(disconnectTimeout); 152 } 153 return; 154 } 155 156 // If this call is already disconnected then we have nothing more to do. 157 if (mCall.isDisconnected()) { 158 Log.w(this, "Call has already been disconnected," + 159 " ignore the broadcast Call %s", mCall); 160 return; 161 } 162 163 // TODO: Remove the assumption that phone numbers are either SIP or TEL. 164 // This does not impact self-managed ConnectionServices as they do not use the 165 // NewOutgoingCallIntentBroadcaster. 166 Uri resultHandleUri = Uri.fromParts( 167 mPhoneNumberUtilsAdapter.isUriNumber(resultNumber) ? 168 PhoneAccount.SCHEME_SIP : PhoneAccount.SCHEME_TEL, 169 resultNumber, null); 170 171 Uri originalUri = mIntent.getData(); 172 173 if (originalUri.getSchemeSpecificPart().equals(resultNumber)) { 174 Log.v(this, "Call number unmodified after" + 175 " new outgoing call intent broadcast."); 176 } else { 177 Log.v(this, "Retrieved modified handle after outgoing call intent" + 178 " broadcast: Original: %s, Modified: %s", 179 Log.pii(originalUri), 180 Log.pii(resultHandleUri)); 181 } 182 183 GatewayInfo gatewayInfo = getGateWayInfoFromIntent(intent, resultHandleUri); 184 placeOutgoingCallImmediately(mCall, resultHandleUri, gatewayInfo, 185 mIntent.getBooleanExtra( 186 TelecomManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, false), 187 mIntent.getIntExtra(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, 188 VideoProfile.STATE_AUDIO_ONLY)); 189 } 190 } finally { 191 Trace.endSection(); 192 Log.endSession(); 193 } 194 } 195 } 196 197 /** 198 * Processes the supplied intent and starts the outgoing call broadcast process relevant to the 199 * intent. 200 * 201 * This method will handle three kinds of actions: 202 * 203 * - CALL (intent launched by all third party dialers) 204 * - CALL_PRIVILEGED (intent launched by system apps e.g. system Dialer, voice Dialer) 205 * - CALL_EMERGENCY (intent launched by lock screen emergency dialer) 206 * 207 * @return {@link DisconnectCause#NOT_DISCONNECTED} if the call succeeded, and an appropriate 208 * {@link DisconnectCause} if the call did not, describing why it failed. 209 */ 210 @VisibleForTesting evaluateCall()211 public CallDisposition evaluateCall() { 212 CallDisposition result = new CallDisposition(); 213 214 Intent intent = mIntent; 215 String action = intent.getAction(); 216 final Uri handle = intent.getData(); 217 218 if (handle == null) { 219 Log.w(this, "Empty handle obtained from the call intent."); 220 result.disconnectCause = DisconnectCause.INVALID_NUMBER; 221 return result; 222 } 223 224 boolean isVoicemailNumber = PhoneAccount.SCHEME_VOICEMAIL.equals(handle.getScheme()); 225 if (isVoicemailNumber) { 226 if (Intent.ACTION_CALL.equals(action) 227 || Intent.ACTION_CALL_PRIVILEGED.equals(action)) { 228 // Voicemail calls will be handled directly by the telephony connection manager 229 Log.i(this, "Voicemail number dialed. Skipping redirection and broadcast", intent); 230 mIntent.putExtra(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, 231 VideoProfile.STATE_AUDIO_ONLY); 232 result.callImmediately = true; 233 result.requestRedirection = false; 234 result.sendBroadcast = false; 235 result.callingAddress = handle; 236 return result; 237 } else { 238 Log.i(this, "Unhandled intent %s. Ignoring and not placing call.", intent); 239 result.disconnectCause = DisconnectCause.OUTGOING_CANCELED; 240 return result; 241 } 242 } 243 244 PhoneAccountHandle targetPhoneAccount = mIntent.getParcelableExtra( 245 TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE); 246 boolean isSelfManaged = false; 247 if (targetPhoneAccount != null) { 248 PhoneAccount phoneAccount = 249 mCallsManager.getPhoneAccountRegistrar().getPhoneAccountUnchecked( 250 targetPhoneAccount); 251 if (phoneAccount != null) { 252 isSelfManaged = phoneAccount.isSelfManaged(); 253 } 254 } 255 256 result.number = ""; 257 result.callingAddress = handle; 258 259 if (isSelfManaged) { 260 // Self-managed call. 261 result.callImmediately = true; 262 result.sendBroadcast = false; 263 result.requestRedirection = false; 264 Log.i(this, "Skipping NewOutgoingCallBroadcast for self-managed call."); 265 return result; 266 } 267 268 // Placing a managed call 269 String number = getNumberFromCallIntent(intent); 270 result.number = number; 271 if (number == null) { 272 result.disconnectCause = DisconnectCause.NO_PHONE_NUMBER_SUPPLIED; 273 return result; 274 } 275 276 final boolean isPotentialEmergencyNumber = isPotentialEmergencyNumber(number); 277 Log.v(this, "isPotentialEmergencyNumber = %s", isPotentialEmergencyNumber); 278 279 action = calculateCallIntentAction(intent, isPotentialEmergencyNumber); 280 intent.setAction(action); 281 282 if (Intent.ACTION_CALL.equals(action)) { 283 if (isPotentialEmergencyNumber) { 284 if (!mIsDefaultOrSystemPhoneApp) { 285 Log.w(this, "Cannot call potential emergency number %s with CALL Intent %s " 286 + "unless caller is system or default dialer.", number, intent); 287 launchSystemDialer(intent.getData()); 288 result.disconnectCause = DisconnectCause.OUTGOING_CANCELED; 289 return result; 290 } else { 291 result.callImmediately = true; 292 result.requestRedirection = false; 293 } 294 } 295 } else if (Intent.ACTION_CALL_EMERGENCY.equals(action)) { 296 if (!isPotentialEmergencyNumber) { 297 Log.w(this, "Cannot call non-potential-emergency number %s with EMERGENCY_CALL " 298 + "Intent %s.", number, intent); 299 result.disconnectCause = DisconnectCause.OUTGOING_CANCELED; 300 return result; 301 } 302 result.callImmediately = true; 303 result.requestRedirection = false; 304 } else { 305 Log.w(this, "Unhandled Intent %s. Ignoring and not placing call.", intent); 306 result.disconnectCause = DisconnectCause.INVALID_NUMBER; 307 return result; 308 } 309 310 String scheme = mPhoneNumberUtilsAdapter.isUriNumber(number) 311 ? PhoneAccount.SCHEME_SIP : PhoneAccount.SCHEME_TEL; 312 result.callingAddress = Uri.fromParts(scheme, number, null); 313 return result; 314 } 315 getNumberFromCallIntent(Intent intent)316 private String getNumberFromCallIntent(Intent intent) { 317 String number = null; 318 319 Uri uri = intent.getData(); 320 if (uri != null) { 321 String scheme = uri.getScheme(); 322 if (scheme != null) { 323 if (scheme.equals("tel") || scheme.equals("sip")) { 324 number = uri.getSchemeSpecificPart(); 325 } 326 } 327 } 328 329 if (TextUtils.isEmpty(number)) { 330 Log.w(this, "Empty number obtained from the call intent."); 331 return null; 332 } 333 334 boolean isUriNumber = mPhoneNumberUtilsAdapter.isUriNumber(number); 335 if (!isUriNumber) { 336 number = mPhoneNumberUtilsAdapter.convertKeypadLettersToDigits(number); 337 number = mPhoneNumberUtilsAdapter.stripSeparators(number); 338 } 339 return number; 340 } 341 processCall(Call call, CallDisposition disposition)342 public void processCall(Call call, CallDisposition disposition) { 343 mCall = call; 344 if (disposition.callImmediately) { 345 boolean speakerphoneOn = mIntent.getBooleanExtra( 346 TelecomManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, false); 347 int videoState = mIntent.getIntExtra( 348 TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, 349 VideoProfile.STATE_AUDIO_ONLY); 350 placeOutgoingCallImmediately(mCall, disposition.callingAddress, null, 351 speakerphoneOn, videoState); 352 353 // Don't return but instead continue and send the ACTION_NEW_OUTGOING_CALL broadcast 354 // so that third parties can still inspect (but not intercept) the outgoing call. When 355 // the broadcast finally reaches the OutgoingCallBroadcastReceiver, we'll know not to 356 // initiate the call again because of the presence of the EXTRA_ALREADY_CALLED extra. 357 } 358 359 boolean callRedirectionWithService = false; 360 if (disposition.requestRedirection) { 361 CallRedirectionProcessor callRedirectionProcessor = new CallRedirectionProcessor( 362 mContext, mCallsManager, mCall, disposition.callingAddress, 363 mCallsManager.getPhoneAccountRegistrar(), 364 getGateWayInfoFromIntent(mIntent, mIntent.getData()), 365 mIntent.getBooleanExtra(TelecomManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, 366 false), 367 mIntent.getIntExtra(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, 368 VideoProfile.STATE_AUDIO_ONLY)); 369 /** 370 * If there is an available {@link android.telecom.CallRedirectionService}, use the 371 * {@link CallRedirectionProcessor} to perform call redirection instead of using 372 * broadcasting. 373 */ 374 callRedirectionWithService = callRedirectionProcessor 375 .canMakeCallRedirectionWithService(); 376 if (callRedirectionWithService) { 377 callRedirectionProcessor.performCallRedirection(); 378 } 379 } 380 381 if (disposition.sendBroadcast) { 382 UserHandle targetUser = mCall.getInitiatingUser(); 383 Log.i(this, "Sending NewOutgoingCallBroadcast for %s to %s", mCall, targetUser); 384 broadcastIntent(mIntent, disposition.number, 385 !disposition.callImmediately && !callRedirectionWithService, targetUser); 386 } 387 } 388 389 /** 390 * Sends a new outgoing call ordered broadcast so that third party apps can cancel the 391 * placement of the call or redirect it to a different number. 392 * 393 * @param originalCallIntent The original call intent. 394 * @param number Call number that was stored in the original call intent. 395 * @param receiverRequired Whether or not the result from the ordered broadcast should be 396 * processed using a {@link NewOutgoingCallIntentBroadcaster}. 397 * @param targetUser User that the broadcast sent to. 398 */ broadcastIntent( Intent originalCallIntent, String number, boolean receiverRequired, UserHandle targetUser)399 private void broadcastIntent( 400 Intent originalCallIntent, 401 String number, 402 boolean receiverRequired, 403 UserHandle targetUser) { 404 Intent broadcastIntent = new Intent(Intent.ACTION_NEW_OUTGOING_CALL); 405 if (number != null) { 406 broadcastIntent.putExtra(Intent.EXTRA_PHONE_NUMBER, number); 407 } 408 409 // Force receivers of this broadcast intent to run at foreground priority because we 410 // want to finish processing the broadcast intent as soon as possible. 411 broadcastIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND 412 | Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); 413 Log.v(this, "Broadcasting intent: %s.", broadcastIntent); 414 415 checkAndCopyProviderExtras(originalCallIntent, broadcastIntent); 416 417 final BroadcastOptions options = BroadcastOptions.makeBasic(); 418 options.setBackgroundActivityStartsAllowed(true); 419 mContext.sendOrderedBroadcastAsUser( 420 broadcastIntent, 421 targetUser, 422 android.Manifest.permission.PROCESS_OUTGOING_CALLS, 423 AppOpsManager.OP_PROCESS_OUTGOING_CALLS, 424 options.toBundle(), 425 receiverRequired ? new NewOutgoingCallBroadcastIntentReceiver() : null, 426 null, // scheduler 427 Activity.RESULT_OK, // initialCode 428 number, // initialData: initial value for the result data (number to be modified) 429 null); // initialExtras 430 } 431 432 /** 433 * Copy all the expected extras set when a 3rd party gateway provider is to be used, from the 434 * source intent to the destination one. 435 * 436 * @param src Intent which may contain the provider's extras. 437 * @param dst Intent where a copy of the extras will be added if applicable. 438 */ checkAndCopyProviderExtras(Intent src, Intent dst)439 public void checkAndCopyProviderExtras(Intent src, Intent dst) { 440 if (src == null) { 441 return; 442 } 443 if (hasGatewayProviderExtras(src)) { 444 dst.putExtra(EXTRA_GATEWAY_PROVIDER_PACKAGE, 445 src.getStringExtra(EXTRA_GATEWAY_PROVIDER_PACKAGE)); 446 dst.putExtra(EXTRA_GATEWAY_URI, 447 src.getStringExtra(EXTRA_GATEWAY_URI)); 448 Log.d(this, "Found and copied gateway provider extras to broadcast intent."); 449 return; 450 } 451 452 Log.d(this, "No provider extras found in call intent."); 453 } 454 455 /** 456 * Check if valid gateway provider information is stored as extras in the intent 457 * 458 * @param intent to check for 459 * @return true if the intent has all the gateway information extras needed. 460 */ hasGatewayProviderExtras(Intent intent)461 private boolean hasGatewayProviderExtras(Intent intent) { 462 final String name = intent.getStringExtra(EXTRA_GATEWAY_PROVIDER_PACKAGE); 463 final String uriString = intent.getStringExtra(EXTRA_GATEWAY_URI); 464 465 return !TextUtils.isEmpty(name) && !TextUtils.isEmpty(uriString); 466 } 467 getGatewayUriFromString(String gatewayUriString)468 private static Uri getGatewayUriFromString(String gatewayUriString) { 469 return TextUtils.isEmpty(gatewayUriString) ? null : Uri.parse(gatewayUriString); 470 } 471 472 /** 473 * Extracts gateway provider information from a provided intent.. 474 * 475 * @param intent to extract gateway provider information from. 476 * @param trueHandle The actual call handle that the user is trying to dial 477 * @return GatewayInfo object containing extracted gateway provider information as well as 478 * the actual handle the user is trying to dial. 479 */ getGateWayInfoFromIntent(Intent intent, Uri trueHandle)480 public static GatewayInfo getGateWayInfoFromIntent(Intent intent, Uri trueHandle) { 481 if (intent == null) { 482 return null; 483 } 484 485 // Check if gateway extras are present. 486 String gatewayPackageName = intent.getStringExtra(EXTRA_GATEWAY_PROVIDER_PACKAGE); 487 Uri gatewayUri = getGatewayUriFromString(intent.getStringExtra(EXTRA_GATEWAY_URI)); 488 if (!TextUtils.isEmpty(gatewayPackageName) && gatewayUri != null) { 489 return new GatewayInfo(gatewayPackageName, gatewayUri, trueHandle); 490 } 491 492 return null; 493 } 494 placeOutgoingCallImmediately(Call call, Uri handle, GatewayInfo gatewayInfo, boolean speakerphoneOn, int videoState)495 private void placeOutgoingCallImmediately(Call call, Uri handle, GatewayInfo gatewayInfo, 496 boolean speakerphoneOn, int videoState) { 497 Log.i(this, 498 "Placing call immediately instead of waiting for OutgoingCallBroadcastReceiver"); 499 // Since we are not going to go through "Outgoing call broadcast", make sure 500 // we mark it as ready. 501 mCall.setNewOutgoingCallIntentBroadcastIsDone(); 502 mCallsManager.placeOutgoingCall(call, handle, gatewayInfo, speakerphoneOn, videoState); 503 } 504 launchSystemDialer(Uri handle)505 private void launchSystemDialer(Uri handle) { 506 Intent systemDialerIntent = new Intent(); 507 systemDialerIntent.setComponent(mDefaultDialerCache.getDialtactsSystemDialerComponent()); 508 systemDialerIntent.setAction(Intent.ACTION_DIAL); 509 systemDialerIntent.setData(handle); 510 systemDialerIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 511 Log.v(this, "calling startActivity for default dialer: %s", systemDialerIntent); 512 mContext.startActivityAsUser(systemDialerIntent, UserHandle.CURRENT); 513 } 514 515 /** 516 * Check whether or not this is an emergency number, in order to enforce the restriction 517 * that only the CALL_PRIVILEGED and CALL_EMERGENCY intents are allowed to make emergency 518 * calls. 519 * 520 * To prevent malicious 3rd party apps from making emergency calls by passing in an 521 * "invalid" number like "9111234" (that isn't technically an emergency number but might 522 * still result in an emergency call with some networks), we use 523 * isPotentialLocalEmergencyNumber instead of isLocalEmergencyNumber. 524 * 525 * @param number number to inspect in order to determine whether or not an emergency number 526 * is potentially being dialed 527 * @return True if the handle is potentially an emergency number. 528 */ isPotentialEmergencyNumber(String number)529 private boolean isPotentialEmergencyNumber(String number) { 530 Log.v(this, "Checking restrictions for number : %s", Log.pii(number)); 531 if (number == null) return false; 532 try { 533 return mContext.getSystemService(TelephonyManager.class).isPotentialEmergencyNumber( 534 number); 535 } catch (Exception e) { 536 Log.e(this, e, "isPotentialEmergencyNumber: Telephony threw an exception."); 537 return false; 538 } 539 } 540 541 /** 542 * Given a call intent and whether or not the number to dial is an emergency number, determine 543 * the appropriate call intent action. 544 * 545 * @param intent Intent to evaluate 546 * @param isPotentialEmergencyNumber Whether or not the number is potentially an emergency 547 * number. 548 * @return The appropriate action. 549 */ calculateCallIntentAction(Intent intent, boolean isPotentialEmergencyNumber)550 private String calculateCallIntentAction(Intent intent, boolean isPotentialEmergencyNumber) { 551 String action = intent.getAction(); 552 553 /* Change CALL_PRIVILEGED into CALL or CALL_EMERGENCY as needed. */ 554 if (Intent.ACTION_CALL_PRIVILEGED.equals(action)) { 555 if (isPotentialEmergencyNumber) { 556 Log.i(this, "ACTION_CALL_PRIVILEGED is used while the number is a potential" 557 + " emergency number. Using ACTION_CALL_EMERGENCY as an action instead."); 558 action = Intent.ACTION_CALL_EMERGENCY; 559 } else { 560 action = Intent.ACTION_CALL; 561 } 562 Log.v(this, " - updating action from CALL_PRIVILEGED to %s", action); 563 } 564 return action; 565 } 566 getDisconnectTimeoutFromApp(Bundle resultExtras, long defaultTimeout)567 private long getDisconnectTimeoutFromApp(Bundle resultExtras, long defaultTimeout) { 568 if (resultExtras != null) { 569 long disconnectTimeout = resultExtras.getLong( 570 TelecomManager.EXTRA_NEW_OUTGOING_CALL_CANCEL_TIMEOUT, defaultTimeout); 571 if (disconnectTimeout < 0) { 572 disconnectTimeout = 0; 573 } 574 return Math.min(disconnectTimeout, 575 Timeouts.getMaxNewOutgoingCallCancelMillis(mContext.getContentResolver())); 576 } else { 577 return defaultTimeout; 578 } 579 } 580 } 581