NewOutgoingCallIntentBroadcaster.java revision e05257c9cd0b86f0c161bc12fc913c76e7b8ae6c
133501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee/* 233501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * Copyright (C) 2014 The Android Open Source Project 333501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * 433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * Licensed under the Apache License, Version 2.0 (the "License"); 533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * you may not use this file except in compliance with the License. 633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * You may obtain a copy of the License at 733501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * 833501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * http://www.apache.org/licenses/LICENSE-2.0 933501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * 1033501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * Unless required by applicable law or agreed to in writing, software 1133501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * distributed under the License is distributed on an "AS IS" BASIS, 1233501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1333501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * See the License for the specific language governing permissions and 1433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * limitations under the License. 1533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee */ 1633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 1733501635c2cd21f40793041eff3b8ce3a5710d49Yorke Leepackage com.android.telecomm; 1833501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 1933501635c2cd21f40793041eff3b8ce3a5710d49Yorke Leeimport android.app.Activity; 2033501635c2cd21f40793041eff3b8ce3a5710d49Yorke Leeimport android.content.BroadcastReceiver; 2133501635c2cd21f40793041eff3b8ce3a5710d49Yorke Leeimport android.content.Context; 2233501635c2cd21f40793041eff3b8ce3a5710d49Yorke Leeimport android.content.Intent; 2333501635c2cd21f40793041eff3b8ce3a5710d49Yorke Leeimport android.content.res.Resources; 2433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Leeimport android.net.Uri; 2533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Leeimport android.os.UserHandle; 2633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Leeimport android.telecomm.GatewayInfo; 2756a76b79e2a03eb0fe070d3ef17e474ae27bb6f3Jay Shraunerimport android.telecomm.PhoneAccount; 28b35fc31be63df5d78183d6c94f53eea45c3542deEvan Charltonimport android.telecomm.TelecommManager; 296fb37c87836b5245046bd3b14320823ab839a10cIhab Awadimport android.telecomm.VideoProfile; 30d7255872e2204a074bc5dfb5dceb4da13574864cYorke Leeimport android.telephony.DisconnectCause; 3133501635c2cd21f40793041eff3b8ce3a5710d49Yorke Leeimport android.telephony.PhoneNumberUtils; 3233501635c2cd21f40793041eff3b8ce3a5710d49Yorke Leeimport android.text.TextUtils; 3333501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 3433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee/** 3533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * OutgoingCallIntentBroadcaster receives CALL and CALL_PRIVILEGED Intents, and broadcasts the 3633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * ACTION_NEW_OUTGOING_CALL intent. ACTION_NEW_OUTGOING_CALL is an ordered broadcast intent which 3733501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * contains the phone number being dialed. Applications can use this intent to (1) see which numbers 3833501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * are being dialed, (2) redirect a call (change the number being dialed), or (3) prevent a call 3933501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * from being placed. 4033501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * 4133501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * After the other applications have had a chance to see the ACTION_NEW_OUTGOING_CALL intent, it 4233501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * finally reaches the {@link NewOutgoingCallBroadcastIntentReceiver}. 4333501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * 4433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * Calls where no number is present (like for a CDMA "empty flash" or a nonexistent voicemail 4533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * number) are exempt from being broadcast. 4633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * 4733501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * Calls to emergency numbers are still broadcast for informative purposes. The call is placed 4833501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * prior to sending ACTION_NEW_OUTGOING_CALL and cannot be redirected nor prevented. 4933501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee */ 5033501635c2cd21f40793041eff3b8ce3a5710d49Yorke Leeclass NewOutgoingCallIntentBroadcaster { 5133501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee /** Required permission for any app that wants to consume ACTION_NEW_OUTGOING_CALL. */ 5233501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee private static final String PERMISSION = android.Manifest.permission.PROCESS_OUTGOING_CALLS; 5333501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 5433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee private static final String EXTRA_ACTUAL_NUMBER_TO_DIAL = 5533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee "android.telecomm.extra.ACTUAL_NUMBER_TO_DIAL"; 5633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 5733501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee /** 5833501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * Legacy string constants used to retrieve gateway provider extras from intents. These still 5933501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * need to be copied from the source call intent to the destination intent in order to 6033501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * support third party gateway providers that are still using old string constants in 6133501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * Telephony. 6233501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee */ 6333501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee public static final String EXTRA_GATEWAY_PROVIDER_PACKAGE = 6433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee "com.android.phone.extra.GATEWAY_PROVIDER_PACKAGE"; 6533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee public static final String EXTRA_GATEWAY_URI = "com.android.phone.extra.GATEWAY_URI"; 66571f0737002251f09b9ef696dc8b4c9ce02abbaeSantos Cordon public static final String EXTRA_GATEWAY_ORIGINAL_URI = 67571f0737002251f09b9ef696dc8b4c9ce02abbaeSantos Cordon "com.android.phone.extra.GATEWAY_ORIGINAL_URI"; 6833501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 6933501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee private final CallsManager mCallsManager; 700d3076c3dfa54f1102a843735ca774759e52d8b8Nancy Chen private final Call mCall; 7133501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee private final Intent mIntent; 72cce5deb2bc998d6385152292153a9423f5206c28Yorke Lee /* 73cce5deb2bc998d6385152292153a9423f5206c28Yorke Lee * Whether or not the outgoing call intent originated from the default phone application. If 74cce5deb2bc998d6385152292153a9423f5206c28Yorke Lee * so, it will be allowed to make emergency calls, even with the ACTION_CALL intent. 75cce5deb2bc998d6385152292153a9423f5206c28Yorke Lee */ 76cce5deb2bc998d6385152292153a9423f5206c28Yorke Lee private final boolean mIsDefaultOrSystemPhoneApp; 7733501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 780d3076c3dfa54f1102a843735ca774759e52d8b8Nancy Chen NewOutgoingCallIntentBroadcaster(CallsManager callsManager, Call call, Intent intent, 79cce5deb2bc998d6385152292153a9423f5206c28Yorke Lee boolean isDefaultPhoneApp) { 8033501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee mCallsManager = callsManager; 810d3076c3dfa54f1102a843735ca774759e52d8b8Nancy Chen mCall = call; 8233501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee mIntent = intent; 83cce5deb2bc998d6385152292153a9423f5206c28Yorke Lee mIsDefaultOrSystemPhoneApp = isDefaultPhoneApp; 8433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } 8533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 8633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee /** 8733501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * Processes the result of the outgoing call broadcast intent, and performs callbacks to 8833501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * the OutgoingCallIntentBroadcasterListener as necessary. 8933501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee */ 9033501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee private class NewOutgoingCallBroadcastIntentReceiver extends BroadcastReceiver { 9133501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 9233501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee @Override 9333501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee public void onReceive(Context context, Intent intent) { 94b33087514fb354c9d10c29f9cb071ed2ae2a6124Sailesh Nepal Log.v(this, "onReceive: %s", intent); 9533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 9633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee // Once the NEW_OUTGOING_CALL broadcast is finished, the resultData is used as the 9733501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee // actual number to call. (If null, no call will be placed.) 98308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen String resultNumber = getResultData(); 99308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen Log.v(this, "- got number from resultData: %s", Log.pii(resultNumber)); 10033501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 1012d0b331f659e4e95621e738bbddaa38a80a70d4cSantos Cordon boolean endEarly = false; 102308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen if (resultNumber == null) { 10333501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee Log.v(this, "Call cancelled (null number), returning..."); 1042d0b331f659e4e95621e738bbddaa38a80a70d4cSantos Cordon endEarly = true; 105308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen } else if (PhoneNumberUtils.isPotentialLocalEmergencyNumber(context, resultNumber)) { 106308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen Log.w(this, "Cannot modify outgoing call to emergency number %s.", resultNumber); 1072d0b331f659e4e95621e738bbddaa38a80a70d4cSantos Cordon endEarly = true; 1082d0b331f659e4e95621e738bbddaa38a80a70d4cSantos Cordon } 1092d0b331f659e4e95621e738bbddaa38a80a70d4cSantos Cordon 1102d0b331f659e4e95621e738bbddaa38a80a70d4cSantos Cordon if (endEarly) { 1112d0b331f659e4e95621e738bbddaa38a80a70d4cSantos Cordon if (mCall != null) { 1122d0b331f659e4e95621e738bbddaa38a80a70d4cSantos Cordon mCall.disconnect(); 1132d0b331f659e4e95621e738bbddaa38a80a70d4cSantos Cordon } 11433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee return; 11533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } 11633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 117d75fabf9b3787b851a29e1396d9525706c11864dNancy Chen Uri resultHandleUri = Uri.fromParts(PhoneNumberUtils.isUriNumber(resultNumber) ? 11856a76b79e2a03eb0fe070d3ef17e474ae27bb6f3Jay Shrauner PhoneAccount.SCHEME_SIP : PhoneAccount.SCHEME_TEL, resultNumber, null); 11933501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 12033501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee Uri originalUri = mIntent.getData(); 12133501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 122308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen if (originalUri.getSchemeSpecificPart().equals(resultNumber)) { 123308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen Log.v(this, "Call number unmodified after new outgoing call intent broadcast."); 12433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } else { 12533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee Log.v(this, "Retrieved modified handle after outgoing call intent broadcast: " 12633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee + "Original: %s, Modified: %s", 12733501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee Log.pii(originalUri), 12833501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee Log.pii(resultHandleUri)); 12933501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } 13033501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 13133501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee GatewayInfo gatewayInfo = getGateWayInfoFromIntent(intent, resultHandleUri); 132bc9ef17acc7940fdaec78a5dc1efdd29dff41488Nancy Chen mCallsManager.placeOutgoingCall(mCall, resultHandleUri, gatewayInfo, 133b35fc31be63df5d78183d6c94f53eea45c3542deEvan Charlton mIntent.getBooleanExtra(TelecommManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, 134c4abd91cd8a67b530ebafe146af10136db8e6605Tyler Gunn false), 135b35fc31be63df5d78183d6c94f53eea45c3542deEvan Charlton mIntent.getIntExtra(TelecommManager.EXTRA_START_CALL_WITH_VIDEO_STATE, 1366fb37c87836b5245046bd3b14320823ab839a10cIhab Awad VideoProfile.VideoState.AUDIO_ONLY)); 13733501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } 13833501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } 13933501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 14033501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee /** 14133501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * Processes the supplied intent and starts the outgoing call broadcast process relevant to the 14233501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * intent. 14333501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * 14433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * This method will handle three kinds of actions: 14533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * 14633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * - CALL (intent launched by all third party dialers) 14733501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * - CALL_PRIVILEGED (intent launched by system apps e.g. system Dialer, voice Dialer) 14833501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * - CALL_EMERGENCY (intent launched by lock screen emergency dialer) 149cce5deb2bc998d6385152292153a9423f5206c28Yorke Lee * 150d7255872e2204a074bc5dfb5dceb4da13574864cYorke Lee * @return {@link CallActivity#OUTGOING_CALL_SUCCEEDED} if the call succeeded, and an 151d7255872e2204a074bc5dfb5dceb4da13574864cYorke Lee * appropriate {@link DisconnectCause} if the call did not, describing why it failed. 15233501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee */ 153d7255872e2204a074bc5dfb5dceb4da13574864cYorke Lee int processIntent() { 15433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee Log.v(this, "Processing call intent in OutgoingCallIntentBroadcaster."); 15533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 15633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee final Context context = TelecommApp.getInstance(); 157308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen 15833501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee Intent intent = mIntent; 159308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen String action = intent.getAction(); 160308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen final Uri handle = intent.getData(); 161308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen 162308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen if (handle == null) { 163308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen Log.w(this, "Empty handle obtained from the call intent."); 164308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen return DisconnectCause.INVALID_NUMBER; 165308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen } 16633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 16756a76b79e2a03eb0fe070d3ef17e474ae27bb6f3Jay Shrauner boolean isVoicemailNumber = PhoneAccount.SCHEME_VOICEMAIL.equals(handle.getScheme()); 168308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen if (isVoicemailNumber) { 169308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen if (Intent.ACTION_CALL.equals(action)) { 170308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen // Voicemail calls will be handled directly by the telephony connection manager 171308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen Log.i(this, "Placing call immediately instead of waiting for " 172308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen + " OutgoingCallBroadcastReceiver: %s", intent); 17333501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 174308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen boolean speakerphoneOn = mIntent.getBooleanExtra( 175308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen TelecommManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, false); 176308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen mCallsManager.placeOutgoingCall(mCall, handle, null, speakerphoneOn, 177308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen VideoProfile.VideoState.AUDIO_ONLY); 178308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen 179308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen return DisconnectCause.NOT_DISCONNECTED; 180d7255872e2204a074bc5dfb5dceb4da13574864cYorke Lee } else { 181308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen Log.i(this, "Unhandled intent %s. Ignoring and not placing call.", intent); 182308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen return DisconnectCause.OUTGOING_CANCELED; 183d7255872e2204a074bc5dfb5dceb4da13574864cYorke Lee } 18433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } 18533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 186308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen String number = PhoneNumberUtils.getNumberFromIntent(intent, context); 187308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen if (TextUtils.isEmpty(number)) { 188308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen Log.w(this, "Empty number obtained from the call intent."); 189308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen return DisconnectCause.NO_PHONE_NUMBER_SUPPLIED; 190308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen } 191b58f453c46a695347a69f8c973a77796e5c1fdf7Santos Cordon 192308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen boolean isUriNumber = PhoneNumberUtils.isUriNumber(number); 193b58f453c46a695347a69f8c973a77796e5c1fdf7Santos Cordon if (!isUriNumber) { 194308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen number = PhoneNumberUtils.convertKeypadLettersToDigits(number); 195308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen number = PhoneNumberUtils.stripSeparators(number); 19633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } 19733501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 198308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen final boolean isPotentialEmergencyNumber = isPotentialEmergencyNumber(context, number); 19933501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee Log.v(this, "isPotentialEmergencyNumber = %s", isPotentialEmergencyNumber); 20033501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 20133501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee rewriteCallIntentAction(intent, isPotentialEmergencyNumber); 202e05257c9cd0b86f0c161bc12fc913c76e7b8ae6cYorke Lee action = intent.getAction(); 20333501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee // True for certain types of numbers that are not intended to be intercepted or modified 20433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee // by third parties (e.g. emergency numbers). 20533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee boolean callImmediately = false; 20633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 20733501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee if (Intent.ACTION_CALL.equals(action)) { 20833501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee if (isPotentialEmergencyNumber) { 209cce5deb2bc998d6385152292153a9423f5206c28Yorke Lee if (!mIsDefaultOrSystemPhoneApp) { 210cce5deb2bc998d6385152292153a9423f5206c28Yorke Lee Log.w(this, "Cannot call potential emergency number %s with CALL Intent %s " 211308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen + "unless caller is system or default dialer.", number, intent); 212cce5deb2bc998d6385152292153a9423f5206c28Yorke Lee launchSystemDialer(context, intent.getData()); 213d7255872e2204a074bc5dfb5dceb4da13574864cYorke Lee return DisconnectCause.OUTGOING_CANCELED; 214cce5deb2bc998d6385152292153a9423f5206c28Yorke Lee } else { 215cce5deb2bc998d6385152292153a9423f5206c28Yorke Lee callImmediately = true; 216cce5deb2bc998d6385152292153a9423f5206c28Yorke Lee } 21733501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } 21833501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } else if (Intent.ACTION_CALL_EMERGENCY.equals(action)) { 21933501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee if (!isPotentialEmergencyNumber) { 22033501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee Log.w(this, "Cannot call non-potential-emergency number %s with EMERGENCY_CALL " 221308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen + "Intent %s.", number, intent); 222d7255872e2204a074bc5dfb5dceb4da13574864cYorke Lee return DisconnectCause.OUTGOING_CANCELED; 22333501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } 22433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee callImmediately = true; 22533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } else { 22633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee Log.w(this, "Unhandled Intent %s. Ignoring and not placing call.", intent); 227d7255872e2204a074bc5dfb5dceb4da13574864cYorke Lee return DisconnectCause.INVALID_NUMBER; 22833501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } 22933501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 23033501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee if (callImmediately) { 23133501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee Log.i(this, "Placing call immediately instead of waiting for " 23233501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee + " OutgoingCallBroadcastReceiver: %s", intent); 23356a76b79e2a03eb0fe070d3ef17e474ae27bb6f3Jay Shrauner String scheme = isUriNumber ? PhoneAccount.SCHEME_SIP : PhoneAccount.SCHEME_TEL; 234905dfba7883666f45a0c6958d8bc6c19d68972d9Sailesh Nepal boolean speakerphoneOn = mIntent.getBooleanExtra( 235b35fc31be63df5d78183d6c94f53eea45c3542deEvan Charlton TelecommManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, false); 236905dfba7883666f45a0c6958d8bc6c19d68972d9Sailesh Nepal int videoState = mIntent.getIntExtra( 237b35fc31be63df5d78183d6c94f53eea45c3542deEvan Charlton TelecommManager.EXTRA_START_CALL_WITH_VIDEO_STATE, 2386fb37c87836b5245046bd3b14320823ab839a10cIhab Awad VideoProfile.VideoState.AUDIO_ONLY); 239308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen mCallsManager.placeOutgoingCall(mCall, Uri.fromParts(scheme, number, null), null, 2400d3076c3dfa54f1102a843735ca774759e52d8b8Nancy Chen speakerphoneOn, videoState); 24133501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 24233501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee // Don't return but instead continue and send the ACTION_NEW_OUTGOING_CALL broadcast 24333501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee // so that third parties can still inspect (but not intercept) the outgoing call. When 24433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee // the broadcast finally reaches the OutgoingCallBroadcastReceiver, we'll know not to 24533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee // initiate the call again because of the presence of the EXTRA_ALREADY_CALLED extra. 24633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } 24733501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 248308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen broadcastIntent(intent, number, context, !callImmediately); 249d7255872e2204a074bc5dfb5dceb4da13574864cYorke Lee return DisconnectCause.NOT_DISCONNECTED; 25033501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } 25133501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 25233501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee /** 25333501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * Sends a new outgoing call ordered broadcast so that third party apps can cancel the 25433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * placement of the call or redirect it to a different number. 25533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * 25633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * @param originalCallIntent The original call intent. 257308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen * @param number Call number that was stored in the original call intent. 25833501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * @param context Valid context to send the ordered broadcast using. 25933501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * @param receiverRequired Whether or not the result from the ordered broadcast should be 26033501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * processed using a {@link NewOutgoingCallIntentBroadcaster}. 26133501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee */ 26233501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee private void broadcastIntent( 26333501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee Intent originalCallIntent, 264308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen String number, 26533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee Context context, 26633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee boolean receiverRequired) { 26733501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee Intent broadcastIntent = new Intent(Intent.ACTION_NEW_OUTGOING_CALL); 268308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen if (number != null) { 269308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen broadcastIntent.putExtra(Intent.EXTRA_PHONE_NUMBER, number); 27033501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } 27133501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 27233501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee // Force receivers of this broadcast intent to run at foreground priority because we 27333501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee // want to finish processing the broadcast intent as soon as possible. 27433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee broadcastIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); 27533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee Log.v(this, "Broadcasting intent: %s.", broadcastIntent); 27633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 27777d2d0e90bc2a67d526743b8e32f920a0d755fbaNancy Chen checkAndCopyProviderExtras(originalCallIntent, broadcastIntent); 27833501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 27933501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee context.sendOrderedBroadcastAsUser( 28033501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee broadcastIntent, 28133501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee UserHandle.OWNER, 28233501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee PERMISSION, 28333501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee receiverRequired ? new NewOutgoingCallBroadcastIntentReceiver() : null, 28433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee null, // scheduler 28533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee Activity.RESULT_OK, // initialCode 286308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen number, // initialData: initial value for the result data (number to be modified) 28733501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee null); // initialExtras 28833501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } 28933501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 29033501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee /** 29133501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * Copy all the expected extras set when a 3rd party gateway provider is to be used, from the 29233501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * source intent to the destination one. 29333501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * 29433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * @param src Intent which may contain the provider's extras. 29533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * @param dst Intent where a copy of the extras will be added if applicable. 29633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee */ 29777d2d0e90bc2a67d526743b8e32f920a0d755fbaNancy Chen public void checkAndCopyProviderExtras(Intent src, Intent dst) { 29877d2d0e90bc2a67d526743b8e32f920a0d755fbaNancy Chen if (src == null) { 29977d2d0e90bc2a67d526743b8e32f920a0d755fbaNancy Chen return; 30077d2d0e90bc2a67d526743b8e32f920a0d755fbaNancy Chen } 30133501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee if (hasGatewayProviderExtras(src)) { 30233501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee dst.putExtra(EXTRA_GATEWAY_PROVIDER_PACKAGE, 30333501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee src.getStringExtra(EXTRA_GATEWAY_PROVIDER_PACKAGE)); 30433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee dst.putExtra(EXTRA_GATEWAY_URI, 30533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee src.getStringExtra(EXTRA_GATEWAY_URI)); 30633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee Log.d(this, "Found and copied gateway provider extras to broadcast intent."); 30733501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee return; 30833501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } 30933501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 31077d2d0e90bc2a67d526743b8e32f920a0d755fbaNancy Chen Log.d(this, "No provider extras found in call intent."); 31133501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } 31233501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 31333501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee /** 31433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * Check if valid gateway provider information is stored as extras in the intent 31533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * 31633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * @param intent to check for 31733501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * @return true if the intent has all the gateway information extras needed. 31833501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee */ 31933501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee private boolean hasGatewayProviderExtras(Intent intent) { 32033501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee final String name = intent.getStringExtra(EXTRA_GATEWAY_PROVIDER_PACKAGE); 32133501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee final String uriString = intent.getStringExtra(EXTRA_GATEWAY_URI); 32233501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 32333501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee return !TextUtils.isEmpty(name) && !TextUtils.isEmpty(uriString); 32433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } 32533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 32633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee private static Uri getGatewayUriFromString(String gatewayUriString) { 32733501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee return TextUtils.isEmpty(gatewayUriString) ? null : Uri.parse(gatewayUriString); 32833501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } 32933501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 33033501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee /** 33133501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * Extracts gateway provider information from a provided intent.. 33233501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * 33333501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * @param intent to extract gateway provider information from. 33433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * @param trueHandle The actual call handle that the user is trying to dial 33533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * @return GatewayInfo object containing extracted gateway provider information as well as 33633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * the actual handle the user is trying to dial. 33733501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee */ 33833501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee public static GatewayInfo getGateWayInfoFromIntent(Intent intent, Uri trueHandle) { 33933501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee if (intent == null) { 34033501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee return null; 34133501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } 34233501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 34333501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee // Check if gateway extras are present. 34433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee String gatewayPackageName = intent.getStringExtra(EXTRA_GATEWAY_PROVIDER_PACKAGE); 34533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee Uri gatewayUri = getGatewayUriFromString(intent.getStringExtra(EXTRA_GATEWAY_URI)); 34633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee if (!TextUtils.isEmpty(gatewayPackageName) && gatewayUri != null) { 34733501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee return new GatewayInfo(gatewayPackageName, gatewayUri, trueHandle); 34833501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } 34933501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 35033501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee return null; 35133501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } 35233501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 35333501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee private void launchSystemDialer(Context context, Uri handle) { 35433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee Intent systemDialerIntent = new Intent(); 35533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee final Resources resources = context.getResources(); 35633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee systemDialerIntent.setClassName( 35733501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee resources.getString(R.string.ui_default_package), 35833501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee resources.getString(R.string.dialer_default_class)); 35933501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee systemDialerIntent.setAction(Intent.ACTION_DIAL); 36033501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee systemDialerIntent.setData(handle); 36133501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee systemDialerIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 36233501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee Log.v(this, "calling startActivity for default dialer: %s", systemDialerIntent); 36333501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee context.startActivity(systemDialerIntent); 36433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } 36533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 36633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee /** 36733501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * Check whether or not this is an emergency number, in order to enforce the restriction 36833501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * that only the CALL_PRIVILEGED and CALL_EMERGENCY intents are allowed to make emergency 36933501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * calls. 37033501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * 37133501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * To prevent malicious 3rd party apps from making emergency calls by passing in an 37233501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * "invalid" number like "9111234" (that isn't technically an emergency number but might 37333501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * still result in an emergency call with some networks), we use 37433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * isPotentialLocalEmergencyNumber instead of isLocalEmergencyNumber. 37533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * 37633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * @param context Valid context 377308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen * @param number number to inspect in order to determine whether or not an emergency number 37833501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * is potentially being dialed 37933501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * @return True if the handle is potentially an emergency number. 38033501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee */ 381308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen private boolean isPotentialEmergencyNumber(Context context, String number) { 382308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen Log.v(this, "Checking restrictions for number : %s", Log.pii(number)); 383308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen return (number != null) && PhoneNumberUtils.isPotentialLocalEmergencyNumber(context,number); 38433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } 38533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 38633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee /** 38733501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * Given a call intent and whether or not the number to dial is an emergency number, rewrite 38833501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * the call intent action to an appropriate one. 38933501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * 39033501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * @param intent Intent to rewrite the action for 391308ab8bd691f4a1bc4c7c094bcffc84f5fe345aaNancy Chen * @param isPotentialEmergencyNumber Whether or not the number is potentially an emergency 39233501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee * number. 39333501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee */ 39433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee private void rewriteCallIntentAction(Intent intent, boolean isPotentialEmergencyNumber) { 39533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee if (CallActivity.class.getName().equals(intent.getComponent().getClassName())) { 39633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee // If we were launched directly from the CallActivity, not one of its more privileged 39733501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee // aliases, then make sure that only the non-privileged actions are allowed. 39833501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee if (!Intent.ACTION_CALL.equals(intent.getAction())) { 39933501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee Log.w(this, "Attempt to deliver non-CALL action; forcing to CALL"); 40033501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee intent.setAction(Intent.ACTION_CALL); 40133501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } 40233501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } 40333501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 40433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee String action = intent.getAction(); 40533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee 40633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee /* Change CALL_PRIVILEGED into CALL or CALL_EMERGENCY as needed. */ 40733501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee if (Intent.ACTION_CALL_PRIVILEGED.equals(action)) { 40833501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee if (isPotentialEmergencyNumber) { 40933501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee Log.i(this, "ACTION_CALL_PRIVILEGED is used while the number is a potential" 41033501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee + " emergency number. Using ACTION_CALL_EMERGENCY as an action instead."); 41133501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee action = Intent.ACTION_CALL_EMERGENCY; 41233501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } else { 41333501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee action = Intent.ACTION_CALL; 41433501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } 41533501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee Log.v(this, " - updating action from CALL_PRIVILEGED to %s", action); 41633501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee intent.setAction(action); 41733501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } 41833501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee } 41933501635c2cd21f40793041eff3b8ce3a5710d49Yorke Lee} 420