Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
| 5 | * in compliance with the License. You may obtain a copy of the License at |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 6 | * |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 8 | * |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License |
| 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
| 11 | * or implied. See the License for the specific language governing permissions and limitations under |
| 12 | * the License. |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 13 | */ |
| 14 | |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 15 | package android.telecom; |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 16 | |
Tyler Gunn | 5567d74 | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 17 | import static android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE; |
| 18 | |
Hall Liu | 0464b9b | 2016-01-12 15:32:58 -0800 | [diff] [blame] | 19 | import android.Manifest; |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 20 | import android.annotation.IntDef; |
Hall Liu | b230624 | 2019-11-15 17:13:05 -0800 | [diff] [blame] | 21 | import android.annotation.NonNull; |
Slava Shklyaev | e65e401 | 2019-03-04 16:02:34 +0000 | [diff] [blame] | 22 | import android.annotation.Nullable; |
Yorke Lee | c61d136 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 23 | import android.annotation.RequiresPermission; |
Jeff Sharkey | 910e081 | 2017-04-21 16:29:27 -0600 | [diff] [blame] | 24 | import android.annotation.SuppressAutoDoc; |
Jeff Sharkey | bfc4fcd | 2017-06-05 17:38:17 -0600 | [diff] [blame] | 25 | import android.annotation.SuppressLint; |
Santos Cordon | 6c7a388 | 2014-06-25 15:30:08 -0700 | [diff] [blame] | 26 | import android.annotation.SystemApi; |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 27 | import android.annotation.SystemService; |
Tyler Gunn | 6c14a699 | 2019-02-04 15:12:06 -0800 | [diff] [blame] | 28 | import android.annotation.TestApi; |
Artur Satayev | a526490 | 2019-12-10 17:47:56 +0000 | [diff] [blame] | 29 | import android.compat.annotation.UnsupportedAppUsage; |
Santos Cordon | 6c7a388 | 2014-06-25 15:30:08 -0700 | [diff] [blame] | 30 | import android.content.ComponentName; |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 31 | import android.content.Context; |
Yorke Lee | 3e56ba1 | 2015-04-23 12:32:36 -0700 | [diff] [blame] | 32 | import android.content.Intent; |
Nancy Chen | b2299c1 | 2014-10-29 18:22:11 -0700 | [diff] [blame] | 33 | import android.net.Uri; |
Sanket Padawe | f6a9e5b | 2018-01-05 14:26:16 -0800 | [diff] [blame] | 34 | import android.os.Build; |
Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 35 | import android.os.Bundle; |
Santos Cordon | 6c7a388 | 2014-06-25 15:30:08 -0700 | [diff] [blame] | 36 | import android.os.RemoteException; |
| 37 | import android.os.ServiceManager; |
Tyler Gunn | 7e45b72 | 2018-12-04 12:56:45 -0800 | [diff] [blame] | 38 | import android.os.UserHandle; |
Chen Xu | 7631ff7 | 2019-09-26 16:11:59 -0700 | [diff] [blame] | 39 | import android.telephony.Annotation.CallState; |
Brad Ebinger | e783331 | 2019-05-07 10:55:55 -0700 | [diff] [blame] | 40 | import android.telephony.SubscriptionManager; |
Yorke Lee | 2ae312e | 2014-09-12 17:58:48 -0700 | [diff] [blame] | 41 | import android.telephony.TelephonyManager; |
Anthony Lee | 6727926 | 2014-10-27 11:28:40 -0700 | [diff] [blame] | 42 | import android.text.TextUtils; |
Santos Cordon | 6c7a388 | 2014-06-25 15:30:08 -0700 | [diff] [blame] | 43 | import android.util.Log; |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 44 | |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 45 | import com.android.internal.telecom.ITelecomService; |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 46 | |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 47 | import java.lang.annotation.Retention; |
| 48 | import java.lang.annotation.RetentionPolicy; |
Jay Shrauner | 7746a94 | 2014-08-26 12:15:15 -0700 | [diff] [blame] | 49 | import java.util.ArrayList; |
Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 50 | import java.util.Collections; |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 51 | import java.util.List; |
Tyler Gunn | 7e45b72 | 2018-12-04 12:56:45 -0800 | [diff] [blame] | 52 | import java.util.concurrent.Executor; |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 53 | |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 54 | /** |
Santos Cordon | d9e614f | 2014-10-28 13:10:36 -0700 | [diff] [blame] | 55 | * Provides access to information about active calls and registration/call-management functionality. |
Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 56 | * Apps can use methods in this class to determine the current call state. |
Santos Cordon | d9e614f | 2014-10-28 13:10:36 -0700 | [diff] [blame] | 57 | * <p> |
| 58 | * Apps do not instantiate this class directly; instead, they retrieve a reference to an instance |
| 59 | * through {@link Context#getSystemService Context.getSystemService(Context.TELECOM_SERVICE)}. |
| 60 | * <p> |
| 61 | * Note that access to some telecom information is permission-protected. Your app cannot access the |
| 62 | * protected information or gain access to protected functionality unless it has the appropriate |
| 63 | * permissions declared in its manifest file. Where permissions apply, they are noted in the method |
| 64 | * descriptions. |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 65 | */ |
Jeff Sharkey | 910e081 | 2017-04-21 16:29:27 -0600 | [diff] [blame] | 66 | @SuppressAutoDoc |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 67 | @SystemService(Context.TELECOM_SERVICE) |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 68 | public class TelecomManager { |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 69 | |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 70 | /** |
Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 71 | * Activity action: Starts the UI for handing an incoming call. This intent starts the in-call |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 72 | * UI by notifying the Telecom system that an incoming call exists for a specific call service |
| 73 | * (see {@link android.telecom.ConnectionService}). Telecom reads the Intent extras to find |
| 74 | * and bind to the appropriate {@link android.telecom.ConnectionService} which Telecom will |
Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 75 | * ultimately use to control and get information about the call. |
| 76 | * <p> |
| 77 | * Input: get*Extra field {@link #EXTRA_PHONE_ACCOUNT_HANDLE} contains the component name of the |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 78 | * {@link android.telecom.ConnectionService} that Telecom should bind to. Telecom will then |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 79 | * ask the connection service for more information about the call prior to showing any UI. |
Brad Ebinger | 23b1c6d | 2017-01-12 13:10:40 -0800 | [diff] [blame] | 80 | * |
| 81 | * @deprecated Use {@link #addNewIncomingCall} instead. |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 82 | */ |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 83 | public static final String ACTION_INCOMING_CALL = "android.telecom.action.INCOMING_CALL"; |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 84 | |
| 85 | /** |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 86 | * Similar to {@link #ACTION_INCOMING_CALL}, but is used only by Telephony to add a new |
| 87 | * sim-initiated MO call for carrier testing. |
Brad Ebinger | 23b1c6d | 2017-01-12 13:10:40 -0800 | [diff] [blame] | 88 | * @deprecated Use {@link #addNewUnknownCall} instead. |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 89 | * @hide |
| 90 | */ |
| 91 | public static final String ACTION_NEW_UNKNOWN_CALL = "android.telecom.action.NEW_UNKNOWN_CALL"; |
| 92 | |
| 93 | /** |
Santos Cordon | 895d4b8 | 2015-06-25 16:41:48 -0700 | [diff] [blame] | 94 | * An {@link android.content.Intent} action sent by the telecom framework to start a |
| 95 | * configuration dialog for a registered {@link PhoneAccount}. There is no default dialog |
| 96 | * and each app that registers a {@link PhoneAccount} should provide one if desired. |
| 97 | * <p> |
| 98 | * A user can access the list of enabled {@link android.telecom.PhoneAccount}s through the Phone |
| 99 | * app's settings menu. For each entry, the settings app will add a click action. When |
| 100 | * triggered, the click-action will start this intent along with the extra |
| 101 | * {@link #EXTRA_PHONE_ACCOUNT_HANDLE} to indicate the {@link PhoneAccount} to configure. If the |
| 102 | * {@link PhoneAccount} package does not register an {@link android.app.Activity} for this |
| 103 | * intent, then it will not be sent. |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 104 | */ |
Santos Cordon | 895d4b8 | 2015-06-25 16:41:48 -0700 | [diff] [blame] | 105 | public static final String ACTION_CONFIGURE_PHONE_ACCOUNT = |
| 106 | "android.telecom.action.CONFIGURE_PHONE_ACCOUNT"; |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 107 | |
| 108 | /** |
Andrew Lee | 873cfbf | 2015-02-26 15:22:00 -0800 | [diff] [blame] | 109 | * The {@link android.content.Intent} action used to show the call accessibility settings page. |
| 110 | */ |
| 111 | public static final String ACTION_SHOW_CALL_ACCESSIBILITY_SETTINGS = |
| 112 | "android.telecom.action.SHOW_CALL_ACCESSIBILITY_SETTINGS"; |
| 113 | |
| 114 | /** |
Yorke Lee | 3818a89 | 2014-07-21 15:57:17 -0700 | [diff] [blame] | 115 | * The {@link android.content.Intent} action used to show the call settings page. |
| 116 | */ |
| 117 | public static final String ACTION_SHOW_CALL_SETTINGS = |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 118 | "android.telecom.action.SHOW_CALL_SETTINGS"; |
Yorke Lee | 3818a89 | 2014-07-21 15:57:17 -0700 | [diff] [blame] | 119 | |
| 120 | /** |
Andrew Lee | 866080f | 2015-02-19 12:05:33 -0800 | [diff] [blame] | 121 | * The {@link android.content.Intent} action used to show the respond via SMS settings page. |
| 122 | */ |
| 123 | public static final String ACTION_SHOW_RESPOND_VIA_SMS_SETTINGS = |
| 124 | "android.telecom.action.SHOW_RESPOND_VIA_SMS_SETTINGS"; |
| 125 | |
| 126 | /** |
Evan Charlton | 6d8604f | 2014-09-04 12:38:17 -0700 | [diff] [blame] | 127 | * The {@link android.content.Intent} action used to show the settings page used to configure |
| 128 | * {@link PhoneAccount} preferences. |
| 129 | */ |
| 130 | public static final String ACTION_CHANGE_PHONE_ACCOUNTS = |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 131 | "android.telecom.action.CHANGE_PHONE_ACCOUNTS"; |
Evan Charlton | 6d8604f | 2014-09-04 12:38:17 -0700 | [diff] [blame] | 132 | |
| 133 | /** |
Tyler Gunn | d9da6ce | 2017-04-14 13:43:30 -0700 | [diff] [blame] | 134 | * {@link android.content.Intent} action used indicate that a new phone account was just |
| 135 | * registered. |
| 136 | * <p> |
| 137 | * The Intent {@link Intent#getExtras() extras} will contain {@link #EXTRA_PHONE_ACCOUNT_HANDLE} |
| 138 | * to indicate which {@link PhoneAccount} was registered. |
| 139 | * <p> |
| 140 | * Will only be sent to the default dialer app (see {@link #getDefaultDialerPackage()}). |
Santos Cordon | c66f3ba | 2015-02-27 15:22:07 -0800 | [diff] [blame] | 141 | */ |
Santos Cordon | c66f3ba | 2015-02-27 15:22:07 -0800 | [diff] [blame] | 142 | public static final String ACTION_PHONE_ACCOUNT_REGISTERED = |
| 143 | "android.telecom.action.PHONE_ACCOUNT_REGISTERED"; |
| 144 | |
| 145 | /** |
Tyler Gunn | d9da6ce | 2017-04-14 13:43:30 -0700 | [diff] [blame] | 146 | * {@link android.content.Intent} action used indicate that a phone account was just |
| 147 | * unregistered. |
| 148 | * <p> |
| 149 | * The Intent {@link Intent#getExtras() extras} will contain {@link #EXTRA_PHONE_ACCOUNT_HANDLE} |
| 150 | * to indicate which {@link PhoneAccount} was unregistered. |
| 151 | * <p> |
| 152 | * Will only be sent to the default dialer app (see {@link #getDefaultDialerPackage()}). |
Bryce Lee | 30b0aa0 | 2015-09-23 21:53:53 -0700 | [diff] [blame] | 153 | */ |
Bryce Lee | 30b0aa0 | 2015-09-23 21:53:53 -0700 | [diff] [blame] | 154 | public static final String ACTION_PHONE_ACCOUNT_UNREGISTERED = |
| 155 | "android.telecom.action.PHONE_ACCOUNT_UNREGISTERED"; |
| 156 | |
| 157 | /** |
Yorke Lee | 1011f48 | 2015-04-23 15:58:27 -0700 | [diff] [blame] | 158 | * Activity action: Shows a dialog asking the user whether or not they want to replace the |
| 159 | * current default Dialer with the one specified in |
| 160 | * {@link #EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME}. |
| 161 | * |
| 162 | * Usage example: |
| 163 | * <pre> |
| 164 | * Intent intent = new Intent(TelecomManager.ACTION_CHANGE_DEFAULT_DIALER); |
| 165 | * intent.putExtra(TelecomManager.EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME, |
| 166 | * getActivity().getPackageName()); |
| 167 | * startActivity(intent); |
| 168 | * </pre> |
Hai Zhang | 929085f | 2019-05-03 15:31:43 +0800 | [diff] [blame] | 169 | * <p> |
| 170 | * This is no longer supported since Q, please use |
| 171 | * {@link android.app.role.RoleManager#createRequestRoleIntent(String)} with |
| 172 | * {@link android.app.role.RoleManager#ROLE_DIALER} instead. |
Yorke Lee | 1011f48 | 2015-04-23 15:58:27 -0700 | [diff] [blame] | 173 | */ |
| 174 | public static final String ACTION_CHANGE_DEFAULT_DIALER = |
| 175 | "android.telecom.action.CHANGE_DEFAULT_DIALER"; |
| 176 | |
| 177 | /** |
Yorke Lee | 107c4ce | 2015-06-15 12:08:24 -0700 | [diff] [blame] | 178 | * Broadcast intent action indicating that the current default dialer has changed. |
| 179 | * The string extra {@link #EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME} will contain the |
| 180 | * name of the package that the default dialer was changed to. |
| 181 | * |
| 182 | * @see #EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME |
| 183 | */ |
| 184 | public static final String ACTION_DEFAULT_DIALER_CHANGED = |
| 185 | "android.telecom.action.DEFAULT_DIALER_CHANGED"; |
| 186 | |
| 187 | /** |
Yorke Lee | 1011f48 | 2015-04-23 15:58:27 -0700 | [diff] [blame] | 188 | * Extra value used to provide the package name for {@link #ACTION_CHANGE_DEFAULT_DIALER}. |
| 189 | */ |
| 190 | public static final String EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME = |
| 191 | "android.telecom.extra.CHANGE_DEFAULT_DIALER_PACKAGE_NAME"; |
| 192 | |
| 193 | /** |
tonyzhu | ff60f5e | 2018-10-01 19:14:59 +0800 | [diff] [blame] | 194 | * Broadcast intent action indicating that the current default call screening app has changed. |
| 195 | * |
| 196 | * The string extra {@link #EXTRA_DEFAULT_CALL_SCREENING_APP_COMPONENT_NAME} will contain the |
| 197 | * name of the Component of the previous or the new call screening app. |
| 198 | * |
| 199 | * The boolean extra {@link #EXTRA_IS_DEFAULT_CALL_SCREENING_APP} will indicate the component |
| 200 | * name in the String extra {@link #EXTRA_DEFAULT_CALL_SCREENING_APP_COMPONENT_NAME} is default |
| 201 | * call screening app or not. |
| 202 | */ |
| 203 | public static final String ACTION_DEFAULT_CALL_SCREENING_APP_CHANGED = |
| 204 | "android.telecom.action.DEFAULT_CALL_SCREENING_APP_CHANGED"; |
| 205 | |
| 206 | /** |
| 207 | * Extra value used with {@link #ACTION_DEFAULT_CALL_SCREENING_APP_CHANGED} broadcast to |
| 208 | * indicate the ComponentName of the call screening app which has changed. |
| 209 | */ |
| 210 | public static final String EXTRA_DEFAULT_CALL_SCREENING_APP_COMPONENT_NAME = |
| 211 | "android.telecom.extra.DEFAULT_CALL_SCREENING_APP_COMPONENT_NAME"; |
| 212 | |
| 213 | /** |
| 214 | * Extra value used with {@link #ACTION_DEFAULT_CALL_SCREENING_APP_CHANGED} broadcast to |
| 215 | * indicate whether an app is the default call screening app. |
| 216 | */ |
| 217 | public static final String EXTRA_IS_DEFAULT_CALL_SCREENING_APP = |
| 218 | "android.telecom.extra.IS_DEFAULT_CALL_SCREENING_APP"; |
| 219 | |
| 220 | /** |
Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 221 | * Optional extra for {@link android.content.Intent#ACTION_CALL} containing a boolean that |
| 222 | * determines whether the speakerphone should be automatically turned on for an outgoing call. |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 223 | */ |
| 224 | public static final String EXTRA_START_CALL_WITH_SPEAKERPHONE = |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 225 | "android.telecom.extra.START_CALL_WITH_SPEAKERPHONE"; |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 226 | |
| 227 | /** |
Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 228 | * Optional extra for {@link android.content.Intent#ACTION_CALL} containing an integer that |
| 229 | * determines the desired video state for an outgoing call. |
Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 230 | * Valid options: |
Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 231 | * {@link VideoProfile#STATE_AUDIO_ONLY}, |
| 232 | * {@link VideoProfile#STATE_BIDIRECTIONAL}, |
| 233 | * {@link VideoProfile#STATE_RX_ENABLED}, |
| 234 | * {@link VideoProfile#STATE_TX_ENABLED}. |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 235 | */ |
| 236 | public static final String EXTRA_START_CALL_WITH_VIDEO_STATE = |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 237 | "android.telecom.extra.START_CALL_WITH_VIDEO_STATE"; |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 238 | |
| 239 | /** |
Tyler Gunn | 3765356 | 2017-03-13 18:15:15 -0700 | [diff] [blame] | 240 | * Optional extra for {@link #addNewIncomingCall(PhoneAccountHandle, Bundle)} containing an |
| 241 | * integer that determines the requested video state for an incoming call. |
| 242 | * Valid options: |
| 243 | * {@link VideoProfile#STATE_AUDIO_ONLY}, |
| 244 | * {@link VideoProfile#STATE_BIDIRECTIONAL}, |
| 245 | * {@link VideoProfile#STATE_RX_ENABLED}, |
| 246 | * {@link VideoProfile#STATE_TX_ENABLED}. |
| 247 | */ |
| 248 | public static final String EXTRA_INCOMING_VIDEO_STATE = |
| 249 | "android.telecom.extra.INCOMING_VIDEO_STATE"; |
| 250 | |
| 251 | /** |
Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 252 | * The extra used with an {@link android.content.Intent#ACTION_CALL} and |
| 253 | * {@link android.content.Intent#ACTION_DIAL} {@code Intent} to specify a |
| 254 | * {@link PhoneAccountHandle} to use when making the call. |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 255 | * <p class="note"> |
Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 256 | * Retrieve with {@link android.content.Intent#getParcelableExtra(String)}. |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 257 | */ |
Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 258 | public static final String EXTRA_PHONE_ACCOUNT_HANDLE = |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 259 | "android.telecom.extra.PHONE_ACCOUNT_HANDLE"; |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 260 | |
| 261 | /** |
Tyler Gunn | 335ff2e | 2015-07-30 14:18:33 -0700 | [diff] [blame] | 262 | * Optional extra for {@link android.content.Intent#ACTION_CALL} containing a string call |
| 263 | * subject which will be associated with an outgoing call. Should only be specified if the |
| 264 | * {@link PhoneAccount} supports the capability {@link PhoneAccount#CAPABILITY_CALL_SUBJECT}. |
| 265 | */ |
| 266 | public static final String EXTRA_CALL_SUBJECT = "android.telecom.extra.CALL_SUBJECT"; |
| 267 | |
| 268 | /** |
Yorke Lee | 04ea7d3 | 2015-06-05 15:59:18 -0700 | [diff] [blame] | 269 | * The extra used by a {@link ConnectionService} to provide the handle of the caller that |
| 270 | * has initiated a new incoming call. |
| 271 | */ |
Yorke Lee | 02fb5bc | 2015-06-09 12:27:36 -0700 | [diff] [blame] | 272 | public static final String EXTRA_INCOMING_CALL_ADDRESS = |
| 273 | "android.telecom.extra.INCOMING_CALL_ADDRESS"; |
Yorke Lee | 04ea7d3 | 2015-06-05 15:59:18 -0700 | [diff] [blame] | 274 | |
| 275 | /** |
Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 276 | * Optional extra for {@link #ACTION_INCOMING_CALL} containing a {@link Bundle} which contains |
| 277 | * metadata about the call. This {@link Bundle} will be returned to the |
| 278 | * {@link ConnectionService}. |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 279 | */ |
| 280 | public static final String EXTRA_INCOMING_CALL_EXTRAS = |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 281 | "android.telecom.extra.INCOMING_CALL_EXTRAS"; |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 282 | |
| 283 | /** |
Joseph Pirozzo | 40ea5ee | 2018-01-02 16:15:23 -0800 | [diff] [blame] | 284 | * Optional extra for {@link #ACTION_INCOMING_CALL} containing a boolean to indicate that the |
| 285 | * call has an externally generated ringer. Used by the HfpClientConnectionService when In Band |
| 286 | * Ringtone is enabled to prevent two ringers from being generated. |
| 287 | * @hide |
| 288 | */ |
| 289 | public static final String EXTRA_CALL_EXTERNAL_RINGER = |
| 290 | "android.telecom.extra.CALL_EXTERNAL_RINGER"; |
| 291 | |
| 292 | /** |
Nancy Chen | 10798dc | 2014-08-08 14:00:25 -0700 | [diff] [blame] | 293 | * Optional extra for {@link android.content.Intent#ACTION_CALL} and |
| 294 | * {@link android.content.Intent#ACTION_DIAL} {@code Intent} containing a {@link Bundle} |
| 295 | * which contains metadata about the call. This {@link Bundle} will be saved into |
Santos Cordon | 7a060d5 | 2015-06-19 14:52:04 -0700 | [diff] [blame] | 296 | * {@code Call.Details} and passed to the {@link ConnectionService} when placing the call. |
Nancy Chen | 10798dc | 2014-08-08 14:00:25 -0700 | [diff] [blame] | 297 | */ |
| 298 | public static final String EXTRA_OUTGOING_CALL_EXTRAS = |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 299 | "android.telecom.extra.OUTGOING_CALL_EXTRAS"; |
Nancy Chen | 10798dc | 2014-08-08 14:00:25 -0700 | [diff] [blame] | 300 | |
| 301 | /** |
sqian | 6d9e745 | 2019-02-08 21:42:15 -0800 | [diff] [blame] | 302 | * An optional boolean extra on {@link android.content.Intent#ACTION_CALL_EMERGENCY} to tell |
| 303 | * whether the user's dial intent is emergency; this is required to specify when the dialed |
| 304 | * number is ambiguous, identified as both emergency number and any other non-emergency number; |
| 305 | * e.g. in some situation, 611 could be both an emergency number in a country and a |
| 306 | * non-emergency number of a carrier's customer service hotline. |
| 307 | * |
| 308 | * @hide |
| 309 | */ |
| 310 | @SystemApi |
| 311 | public static final String EXTRA_IS_USER_INTENT_EMERGENCY_CALL = |
| 312 | "android.telecom.extra.IS_USER_INTENT_EMERGENCY_CALL"; |
| 313 | |
| 314 | /** |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 315 | * @hide |
| 316 | */ |
| 317 | public static final String EXTRA_UNKNOWN_CALL_HANDLE = |
| 318 | "android.telecom.extra.UNKNOWN_CALL_HANDLE"; |
| 319 | |
| 320 | /** |
Sailesh Nepal | da6bb38 | 2016-04-14 19:51:46 -0700 | [diff] [blame] | 321 | * Optional extra for incoming and outgoing calls containing a long which specifies the time the |
| 322 | * call was created. This value is in milliseconds since boot. |
| 323 | * @hide |
| 324 | */ |
| 325 | public static final String EXTRA_CALL_CREATED_TIME_MILLIS = |
| 326 | "android.telecom.extra.CALL_CREATED_TIME_MILLIS"; |
| 327 | |
| 328 | /** |
| 329 | * Optional extra for incoming and outgoing calls containing a long which specifies the time |
| 330 | * telecom began routing the call. This value is in milliseconds since boot. |
| 331 | * @hide |
| 332 | */ |
| 333 | public static final String EXTRA_CALL_TELECOM_ROUTING_START_TIME_MILLIS = |
| 334 | "android.telecom.extra.CALL_TELECOM_ROUTING_START_TIME_MILLIS"; |
| 335 | |
| 336 | /** |
| 337 | * Optional extra for incoming and outgoing calls containing a long which specifies the time |
| 338 | * telecom finished routing the call. This value is in milliseconds since boot. |
| 339 | * @hide |
| 340 | */ |
| 341 | public static final String EXTRA_CALL_TELECOM_ROUTING_END_TIME_MILLIS = |
| 342 | "android.telecom.extra.CALL_TELECOM_ROUTING_END_TIME_MILLIS"; |
| 343 | |
| 344 | /** |
Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 345 | * Optional extra for {@link android.telephony.TelephonyManager#ACTION_PHONE_STATE_CHANGED} |
| 346 | * containing the disconnect code. |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 347 | */ |
| 348 | public static final String EXTRA_CALL_DISCONNECT_CAUSE = |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 349 | "android.telecom.extra.CALL_DISCONNECT_CAUSE"; |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 350 | |
| 351 | /** |
Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 352 | * Optional extra for {@link android.telephony.TelephonyManager#ACTION_PHONE_STATE_CHANGED} |
| 353 | * containing the disconnect message. |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 354 | */ |
| 355 | public static final String EXTRA_CALL_DISCONNECT_MESSAGE = |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 356 | "android.telecom.extra.CALL_DISCONNECT_MESSAGE"; |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 357 | |
| 358 | /** |
Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 359 | * Optional extra for {@link android.telephony.TelephonyManager#ACTION_PHONE_STATE_CHANGED} |
| 360 | * containing the component name of the associated connection service. |
Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 361 | * @hide |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 362 | */ |
Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 363 | @SystemApi |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 364 | public static final String EXTRA_CONNECTION_SERVICE = |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 365 | "android.telecom.extra.CONNECTION_SERVICE"; |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 366 | |
| 367 | /** |
Hall Liu | 90f6290 | 2015-11-19 16:19:24 -0800 | [diff] [blame] | 368 | * Optional extra for communicating the call technology used by a |
| 369 | * {@link com.android.internal.telephony.Connection} to Telecom |
| 370 | * @hide |
| 371 | */ |
| 372 | public static final String EXTRA_CALL_TECHNOLOGY_TYPE = |
| 373 | "android.telecom.extra.CALL_TECHNOLOGY_TYPE"; |
| 374 | |
| 375 | /** |
Wei Huang | 7f7f72e | 2018-05-30 19:21:36 +0800 | [diff] [blame] | 376 | * Optional extra for communicating the call network technology used by a |
| 377 | * {@link android.telecom.Connection} to Telecom and InCallUI. |
| 378 | * |
| 379 | * @see {@code NETWORK_TYPE_*} in {@link android.telephony.TelephonyManager}. |
| 380 | */ |
| 381 | public static final String EXTRA_CALL_NETWORK_TYPE = |
| 382 | "android.telecom.extra.CALL_NETWORK_TYPE"; |
| 383 | |
| 384 | /** |
Nancy Chen | 7ab1dc4 | 2014-09-09 18:18:26 -0700 | [diff] [blame] | 385 | * An optional {@link android.content.Intent#ACTION_CALL} intent extra denoting the |
| 386 | * package name of the app specifying an alternative gateway for the call. |
| 387 | * The value is a string. |
| 388 | * |
| 389 | * (The following comment corresponds to the all GATEWAY_* extras) |
| 390 | * An app which sends the {@link android.content.Intent#ACTION_CALL} intent can specify an |
| 391 | * alternative address to dial which is different from the one specified and displayed to |
| 392 | * the user. This alternative address is referred to as the gateway address. |
| 393 | */ |
| 394 | public static final String GATEWAY_PROVIDER_PACKAGE = |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 395 | "android.telecom.extra.GATEWAY_PROVIDER_PACKAGE"; |
Nancy Chen | 7ab1dc4 | 2014-09-09 18:18:26 -0700 | [diff] [blame] | 396 | |
| 397 | /** |
| 398 | * An optional {@link android.content.Intent#ACTION_CALL} intent extra corresponding to the |
| 399 | * original address to dial for the call. This is used when an alternative gateway address is |
| 400 | * provided to recall the original address. |
| 401 | * The value is a {@link android.net.Uri}. |
| 402 | * |
| 403 | * (See {@link #GATEWAY_PROVIDER_PACKAGE} for details) |
| 404 | */ |
| 405 | public static final String GATEWAY_ORIGINAL_ADDRESS = |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 406 | "android.telecom.extra.GATEWAY_ORIGINAL_ADDRESS"; |
Nancy Chen | 7ab1dc4 | 2014-09-09 18:18:26 -0700 | [diff] [blame] | 407 | |
| 408 | /** |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 409 | * The number which the party on the other side of the line will see (and use to return the |
| 410 | * call). |
| 411 | * <p> |
Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 412 | * {@link ConnectionService}s which interact with {@link RemoteConnection}s should only populate |
| 413 | * this if the {@link android.telephony.TelephonyManager#getLine1Number()} value, as that is the |
| 414 | * user's expected caller ID. |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 415 | */ |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 416 | public static final String EXTRA_CALL_BACK_NUMBER = "android.telecom.extra.CALL_BACK_NUMBER"; |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 417 | |
| 418 | /** |
Hall Liu | 8f613fb | 2017-02-14 18:11:11 -0800 | [diff] [blame] | 419 | * The number of milliseconds that Telecom should wait after disconnecting a call via the |
| 420 | * ACTION_NEW_OUTGOING_CALL broadcast, in order to wait for the app which cancelled the call |
| 421 | * to make a new one. |
| 422 | * @hide |
| 423 | */ |
| 424 | public static final String EXTRA_NEW_OUTGOING_CALL_CANCEL_TIMEOUT = |
| 425 | "android.telecom.extra.NEW_OUTGOING_CALL_CANCEL_TIMEOUT"; |
| 426 | |
| 427 | /** |
Tyler Gunn | 9f6f047 | 2017-04-17 18:25:22 -0700 | [diff] [blame] | 428 | * Boolean extra specified to indicate that the intention of adding a call is to handover an |
Tyler Gunn | 8bf7657 | 2017-04-06 15:30:08 -0700 | [diff] [blame] | 429 | * existing call from the user's device to a different {@link PhoneAccount}. |
| 430 | * <p> |
Tyler Gunn | 9f6f047 | 2017-04-17 18:25:22 -0700 | [diff] [blame] | 431 | * Used when calling {@link #addNewIncomingCall(PhoneAccountHandle, Bundle)} |
| 432 | * to indicate to Telecom that the purpose of adding a new incoming call is to handover an |
| 433 | * existing call from the user's device to a different {@link PhoneAccount}. This occurs on |
| 434 | * the receiving side of a handover. |
| 435 | * <p> |
| 436 | * Used when Telecom calls |
| 437 | * {@link ConnectionService#onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)} |
| 438 | * to indicate that the purpose of Telecom requesting a new outgoing connection it to request |
| 439 | * a handover to this {@link ConnectionService} from an ongoing call on the user's device. This |
| 440 | * occurs on the initiating side of a handover. |
| 441 | * <p> |
Tyler Gunn | 727c6bd | 2017-04-11 09:51:40 -0700 | [diff] [blame] | 442 | * The phone number of the call used by Telecom to determine which call should be handed over. |
Tyler Gunn | 8bf7657 | 2017-04-06 15:30:08 -0700 | [diff] [blame] | 443 | * @hide |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 444 | * @deprecated Use the public handover APIs. See |
| 445 | * {@link Call#handoverTo(PhoneAccountHandle, int, Bundle)} for more information. |
Tyler Gunn | 8bf7657 | 2017-04-06 15:30:08 -0700 | [diff] [blame] | 446 | */ |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 447 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 119305590) |
Tyler Gunn | 8bf7657 | 2017-04-06 15:30:08 -0700 | [diff] [blame] | 448 | public static final String EXTRA_IS_HANDOVER = "android.telecom.extra.IS_HANDOVER"; |
| 449 | |
| 450 | /** |
Tyler Gunn | 79bc1ec | 2018-01-22 15:17:54 -0800 | [diff] [blame] | 451 | * When {@code true} indicates that a request to create a new connection is for the purpose of |
| 452 | * a handover. Note: This is used with the |
| 453 | * {@link android.telecom.Call#handoverTo(PhoneAccountHandle, int, Bundle)} API as part of the |
| 454 | * internal communication mechanism with the {@link android.telecom.ConnectionService}. It is |
| 455 | * not the same as the legacy {@link #EXTRA_IS_HANDOVER} extra. |
| 456 | * @hide |
| 457 | */ |
| 458 | public static final String EXTRA_IS_HANDOVER_CONNECTION = |
| 459 | "android.telecom.extra.IS_HANDOVER_CONNECTION"; |
| 460 | |
| 461 | /** |
Tyler Gunn | 3af3869 | 2017-05-26 13:30:09 -0700 | [diff] [blame] | 462 | * Parcelable extra used with {@link #EXTRA_IS_HANDOVER} to indicate the source |
| 463 | * {@link PhoneAccountHandle} when initiating a handover which {@link ConnectionService} |
| 464 | * the handover is from. |
| 465 | * @hide |
| 466 | */ |
| 467 | public static final String EXTRA_HANDOVER_FROM_PHONE_ACCOUNT = |
| 468 | "android.telecom.extra.HANDOVER_FROM_PHONE_ACCOUNT"; |
| 469 | |
| 470 | /** |
Tyler Gunn | 9f6f047 | 2017-04-17 18:25:22 -0700 | [diff] [blame] | 471 | * Extra key specified in the {@link ConnectionRequest#getExtras()} when Telecom calls |
| 472 | * {@link ConnectionService#onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)} |
| 473 | * to inform the {@link ConnectionService} what the initial {@link CallAudioState} of the |
| 474 | * {@link Connection} will be. |
| 475 | * @hide |
| 476 | */ |
| 477 | public static final String EXTRA_CALL_AUDIO_STATE = "android.telecom.extra.CALL_AUDIO_STATE"; |
| 478 | |
| 479 | /** |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 480 | * A boolean extra, which when set on the {@link Intent#ACTION_CALL} intent or on the bundle |
| 481 | * passed into {@link #placeCall(Uri, Bundle)}, indicates that the call should be initiated with |
| 482 | * an RTT session open. See {@link android.telecom.Call.RttCall} for more information on RTT. |
| 483 | */ |
| 484 | public static final String EXTRA_START_CALL_WITH_RTT = |
| 485 | "android.telecom.extra.START_CALL_WITH_RTT"; |
| 486 | |
| 487 | /** |
Grace Jia | 91cec6e | 2019-12-16 14:23:05 -0800 | [diff] [blame^] | 488 | * Start an activity indicating that the completion of an outgoing call or an incoming call |
| 489 | * which was not blocked by the {@link CallScreeningService}, and which was NOT terminated |
| 490 | * while the call was in {@link Call#STATE_AUDIO_PROCESSING}. |
| 491 | * |
| 492 | * The {@link Uri} extra {@link #EXTRA_HANDLE} will contain the uri handle(phone number) for the |
| 493 | * call which completed. |
| 494 | * |
| 495 | * The integer extra {@link #EXTRA_DISCONNECT_CAUSE} will indicate the reason for the call |
| 496 | * disconnection. See {@link #EXTRA_DISCONNECT_CAUSE} for more information. |
| 497 | * |
| 498 | * The integer extra {@link #EXTRA_CALL_DURATION} will indicate the duration of the call. See |
| 499 | * {@link #EXTRA_CALL_DURATION} for more information. |
| 500 | */ |
| 501 | public static final String ACTION_POST_CALL = "android.telecom.action.POST_CALL"; |
| 502 | |
| 503 | /** |
| 504 | * A {@link Uri} extra, which when set on the {@link #ACTION_POST_CALL} intent, indicates the |
| 505 | * uri handle(phone number) of the completed call. |
| 506 | */ |
| 507 | public static final String EXTRA_HANDLE = "android.telecom.extra.HANDLE"; |
| 508 | |
| 509 | /** |
| 510 | * A integer value provided for completed calls to indicate the reason for the call |
| 511 | * disconnection. |
| 512 | * <p> |
| 513 | * Allowed values: |
| 514 | * <ul> |
| 515 | * <li>{@link DisconnectCause#UNKNOWN}</li> |
| 516 | * <li>{@link DisconnectCause#LOCAL}</li> |
| 517 | * <li>{@link DisconnectCause#REMOTE}</li> |
| 518 | * <li>{@link DisconnectCause#REJECTED}</li> |
| 519 | * <li>{@link DisconnectCause#MISSED}</li> |
| 520 | * </ul> |
| 521 | * </p> |
| 522 | */ |
| 523 | public static final String EXTRA_DISCONNECT_CAUSE = "android.telecom.extra.DISCONNECT_CAUSE"; |
| 524 | |
| 525 | /** |
| 526 | * A integer value provided for completed calls to indicate the duration of the call. |
| 527 | * <p> |
| 528 | * Allowed values: |
| 529 | * <ul> |
| 530 | * <li>{@link #DURATION_VERY_SHORT}</li> |
| 531 | * <li>{@link #DURATION_SHORT}</li> |
| 532 | * <li>{@link #DURATION_MEDIUM}</li> |
| 533 | * <li>{@link #DURATION_LONG}</li> |
| 534 | * </ul> |
| 535 | * </p> |
| 536 | */ |
| 537 | public static final String EXTRA_CALL_DURATION = "android.telecom.extra.CALL_DURATION"; |
| 538 | |
| 539 | /** |
| 540 | * A integer value for {@link #EXTRA_CALL_DURATION}, indicates the duration of the completed |
| 541 | * call was < 3 seconds. |
| 542 | */ |
| 543 | public static final int DURATION_VERY_SHORT = 0; |
| 544 | |
| 545 | /** |
| 546 | * A integer value for {@link #EXTRA_CALL_DURATION}, indicates the duration of the completed |
| 547 | * call was >= 3 seconds and < 60 seconds. |
| 548 | */ |
| 549 | public static final int DURATION_SHORT = 1; |
| 550 | |
| 551 | /** |
| 552 | * A integer value for {@link #EXTRA_CALL_DURATION}, indicates the duration of the completed |
| 553 | * call was >= 60 seconds and < 120 seconds. |
| 554 | */ |
| 555 | public static final int DURATION_MEDIUM = 2; |
| 556 | |
| 557 | /** |
| 558 | * A integer value for {@link #EXTRA_CALL_DURATION}, indicates the duration of the completed |
| 559 | * call was >= 120 seconds. |
| 560 | */ |
| 561 | public static final int DURATION_LONG = 3; |
| 562 | |
| 563 | /** |
| 564 | * The threshold between {@link #DURATION_VERY_SHORT} calls and {@link #DURATION_SHORT} calls in |
| 565 | * milliseconds. |
| 566 | * @hide |
| 567 | */ |
| 568 | public static final long VERY_SHORT_CALL_TIME_MS = 3000; |
| 569 | |
| 570 | /** |
| 571 | * The threshold between {@link #DURATION_SHORT} calls and {@link #DURATION_MEDIUM} calls in |
| 572 | * milliseconds. |
| 573 | * @hide |
| 574 | */ |
| 575 | public static final long SHORT_CALL_TIME_MS = 60000; |
| 576 | |
| 577 | /** |
| 578 | * The threshold between {@link #DURATION_MEDIUM} calls and {@link #DURATION_LONG} calls in |
| 579 | * milliseconds. |
| 580 | * @hide |
| 581 | */ |
| 582 | public static final long MEDIUM_CALL_TIME_MS = 120000; |
| 583 | |
| 584 | /** |
Santos Cordon | f2600eb | 2015-06-22 15:02:20 -0700 | [diff] [blame] | 585 | * A boolean meta-data value indicating whether an {@link InCallService} implements an |
| 586 | * in-call user interface. Dialer implementations (see {@link #getDefaultDialerPackage()}) which |
| 587 | * would also like to replace the in-call interface should set this meta-data to {@code true} in |
| 588 | * the manifest registration of their {@link InCallService}. |
| 589 | */ |
| 590 | public static final String METADATA_IN_CALL_SERVICE_UI = "android.telecom.IN_CALL_SERVICE_UI"; |
| 591 | |
| 592 | /** |
Santos Cordon | 8888155 | 2015-12-10 17:29:54 -0800 | [diff] [blame] | 593 | * A boolean meta-data value indicating whether an {@link InCallService} implements an |
| 594 | * in-call user interface to be used while the device is in car-mode (see |
Hector Dearman | 923382c | 2018-12-13 16:42:33 +0000 | [diff] [blame] | 595 | * {@link android.content.res.Configuration#UI_MODE_TYPE_CAR}). |
Santos Cordon | 8888155 | 2015-12-10 17:29:54 -0800 | [diff] [blame] | 596 | */ |
| 597 | public static final String METADATA_IN_CALL_SERVICE_CAR_MODE_UI = |
| 598 | "android.telecom.IN_CALL_SERVICE_CAR_MODE_UI"; |
| 599 | |
| 600 | /** |
Sailesh Nepal | 9c2618b | 2016-01-23 16:28:22 -0800 | [diff] [blame] | 601 | * A boolean meta-data value indicating whether an {@link InCallService} implements ringing. |
| 602 | * Dialer implementations (see {@link #getDefaultDialerPackage()}) which would also like to |
| 603 | * override the system provided ringing should set this meta-data to {@code true} in the |
| 604 | * manifest registration of their {@link InCallService}. |
Tyler Gunn | 556d240 | 2019-04-10 08:59:43 -0700 | [diff] [blame] | 605 | * <p> |
| 606 | * When {@code true}, it is the {@link InCallService}'s responsibility to play a ringtone for |
| 607 | * all incoming calls. |
Sailesh Nepal | 9c2618b | 2016-01-23 16:28:22 -0800 | [diff] [blame] | 608 | */ |
| 609 | public static final String METADATA_IN_CALL_SERVICE_RINGING = |
| 610 | "android.telecom.IN_CALL_SERVICE_RINGING"; |
| 611 | |
| 612 | /** |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 613 | * A boolean meta-data value indicating whether an {@link InCallService} wants to be informed of |
| 614 | * calls which have the {@link Call.Details#PROPERTY_IS_EXTERNAL_CALL} property. An external |
| 615 | * call is one which a {@link ConnectionService} knows about, but is not connected to directly. |
| 616 | * Dialer implementations (see {@link #getDefaultDialerPackage()}) which would like to be |
| 617 | * informed of external calls should set this meta-data to {@code true} in the manifest |
| 618 | * registration of their {@link InCallService}. By default, the {@link InCallService} will NOT |
| 619 | * be informed of external calls. |
| 620 | */ |
| 621 | public static final String METADATA_INCLUDE_EXTERNAL_CALLS = |
| 622 | "android.telecom.INCLUDE_EXTERNAL_CALLS"; |
| 623 | |
| 624 | /** |
Tyler Gunn | 24e1833 | 2017-02-10 09:42:49 -0800 | [diff] [blame] | 625 | * A boolean meta-data value indicating whether an {@link InCallService} wants to be informed of |
| 626 | * calls which have the {@link Call.Details#PROPERTY_SELF_MANAGED} property. A self-managed |
| 627 | * call is one which originates from a self-managed {@link ConnectionService} which has chosen |
| 628 | * to implement its own call user interface. An {@link InCallService} implementation which |
| 629 | * would like to be informed of external calls should set this meta-data to {@code true} in the |
| 630 | * manifest registration of their {@link InCallService}. By default, the {@link InCallService} |
| 631 | * will NOT be informed about self-managed calls. |
| 632 | * <p> |
| 633 | * An {@link InCallService} which receives self-managed calls is free to view and control the |
| 634 | * state of calls in the self-managed {@link ConnectionService}. An example use-case is |
Tyler Gunn | 3765356 | 2017-03-13 18:15:15 -0700 | [diff] [blame] | 635 | * exposing these calls to an automotive device via its companion app. |
| 636 | * <p> |
| 637 | * This meta-data can only be set for an {@link InCallService} which also sets |
| 638 | * {@link #METADATA_IN_CALL_SERVICE_UI}. Only the default phone/dialer app, or a car-mode |
| 639 | * {@link InCallService} can see self-managed calls. |
Tyler Gunn | 24e1833 | 2017-02-10 09:42:49 -0800 | [diff] [blame] | 640 | * <p> |
| 641 | * See also {@link Connection#PROPERTY_SELF_MANAGED}. |
| 642 | */ |
| 643 | public static final String METADATA_INCLUDE_SELF_MANAGED_CALLS = |
| 644 | "android.telecom.INCLUDE_SELF_MANAGED_CALLS"; |
| 645 | |
| 646 | /** |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 647 | * The dual tone multi-frequency signaling character sent to indicate the dialing system should |
| 648 | * pause for a predefined period. |
| 649 | */ |
| 650 | public static final char DTMF_CHARACTER_PAUSE = ','; |
| 651 | |
| 652 | /** |
| 653 | * The dual-tone multi-frequency signaling character sent to indicate the dialing system should |
| 654 | * wait for user confirmation before proceeding. |
| 655 | */ |
| 656 | public static final char DTMF_CHARACTER_WAIT = ';'; |
| 657 | |
| 658 | /** |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 659 | * @hide |
| 660 | */ |
| 661 | @IntDef(prefix = { "TTY_MODE_" }, |
| 662 | value = {TTY_MODE_OFF, TTY_MODE_FULL, TTY_MODE_HCO, TTY_MODE_VCO}) |
| 663 | @Retention(RetentionPolicy.SOURCE) |
| 664 | public @interface TtyMode {} |
| 665 | |
| 666 | /** |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 667 | * TTY (teletypewriter) mode is off. |
| 668 | * |
| 669 | * @hide |
| 670 | */ |
Tyler Gunn | 6c14a699 | 2019-02-04 15:12:06 -0800 | [diff] [blame] | 671 | @TestApi |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 672 | @SystemApi |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 673 | public static final int TTY_MODE_OFF = 0; |
| 674 | |
| 675 | /** |
| 676 | * TTY (teletypewriter) mode is on. The speaker is off and the microphone is muted. The user |
| 677 | * will communicate with the remote party by sending and receiving text messages. |
| 678 | * |
| 679 | * @hide |
| 680 | */ |
Tyler Gunn | 6c14a699 | 2019-02-04 15:12:06 -0800 | [diff] [blame] | 681 | @TestApi |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 682 | @SystemApi |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 683 | public static final int TTY_MODE_FULL = 1; |
| 684 | |
| 685 | /** |
| 686 | * TTY (teletypewriter) mode is in hearing carryover mode (HCO). The microphone is muted but the |
| 687 | * speaker is on. The user will communicate with the remote party by sending text messages and |
| 688 | * hearing an audible reply. |
| 689 | * |
| 690 | * @hide |
| 691 | */ |
Tyler Gunn | 6c14a699 | 2019-02-04 15:12:06 -0800 | [diff] [blame] | 692 | @TestApi |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 693 | @SystemApi |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 694 | public static final int TTY_MODE_HCO = 2; |
| 695 | |
| 696 | /** |
| 697 | * TTY (teletypewriter) mode is in voice carryover mode (VCO). The speaker is off but the |
| 698 | * microphone is still on. User will communicate with the remote party by speaking and receiving |
| 699 | * text message replies. |
| 700 | * |
| 701 | * @hide |
| 702 | */ |
Tyler Gunn | 6c14a699 | 2019-02-04 15:12:06 -0800 | [diff] [blame] | 703 | @TestApi |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 704 | @SystemApi |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 705 | public static final int TTY_MODE_VCO = 3; |
| 706 | |
| 707 | /** |
| 708 | * Broadcast intent action indicating that the current TTY mode has changed. An intent extra |
| 709 | * provides this state as an int. |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 710 | * |
Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 711 | * @see #EXTRA_CURRENT_TTY_MODE |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 712 | * @hide |
| 713 | */ |
| 714 | public static final String ACTION_CURRENT_TTY_MODE_CHANGED = |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 715 | "android.telecom.action.CURRENT_TTY_MODE_CHANGED"; |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 716 | |
| 717 | /** |
| 718 | * The lookup key for an int that indicates the current TTY mode. |
| 719 | * Valid modes are: |
| 720 | * - {@link #TTY_MODE_OFF} |
| 721 | * - {@link #TTY_MODE_FULL} |
| 722 | * - {@link #TTY_MODE_HCO} |
| 723 | * - {@link #TTY_MODE_VCO} |
| 724 | * |
| 725 | * @hide |
| 726 | */ |
| 727 | public static final String EXTRA_CURRENT_TTY_MODE = |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 728 | "android.telecom.intent.extra.CURRENT_TTY_MODE"; |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 729 | |
| 730 | /** |
Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 731 | * Broadcast intent action indicating that the TTY preferred operating mode has changed. An |
| 732 | * intent extra provides the new mode as an int. |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 733 | * |
Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 734 | * @see #EXTRA_TTY_PREFERRED_MODE |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 735 | * @hide |
| 736 | */ |
| 737 | public static final String ACTION_TTY_PREFERRED_MODE_CHANGED = |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 738 | "android.telecom.action.TTY_PREFERRED_MODE_CHANGED"; |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 739 | |
| 740 | /** |
Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 741 | * The lookup key for an int that indicates preferred TTY mode. Valid modes are: - |
| 742 | * {@link #TTY_MODE_OFF} - {@link #TTY_MODE_FULL} - {@link #TTY_MODE_HCO} - |
| 743 | * {@link #TTY_MODE_VCO} |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 744 | * |
| 745 | * @hide |
| 746 | */ |
| 747 | public static final String EXTRA_TTY_PREFERRED_MODE = |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 748 | "android.telecom.intent.extra.TTY_PREFERRED"; |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 749 | |
Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 750 | /** |
Bryce Lee | 5e4dd3e | 2015-08-03 16:59:10 -0700 | [diff] [blame] | 751 | * Broadcast intent action for letting custom component know to show the missed call |
Sailesh Nepal | be15ad9 | 2016-01-21 19:26:20 -0800 | [diff] [blame] | 752 | * notification. If no custom component exists then this is sent to the default dialer which |
| 753 | * should post a missed-call notification. |
Bryce Lee | 5e4dd3e | 2015-08-03 16:59:10 -0700 | [diff] [blame] | 754 | */ |
Bryce Lee | 5e4dd3e | 2015-08-03 16:59:10 -0700 | [diff] [blame] | 755 | public static final String ACTION_SHOW_MISSED_CALLS_NOTIFICATION = |
| 756 | "android.telecom.action.SHOW_MISSED_CALLS_NOTIFICATION"; |
| 757 | |
| 758 | /** |
Sailesh Nepal | be15ad9 | 2016-01-21 19:26:20 -0800 | [diff] [blame] | 759 | * The number of calls associated with the notification. If the number is zero then the missed |
| 760 | * call notification should be dismissed. |
Bryce Lee | 5e4dd3e | 2015-08-03 16:59:10 -0700 | [diff] [blame] | 761 | */ |
Bryce Lee | 5e4dd3e | 2015-08-03 16:59:10 -0700 | [diff] [blame] | 762 | public static final String EXTRA_NOTIFICATION_COUNT = |
| 763 | "android.telecom.extra.NOTIFICATION_COUNT"; |
| 764 | |
| 765 | /** |
| 766 | * The number associated with the missed calls. This number is only relevant |
| 767 | * when EXTRA_NOTIFICATION_COUNT is 1. |
Bryce Lee | 5e4dd3e | 2015-08-03 16:59:10 -0700 | [diff] [blame] | 768 | */ |
Bryce Lee | 5e4dd3e | 2015-08-03 16:59:10 -0700 | [diff] [blame] | 769 | public static final String EXTRA_NOTIFICATION_PHONE_NUMBER = |
| 770 | "android.telecom.extra.NOTIFICATION_PHONE_NUMBER"; |
| 771 | |
| 772 | /** |
Bryce Lee | 8d41d1d | 2015-08-10 07:40:42 -0700 | [diff] [blame] | 773 | * The intent to clear missed calls. |
| 774 | * @hide |
| 775 | */ |
| 776 | @SystemApi |
| 777 | public static final String EXTRA_CLEAR_MISSED_CALLS_INTENT = |
| 778 | "android.telecom.extra.CLEAR_MISSED_CALLS_INTENT"; |
| 779 | |
| 780 | /** |
| 781 | * The intent to call back a missed call. |
| 782 | * @hide |
| 783 | */ |
| 784 | @SystemApi |
| 785 | public static final String EXTRA_CALL_BACK_INTENT = |
| 786 | "android.telecom.extra.CALL_BACK_INTENT"; |
| 787 | |
| 788 | /** |
Charles He | 858f132 | 2017-11-27 17:11:04 -0800 | [diff] [blame] | 789 | * The dialer activity responsible for placing emergency calls from, for example, a locked |
| 790 | * keyguard. |
| 791 | * @hide |
| 792 | */ |
| 793 | public static final ComponentName EMERGENCY_DIALER_COMPONENT = |
| 794 | ComponentName.createRelative("com.android.phone", ".EmergencyDialer"); |
| 795 | |
| 796 | /** |
Eric Erfanian | 62706c5 | 2017-12-06 16:27:53 -0800 | [diff] [blame] | 797 | * The boolean indicated by this extra controls whether or not a call is eligible to undergo |
| 798 | * assisted dialing. This extra is stored under {@link #EXTRA_OUTGOING_CALL_EXTRAS}. |
Tyler Gunn | 5567d74 | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 799 | * <p> |
| 800 | * The call initiator can use this extra to indicate that a call used assisted dialing to help |
| 801 | * place the call. This is most commonly used by a Dialer app which provides the ability to |
| 802 | * automatically add dialing prefixes when placing international calls. |
| 803 | * <p> |
| 804 | * Setting this extra on the outgoing call extras will cause the |
| 805 | * {@link Connection#PROPERTY_ASSISTED_DIALING_USED} property and |
| 806 | * {@link Call.Details#PROPERTY_ASSISTED_DIALING_USED} property to be set on the |
| 807 | * {@link Connection}/{@link Call} in question. When the call is logged to the call log, the |
| 808 | * {@link android.provider.CallLog.Calls#FEATURES_ASSISTED_DIALING_USED} call feature is set to |
| 809 | * indicate that assisted dialing was used for the call. |
Eric Erfanian | 62706c5 | 2017-12-06 16:27:53 -0800 | [diff] [blame] | 810 | */ |
| 811 | public static final String EXTRA_USE_ASSISTED_DIALING = |
| 812 | "android.telecom.extra.USE_ASSISTED_DIALING"; |
| 813 | |
| 814 | /** |
Shaotang Li | 8cec25c | 2018-07-19 17:29:39 +0800 | [diff] [blame] | 815 | * Optional extra for {@link #placeCall(Uri, Bundle)} containing an integer that specifies |
| 816 | * the source where user initiated this call. This data is used in metrics. |
| 817 | * Valid source are: |
| 818 | * {@link ParcelableCallAnalytics#CALL_SOURCE_UNSPECIFIED}, |
| 819 | * {@link ParcelableCallAnalytics#CALL_SOURCE_EMERGENCY_DIALPAD}, |
| 820 | * {@link ParcelableCallAnalytics#CALL_SOURCE_EMERGENCY_SHORTCUT}. |
| 821 | * |
| 822 | * @hide |
| 823 | */ |
| 824 | public static final String EXTRA_CALL_SOURCE = "android.telecom.extra.CALL_SOURCE"; |
| 825 | |
| 826 | /** |
Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 827 | * The following 4 constants define how properties such as phone numbers and names are |
| 828 | * displayed to the user. |
| 829 | */ |
| 830 | |
Santos Cordon | ed769ae | 2015-05-13 18:47:38 -0700 | [diff] [blame] | 831 | /** |
| 832 | * Indicates that the address or number of a call is allowed to be displayed for caller ID. |
Charles He | 858f132 | 2017-11-27 17:11:04 -0800 | [diff] [blame] | 833 | */ |
Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 834 | public static final int PRESENTATION_ALLOWED = 1; |
| 835 | |
Santos Cordon | ed769ae | 2015-05-13 18:47:38 -0700 | [diff] [blame] | 836 | /** |
| 837 | * Indicates that the address or number of a call is blocked by the other party. |
| 838 | */ |
Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 839 | public static final int PRESENTATION_RESTRICTED = 2; |
| 840 | |
Santos Cordon | ed769ae | 2015-05-13 18:47:38 -0700 | [diff] [blame] | 841 | /** |
| 842 | * Indicates that the address or number of a call is not specified or known by the carrier. |
| 843 | */ |
Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 844 | public static final int PRESENTATION_UNKNOWN = 3; |
| 845 | |
Santos Cordon | ed769ae | 2015-05-13 18:47:38 -0700 | [diff] [blame] | 846 | /** |
| 847 | * Indicates that the address or number of a call belongs to a pay phone. |
| 848 | */ |
Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 849 | public static final int PRESENTATION_PAYPHONE = 4; |
| 850 | |
Tyler Gunn | 5567d74 | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 851 | /** @hide */ |
| 852 | @Retention(RetentionPolicy.SOURCE) |
| 853 | @IntDef( |
| 854 | prefix = { "PRESENTATION_" }, |
| 855 | value = {PRESENTATION_ALLOWED, PRESENTATION_RESTRICTED, PRESENTATION_UNKNOWN, |
| 856 | PRESENTATION_PAYPHONE}) |
| 857 | public @interface Presentation {} |
| 858 | |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 859 | private static final String TAG = "TelecomManager"; |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 860 | |
| 861 | private final Context mContext; |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 862 | |
Hall Liu | e1bc2ec | 2015-10-09 15:58:37 -0700 | [diff] [blame] | 863 | private final ITelecomService mTelecomServiceOverride; |
| 864 | |
Santos Cordon | 6c7a388 | 2014-06-25 15:30:08 -0700 | [diff] [blame] | 865 | /** |
| 866 | * @hide |
| 867 | */ |
Chen Xu | 4c0b06d | 2018-10-22 16:54:39 +0000 | [diff] [blame] | 868 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 869 | public static TelecomManager from(Context context) { |
| 870 | return (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE); |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 871 | } |
Santos Cordon | 6c7a388 | 2014-06-25 15:30:08 -0700 | [diff] [blame] | 872 | |
| 873 | /** |
| 874 | * @hide |
| 875 | */ |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 876 | public TelecomManager(Context context) { |
Hall Liu | e1bc2ec | 2015-10-09 15:58:37 -0700 | [diff] [blame] | 877 | this(context, null); |
| 878 | } |
| 879 | |
| 880 | /** |
| 881 | * @hide |
| 882 | */ |
| 883 | public TelecomManager(Context context, ITelecomService telecomServiceImpl) { |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 884 | Context appContext = context.getApplicationContext(); |
| 885 | if (appContext != null) { |
| 886 | mContext = appContext; |
| 887 | } else { |
| 888 | mContext = context; |
| 889 | } |
Hall Liu | e1bc2ec | 2015-10-09 15:58:37 -0700 | [diff] [blame] | 890 | mTelecomServiceOverride = telecomServiceImpl; |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 891 | } |
| 892 | |
| 893 | /** |
Santos Cordon | 91371dc | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 894 | * Return the {@link PhoneAccount} which will be used to place outgoing calls to addresses with |
| 895 | * the specified {@code uriScheme}. This {@link PhoneAccount} will always be a member of the |
| 896 | * list which is returned from invoking {@link #getCallCapablePhoneAccounts()}. The specific |
| 897 | * account returned depends on the following priorities: |
| 898 | * <ul> |
| 899 | * <li> If the user-selected default {@link PhoneAccount} supports the specified scheme, it will |
| 900 | * be returned. |
| 901 | * </li> |
| 902 | * <li> If there exists only one {@link PhoneAccount} that supports the specified scheme, it |
| 903 | * will be returned. |
| 904 | * </li> |
| 905 | * </ul> |
Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 906 | * <p> |
Santos Cordon | 91371dc | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 907 | * If no {@link PhoneAccount} fits the criteria above, this method will return {@code null}. |
| 908 | * |
Yorke Lee | c61d136 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 909 | * Requires permission: {@link android.Manifest.permission#READ_PHONE_STATE} |
| 910 | * |
Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 911 | * @param uriScheme The URI scheme. |
Santos Cordon | 91371dc | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 912 | * @return The {@link PhoneAccountHandle} corresponding to the account to be used. |
Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 913 | */ |
Yorke Lee | c61d136 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 914 | @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) |
Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 915 | public PhoneAccountHandle getDefaultOutgoingPhoneAccount(String uriScheme) { |
Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 916 | try { |
| 917 | if (isServiceConnected()) { |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 918 | return getTelecomService().getDefaultOutgoingPhoneAccount(uriScheme, |
| 919 | mContext.getOpPackageName()); |
Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 920 | } |
| 921 | } catch (RemoteException e) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 922 | Log.e(TAG, "Error calling ITelecomService#getDefaultOutgoingPhoneAccount", e); |
Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 923 | } |
| 924 | return null; |
| 925 | } |
| 926 | |
| 927 | /** |
Andrew Lee | d4abbfb | 2014-09-03 14:58:27 -0700 | [diff] [blame] | 928 | * Return the {@link PhoneAccount} which is the user-chosen default for making outgoing phone |
| 929 | * calls. This {@code PhoneAccount} will always be a member of the list which is returned from |
Nancy Chen | 210ef03 | 2014-09-15 17:58:42 -0700 | [diff] [blame] | 930 | * calling {@link #getCallCapablePhoneAccounts()} |
Santos Cordon | 91371dc | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 931 | * <p> |
Andrew Lee | d4abbfb | 2014-09-03 14:58:27 -0700 | [diff] [blame] | 932 | * Apps must be prepared for this method to return {@code null}, indicating that there currently |
| 933 | * exists no user-chosen default {@code PhoneAccount}. |
Tyler Gunn | 36c50ed | 2018-11-15 07:29:49 -0800 | [diff] [blame] | 934 | * <p> |
| 935 | * The default dialer has access to use this method. |
Andrew Lee | d4abbfb | 2014-09-03 14:58:27 -0700 | [diff] [blame] | 936 | * |
Slava Shklyaev | e65e401 | 2019-03-04 16:02:34 +0000 | [diff] [blame] | 937 | * @return The user outgoing phone account selected by the user, or {@code null} if there is no |
| 938 | * user selected outgoing {@link PhoneAccountHandle}. |
Andrew Lee | d4abbfb | 2014-09-03 14:58:27 -0700 | [diff] [blame] | 939 | */ |
Tyler Gunn | 36c50ed | 2018-11-15 07:29:49 -0800 | [diff] [blame] | 940 | @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) |
Slava Shklyaev | e65e401 | 2019-03-04 16:02:34 +0000 | [diff] [blame] | 941 | public @Nullable PhoneAccountHandle getUserSelectedOutgoingPhoneAccount() { |
Andrew Lee | d4abbfb | 2014-09-03 14:58:27 -0700 | [diff] [blame] | 942 | try { |
| 943 | if (isServiceConnected()) { |
Tyler Gunn | 36c50ed | 2018-11-15 07:29:49 -0800 | [diff] [blame] | 944 | return getTelecomService().getUserSelectedOutgoingPhoneAccount( |
| 945 | mContext.getOpPackageName()); |
Andrew Lee | d4abbfb | 2014-09-03 14:58:27 -0700 | [diff] [blame] | 946 | } |
| 947 | } catch (RemoteException e) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 948 | Log.e(TAG, "Error calling ITelecomService#getUserSelectedOutgoingPhoneAccount", e); |
Andrew Lee | d4abbfb | 2014-09-03 14:58:27 -0700 | [diff] [blame] | 949 | } |
| 950 | return null; |
| 951 | } |
| 952 | |
| 953 | /** |
Tyler Gunn | 36c50ed | 2018-11-15 07:29:49 -0800 | [diff] [blame] | 954 | * Sets the user-chosen default {@link PhoneAccountHandle} for making outgoing phone calls. |
| 955 | * |
| 956 | * @param accountHandle The {@link PhoneAccountHandle} which will be used by default for making |
Slava Shklyaev | e65e401 | 2019-03-04 16:02:34 +0000 | [diff] [blame] | 957 | * outgoing voice calls, or {@code null} if no default is specified (the |
| 958 | * user will be asked each time a call is placed in this case). |
Andrew Lee | 59cac3a | 2014-08-28 16:50:10 -0700 | [diff] [blame] | 959 | * @hide |
| 960 | */ |
Tyler Gunn | 36c50ed | 2018-11-15 07:29:49 -0800 | [diff] [blame] | 961 | @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) |
Tyler Gunn | 6c14a699 | 2019-02-04 15:12:06 -0800 | [diff] [blame] | 962 | @TestApi |
Tyler Gunn | 36c50ed | 2018-11-15 07:29:49 -0800 | [diff] [blame] | 963 | @SystemApi |
Slava Shklyaev | e65e401 | 2019-03-04 16:02:34 +0000 | [diff] [blame] | 964 | public void setUserSelectedOutgoingPhoneAccount(@Nullable PhoneAccountHandle accountHandle) { |
Andrew Lee | 59cac3a | 2014-08-28 16:50:10 -0700 | [diff] [blame] | 965 | try { |
| 966 | if (isServiceConnected()) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 967 | getTelecomService().setUserSelectedOutgoingPhoneAccount(accountHandle); |
Andrew Lee | 59cac3a | 2014-08-28 16:50:10 -0700 | [diff] [blame] | 968 | } |
| 969 | } catch (RemoteException e) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 970 | Log.e(TAG, "Error calling ITelecomService#setUserSelectedOutgoingPhoneAccount"); |
Andrew Lee | 59cac3a | 2014-08-28 16:50:10 -0700 | [diff] [blame] | 971 | } |
| 972 | } |
| 973 | |
| 974 | /** |
Andrew Lee | 59cac3a | 2014-08-28 16:50:10 -0700 | [diff] [blame] | 975 | * Returns the current SIM call manager. Apps must be prepared for this method to return |
Brad Ebinger | e783331 | 2019-05-07 10:55:55 -0700 | [diff] [blame] | 976 | * {@code null}, indicating that there currently exists no SIM call manager {@link PhoneAccount} |
| 977 | * for the default voice subscription. |
Santos Cordon | 91371dc | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 978 | * |
Brad Ebinger | e783331 | 2019-05-07 10:55:55 -0700 | [diff] [blame] | 979 | * @return The phone account handle of the current sim call manager for the default voice |
| 980 | * subscription. |
| 981 | * @see SubscriptionManager#getDefaultVoiceSubscriptionId() |
Andrew Lee | 59cac3a | 2014-08-28 16:50:10 -0700 | [diff] [blame] | 982 | */ |
| 983 | public PhoneAccountHandle getSimCallManager() { |
| 984 | try { |
| 985 | if (isServiceConnected()) { |
Brad Ebinger | e783331 | 2019-05-07 10:55:55 -0700 | [diff] [blame] | 986 | return getTelecomService().getSimCallManager( |
| 987 | SubscriptionManager.getDefaultSubscriptionId()); |
Andrew Lee | 59cac3a | 2014-08-28 16:50:10 -0700 | [diff] [blame] | 988 | } |
| 989 | } catch (RemoteException e) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 990 | Log.e(TAG, "Error calling ITelecomService#getSimCallManager"); |
Andrew Lee | 59cac3a | 2014-08-28 16:50:10 -0700 | [diff] [blame] | 991 | } |
| 992 | return null; |
| 993 | } |
| 994 | |
| 995 | /** |
Brad Ebinger | e783331 | 2019-05-07 10:55:55 -0700 | [diff] [blame] | 996 | * Returns current SIM call manager for the Telephony Subscription ID specified. Apps must be |
| 997 | * prepared for this method to return {@code null}, indicating that there currently exists no |
| 998 | * SIM call manager {@link PhoneAccount} for the subscription specified. |
| 999 | * |
| 1000 | * @param subscriptionId The Telephony Subscription ID that the SIM call manager should be |
| 1001 | * queried for. |
| 1002 | * @return The phone account handle of the current sim call manager. |
| 1003 | * @see SubscriptionManager#getActiveSubscriptionInfoList() |
Brad Ebinger | e783331 | 2019-05-07 10:55:55 -0700 | [diff] [blame] | 1004 | */ |
Tyler Gunn | 5567d74 | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 1005 | public @Nullable PhoneAccountHandle getSimCallManagerForSubscription(int subscriptionId) { |
Brad Ebinger | e783331 | 2019-05-07 10:55:55 -0700 | [diff] [blame] | 1006 | try { |
| 1007 | if (isServiceConnected()) { |
| 1008 | return getTelecomService().getSimCallManager(subscriptionId); |
| 1009 | } |
| 1010 | } catch (RemoteException e) { |
| 1011 | Log.e(TAG, "Error calling ITelecomService#getSimCallManager"); |
| 1012 | } |
| 1013 | return null; |
| 1014 | } |
| 1015 | |
| 1016 | /** |
| 1017 | * Returns the current SIM call manager for the user-chosen default Telephony Subscription ID |
| 1018 | * (see {@link SubscriptionManager#getDefaultSubscriptionId()}) and the specified user. Apps |
| 1019 | * must be prepared for this method to return {@code null}, indicating that there currently |
| 1020 | * exists no SIM call manager {@link PhoneAccount} for the default voice subscription. |
Sailesh Nepal | cf85562 | 2015-07-28 19:22:14 -0700 | [diff] [blame] | 1021 | * |
| 1022 | * @return The phone account handle of the current sim call manager. |
| 1023 | * |
| 1024 | * @hide |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 1025 | * @deprecated Use {@link #getSimCallManager()}. |
Sailesh Nepal | cf85562 | 2015-07-28 19:22:14 -0700 | [diff] [blame] | 1026 | */ |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 1027 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 119305590) |
Sailesh Nepal | cf85562 | 2015-07-28 19:22:14 -0700 | [diff] [blame] | 1028 | public PhoneAccountHandle getSimCallManager(int userId) { |
| 1029 | try { |
| 1030 | if (isServiceConnected()) { |
| 1031 | return getTelecomService().getSimCallManagerForUser(userId); |
| 1032 | } |
| 1033 | } catch (RemoteException e) { |
| 1034 | Log.e(TAG, "Error calling ITelecomService#getSimCallManagerForUser"); |
| 1035 | } |
| 1036 | return null; |
| 1037 | } |
| 1038 | |
| 1039 | /** |
Evan Charlton | eb0a8d5 | 2014-09-04 12:03:34 -0700 | [diff] [blame] | 1040 | * Returns the current connection manager. Apps must be prepared for this method to return |
Brad Ebinger | e783331 | 2019-05-07 10:55:55 -0700 | [diff] [blame] | 1041 | * {@code null}, indicating that there currently exists no Connection Manager |
| 1042 | * {@link PhoneAccount} for the default voice subscription. |
Evan Charlton | eb0a8d5 | 2014-09-04 12:03:34 -0700 | [diff] [blame] | 1043 | * |
| 1044 | * @return The phone account handle of the current connection manager. |
Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 1045 | * @hide |
Evan Charlton | eb0a8d5 | 2014-09-04 12:03:34 -0700 | [diff] [blame] | 1046 | */ |
Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 1047 | @SystemApi |
Evan Charlton | eb0a8d5 | 2014-09-04 12:03:34 -0700 | [diff] [blame] | 1048 | public PhoneAccountHandle getConnectionManager() { |
| 1049 | return getSimCallManager(); |
| 1050 | } |
| 1051 | |
| 1052 | /** |
Nancy Chen | 210ef03 | 2014-09-15 17:58:42 -0700 | [diff] [blame] | 1053 | * Returns a list of the {@link PhoneAccountHandle}s which can be used to make and receive phone |
| 1054 | * calls which support the specified URI scheme. |
Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 1055 | * <P> |
| 1056 | * For example, invoking with {@code "tel"} will find all {@link PhoneAccountHandle}s which |
| 1057 | * support telephone calls (e.g. URIs such as {@code tel:555-555-1212}). Invoking with |
| 1058 | * {@code "sip"} will find all {@link PhoneAccountHandle}s which support SIP calls (e.g. URIs |
| 1059 | * such as {@code sip:example@sipexample.com}). |
| 1060 | * |
| 1061 | * @param uriScheme The URI scheme. |
| 1062 | * @return A list of {@code PhoneAccountHandle} objects supporting the URI scheme. |
Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 1063 | * @hide |
Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 1064 | */ |
Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 1065 | @SystemApi |
Jeff Sharkey | bfc4fcd | 2017-06-05 17:38:17 -0600 | [diff] [blame] | 1066 | @RequiresPermission(anyOf = { |
Tyler Gunn | 5567d74 | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 1067 | READ_PRIVILEGED_PHONE_STATE, |
Jeff Sharkey | bfc4fcd | 2017-06-05 17:38:17 -0600 | [diff] [blame] | 1068 | android.Manifest.permission.READ_PHONE_STATE |
| 1069 | }) |
Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 1070 | public List<PhoneAccountHandle> getPhoneAccountsSupportingScheme(String uriScheme) { |
| 1071 | try { |
| 1072 | if (isServiceConnected()) { |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 1073 | return getTelecomService().getPhoneAccountsSupportingScheme(uriScheme, |
| 1074 | mContext.getOpPackageName()); |
Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 1075 | } |
| 1076 | } catch (RemoteException e) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1077 | Log.e(TAG, "Error calling ITelecomService#getPhoneAccountsSupportingScheme", e); |
Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 1078 | } |
| 1079 | return new ArrayList<>(); |
| 1080 | } |
| 1081 | |
Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 1082 | |
| 1083 | /** |
Santos Cordon | 91371dc | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 1084 | * Returns a list of {@link PhoneAccountHandle}s which can be used to make and receive phone |
| 1085 | * calls. The returned list includes only those accounts which have been explicitly enabled |
| 1086 | * by the user. |
Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 1087 | * |
Yorke Lee | c61d136 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 1088 | * Requires permission: {@link android.Manifest.permission#READ_PHONE_STATE} |
| 1089 | * |
Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 1090 | * @see #EXTRA_PHONE_ACCOUNT_HANDLE |
| 1091 | * @return A list of {@code PhoneAccountHandle} objects. |
Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 1092 | */ |
Yorke Lee | c61d136 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 1093 | @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) |
Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 1094 | public List<PhoneAccountHandle> getCallCapablePhoneAccounts() { |
Santos Cordon | 91371dc | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 1095 | return getCallCapablePhoneAccounts(false); |
| 1096 | } |
| 1097 | |
| 1098 | /** |
Tyler Gunn | 8931707 | 2017-04-07 14:57:37 -0700 | [diff] [blame] | 1099 | * Returns a list of {@link PhoneAccountHandle}s for self-managed {@link ConnectionService}s. |
| 1100 | * <p> |
| 1101 | * Self-Managed {@link ConnectionService}s have a {@link PhoneAccount} with |
| 1102 | * {@link PhoneAccount#CAPABILITY_SELF_MANAGED}. |
| 1103 | * <p> |
| 1104 | * Requires permission {@link android.Manifest.permission#READ_PHONE_STATE}, or that the caller |
| 1105 | * is the default dialer app. |
| 1106 | * <p> |
| 1107 | * A {@link SecurityException} will be thrown if a called is not the default dialer, or lacks |
| 1108 | * the {@link android.Manifest.permission#READ_PHONE_STATE} permission. |
| 1109 | * |
| 1110 | * @return A list of {@code PhoneAccountHandle} objects. |
| 1111 | */ |
| 1112 | @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) |
| 1113 | public List<PhoneAccountHandle> getSelfManagedPhoneAccounts() { |
| 1114 | try { |
| 1115 | if (isServiceConnected()) { |
| 1116 | return getTelecomService().getSelfManagedPhoneAccounts(mContext.getOpPackageName()); |
| 1117 | } |
| 1118 | } catch (RemoteException e) { |
| 1119 | Log.e(TAG, "Error calling ITelecomService#getSelfManagedPhoneAccounts()", e); |
| 1120 | } |
| 1121 | return new ArrayList<>(); |
| 1122 | } |
| 1123 | |
| 1124 | /** |
Santos Cordon | 91371dc | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 1125 | * Returns a list of {@link PhoneAccountHandle}s including those which have not been enabled |
| 1126 | * by the user. |
| 1127 | * |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 1128 | * @param includeDisabledAccounts When {@code true}, disabled phone accounts will be included, |
Hall Liu | b230624 | 2019-11-15 17:13:05 -0800 | [diff] [blame] | 1129 | * when {@code false}, only enabled phone accounts will be |
| 1130 | * included. |
Santos Cordon | 91371dc | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 1131 | * @return A list of {@code PhoneAccountHandle} objects. |
| 1132 | * @hide |
| 1133 | */ |
Hall Liu | b230624 | 2019-11-15 17:13:05 -0800 | [diff] [blame] | 1134 | @SystemApi |
| 1135 | @TestApi |
| 1136 | @RequiresPermission(READ_PRIVILEGED_PHONE_STATE) |
| 1137 | public @NonNull List<PhoneAccountHandle> getCallCapablePhoneAccounts( |
| 1138 | boolean includeDisabledAccounts) { |
Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 1139 | try { |
| 1140 | if (isServiceConnected()) { |
Santos Cordon | 91371dc | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 1141 | return getTelecomService().getCallCapablePhoneAccounts( |
| 1142 | includeDisabledAccounts, mContext.getOpPackageName()); |
Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 1143 | } |
| 1144 | } catch (RemoteException e) { |
Santos Cordon | 91371dc | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 1145 | Log.e(TAG, "Error calling ITelecomService#getCallCapablePhoneAccounts(" + |
| 1146 | includeDisabledAccounts + ")", e); |
Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 1147 | } |
| 1148 | return new ArrayList<>(); |
| 1149 | } |
| 1150 | |
Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 1151 | /** |
Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 1152 | * Returns a list of all {@link PhoneAccount}s registered for the calling package. |
| 1153 | * |
| 1154 | * @return A list of {@code PhoneAccountHandle} objects. |
Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 1155 | * @hide |
Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 1156 | */ |
Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 1157 | @SystemApi |
Jeff Sharkey | bfc4fcd | 2017-06-05 17:38:17 -0600 | [diff] [blame] | 1158 | @SuppressLint("Doclava125") |
Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 1159 | public List<PhoneAccountHandle> getPhoneAccountsForPackage() { |
| 1160 | try { |
| 1161 | if (isServiceConnected()) { |
| 1162 | return getTelecomService().getPhoneAccountsForPackage(mContext.getPackageName()); |
| 1163 | } |
| 1164 | } catch (RemoteException e) { |
| 1165 | Log.e(TAG, "Error calling ITelecomService#getPhoneAccountsForPackage", e); |
| 1166 | } |
| 1167 | return null; |
| 1168 | } |
| 1169 | |
| 1170 | /** |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 1171 | * Return the {@link PhoneAccount} for a specified {@link PhoneAccountHandle}. Object includes |
| 1172 | * resources which can be used in a user interface. |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1173 | * |
Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 1174 | * @param account The {@link PhoneAccountHandle}. |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 1175 | * @return The {@link PhoneAccount} object. |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1176 | */ |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 1177 | public PhoneAccount getPhoneAccount(PhoneAccountHandle account) { |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1178 | try { |
| 1179 | if (isServiceConnected()) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1180 | return getTelecomService().getPhoneAccount(account); |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1181 | } |
| 1182 | } catch (RemoteException e) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1183 | Log.e(TAG, "Error calling ITelecomService#getPhoneAccount", e); |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1184 | } |
| 1185 | return null; |
| 1186 | } |
| 1187 | |
| 1188 | /** |
Nancy Chen | 210ef03 | 2014-09-15 17:58:42 -0700 | [diff] [blame] | 1189 | * Returns a count of all {@link PhoneAccount}s. |
Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 1190 | * |
Nancy Chen | 210ef03 | 2014-09-15 17:58:42 -0700 | [diff] [blame] | 1191 | * @return The count of {@link PhoneAccount}s. |
Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 1192 | * @hide |
| 1193 | */ |
| 1194 | @SystemApi |
| 1195 | public int getAllPhoneAccountsCount() { |
| 1196 | try { |
| 1197 | if (isServiceConnected()) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1198 | return getTelecomService().getAllPhoneAccountsCount(); |
Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 1199 | } |
| 1200 | } catch (RemoteException e) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1201 | Log.e(TAG, "Error calling ITelecomService#getAllPhoneAccountsCount", e); |
Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 1202 | } |
| 1203 | return 0; |
| 1204 | } |
| 1205 | |
| 1206 | /** |
| 1207 | * Returns a list of all {@link PhoneAccount}s. |
| 1208 | * |
| 1209 | * @return All {@link PhoneAccount}s. |
| 1210 | * @hide |
| 1211 | */ |
| 1212 | @SystemApi |
| 1213 | public List<PhoneAccount> getAllPhoneAccounts() { |
| 1214 | try { |
| 1215 | if (isServiceConnected()) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1216 | return getTelecomService().getAllPhoneAccounts(); |
Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 1217 | } |
| 1218 | } catch (RemoteException e) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1219 | Log.e(TAG, "Error calling ITelecomService#getAllPhoneAccounts", e); |
Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 1220 | } |
| 1221 | return Collections.EMPTY_LIST; |
| 1222 | } |
| 1223 | |
| 1224 | /** |
| 1225 | * Returns a list of all {@link PhoneAccountHandle}s. |
| 1226 | * |
| 1227 | * @return All {@link PhoneAccountHandle}s. |
| 1228 | * @hide |
| 1229 | */ |
| 1230 | @SystemApi |
| 1231 | public List<PhoneAccountHandle> getAllPhoneAccountHandles() { |
| 1232 | try { |
| 1233 | if (isServiceConnected()) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1234 | return getTelecomService().getAllPhoneAccountHandles(); |
Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 1235 | } |
| 1236 | } catch (RemoteException e) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1237 | Log.e(TAG, "Error calling ITelecomService#getAllPhoneAccountHandles", e); |
Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 1238 | } |
| 1239 | return Collections.EMPTY_LIST; |
| 1240 | } |
| 1241 | |
| 1242 | /** |
Brad Ebinger | ec0d334 | 2016-01-29 15:40:43 -0800 | [diff] [blame] | 1243 | * Register a {@link PhoneAccount} for use by the system that will be stored in Device Encrypted |
| 1244 | * storage. When registering {@link PhoneAccount}s, existing registrations will be overwritten |
| 1245 | * if the {@link PhoneAccountHandle} matches that of a {@link PhoneAccount} which is already |
Santos Cordon | d9e614f | 2014-10-28 13:10:36 -0700 | [diff] [blame] | 1246 | * registered. Once registered, the {@link PhoneAccount} is listed to the user as an option |
| 1247 | * when placing calls. The user may still need to enable the {@link PhoneAccount} within |
| 1248 | * the phone app settings before the account is usable. |
| 1249 | * <p> |
| 1250 | * A {@link SecurityException} will be thrown if an app tries to register a |
| 1251 | * {@link PhoneAccountHandle} where the package name specified within |
| 1252 | * {@link PhoneAccountHandle#getComponentName()} does not match the package name of the app. |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1253 | * |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 1254 | * @param account The complete {@link PhoneAccount}. |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1255 | */ |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 1256 | public void registerPhoneAccount(PhoneAccount account) { |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1257 | try { |
| 1258 | if (isServiceConnected()) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1259 | getTelecomService().registerPhoneAccount(account); |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1260 | } |
| 1261 | } catch (RemoteException e) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1262 | Log.e(TAG, "Error calling ITelecomService#registerPhoneAccount", e); |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1263 | } |
| 1264 | } |
| 1265 | |
| 1266 | /** |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 1267 | * Remove a {@link PhoneAccount} registration from the system. |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1268 | * |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 1269 | * @param accountHandle A {@link PhoneAccountHandle} for the {@link PhoneAccount} to unregister. |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1270 | */ |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 1271 | public void unregisterPhoneAccount(PhoneAccountHandle accountHandle) { |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1272 | try { |
| 1273 | if (isServiceConnected()) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1274 | getTelecomService().unregisterPhoneAccount(accountHandle); |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1275 | } |
| 1276 | } catch (RemoteException e) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1277 | Log.e(TAG, "Error calling ITelecomService#unregisterPhoneAccount", e); |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1278 | } |
| 1279 | } |
| 1280 | |
| 1281 | /** |
Nancy Chen | 7ab1dc4 | 2014-09-09 18:18:26 -0700 | [diff] [blame] | 1282 | * Remove all Accounts that belong to the calling package from the system. |
Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 1283 | * @hide |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1284 | */ |
Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 1285 | @SystemApi |
Jeff Sharkey | bfc4fcd | 2017-06-05 17:38:17 -0600 | [diff] [blame] | 1286 | @SuppressLint("Doclava125") |
Yorke Lee | 0604427 | 2015-04-14 15:16:59 -0700 | [diff] [blame] | 1287 | public void clearPhoneAccounts() { |
| 1288 | clearAccounts(); |
| 1289 | } |
| 1290 | /** |
| 1291 | * Remove all Accounts that belong to the calling package from the system. |
| 1292 | * @deprecated Use {@link #clearPhoneAccounts()} instead. |
| 1293 | * @hide |
| 1294 | */ |
| 1295 | @SystemApi |
Jeff Sharkey | bfc4fcd | 2017-06-05 17:38:17 -0600 | [diff] [blame] | 1296 | @SuppressLint("Doclava125") |
Nancy Chen | 7ab1dc4 | 2014-09-09 18:18:26 -0700 | [diff] [blame] | 1297 | public void clearAccounts() { |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1298 | try { |
| 1299 | if (isServiceConnected()) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1300 | getTelecomService().clearAccounts(mContext.getPackageName()); |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1301 | } |
| 1302 | } catch (RemoteException e) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1303 | Log.e(TAG, "Error calling ITelecomService#clearAccounts", e); |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1304 | } |
| 1305 | } |
| 1306 | |
| 1307 | /** |
Anthony Lee | 6727926 | 2014-10-27 11:28:40 -0700 | [diff] [blame] | 1308 | * Remove all Accounts that belong to the specified package from the system. |
| 1309 | * @hide |
| 1310 | */ |
| 1311 | public void clearAccountsForPackage(String packageName) { |
| 1312 | try { |
| 1313 | if (isServiceConnected() && !TextUtils.isEmpty(packageName)) { |
| 1314 | getTelecomService().clearAccounts(packageName); |
| 1315 | } |
| 1316 | } catch (RemoteException e) { |
Nancy Chen | 5cf2784 | 2015-01-24 23:30:27 -0800 | [diff] [blame] | 1317 | Log.e(TAG, "Error calling ITelecomService#clearAccountsForPackage", e); |
Anthony Lee | 6727926 | 2014-10-27 11:28:40 -0700 | [diff] [blame] | 1318 | } |
| 1319 | } |
| 1320 | |
Yorke Lee | 1011f48 | 2015-04-23 15:58:27 -0700 | [diff] [blame] | 1321 | |
Anthony Lee | 6727926 | 2014-10-27 11:28:40 -0700 | [diff] [blame] | 1322 | /** |
Yorke Lee | 1011f48 | 2015-04-23 15:58:27 -0700 | [diff] [blame] | 1323 | * @deprecated - Use {@link TelecomManager#getDefaultDialerPackage} to directly access |
| 1324 | * the default dialer's package name instead. |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1325 | * @hide |
| 1326 | */ |
Santos Cordon | 6c7a388 | 2014-06-25 15:30:08 -0700 | [diff] [blame] | 1327 | @SystemApi |
Jeff Sharkey | bfc4fcd | 2017-06-05 17:38:17 -0600 | [diff] [blame] | 1328 | @SuppressLint("Doclava125") |
Santos Cordon | 6c7a388 | 2014-06-25 15:30:08 -0700 | [diff] [blame] | 1329 | public ComponentName getDefaultPhoneApp() { |
| 1330 | try { |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1331 | if (isServiceConnected()) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1332 | return getTelecomService().getDefaultPhoneApp(); |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1333 | } |
Santos Cordon | 6c7a388 | 2014-06-25 15:30:08 -0700 | [diff] [blame] | 1334 | } catch (RemoteException e) { |
| 1335 | Log.e(TAG, "RemoteException attempting to get the default phone app.", e); |
| 1336 | } |
| 1337 | return null; |
| 1338 | } |
| 1339 | |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1340 | /** |
Yorke Lee | 1011f48 | 2015-04-23 15:58:27 -0700 | [diff] [blame] | 1341 | * Used to determine the currently selected default dialer package. |
| 1342 | * |
| 1343 | * @return package name for the default dialer package or null if no package has been |
| 1344 | * selected as the default dialer. |
| 1345 | */ |
| 1346 | public String getDefaultDialerPackage() { |
| 1347 | try { |
| 1348 | if (isServiceConnected()) { |
| 1349 | return getTelecomService().getDefaultDialerPackage(); |
| 1350 | } |
| 1351 | } catch (RemoteException e) { |
| 1352 | Log.e(TAG, "RemoteException attempting to get the default dialer package name.", e); |
| 1353 | } |
| 1354 | return null; |
| 1355 | } |
| 1356 | |
| 1357 | /** |
Tyler Gunn | 5567d74 | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 1358 | * Used to determine the currently selected default dialer package for a specific user. |
| 1359 | * |
| 1360 | * @param userId the user id to query the default dialer package for. |
| 1361 | * @return package name for the default dialer package or null if no package has been |
| 1362 | * selected as the default dialer. |
| 1363 | * @hide |
| 1364 | */ |
| 1365 | @SystemApi |
| 1366 | @TestApi |
| 1367 | @RequiresPermission(READ_PRIVILEGED_PHONE_STATE) |
| 1368 | public @Nullable String getDefaultDialerPackage(int userId) { |
| 1369 | try { |
| 1370 | if (isServiceConnected()) { |
| 1371 | return getTelecomService().getDefaultDialerPackageForUser(userId); |
| 1372 | } |
| 1373 | } catch (RemoteException e) { |
| 1374 | Log.e(TAG, "RemoteException attempting to get the default dialer package name.", e); |
| 1375 | } |
| 1376 | return null; |
| 1377 | } |
| 1378 | |
| 1379 | /** |
Yorke Lee | 107c4ce | 2015-06-15 12:08:24 -0700 | [diff] [blame] | 1380 | * Used to set the default dialer package. |
| 1381 | * |
Slava Shklyaev | e65e401 | 2019-03-04 16:02:34 +0000 | [diff] [blame] | 1382 | * @param packageName to set the default dialer to, or {@code null} if the system provided |
| 1383 | * dialer should be used instead. |
Yorke Lee | 107c4ce | 2015-06-15 12:08:24 -0700 | [diff] [blame] | 1384 | * |
| 1385 | * @result {@code true} if the default dialer was successfully changed, {@code false} if |
| 1386 | * the specified package does not correspond to an installed dialer, or is already |
| 1387 | * the default dialer. |
| 1388 | * |
| 1389 | * Requires permission: {@link android.Manifest.permission#MODIFY_PHONE_STATE} |
| 1390 | * Requires permission: {@link android.Manifest.permission#WRITE_SECURE_SETTINGS} |
| 1391 | * |
| 1392 | * @hide |
Tyler Gunn | 7e45b72 | 2018-12-04 12:56:45 -0800 | [diff] [blame] | 1393 | * @deprecated Use |
Hai Zhang | f5e8ccd | 2019-03-06 20:12:24 -0800 | [diff] [blame] | 1394 | * {@link android.app.role.RoleManager#addRoleHolderAsUser(String, String, int, UserHandle, |
| 1395 | * Executor, java.util.function.Consumer)} instead. |
Suprabh Shukla | 169bed7 | 2019-05-13 13:54:58 -0700 | [diff] [blame] | 1396 | * @removed |
Yorke Lee | 107c4ce | 2015-06-15 12:08:24 -0700 | [diff] [blame] | 1397 | */ |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 1398 | @SystemApi |
Tyler Gunn | 7e45b72 | 2018-12-04 12:56:45 -0800 | [diff] [blame] | 1399 | @Deprecated |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 1400 | @RequiresPermission(allOf = { |
| 1401 | android.Manifest.permission.MODIFY_PHONE_STATE, |
| 1402 | android.Manifest.permission.WRITE_SECURE_SETTINGS}) |
Slava Shklyaev | e65e401 | 2019-03-04 16:02:34 +0000 | [diff] [blame] | 1403 | public boolean setDefaultDialer(@Nullable String packageName) { |
Yorke Lee | 107c4ce | 2015-06-15 12:08:24 -0700 | [diff] [blame] | 1404 | try { |
| 1405 | if (isServiceConnected()) { |
| 1406 | return getTelecomService().setDefaultDialer(packageName); |
| 1407 | } |
| 1408 | } catch (RemoteException e) { |
| 1409 | Log.e(TAG, "RemoteException attempting to set the default dialer.", e); |
| 1410 | } |
| 1411 | return false; |
| 1412 | } |
| 1413 | |
| 1414 | /** |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 1415 | * Determines the package name of the system-provided default phone app. |
Yorke Lee | 1011f48 | 2015-04-23 15:58:27 -0700 | [diff] [blame] | 1416 | * |
Slava Shklyaev | e65e401 | 2019-03-04 16:02:34 +0000 | [diff] [blame] | 1417 | * @return package name for the system dialer package or {@code null} if no system dialer is |
| 1418 | * preloaded. |
Yorke Lee | 1011f48 | 2015-04-23 15:58:27 -0700 | [diff] [blame] | 1419 | */ |
Slava Shklyaev | e65e401 | 2019-03-04 16:02:34 +0000 | [diff] [blame] | 1420 | public @Nullable String getSystemDialerPackage() { |
Yorke Lee | 1011f48 | 2015-04-23 15:58:27 -0700 | [diff] [blame] | 1421 | try { |
| 1422 | if (isServiceConnected()) { |
| 1423 | return getTelecomService().getSystemDialerPackage(); |
| 1424 | } |
| 1425 | } catch (RemoteException e) { |
| 1426 | Log.e(TAG, "RemoteException attempting to get the system dialer package name.", e); |
| 1427 | } |
| 1428 | return null; |
| 1429 | } |
| 1430 | |
| 1431 | /** |
Nancy Chen | 443e501 | 2014-10-15 15:48:21 -0700 | [diff] [blame] | 1432 | * Return whether a given phone number is the configured voicemail number for a |
| 1433 | * particular phone account. |
| 1434 | * |
Yorke Lee | c61d136 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 1435 | * Requires permission: {@link android.Manifest.permission#READ_PHONE_STATE} |
| 1436 | * |
Nancy Chen | 443e501 | 2014-10-15 15:48:21 -0700 | [diff] [blame] | 1437 | * @param accountHandle The handle for the account to check the voicemail number against |
| 1438 | * @param number The number to look up. |
Nancy Chen | 443e501 | 2014-10-15 15:48:21 -0700 | [diff] [blame] | 1439 | */ |
Yorke Lee | c61d136 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 1440 | @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) |
Nancy Chen | 443e501 | 2014-10-15 15:48:21 -0700 | [diff] [blame] | 1441 | public boolean isVoiceMailNumber(PhoneAccountHandle accountHandle, String number) { |
| 1442 | try { |
| 1443 | if (isServiceConnected()) { |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 1444 | return getTelecomService().isVoiceMailNumber(accountHandle, number, |
| 1445 | mContext.getOpPackageName()); |
Nancy Chen | 443e501 | 2014-10-15 15:48:21 -0700 | [diff] [blame] | 1446 | } |
| 1447 | } catch (RemoteException e) { |
Nancy Chen | 5cf2784 | 2015-01-24 23:30:27 -0800 | [diff] [blame] | 1448 | Log.e(TAG, "RemoteException calling ITelecomService#isVoiceMailNumber.", e); |
Nancy Chen | 443e501 | 2014-10-15 15:48:21 -0700 | [diff] [blame] | 1449 | } |
| 1450 | return false; |
| 1451 | } |
| 1452 | |
| 1453 | /** |
Yorke Lee | 49e2d46 | 2015-04-15 16:14:22 -0700 | [diff] [blame] | 1454 | * Return the voicemail number for a given phone account. |
Nancy Chen | 8c066f7 | 2014-12-03 15:18:08 -0800 | [diff] [blame] | 1455 | * |
Yorke Lee | c61d136 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 1456 | * Requires permission: {@link android.Manifest.permission#READ_PHONE_STATE} |
| 1457 | * |
Yorke Lee | 49e2d46 | 2015-04-15 16:14:22 -0700 | [diff] [blame] | 1458 | * @param accountHandle The handle for the phone account. |
| 1459 | * @return The voicemail number for the phone account, and {@code null} if one has not been |
| 1460 | * configured. |
Nancy Chen | 8c066f7 | 2014-12-03 15:18:08 -0800 | [diff] [blame] | 1461 | */ |
Yorke Lee | c61d136 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 1462 | @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) |
Yorke Lee | 49e2d46 | 2015-04-15 16:14:22 -0700 | [diff] [blame] | 1463 | public String getVoiceMailNumber(PhoneAccountHandle accountHandle) { |
Nancy Chen | 8c066f7 | 2014-12-03 15:18:08 -0800 | [diff] [blame] | 1464 | try { |
| 1465 | if (isServiceConnected()) { |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 1466 | return getTelecomService().getVoiceMailNumber(accountHandle, |
| 1467 | mContext.getOpPackageName()); |
Nancy Chen | 8c066f7 | 2014-12-03 15:18:08 -0800 | [diff] [blame] | 1468 | } |
| 1469 | } catch (RemoteException e) { |
Nancy Chen | 5cf2784 | 2015-01-24 23:30:27 -0800 | [diff] [blame] | 1470 | Log.e(TAG, "RemoteException calling ITelecomService#hasVoiceMailNumber.", e); |
Nancy Chen | 8c066f7 | 2014-12-03 15:18:08 -0800 | [diff] [blame] | 1471 | } |
Yorke Lee | 49e2d46 | 2015-04-15 16:14:22 -0700 | [diff] [blame] | 1472 | return null; |
Nancy Chen | 8c066f7 | 2014-12-03 15:18:08 -0800 | [diff] [blame] | 1473 | } |
| 1474 | |
| 1475 | /** |
Nancy Chen | 5cf2784 | 2015-01-24 23:30:27 -0800 | [diff] [blame] | 1476 | * Return the line 1 phone number for given phone account. |
| 1477 | * |
Yorke Lee | c61d136 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 1478 | * Requires permission: {@link android.Manifest.permission#READ_PHONE_STATE} |
| 1479 | * |
Nancy Chen | 5cf2784 | 2015-01-24 23:30:27 -0800 | [diff] [blame] | 1480 | * @param accountHandle The handle for the account retrieve a number for. |
| 1481 | * @return A string representation of the line 1 phone number. |
Nancy Chen | 5cf2784 | 2015-01-24 23:30:27 -0800 | [diff] [blame] | 1482 | */ |
Yorke Lee | c61d136 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 1483 | @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) |
Nancy Chen | 5cf2784 | 2015-01-24 23:30:27 -0800 | [diff] [blame] | 1484 | public String getLine1Number(PhoneAccountHandle accountHandle) { |
| 1485 | try { |
| 1486 | if (isServiceConnected()) { |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 1487 | return getTelecomService().getLine1Number(accountHandle, |
| 1488 | mContext.getOpPackageName()); |
Nancy Chen | 5cf2784 | 2015-01-24 23:30:27 -0800 | [diff] [blame] | 1489 | } |
| 1490 | } catch (RemoteException e) { |
| 1491 | Log.e(TAG, "RemoteException calling ITelecomService#getLine1Number.", e); |
| 1492 | } |
| 1493 | return null; |
| 1494 | } |
| 1495 | |
| 1496 | /** |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1497 | * Returns whether there is an ongoing phone call (can be in dialing, ringing, active or holding |
Tyler Gunn | 24e1833 | 2017-02-10 09:42:49 -0800 | [diff] [blame] | 1498 | * states) originating from either a manager or self-managed {@link ConnectionService}. |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1499 | * <p> |
| 1500 | * Requires permission: {@link android.Manifest.permission#READ_PHONE_STATE} |
Tyler Gunn | 24e1833 | 2017-02-10 09:42:49 -0800 | [diff] [blame] | 1501 | * |
| 1502 | * @return {@code true} if there is an ongoing call in either a managed or self-managed |
| 1503 | * {@link ConnectionService}, {@code false} otherwise. |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1504 | */ |
Yorke Lee | c61d136 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 1505 | @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1506 | public boolean isInCall() { |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1507 | try { |
| 1508 | if (isServiceConnected()) { |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 1509 | return getTelecomService().isInCall(mContext.getOpPackageName()); |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1510 | } |
| 1511 | } catch (RemoteException e) { |
Yorke Lee | 2ae312e | 2014-09-12 17:58:48 -0700 | [diff] [blame] | 1512 | Log.e(TAG, "RemoteException calling isInCall().", e); |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1513 | } |
| 1514 | return false; |
| 1515 | } |
| 1516 | |
| 1517 | /** |
Tyler Gunn | 24e1833 | 2017-02-10 09:42:49 -0800 | [diff] [blame] | 1518 | * Returns whether there is an ongoing call originating from a managed |
| 1519 | * {@link ConnectionService}. An ongoing call can be in dialing, ringing, active or holding |
| 1520 | * states. |
| 1521 | * <p> |
| 1522 | * If you also need to know if there are ongoing self-managed calls, use {@link #isInCall()} |
| 1523 | * instead. |
| 1524 | * <p> |
| 1525 | * Requires permission: {@link android.Manifest.permission#READ_PHONE_STATE} |
| 1526 | * |
| 1527 | * @return {@code true} if there is an ongoing call in a managed {@link ConnectionService}, |
| 1528 | * {@code false} otherwise. |
| 1529 | */ |
| 1530 | @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) |
| 1531 | public boolean isInManagedCall() { |
| 1532 | try { |
| 1533 | if (isServiceConnected()) { |
| 1534 | return getTelecomService().isInManagedCall(mContext.getOpPackageName()); |
| 1535 | } |
| 1536 | } catch (RemoteException e) { |
| 1537 | Log.e(TAG, "RemoteException calling isInManagedCall().", e); |
| 1538 | } |
| 1539 | return false; |
| 1540 | } |
| 1541 | |
| 1542 | /** |
Yorke Lee | 2ae312e | 2014-09-12 17:58:48 -0700 | [diff] [blame] | 1543 | * Returns one of the following constants that represents the current state of Telecom: |
| 1544 | * |
| 1545 | * {@link TelephonyManager#CALL_STATE_RINGING} |
| 1546 | * {@link TelephonyManager#CALL_STATE_OFFHOOK} |
| 1547 | * {@link TelephonyManager#CALL_STATE_IDLE} |
Yorke Lee | 7c72c2d | 2014-10-28 14:12:02 -0700 | [diff] [blame] | 1548 | * |
| 1549 | * Note that this API does not require the |
| 1550 | * {@link android.Manifest.permission#READ_PHONE_STATE} permission. This is intentional, to |
| 1551 | * preserve the behavior of {@link TelephonyManager#getCallState()}, which also did not require |
| 1552 | * the permission. |
Tyler Gunn | 24e1833 | 2017-02-10 09:42:49 -0800 | [diff] [blame] | 1553 | * |
| 1554 | * Takes into consideration both managed and self-managed calls. |
| 1555 | * |
Yorke Lee | 2ae312e | 2014-09-12 17:58:48 -0700 | [diff] [blame] | 1556 | * @hide |
| 1557 | */ |
| 1558 | @SystemApi |
Chen Xu | 7631ff7 | 2019-09-26 16:11:59 -0700 | [diff] [blame] | 1559 | public @CallState int getCallState() { |
Yorke Lee | 2ae312e | 2014-09-12 17:58:48 -0700 | [diff] [blame] | 1560 | try { |
| 1561 | if (isServiceConnected()) { |
| 1562 | return getTelecomService().getCallState(); |
| 1563 | } |
| 1564 | } catch (RemoteException e) { |
| 1565 | Log.d(TAG, "RemoteException calling getCallState().", e); |
| 1566 | } |
| 1567 | return TelephonyManager.CALL_STATE_IDLE; |
| 1568 | } |
| 1569 | |
| 1570 | /** |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1571 | * Returns whether there currently exists is a ringing incoming-call. |
| 1572 | * |
Tyler Gunn | 24e1833 | 2017-02-10 09:42:49 -0800 | [diff] [blame] | 1573 | * @return {@code true} if there is a managed or self-managed ringing call. |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1574 | * @hide |
| 1575 | */ |
| 1576 | @SystemApi |
Jeff Sharkey | bfc4fcd | 2017-06-05 17:38:17 -0600 | [diff] [blame] | 1577 | @RequiresPermission(anyOf = { |
Tyler Gunn | 5567d74 | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 1578 | READ_PRIVILEGED_PHONE_STATE, |
Jeff Sharkey | bfc4fcd | 2017-06-05 17:38:17 -0600 | [diff] [blame] | 1579 | android.Manifest.permission.READ_PHONE_STATE |
| 1580 | }) |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1581 | public boolean isRinging() { |
| 1582 | try { |
| 1583 | if (isServiceConnected()) { |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 1584 | return getTelecomService().isRinging(mContext.getOpPackageName()); |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1585 | } |
| 1586 | } catch (RemoteException e) { |
| 1587 | Log.e(TAG, "RemoteException attempting to get ringing state of phone app.", e); |
| 1588 | } |
| 1589 | return false; |
| 1590 | } |
| 1591 | |
| 1592 | /** |
Tyler Gunn | e1aa26c | 2018-05-02 13:23:48 -0700 | [diff] [blame] | 1593 | * Ends the foreground call on the device. |
| 1594 | * <p> |
| 1595 | * If there is a ringing call, calling this method rejects the ringing call. Otherwise the |
| 1596 | * foreground call is ended. |
| 1597 | * <p> |
| 1598 | * Requires permission {@link android.Manifest.permission#ANSWER_PHONE_CALLS}. |
Tyler Gunn | f18ee4c | 2019-05-14 11:08:06 -0700 | [diff] [blame] | 1599 | * <p> |
| 1600 | * Note: this method CANNOT be used to end ongoing emergency calls and will return {@code false} |
| 1601 | * if an attempt is made to end an emergency call. |
Tyler Gunn | e1aa26c | 2018-05-02 13:23:48 -0700 | [diff] [blame] | 1602 | * |
| 1603 | * @return {@code true} if there is a call which will be rejected or terminated, {@code false} |
| 1604 | * otherwise. |
Tyler Gunn | 9bd8db4 | 2019-01-31 10:54:03 -0800 | [diff] [blame] | 1605 | * @deprecated Companion apps for wearable devices should use the {@link InCallService} API |
| 1606 | * instead. Apps performing call screening should use the {@link CallScreeningService} API |
| 1607 | * instead. |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1608 | */ |
Tyler Gunn | e1aa26c | 2018-05-02 13:23:48 -0700 | [diff] [blame] | 1609 | @RequiresPermission(Manifest.permission.ANSWER_PHONE_CALLS) |
Tyler Gunn | 9bd8db4 | 2019-01-31 10:54:03 -0800 | [diff] [blame] | 1610 | @Deprecated |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1611 | public boolean endCall() { |
| 1612 | try { |
| 1613 | if (isServiceConnected()) { |
Tyler Gunn | c865881 | 2018-02-07 16:08:27 -0800 | [diff] [blame] | 1614 | return getTelecomService().endCall(mContext.getPackageName()); |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1615 | } |
| 1616 | } catch (RemoteException e) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1617 | Log.e(TAG, "Error calling ITelecomService#endCall", e); |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1618 | } |
| 1619 | return false; |
| 1620 | } |
| 1621 | |
| 1622 | /** |
| 1623 | * If there is a ringing incoming call, this method accepts the call on behalf of the user. |
Eugene Susla | cae3d3e | 2017-01-31 11:08:11 -0800 | [diff] [blame] | 1624 | * |
Tyler Gunn | 6676bb5 | 2015-10-23 14:39:49 -0700 | [diff] [blame] | 1625 | * If the incoming call is a video call, the call will be answered with the same video state as |
| 1626 | * the incoming call requests. This means, for example, that an incoming call requesting |
| 1627 | * {@link VideoProfile#STATE_BIDIRECTIONAL} will be answered, accepting that state. |
Eugene Susla | cae3d3e | 2017-01-31 11:08:11 -0800 | [diff] [blame] | 1628 | * |
| 1629 | * Requires permission: {@link android.Manifest.permission#MODIFY_PHONE_STATE} or |
| 1630 | * {@link android.Manifest.permission#ANSWER_PHONE_CALLS} |
Tyler Gunn | 9bd8db4 | 2019-01-31 10:54:03 -0800 | [diff] [blame] | 1631 | * |
| 1632 | * @deprecated Companion apps for wearable devices should use the {@link InCallService} API |
| 1633 | * instead. |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1634 | */ |
Eugene Susla | cae3d3e | 2017-01-31 11:08:11 -0800 | [diff] [blame] | 1635 | //TODO: L-release - need to convert all invocation of ITelecmmService#answerRingingCall to use |
| 1636 | // this method (clockwork & gearhead). |
| 1637 | @RequiresPermission(anyOf = |
| 1638 | {Manifest.permission.ANSWER_PHONE_CALLS, Manifest.permission.MODIFY_PHONE_STATE}) |
Tyler Gunn | 9bd8db4 | 2019-01-31 10:54:03 -0800 | [diff] [blame] | 1639 | @Deprecated |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1640 | public void acceptRingingCall() { |
| 1641 | try { |
| 1642 | if (isServiceConnected()) { |
Eugene Susla | cae3d3e | 2017-01-31 11:08:11 -0800 | [diff] [blame] | 1643 | getTelecomService().acceptRingingCall(mContext.getPackageName()); |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1644 | } |
| 1645 | } catch (RemoteException e) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1646 | Log.e(TAG, "Error calling ITelecomService#acceptRingingCall", e); |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1647 | } |
| 1648 | } |
| 1649 | |
| 1650 | /** |
Tyler Gunn | 6676bb5 | 2015-10-23 14:39:49 -0700 | [diff] [blame] | 1651 | * If there is a ringing incoming call, this method accepts the call on behalf of the user, |
| 1652 | * with the specified video state. |
| 1653 | * |
Eugene Susla | cae3d3e | 2017-01-31 11:08:11 -0800 | [diff] [blame] | 1654 | * Requires permission: {@link android.Manifest.permission#MODIFY_PHONE_STATE} or |
| 1655 | * {@link android.Manifest.permission#ANSWER_PHONE_CALLS} |
| 1656 | * |
Tyler Gunn | 6676bb5 | 2015-10-23 14:39:49 -0700 | [diff] [blame] | 1657 | * @param videoState The desired video state to answer the call with. |
Tyler Gunn | 9bd8db4 | 2019-01-31 10:54:03 -0800 | [diff] [blame] | 1658 | * @deprecated Companion apps for wearable devices should use the {@link InCallService} API |
| 1659 | * instead. |
Tyler Gunn | 6676bb5 | 2015-10-23 14:39:49 -0700 | [diff] [blame] | 1660 | */ |
Eugene Susla | cae3d3e | 2017-01-31 11:08:11 -0800 | [diff] [blame] | 1661 | @RequiresPermission(anyOf = |
| 1662 | {Manifest.permission.ANSWER_PHONE_CALLS, Manifest.permission.MODIFY_PHONE_STATE}) |
Tyler Gunn | 9bd8db4 | 2019-01-31 10:54:03 -0800 | [diff] [blame] | 1663 | @Deprecated |
Tyler Gunn | 6676bb5 | 2015-10-23 14:39:49 -0700 | [diff] [blame] | 1664 | public void acceptRingingCall(int videoState) { |
| 1665 | try { |
| 1666 | if (isServiceConnected()) { |
Eugene Susla | cae3d3e | 2017-01-31 11:08:11 -0800 | [diff] [blame] | 1667 | getTelecomService().acceptRingingCallWithVideoState( |
| 1668 | mContext.getPackageName(), videoState); |
Tyler Gunn | 6676bb5 | 2015-10-23 14:39:49 -0700 | [diff] [blame] | 1669 | } |
| 1670 | } catch (RemoteException e) { |
| 1671 | Log.e(TAG, "Error calling ITelecomService#acceptRingingCallWithVideoState", e); |
| 1672 | } |
| 1673 | } |
| 1674 | |
| 1675 | /** |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1676 | * Silences the ringer if a ringing call exists. |
Tyler Gunn | 556d240 | 2019-04-10 08:59:43 -0700 | [diff] [blame] | 1677 | * <p> |
| 1678 | * This method can only be relied upon to stop the ringtone for a call if the ringtone has |
| 1679 | * already started playing. It is intended to handle use-cases such as silencing a ringing call |
| 1680 | * when the user presses the volume button during ringing. |
| 1681 | * <p> |
| 1682 | * If this method is called prior to when the ringtone begins playing, the ringtone will not be |
| 1683 | * silenced. As such it is not intended as a means to avoid playing of a ringtone. |
| 1684 | * <p> |
| 1685 | * A dialer app which wants to have more control over ringtone playing should declare |
| 1686 | * {@link TelecomManager#METADATA_IN_CALL_SERVICE_RINGING} in the manifest entry for their |
| 1687 | * {@link InCallService} implementation to indicate that the app wants to be responsible for |
| 1688 | * playing the ringtone for all incoming calls. |
| 1689 | * <p> |
| 1690 | * Requires permission: {@link android.Manifest.permission#MODIFY_PHONE_STATE} or that the |
| 1691 | * app fills the dialer role (see {@link #getDefaultDialerPackage()}). |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1692 | */ |
Yorke Lee | c61d136 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 1693 | @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1694 | public void silenceRinger() { |
| 1695 | try { |
| 1696 | if (isServiceConnected()) { |
Yorke Lee | f1a349b | 2015-04-29 16:16:50 -0700 | [diff] [blame] | 1697 | getTelecomService().silenceRinger(mContext.getOpPackageName()); |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1698 | } |
| 1699 | } catch (RemoteException e) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1700 | Log.e(TAG, "Error calling ITelecomService#silenceRinger", e); |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1701 | } |
| 1702 | } |
| 1703 | |
Sailesh Nepal | 001bbbb | 2014-07-15 14:40:39 -0700 | [diff] [blame] | 1704 | /** |
| 1705 | * Returns whether TTY is supported on this device. |
Sailesh Nepal | 001bbbb | 2014-07-15 14:40:39 -0700 | [diff] [blame] | 1706 | */ |
Jeff Sharkey | bfc4fcd | 2017-06-05 17:38:17 -0600 | [diff] [blame] | 1707 | @RequiresPermission(anyOf = { |
Tyler Gunn | 5567d74 | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 1708 | READ_PRIVILEGED_PHONE_STATE, |
Jeff Sharkey | bfc4fcd | 2017-06-05 17:38:17 -0600 | [diff] [blame] | 1709 | android.Manifest.permission.READ_PHONE_STATE |
| 1710 | }) |
Sailesh Nepal | 001bbbb | 2014-07-15 14:40:39 -0700 | [diff] [blame] | 1711 | public boolean isTtySupported() { |
| 1712 | try { |
| 1713 | if (isServiceConnected()) { |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 1714 | return getTelecomService().isTtySupported(mContext.getOpPackageName()); |
Sailesh Nepal | 001bbbb | 2014-07-15 14:40:39 -0700 | [diff] [blame] | 1715 | } |
| 1716 | } catch (RemoteException e) { |
| 1717 | Log.e(TAG, "RemoteException attempting to get TTY supported state.", e); |
| 1718 | } |
| 1719 | return false; |
| 1720 | } |
| 1721 | |
| 1722 | /** |
| 1723 | * Returns the current TTY mode of the device. For TTY to be on the user must enable it in |
Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 1724 | * settings and have a wired headset plugged in. |
| 1725 | * Valid modes are: |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1726 | * - {@link TelecomManager#TTY_MODE_OFF} |
| 1727 | * - {@link TelecomManager#TTY_MODE_FULL} |
| 1728 | * - {@link TelecomManager#TTY_MODE_HCO} |
| 1729 | * - {@link TelecomManager#TTY_MODE_VCO} |
Sailesh Nepal | 001bbbb | 2014-07-15 14:40:39 -0700 | [diff] [blame] | 1730 | * @hide |
| 1731 | */ |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 1732 | @SystemApi |
Tyler Gunn | 6c14a699 | 2019-02-04 15:12:06 -0800 | [diff] [blame] | 1733 | @TestApi |
Tyler Gunn | 5567d74 | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 1734 | @RequiresPermission(READ_PRIVILEGED_PHONE_STATE) |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 1735 | public @TtyMode int getCurrentTtyMode() { |
Sailesh Nepal | 001bbbb | 2014-07-15 14:40:39 -0700 | [diff] [blame] | 1736 | try { |
| 1737 | if (isServiceConnected()) { |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 1738 | return getTelecomService().getCurrentTtyMode(mContext.getOpPackageName()); |
Sailesh Nepal | 001bbbb | 2014-07-15 14:40:39 -0700 | [diff] [blame] | 1739 | } |
| 1740 | } catch (RemoteException e) { |
| 1741 | Log.e(TAG, "RemoteException attempting to get the current TTY mode.", e); |
| 1742 | } |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 1743 | return TTY_MODE_OFF; |
Sailesh Nepal | 001bbbb | 2014-07-15 14:40:39 -0700 | [diff] [blame] | 1744 | } |
| 1745 | |
Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 1746 | /** |
| 1747 | * Registers a new incoming call. A {@link ConnectionService} should invoke this method when it |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 1748 | * has an incoming call. For managed {@link ConnectionService}s, the specified |
| 1749 | * {@link PhoneAccountHandle} must have been registered with {@link #registerPhoneAccount} and |
| 1750 | * the user must have enabled the corresponding {@link PhoneAccount}. This can be checked using |
| 1751 | * {@link #getPhoneAccount}. Self-managed {@link ConnectionService}s must have |
| 1752 | * {@link android.Manifest.permission#MANAGE_OWN_CALLS} to add a new incoming call. |
| 1753 | * <p> |
Tyler Gunn | 3765356 | 2017-03-13 18:15:15 -0700 | [diff] [blame] | 1754 | * The incoming call you are adding is assumed to have a video state of |
| 1755 | * {@link VideoProfile#STATE_AUDIO_ONLY}, unless the extra value |
| 1756 | * {@link #EXTRA_INCOMING_VIDEO_STATE} is specified. |
| 1757 | * <p> |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 1758 | * Once invoked, this method will cause the system to bind to the {@link ConnectionService} |
| 1759 | * associated with the {@link PhoneAccountHandle} and request additional information about the |
| 1760 | * call (See {@link ConnectionService#onCreateIncomingConnection}) before starting the incoming |
Brad Ebinger | ec0d334 | 2016-01-29 15:40:43 -0800 | [diff] [blame] | 1761 | * call UI. |
| 1762 | * <p> |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 1763 | * For a managed {@link ConnectionService}, a {@link SecurityException} will be thrown if either |
| 1764 | * the {@link PhoneAccountHandle} does not correspond to a registered {@link PhoneAccount} or |
| 1765 | * the associated {@link PhoneAccount} is not currently enabled by the user. |
| 1766 | * <p> |
| 1767 | * For a self-managed {@link ConnectionService}, a {@link SecurityException} will be thrown if |
| 1768 | * the {@link PhoneAccount} has {@link PhoneAccount#CAPABILITY_SELF_MANAGED} and the calling app |
| 1769 | * does not have {@link android.Manifest.permission#MANAGE_OWN_CALLS}. |
| 1770 | * |
Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 1771 | * @param phoneAccount A {@link PhoneAccountHandle} registered with |
| 1772 | * {@link #registerPhoneAccount}. |
| 1773 | * @param extras A bundle that will be passed through to |
| 1774 | * {@link ConnectionService#onCreateIncomingConnection}. |
| 1775 | */ |
| 1776 | public void addNewIncomingCall(PhoneAccountHandle phoneAccount, Bundle extras) { |
| 1777 | try { |
| 1778 | if (isServiceConnected()) { |
Sanket Padawe | f6a9e5b | 2018-01-05 14:26:16 -0800 | [diff] [blame] | 1779 | if (extras != null && extras.getBoolean(EXTRA_IS_HANDOVER) && |
| 1780 | mContext.getApplicationContext().getApplicationInfo().targetSdkVersion > |
| 1781 | Build.VERSION_CODES.O_MR1) { |
| 1782 | Log.e("TAG", "addNewIncomingCall failed. Use public api " + |
| 1783 | "acceptHandover for API > O-MR1"); |
Tyler Gunn | 9ae6db8 | 2019-02-13 13:51:18 -0800 | [diff] [blame] | 1784 | return; |
Sanket Padawe | f6a9e5b | 2018-01-05 14:26:16 -0800 | [diff] [blame] | 1785 | } |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1786 | getTelecomService().addNewIncomingCall( |
Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 1787 | phoneAccount, extras == null ? new Bundle() : extras); |
| 1788 | } |
| 1789 | } catch (RemoteException e) { |
| 1790 | Log.e(TAG, "RemoteException adding a new incoming call: " + phoneAccount, e); |
| 1791 | } |
| 1792 | } |
| 1793 | |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1794 | /** |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 1795 | * Registers a new unknown call with Telecom. This can only be called by the system Telephony |
| 1796 | * service. This is invoked when Telephony detects a new unknown connection that was neither |
| 1797 | * a new incoming call, nor an user-initiated outgoing call. |
| 1798 | * |
| 1799 | * @param phoneAccount A {@link PhoneAccountHandle} registered with |
| 1800 | * {@link #registerPhoneAccount}. |
| 1801 | * @param extras A bundle that will be passed through to |
| 1802 | * {@link ConnectionService#onCreateIncomingConnection}. |
| 1803 | * @hide |
| 1804 | */ |
| 1805 | @SystemApi |
| 1806 | public void addNewUnknownCall(PhoneAccountHandle phoneAccount, Bundle extras) { |
| 1807 | try { |
| 1808 | if (isServiceConnected()) { |
| 1809 | getTelecomService().addNewUnknownCall( |
| 1810 | phoneAccount, extras == null ? new Bundle() : extras); |
| 1811 | } |
| 1812 | } catch (RemoteException e) { |
| 1813 | Log.e(TAG, "RemoteException adding a new unknown call: " + phoneAccount, e); |
| 1814 | } |
| 1815 | } |
| 1816 | |
| 1817 | /** |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1818 | * Processes the specified dial string as an MMI code. |
| 1819 | * MMI codes are any sequence of characters entered into the dialpad that contain a "*" or "#". |
| 1820 | * Some of these sequences launch special behavior through handled by Telephony. |
Nancy Chen | 95e8a67 | 2014-10-16 18:38:21 -0700 | [diff] [blame] | 1821 | * This method uses the default subscription. |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1822 | * <p> |
| 1823 | * Requires that the method-caller be set as the system dialer app. |
| 1824 | * </p> |
| 1825 | * |
Yorke Lee | c61d136 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 1826 | * Requires permission: {@link android.Manifest.permission#MODIFY_PHONE_STATE} |
| 1827 | * |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1828 | * @param dialString The digits to dial. |
| 1829 | * @return True if the digits were processed as an MMI code, false otherwise. |
| 1830 | */ |
Yorke Lee | c61d136 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 1831 | @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1832 | public boolean handleMmi(String dialString) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1833 | ITelecomService service = getTelecomService(); |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1834 | if (service != null) { |
| 1835 | try { |
Yorke Lee | f1a349b | 2015-04-29 16:16:50 -0700 | [diff] [blame] | 1836 | return service.handlePinMmi(dialString, mContext.getOpPackageName()); |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1837 | } catch (RemoteException e) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1838 | Log.e(TAG, "Error calling ITelecomService#handlePinMmi", e); |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1839 | } |
| 1840 | } |
| 1841 | return false; |
| 1842 | } |
| 1843 | |
| 1844 | /** |
Nancy Chen | 95e8a67 | 2014-10-16 18:38:21 -0700 | [diff] [blame] | 1845 | * Processes the specified dial string as an MMI code. |
| 1846 | * MMI codes are any sequence of characters entered into the dialpad that contain a "*" or "#". |
| 1847 | * Some of these sequences launch special behavior through handled by Telephony. |
| 1848 | * <p> |
| 1849 | * Requires that the method-caller be set as the system dialer app. |
| 1850 | * </p> |
| 1851 | * |
Yorke Lee | c61d136 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 1852 | * Requires permission: {@link android.Manifest.permission#MODIFY_PHONE_STATE} |
| 1853 | * |
Nancy Chen | 95e8a67 | 2014-10-16 18:38:21 -0700 | [diff] [blame] | 1854 | * @param accountHandle The handle for the account the MMI code should apply to. |
| 1855 | * @param dialString The digits to dial. |
| 1856 | * @return True if the digits were processed as an MMI code, false otherwise. |
Nancy Chen | 95e8a67 | 2014-10-16 18:38:21 -0700 | [diff] [blame] | 1857 | */ |
Yorke Lee | c61d136 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 1858 | @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) |
Yorke Lee | 0604427 | 2015-04-14 15:16:59 -0700 | [diff] [blame] | 1859 | public boolean handleMmi(String dialString, PhoneAccountHandle accountHandle) { |
Nancy Chen | 95e8a67 | 2014-10-16 18:38:21 -0700 | [diff] [blame] | 1860 | ITelecomService service = getTelecomService(); |
| 1861 | if (service != null) { |
| 1862 | try { |
Yorke Lee | f1a349b | 2015-04-29 16:16:50 -0700 | [diff] [blame] | 1863 | return service.handlePinMmiForPhoneAccount(accountHandle, dialString, |
| 1864 | mContext.getOpPackageName()); |
Nancy Chen | 95e8a67 | 2014-10-16 18:38:21 -0700 | [diff] [blame] | 1865 | } catch (RemoteException e) { |
| 1866 | Log.e(TAG, "Error calling ITelecomService#handlePinMmi", e); |
| 1867 | } |
| 1868 | } |
| 1869 | return false; |
| 1870 | } |
| 1871 | |
| 1872 | /** |
Yorke Lee | c61d136 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 1873 | * Requires permission: {@link android.Manifest.permission#MODIFY_PHONE_STATE} |
| 1874 | * |
Nancy Chen | b2299c1 | 2014-10-29 18:22:11 -0700 | [diff] [blame] | 1875 | * @param accountHandle The handle for the account to derive an adn query URI for or |
| 1876 | * {@code null} to return a URI which will use the default account. |
| 1877 | * @return The URI (with the content:// scheme) specific to the specified {@link PhoneAccount} |
| 1878 | * for the the content retrieve. |
| 1879 | */ |
Yorke Lee | c61d136 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 1880 | @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) |
Nancy Chen | b2299c1 | 2014-10-29 18:22:11 -0700 | [diff] [blame] | 1881 | public Uri getAdnUriForPhoneAccount(PhoneAccountHandle accountHandle) { |
| 1882 | ITelecomService service = getTelecomService(); |
| 1883 | if (service != null && accountHandle != null) { |
| 1884 | try { |
Yorke Lee | f1a349b | 2015-04-29 16:16:50 -0700 | [diff] [blame] | 1885 | return service.getAdnUriForPhoneAccount(accountHandle, mContext.getOpPackageName()); |
Nancy Chen | b2299c1 | 2014-10-29 18:22:11 -0700 | [diff] [blame] | 1886 | } catch (RemoteException e) { |
| 1887 | Log.e(TAG, "Error calling ITelecomService#getAdnUriForPhoneAccount", e); |
| 1888 | } |
| 1889 | } |
| 1890 | return Uri.parse("content://icc/adn"); |
| 1891 | } |
| 1892 | |
| 1893 | /** |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1894 | * Removes the missed-call notification if one is present. |
| 1895 | * <p> |
| 1896 | * Requires that the method-caller be set as the system dialer app. |
| 1897 | * </p> |
Yorke Lee | c61d136 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 1898 | * |
| 1899 | * Requires permission: {@link android.Manifest.permission#MODIFY_PHONE_STATE} |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1900 | */ |
Yorke Lee | c61d136 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 1901 | @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1902 | public void cancelMissedCallsNotification() { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1903 | ITelecomService service = getTelecomService(); |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1904 | if (service != null) { |
| 1905 | try { |
Yorke Lee | f1a349b | 2015-04-29 16:16:50 -0700 | [diff] [blame] | 1906 | service.cancelMissedCallsNotification(mContext.getOpPackageName()); |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1907 | } catch (RemoteException e) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1908 | Log.e(TAG, "Error calling ITelecomService#cancelMissedCallsNotification", e); |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1909 | } |
| 1910 | } |
| 1911 | } |
| 1912 | |
| 1913 | /** |
| 1914 | * Brings the in-call screen to the foreground if there is an ongoing call. If there is |
| 1915 | * currently no ongoing call, then this method does nothing. |
| 1916 | * <p> |
| 1917 | * Requires that the method-caller be set as the system dialer app or have the |
| 1918 | * {@link android.Manifest.permission#READ_PHONE_STATE} permission. |
| 1919 | * </p> |
| 1920 | * |
| 1921 | * @param showDialpad Brings up the in-call dialpad as part of showing the in-call screen. |
| 1922 | */ |
Yorke Lee | c61d136 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 1923 | @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1924 | public void showInCallScreen(boolean showDialpad) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1925 | ITelecomService service = getTelecomService(); |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1926 | if (service != null) { |
| 1927 | try { |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 1928 | service.showInCallScreen(showDialpad, mContext.getOpPackageName()); |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1929 | } catch (RemoteException e) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1930 | Log.e(TAG, "Error calling ITelecomService#showCallScreen", e); |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1931 | } |
| 1932 | } |
| 1933 | } |
| 1934 | |
Yorke Lee | 3e56ba1 | 2015-04-23 12:32:36 -0700 | [diff] [blame] | 1935 | /** |
| 1936 | * Places a new outgoing call to the provided address using the system telecom service with |
| 1937 | * the specified extras. |
| 1938 | * |
| 1939 | * This method is equivalent to placing an outgoing call using {@link Intent#ACTION_CALL}, |
| 1940 | * except that the outgoing call will always be sent via the system telecom service. If |
| 1941 | * method-caller is either the user selected default dialer app or preloaded system dialer |
| 1942 | * app, then emergency calls will also be allowed. |
| 1943 | * |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 1944 | * Placing a call via a managed {@link ConnectionService} requires permission: |
| 1945 | * {@link android.Manifest.permission#CALL_PHONE} |
Yorke Lee | 3e56ba1 | 2015-04-23 12:32:36 -0700 | [diff] [blame] | 1946 | * |
| 1947 | * Usage example: |
| 1948 | * <pre> |
| 1949 | * Uri uri = Uri.fromParts("tel", "12345", null); |
| 1950 | * Bundle extras = new Bundle(); |
| 1951 | * extras.putBoolean(TelecomManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, true); |
| 1952 | * telecomManager.placeCall(uri, extras); |
| 1953 | * </pre> |
| 1954 | * |
Santos Cordon | 7a060d5 | 2015-06-19 14:52:04 -0700 | [diff] [blame] | 1955 | * The following keys are supported in the supplied extras. |
| 1956 | * <ul> |
| 1957 | * <li>{@link #EXTRA_OUTGOING_CALL_EXTRAS}</li> |
| 1958 | * <li>{@link #EXTRA_PHONE_ACCOUNT_HANDLE}</li> |
| 1959 | * <li>{@link #EXTRA_START_CALL_WITH_SPEAKERPHONE}</li> |
| 1960 | * <li>{@link #EXTRA_START_CALL_WITH_VIDEO_STATE}</li> |
| 1961 | * </ul> |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 1962 | * <p> |
| 1963 | * An app which implements the self-managed {@link ConnectionService} API uses |
| 1964 | * {@link #placeCall(Uri, Bundle)} to inform Telecom of a new outgoing call. A self-managed |
| 1965 | * {@link ConnectionService} must include {@link #EXTRA_PHONE_ACCOUNT_HANDLE} to specify its |
| 1966 | * associated {@link android.telecom.PhoneAccountHandle}. |
| 1967 | * |
| 1968 | * Self-managed {@link ConnectionService}s require permission |
| 1969 | * {@link android.Manifest.permission#MANAGE_OWN_CALLS}. |
Santos Cordon | 7a060d5 | 2015-06-19 14:52:04 -0700 | [diff] [blame] | 1970 | * |
Brad Ebinger | 3636d74 | 2019-05-21 15:28:19 -0700 | [diff] [blame] | 1971 | * <p class="note"><strong>Note:</strong> If this method is used to place an emergency call, it |
| 1972 | * is not guaranteed that the call will be placed on the {@link PhoneAccount} provided in |
| 1973 | * the {@link #EXTRA_PHONE_ACCOUNT_HANDLE} extra (if specified) and may be placed on another |
| 1974 | * {@link PhoneAccount} with the {@link PhoneAccount#CAPABILITY_PLACE_EMERGENCY_CALLS} |
| 1975 | * capability, depending on external factors, such as network conditions and Modem/SIM status. |
| 1976 | * </p> |
| 1977 | * |
Yorke Lee | 3e56ba1 | 2015-04-23 12:32:36 -0700 | [diff] [blame] | 1978 | * @param address The address to make the call to. |
| 1979 | * @param extras Bundle of extras to use with the call. |
| 1980 | */ |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 1981 | @RequiresPermission(anyOf = {android.Manifest.permission.CALL_PHONE, |
| 1982 | android.Manifest.permission.MANAGE_OWN_CALLS}) |
Yorke Lee | 3e56ba1 | 2015-04-23 12:32:36 -0700 | [diff] [blame] | 1983 | public void placeCall(Uri address, Bundle extras) { |
| 1984 | ITelecomService service = getTelecomService(); |
| 1985 | if (service != null) { |
Yorke Lee | a5d5c1d | 2015-05-05 16:25:55 -0700 | [diff] [blame] | 1986 | if (address == null) { |
| 1987 | Log.w(TAG, "Cannot place call to empty address."); |
| 1988 | } |
Yorke Lee | 3e56ba1 | 2015-04-23 12:32:36 -0700 | [diff] [blame] | 1989 | try { |
Yorke Lee | a5d5c1d | 2015-05-05 16:25:55 -0700 | [diff] [blame] | 1990 | service.placeCall(address, extras == null ? new Bundle() : extras, |
| 1991 | mContext.getOpPackageName()); |
Yorke Lee | 3e56ba1 | 2015-04-23 12:32:36 -0700 | [diff] [blame] | 1992 | } catch (RemoteException e) { |
| 1993 | Log.e(TAG, "Error calling ITelecomService#placeCall", e); |
| 1994 | } |
| 1995 | } |
| 1996 | } |
| 1997 | |
Santos Cordon | 91371dc | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 1998 | /** |
| 1999 | * Enables and disables specified phone account. |
| 2000 | * |
| 2001 | * @param handle Handle to the phone account. |
| 2002 | * @param isEnabled Enable state of the phone account. |
| 2003 | * @hide |
| 2004 | */ |
| 2005 | @SystemApi |
Jeff Sharkey | bfc4fcd | 2017-06-05 17:38:17 -0600 | [diff] [blame] | 2006 | @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) |
Santos Cordon | 91371dc | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 2007 | public void enablePhoneAccount(PhoneAccountHandle handle, boolean isEnabled) { |
| 2008 | ITelecomService service = getTelecomService(); |
| 2009 | if (service != null) { |
| 2010 | try { |
| 2011 | service.enablePhoneAccount(handle, isEnabled); |
| 2012 | } catch (RemoteException e) { |
| 2013 | Log.e(TAG, "Error enablePhoneAbbount", e); |
| 2014 | } |
| 2015 | } |
| 2016 | } |
| 2017 | |
Hall Liu | 0464b9b | 2016-01-12 15:32:58 -0800 | [diff] [blame] | 2018 | /** |
| 2019 | * Dumps telecom analytics for uploading. |
| 2020 | * |
| 2021 | * @return |
| 2022 | * @hide |
| 2023 | */ |
| 2024 | @SystemApi |
| 2025 | @RequiresPermission(Manifest.permission.DUMP) |
Hall Liu | 057def5 | 2016-05-05 17:17:07 -0700 | [diff] [blame] | 2026 | public TelecomAnalytics dumpAnalytics() { |
Hall Liu | 0464b9b | 2016-01-12 15:32:58 -0800 | [diff] [blame] | 2027 | ITelecomService service = getTelecomService(); |
Hall Liu | 057def5 | 2016-05-05 17:17:07 -0700 | [diff] [blame] | 2028 | TelecomAnalytics result = null; |
Hall Liu | 0464b9b | 2016-01-12 15:32:58 -0800 | [diff] [blame] | 2029 | if (service != null) { |
| 2030 | try { |
| 2031 | result = service.dumpCallAnalytics(); |
| 2032 | } catch (RemoteException e) { |
| 2033 | Log.e(TAG, "Error dumping call analytics", e); |
| 2034 | } |
| 2035 | } |
| 2036 | return result; |
| 2037 | } |
| 2038 | |
Abhijith Shastry | 1908cb84 | 2016-02-02 11:10:19 -0800 | [diff] [blame] | 2039 | /** |
Abhijith Shastry | a26fe99 | 2016-02-29 11:40:24 -0800 | [diff] [blame] | 2040 | * Creates the {@link Intent} which can be used with {@link Context#startActivity(Intent)} to |
| 2041 | * launch the activity to manage blocked numbers. |
Abhijith Shastry | ec30d2f | 2016-03-04 16:46:08 -0800 | [diff] [blame] | 2042 | * <p> The activity will display the UI to manage blocked numbers only if |
Abhijith Shastry | a26fe99 | 2016-02-29 11:40:24 -0800 | [diff] [blame] | 2043 | * {@link android.provider.BlockedNumberContract#canCurrentUserBlockNumbers(Context)} returns |
| 2044 | * {@code true} for the current user. |
| 2045 | */ |
| 2046 | public Intent createManageBlockedNumbersIntent() { |
| 2047 | ITelecomService service = getTelecomService(); |
| 2048 | Intent result = null; |
| 2049 | if (service != null) { |
| 2050 | try { |
| 2051 | result = service.createManageBlockedNumbersIntent(); |
| 2052 | } catch (RemoteException e) { |
| 2053 | Log.e(TAG, "Error calling ITelecomService#createManageBlockedNumbersIntent", e); |
| 2054 | } |
| 2055 | } |
| 2056 | return result; |
| 2057 | } |
| 2058 | |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 2059 | /** |
| 2060 | * Determines whether Telecom would permit an incoming call to be added via the |
| 2061 | * {@link #addNewIncomingCall(PhoneAccountHandle, Bundle)} API for the specified |
| 2062 | * {@link PhoneAccountHandle}. |
| 2063 | * <p> |
| 2064 | * A {@link ConnectionService} may not add a call for the specified {@link PhoneAccountHandle} |
| 2065 | * in the following situations: |
| 2066 | * <ul> |
| 2067 | * <li>{@link PhoneAccount} does not have property |
| 2068 | * {@link PhoneAccount#CAPABILITY_SELF_MANAGED} set (i.e. it is a managed |
| 2069 | * {@link ConnectionService}), and the active or held call limit has |
| 2070 | * been reached.</li> |
| 2071 | * <li>There is an ongoing emergency call.</li> |
| 2072 | * </ul> |
| 2073 | * |
| 2074 | * @param phoneAccountHandle The {@link PhoneAccountHandle} the call will be added for. |
| 2075 | * @return {@code true} if telecom will permit an incoming call to be added, {@code false} |
| 2076 | * otherwise. |
| 2077 | */ |
| 2078 | public boolean isIncomingCallPermitted(PhoneAccountHandle phoneAccountHandle) { |
Tyler Gunn | 44e0191 | 2017-01-31 10:49:05 -0800 | [diff] [blame] | 2079 | if (phoneAccountHandle == null) { |
| 2080 | return false; |
| 2081 | } |
| 2082 | |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 2083 | ITelecomService service = getTelecomService(); |
| 2084 | if (service != null) { |
| 2085 | try { |
| 2086 | return service.isIncomingCallPermitted(phoneAccountHandle); |
| 2087 | } catch (RemoteException e) { |
| 2088 | Log.e(TAG, "Error isIncomingCallPermitted", e); |
| 2089 | } |
| 2090 | } |
| 2091 | return false; |
| 2092 | } |
| 2093 | |
| 2094 | /** |
| 2095 | * Determines whether Telecom would permit an outgoing call to be placed via the |
| 2096 | * {@link #placeCall(Uri, Bundle)} API for the specified {@link PhoneAccountHandle}. |
| 2097 | * <p> |
| 2098 | * A {@link ConnectionService} may not place a call for the specified {@link PhoneAccountHandle} |
| 2099 | * in the following situations: |
| 2100 | * <ul> |
| 2101 | * <li>{@link PhoneAccount} does not have property |
| 2102 | * {@link PhoneAccount#CAPABILITY_SELF_MANAGED} set (i.e. it is a managed |
| 2103 | * {@link ConnectionService}), and the active, held or ringing call limit has |
| 2104 | * been reached.</li> |
| 2105 | * <li>{@link PhoneAccount} has property {@link PhoneAccount#CAPABILITY_SELF_MANAGED} set |
| 2106 | * (i.e. it is a self-managed {@link ConnectionService} and there is an ongoing call in |
| 2107 | * another {@link ConnectionService}.</li> |
| 2108 | * <li>There is an ongoing emergency call.</li> |
| 2109 | * </ul> |
| 2110 | * |
| 2111 | * @param phoneAccountHandle The {@link PhoneAccountHandle} the call will be added for. |
| 2112 | * @return {@code true} if telecom will permit an outgoing call to be placed, {@code false} |
| 2113 | * otherwise. |
| 2114 | */ |
| 2115 | public boolean isOutgoingCallPermitted(PhoneAccountHandle phoneAccountHandle) { |
| 2116 | ITelecomService service = getTelecomService(); |
| 2117 | if (service != null) { |
| 2118 | try { |
| 2119 | return service.isOutgoingCallPermitted(phoneAccountHandle); |
| 2120 | } catch (RemoteException e) { |
| 2121 | Log.e(TAG, "Error isOutgoingCallPermitted", e); |
| 2122 | } |
| 2123 | } |
| 2124 | return false; |
| 2125 | } |
| 2126 | |
Sanket Padawe | a8eddd4 | 2017-11-03 11:07:35 -0700 | [diff] [blame] | 2127 | /** |
Tyler Gunn | 9d12773 | 2018-03-02 15:45:51 -0800 | [diff] [blame] | 2128 | * Called by an app to indicate that it wishes to accept the handover of an ongoing call to a |
| 2129 | * {@link PhoneAccountHandle} it defines. |
| 2130 | * <p> |
| 2131 | * A call handover is the process where an ongoing call is transferred from one app (i.e. |
| 2132 | * {@link ConnectionService} to another app. The user could, for example, choose to continue a |
| 2133 | * mobile network call in a video calling app. The mobile network call via the Telephony stack |
| 2134 | * is referred to as the source of the handover, and the video calling app is referred to as the |
| 2135 | * destination. |
| 2136 | * <p> |
| 2137 | * When considering a handover scenario the <em>initiating</em> device is where a user initiated |
| 2138 | * the handover process (e.g. by calling {@link android.telecom.Call#handoverTo( |
| 2139 | * PhoneAccountHandle, int, Bundle)}, and the other device is considered the <em>receiving</em> |
| 2140 | * device. |
| 2141 | * <p> |
| 2142 | * For a full discussion of the handover process and the APIs involved, see |
| 2143 | * {@link android.telecom.Call#handoverTo(PhoneAccountHandle, int, Bundle)}. |
| 2144 | * <p> |
| 2145 | * This method is called from the <em>receiving</em> side of a handover to indicate a desire to |
| 2146 | * accept the handover of an ongoing call to another {@link ConnectionService} identified by |
Sanket Padawe | a8eddd4 | 2017-11-03 11:07:35 -0700 | [diff] [blame] | 2147 | * {@link PhoneAccountHandle} destAcct. For managed {@link ConnectionService}s, the specified |
| 2148 | * {@link PhoneAccountHandle} must have been registered with {@link #registerPhoneAccount} and |
| 2149 | * the user must have enabled the corresponding {@link PhoneAccount}. This can be checked using |
| 2150 | * {@link #getPhoneAccount}. Self-managed {@link ConnectionService}s must have |
| 2151 | * {@link android.Manifest.permission#MANAGE_OWN_CALLS} to handover a call to it. |
| 2152 | * <p> |
| 2153 | * Once invoked, this method will cause the system to bind to the {@link ConnectionService} |
| 2154 | * associated with the {@link PhoneAccountHandle} destAcct and call |
| 2155 | * (See {@link ConnectionService#onCreateIncomingHandoverConnection}). |
| 2156 | * <p> |
| 2157 | * For a managed {@link ConnectionService}, a {@link SecurityException} will be thrown if either |
| 2158 | * the {@link PhoneAccountHandle} destAcct does not correspond to a registered |
| 2159 | * {@link PhoneAccount} or the associated {@link PhoneAccount} is not currently enabled by the |
| 2160 | * user. |
| 2161 | * <p> |
| 2162 | * For a self-managed {@link ConnectionService}, a {@link SecurityException} will be thrown if |
| 2163 | * the calling app does not have {@link android.Manifest.permission#MANAGE_OWN_CALLS}. |
| 2164 | * |
| 2165 | * @param srcAddr The {@link android.net.Uri} of the ongoing call to handover to the caller’s |
| 2166 | * {@link ConnectionService}. |
| 2167 | * @param videoState Video state after the handover. |
| 2168 | * @param destAcct The {@link PhoneAccountHandle} registered to the calling package. |
| 2169 | */ |
Tyler Gunn | 9d12773 | 2018-03-02 15:45:51 -0800 | [diff] [blame] | 2170 | public void acceptHandover(Uri srcAddr, @VideoProfile.VideoState int videoState, |
| 2171 | PhoneAccountHandle destAcct) { |
Sanket Padawe | a8eddd4 | 2017-11-03 11:07:35 -0700 | [diff] [blame] | 2172 | try { |
| 2173 | if (isServiceConnected()) { |
| 2174 | getTelecomService().acceptHandover(srcAddr, videoState, destAcct); |
| 2175 | } |
| 2176 | } catch (RemoteException e) { |
| 2177 | Log.e(TAG, "RemoteException acceptHandover: " + e); |
| 2178 | } |
| 2179 | } |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 2180 | |
Tyler Gunn | 5bd9085 | 2018-09-21 09:37:07 -0700 | [diff] [blame] | 2181 | /** |
| 2182 | * Determines if there is an ongoing emergency call. This can be either an outgoing emergency |
| 2183 | * call, as identified by the dialed number, or because a call was identified by the network |
| 2184 | * as an emergency call. |
| 2185 | * @return {@code true} if there is an ongoing emergency call, {@code false} otherwise. |
| 2186 | * @hide |
| 2187 | */ |
| 2188 | @SystemApi |
Tyler Gunn | 6c14a699 | 2019-02-04 15:12:06 -0800 | [diff] [blame] | 2189 | @TestApi |
Tyler Gunn | 5bd9085 | 2018-09-21 09:37:07 -0700 | [diff] [blame] | 2190 | @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) |
| 2191 | public boolean isInEmergencyCall() { |
| 2192 | try { |
| 2193 | if (isServiceConnected()) { |
| 2194 | return getTelecomService().isInEmergencyCall(); |
| 2195 | } |
| 2196 | } catch (RemoteException e) { |
| 2197 | Log.e(TAG, "RemoteException isInEmergencyCall: " + e); |
| 2198 | return false; |
| 2199 | } |
| 2200 | return false; |
| 2201 | } |
| 2202 | |
Tyler Gunn | c37445c | 2018-09-28 16:16:20 -0700 | [diff] [blame] | 2203 | /** |
| 2204 | * Handles {@link Intent#ACTION_CALL} intents trampolined from UserCallActivity. |
| 2205 | * @param intent The {@link Intent#ACTION_CALL} intent to handle. |
Brad Ebinger | a9a33e1 | 2019-09-27 16:55:35 -0700 | [diff] [blame] | 2206 | * @param callingPackageProxy The original package that called this before it was trampolined. |
Tyler Gunn | c37445c | 2018-09-28 16:16:20 -0700 | [diff] [blame] | 2207 | * @hide |
| 2208 | */ |
Brad Ebinger | a9a33e1 | 2019-09-27 16:55:35 -0700 | [diff] [blame] | 2209 | public void handleCallIntent(Intent intent, String callingPackageProxy) { |
Tyler Gunn | c37445c | 2018-09-28 16:16:20 -0700 | [diff] [blame] | 2210 | try { |
| 2211 | if (isServiceConnected()) { |
Brad Ebinger | a9a33e1 | 2019-09-27 16:55:35 -0700 | [diff] [blame] | 2212 | getTelecomService().handleCallIntent(intent, callingPackageProxy); |
Tyler Gunn | c37445c | 2018-09-28 16:16:20 -0700 | [diff] [blame] | 2213 | } |
| 2214 | } catch (RemoteException e) { |
| 2215 | Log.e(TAG, "RemoteException handleCallIntent: " + e); |
| 2216 | } |
Tyler Gunn | c37445c | 2018-09-28 16:16:20 -0700 | [diff] [blame] | 2217 | } |
| 2218 | |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2219 | private ITelecomService getTelecomService() { |
Hall Liu | e1bc2ec | 2015-10-09 15:58:37 -0700 | [diff] [blame] | 2220 | if (mTelecomServiceOverride != null) { |
| 2221 | return mTelecomServiceOverride; |
| 2222 | } |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2223 | return ITelecomService.Stub.asInterface(ServiceManager.getService(Context.TELECOM_SERVICE)); |
Santos Cordon | 6c7a388 | 2014-06-25 15:30:08 -0700 | [diff] [blame] | 2224 | } |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 2225 | |
| 2226 | private boolean isServiceConnected() { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2227 | boolean isConnected = getTelecomService() != null; |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 2228 | if (!isConnected) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2229 | Log.w(TAG, "Telecom Service not found."); |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 2230 | } |
| 2231 | return isConnected; |
| 2232 | } |
Evan Charlton | 235c159 | 2014-09-05 15:41:23 +0000 | [diff] [blame] | 2233 | } |