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