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 | 00d737b | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 17 | import static android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE; |
Nan Wu | c51fd76 | 2022-08-01 21:08:23 +0000 | [diff] [blame] | 18 | import static android.content.Intent.LOCAL_FLAG_FROM_SYSTEM; |
Tyler Gunn | 00d737b | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 19 | |
Hall Liu | 0464b9b | 2016-01-12 15:32:58 -0800 | [diff] [blame] | 20 | import android.Manifest; |
Thomas Stuart | 9bfb243 | 2022-09-27 15:02:07 -0700 | [diff] [blame^] | 21 | import android.annotation.CallbackExecutor; |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 22 | import android.annotation.IntDef; |
Fan Zhang | 5431ef5 | 2019-10-14 13:43:46 -0700 | [diff] [blame] | 23 | import android.annotation.NonNull; |
Slava Shklyaev | e65e401 | 2019-03-04 16:02:34 +0000 | [diff] [blame] | 24 | import android.annotation.Nullable; |
Hui Wang | c47df7f | 2021-12-14 20:37:47 +0000 | [diff] [blame] | 25 | import android.annotation.RequiresFeature; |
Yorke Lee | c61d1366 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 26 | import android.annotation.RequiresPermission; |
Jeff Sharkey | 910e081 | 2017-04-21 16:29:27 -0600 | [diff] [blame] | 27 | import android.annotation.SuppressAutoDoc; |
Jeff Sharkey | bfc4fcd | 2017-06-05 17:38:17 -0600 | [diff] [blame] | 28 | import android.annotation.SuppressLint; |
Santos Cordon | 6c7a388 | 2014-06-25 15:30:08 -0700 | [diff] [blame] | 29 | import android.annotation.SystemApi; |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 30 | import android.annotation.SystemService; |
Brad Ebinger | a8366ae | 2021-03-23 21:01:51 +0000 | [diff] [blame] | 31 | import android.compat.annotation.ChangeId; |
| 32 | import android.compat.annotation.EnabledSince; |
Artur Satayev | 2ebb31c | 2020-01-08 12:24:36 +0000 | [diff] [blame] | 33 | import android.compat.annotation.UnsupportedAppUsage; |
Santos Cordon | 6c7a388 | 2014-06-25 15:30:08 -0700 | [diff] [blame] | 34 | import android.content.ComponentName; |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 35 | import android.content.Context; |
Yorke Lee | 3e56ba1 | 2015-04-23 12:32:36 -0700 | [diff] [blame] | 36 | import android.content.Intent; |
Hui Wang | c47df7f | 2021-12-14 20:37:47 +0000 | [diff] [blame] | 37 | import android.content.pm.PackageManager; |
Nancy Chen | b2299c1 | 2014-10-29 18:22:11 -0700 | [diff] [blame] | 38 | import android.net.Uri; |
Sanket Padawe | f6a9e5b | 2018-01-05 14:26:16 -0800 | [diff] [blame] | 39 | import android.os.Build; |
Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 40 | import android.os.Bundle; |
Kevin Jeon | 767cda3 | 2020-11-17 01:40:16 +0000 | [diff] [blame] | 41 | import android.os.IBinder; |
Thomas Stuart | 9bfb243 | 2022-09-27 15:02:07 -0700 | [diff] [blame^] | 42 | import android.os.OutcomeReceiver; |
Shuo Qian | 4d06526 | 2020-10-20 11:04:28 -0700 | [diff] [blame] | 43 | import android.os.Process; |
Santos Cordon | 6c7a388 | 2014-06-25 15:30:08 -0700 | [diff] [blame] | 44 | import android.os.RemoteException; |
| 45 | import android.os.ServiceManager; |
Tyler Gunn | 7e45b72 | 2018-12-04 12:56:45 -0800 | [diff] [blame] | 46 | import android.os.UserHandle; |
Chen Xu | c9d4ee1 | 2019-09-26 16:11:59 -0700 | [diff] [blame] | 47 | import android.telephony.Annotation.CallState; |
Brad Ebinger | e783331 | 2019-05-07 10:55:55 -0700 | [diff] [blame] | 48 | import android.telephony.SubscriptionManager; |
Yorke Lee | 2ae312e | 2014-09-12 17:58:48 -0700 | [diff] [blame] | 49 | import android.telephony.TelephonyManager; |
Anthony Lee | 6727926 | 2014-10-27 11:28:40 -0700 | [diff] [blame] | 50 | import android.text.TextUtils; |
Santos Cordon | 6c7a388 | 2014-06-25 15:30:08 -0700 | [diff] [blame] | 51 | import android.util.Log; |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 52 | |
Kevin Jeon | 767cda3 | 2020-11-17 01:40:16 +0000 | [diff] [blame] | 53 | import com.android.internal.annotations.GuardedBy; |
Thomas Stuart | 9bfb243 | 2022-09-27 15:02:07 -0700 | [diff] [blame^] | 54 | import com.android.internal.telecom.ClientTransactionalServiceRepository; |
| 55 | import com.android.internal.telecom.ClientTransactionalServiceWrapper; |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 56 | import com.android.internal.telecom.ITelecomService; |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 57 | |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 58 | import java.lang.annotation.Retention; |
| 59 | import java.lang.annotation.RetentionPolicy; |
Jay Shrauner | 7746a94 | 2014-08-26 12:15:15 -0700 | [diff] [blame] | 60 | import java.util.ArrayList; |
Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 61 | import java.util.Collections; |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 62 | import java.util.List; |
Philip P. Moltmann | 00cf9fb | 2020-01-06 16:41:38 -0800 | [diff] [blame] | 63 | import java.util.Objects; |
Tyler Gunn | 7e45b72 | 2018-12-04 12:56:45 -0800 | [diff] [blame] | 64 | import java.util.concurrent.Executor; |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 65 | |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 66 | /** |
Santos Cordon | d9e614f | 2014-10-28 13:10:36 -0700 | [diff] [blame] | 67 | * Provides access to information about active calls and registration/call-management functionality. |
Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 68 | * 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] | 69 | * <p> |
| 70 | * Apps do not instantiate this class directly; instead, they retrieve a reference to an instance |
| 71 | * through {@link Context#getSystemService Context.getSystemService(Context.TELECOM_SERVICE)}. |
| 72 | * <p> |
| 73 | * Note that access to some telecom information is permission-protected. Your app cannot access the |
| 74 | * protected information or gain access to protected functionality unless it has the appropriate |
| 75 | * permissions declared in its manifest file. Where permissions apply, they are noted in the method |
| 76 | * descriptions. |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 77 | */ |
Jeff Sharkey | 910e081 | 2017-04-21 16:29:27 -0600 | [diff] [blame] | 78 | @SuppressAutoDoc |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 79 | @SystemService(Context.TELECOM_SERVICE) |
Hui Wang | c47df7f | 2021-12-14 20:37:47 +0000 | [diff] [blame] | 80 | @RequiresFeature(PackageManager.FEATURE_TELECOM) |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 81 | public class TelecomManager { |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 82 | |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 83 | /** |
Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 84 | * 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] | 85 | * UI by notifying the Telecom system that an incoming call exists for a specific call service |
| 86 | * (see {@link android.telecom.ConnectionService}). Telecom reads the Intent extras to find |
| 87 | * and bind to the appropriate {@link android.telecom.ConnectionService} which Telecom will |
Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 88 | * ultimately use to control and get information about the call. |
| 89 | * <p> |
| 90 | * 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] | 91 | * {@link android.telecom.ConnectionService} that Telecom should bind to. Telecom will then |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 92 | * 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] | 93 | * |
| 94 | * @deprecated Use {@link #addNewIncomingCall} instead. |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 95 | */ |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 96 | public static final String ACTION_INCOMING_CALL = "android.telecom.action.INCOMING_CALL"; |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 97 | |
| 98 | /** |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 99 | * Similar to {@link #ACTION_INCOMING_CALL}, but is used only by Telephony to add a new |
| 100 | * sim-initiated MO call for carrier testing. |
Brad Ebinger | 23b1c6d | 2017-01-12 13:10:40 -0800 | [diff] [blame] | 101 | * @deprecated Use {@link #addNewUnknownCall} instead. |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 102 | * @hide |
| 103 | */ |
| 104 | public static final String ACTION_NEW_UNKNOWN_CALL = "android.telecom.action.NEW_UNKNOWN_CALL"; |
| 105 | |
| 106 | /** |
Santos Cordon | 895d4b8 | 2015-06-25 16:41:48 -0700 | [diff] [blame] | 107 | * An {@link android.content.Intent} action sent by the telecom framework to start a |
| 108 | * configuration dialog for a registered {@link PhoneAccount}. There is no default dialog |
| 109 | * and each app that registers a {@link PhoneAccount} should provide one if desired. |
| 110 | * <p> |
| 111 | * A user can access the list of enabled {@link android.telecom.PhoneAccount}s through the Phone |
| 112 | * app's settings menu. For each entry, the settings app will add a click action. When |
| 113 | * triggered, the click-action will start this intent along with the extra |
| 114 | * {@link #EXTRA_PHONE_ACCOUNT_HANDLE} to indicate the {@link PhoneAccount} to configure. If the |
| 115 | * {@link PhoneAccount} package does not register an {@link android.app.Activity} for this |
| 116 | * intent, then it will not be sent. |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 117 | */ |
Santos Cordon | 895d4b8 | 2015-06-25 16:41:48 -0700 | [diff] [blame] | 118 | public static final String ACTION_CONFIGURE_PHONE_ACCOUNT = |
| 119 | "android.telecom.action.CONFIGURE_PHONE_ACCOUNT"; |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 120 | |
| 121 | /** |
Andrew Lee | 873cfbf | 2015-02-26 15:22:00 -0800 | [diff] [blame] | 122 | * The {@link android.content.Intent} action used to show the call accessibility settings page. |
| 123 | */ |
| 124 | public static final String ACTION_SHOW_CALL_ACCESSIBILITY_SETTINGS = |
| 125 | "android.telecom.action.SHOW_CALL_ACCESSIBILITY_SETTINGS"; |
| 126 | |
| 127 | /** |
Yorke Lee | 3818a892 | 2014-07-21 15:57:17 -0700 | [diff] [blame] | 128 | * The {@link android.content.Intent} action used to show the call settings page. |
| 129 | */ |
| 130 | public static final String ACTION_SHOW_CALL_SETTINGS = |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 131 | "android.telecom.action.SHOW_CALL_SETTINGS"; |
Yorke Lee | 3818a892 | 2014-07-21 15:57:17 -0700 | [diff] [blame] | 132 | |
| 133 | /** |
Andrew Lee | 866080f | 2015-02-19 12:05:33 -0800 | [diff] [blame] | 134 | * The {@link android.content.Intent} action used to show the respond via SMS settings page. |
| 135 | */ |
| 136 | public static final String ACTION_SHOW_RESPOND_VIA_SMS_SETTINGS = |
| 137 | "android.telecom.action.SHOW_RESPOND_VIA_SMS_SETTINGS"; |
| 138 | |
| 139 | /** |
Evan Charlton | 6d8604f | 2014-09-04 12:38:17 -0700 | [diff] [blame] | 140 | * The {@link android.content.Intent} action used to show the settings page used to configure |
| 141 | * {@link PhoneAccount} preferences. |
| 142 | */ |
| 143 | public static final String ACTION_CHANGE_PHONE_ACCOUNTS = |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 144 | "android.telecom.action.CHANGE_PHONE_ACCOUNTS"; |
Evan Charlton | 6d8604f | 2014-09-04 12:38:17 -0700 | [diff] [blame] | 145 | |
| 146 | /** |
Tyler Gunn | d9da6ce | 2017-04-14 13:43:30 -0700 | [diff] [blame] | 147 | * {@link android.content.Intent} action used indicate that a new phone account was just |
| 148 | * registered. |
| 149 | * <p> |
| 150 | * The Intent {@link Intent#getExtras() extras} will contain {@link #EXTRA_PHONE_ACCOUNT_HANDLE} |
| 151 | * to indicate which {@link PhoneAccount} was registered. |
| 152 | * <p> |
| 153 | * Will only be sent to the default dialer app (see {@link #getDefaultDialerPackage()}). |
Santos Cordon | c66f3ba | 2015-02-27 15:22:07 -0800 | [diff] [blame] | 154 | */ |
Santos Cordon | c66f3ba | 2015-02-27 15:22:07 -0800 | [diff] [blame] | 155 | public static final String ACTION_PHONE_ACCOUNT_REGISTERED = |
| 156 | "android.telecom.action.PHONE_ACCOUNT_REGISTERED"; |
| 157 | |
| 158 | /** |
Tyler Gunn | d9da6ce | 2017-04-14 13:43:30 -0700 | [diff] [blame] | 159 | * {@link android.content.Intent} action used indicate that a phone account was just |
| 160 | * unregistered. |
| 161 | * <p> |
| 162 | * The Intent {@link Intent#getExtras() extras} will contain {@link #EXTRA_PHONE_ACCOUNT_HANDLE} |
| 163 | * to indicate which {@link PhoneAccount} was unregistered. |
| 164 | * <p> |
| 165 | * Will only be sent to the default dialer app (see {@link #getDefaultDialerPackage()}). |
Bryce Lee | 30b0aa0 | 2015-09-23 21:53:53 -0700 | [diff] [blame] | 166 | */ |
Bryce Lee | 30b0aa0 | 2015-09-23 21:53:53 -0700 | [diff] [blame] | 167 | public static final String ACTION_PHONE_ACCOUNT_UNREGISTERED = |
| 168 | "android.telecom.action.PHONE_ACCOUNT_UNREGISTERED"; |
| 169 | |
| 170 | /** |
Yorke Lee | 1011f48 | 2015-04-23 15:58:27 -0700 | [diff] [blame] | 171 | * Activity action: Shows a dialog asking the user whether or not they want to replace the |
| 172 | * current default Dialer with the one specified in |
| 173 | * {@link #EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME}. |
| 174 | * |
| 175 | * Usage example: |
| 176 | * <pre> |
| 177 | * Intent intent = new Intent(TelecomManager.ACTION_CHANGE_DEFAULT_DIALER); |
| 178 | * intent.putExtra(TelecomManager.EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME, |
| 179 | * getActivity().getPackageName()); |
| 180 | * startActivity(intent); |
| 181 | * </pre> |
Hai Zhang | 929085f | 2019-05-03 15:31:43 +0800 | [diff] [blame] | 182 | * <p> |
| 183 | * This is no longer supported since Q, please use |
| 184 | * {@link android.app.role.RoleManager#createRequestRoleIntent(String)} with |
| 185 | * {@link android.app.role.RoleManager#ROLE_DIALER} instead. |
Yorke Lee | 1011f48 | 2015-04-23 15:58:27 -0700 | [diff] [blame] | 186 | */ |
| 187 | public static final String ACTION_CHANGE_DEFAULT_DIALER = |
| 188 | "android.telecom.action.CHANGE_DEFAULT_DIALER"; |
| 189 | |
| 190 | /** |
Yorke Lee | 107c4ce | 2015-06-15 12:08:24 -0700 | [diff] [blame] | 191 | * Broadcast intent action indicating that the current default dialer has changed. |
| 192 | * The string extra {@link #EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME} will contain the |
| 193 | * name of the package that the default dialer was changed to. |
| 194 | * |
| 195 | * @see #EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME |
| 196 | */ |
| 197 | public static final String ACTION_DEFAULT_DIALER_CHANGED = |
| 198 | "android.telecom.action.DEFAULT_DIALER_CHANGED"; |
| 199 | |
| 200 | /** |
Yorke Lee | 1011f48 | 2015-04-23 15:58:27 -0700 | [diff] [blame] | 201 | * Extra value used to provide the package name for {@link #ACTION_CHANGE_DEFAULT_DIALER}. |
| 202 | */ |
| 203 | public static final String EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME = |
| 204 | "android.telecom.extra.CHANGE_DEFAULT_DIALER_PACKAGE_NAME"; |
| 205 | |
| 206 | /** |
tonyzhu | ff60f5e | 2018-10-01 19:14:59 +0800 | [diff] [blame] | 207 | * Broadcast intent action indicating that the current default call screening app has changed. |
Tyler Gunn | 78f77f6 | 2020-03-27 12:51:26 -0700 | [diff] [blame] | 208 | * <p> |
| 209 | * Note: This intent is NEVER actually broadcast and will be deprecated in the future. |
| 210 | * <p> |
| 211 | * An app that want to know if it holds the |
| 212 | * {@link android.app.role.RoleManager#ROLE_CALL_SCREENING} role can use |
| 213 | * {@link android.app.role.RoleManager#isRoleHeld(String)} to confirm if it holds the role or |
| 214 | * not. |
tonyzhu | ff60f5e | 2018-10-01 19:14:59 +0800 | [diff] [blame] | 215 | */ |
| 216 | public static final String ACTION_DEFAULT_CALL_SCREENING_APP_CHANGED = |
| 217 | "android.telecom.action.DEFAULT_CALL_SCREENING_APP_CHANGED"; |
| 218 | |
| 219 | /** |
| 220 | * Extra value used with {@link #ACTION_DEFAULT_CALL_SCREENING_APP_CHANGED} broadcast to |
| 221 | * indicate the ComponentName of the call screening app which has changed. |
Tyler Gunn | 78f77f6 | 2020-03-27 12:51:26 -0700 | [diff] [blame] | 222 | * <p> |
| 223 | * Note: This extra is NOT used and will be deprecated in the future. |
tonyzhu | ff60f5e | 2018-10-01 19:14:59 +0800 | [diff] [blame] | 224 | */ |
| 225 | public static final String EXTRA_DEFAULT_CALL_SCREENING_APP_COMPONENT_NAME = |
| 226 | "android.telecom.extra.DEFAULT_CALL_SCREENING_APP_COMPONENT_NAME"; |
| 227 | |
| 228 | /** |
| 229 | * Extra value used with {@link #ACTION_DEFAULT_CALL_SCREENING_APP_CHANGED} broadcast to |
| 230 | * indicate whether an app is the default call screening app. |
Tyler Gunn | 78f77f6 | 2020-03-27 12:51:26 -0700 | [diff] [blame] | 231 | * <p> |
| 232 | * Note: This extra is NOT used and will be deprecated in the future. |
tonyzhu | ff60f5e | 2018-10-01 19:14:59 +0800 | [diff] [blame] | 233 | */ |
| 234 | public static final String EXTRA_IS_DEFAULT_CALL_SCREENING_APP = |
| 235 | "android.telecom.extra.IS_DEFAULT_CALL_SCREENING_APP"; |
| 236 | |
| 237 | /** |
Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 238 | * Optional extra for {@link android.content.Intent#ACTION_CALL} containing a boolean that |
| 239 | * 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] | 240 | */ |
| 241 | public static final String EXTRA_START_CALL_WITH_SPEAKERPHONE = |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 242 | "android.telecom.extra.START_CALL_WITH_SPEAKERPHONE"; |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 243 | |
| 244 | /** |
Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 245 | * Optional extra for {@link android.content.Intent#ACTION_CALL} containing an integer that |
| 246 | * determines the desired video state for an outgoing call. |
Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 247 | * Valid options: |
Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 248 | * {@link VideoProfile#STATE_AUDIO_ONLY}, |
| 249 | * {@link VideoProfile#STATE_BIDIRECTIONAL}, |
| 250 | * {@link VideoProfile#STATE_RX_ENABLED}, |
| 251 | * {@link VideoProfile#STATE_TX_ENABLED}. |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 252 | */ |
| 253 | public static final String EXTRA_START_CALL_WITH_VIDEO_STATE = |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 254 | "android.telecom.extra.START_CALL_WITH_VIDEO_STATE"; |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 255 | |
| 256 | /** |
Tyler Gunn | 3765356 | 2017-03-13 18:15:15 -0700 | [diff] [blame] | 257 | * Optional extra for {@link #addNewIncomingCall(PhoneAccountHandle, Bundle)} containing an |
| 258 | * integer that determines the requested video state for an incoming call. |
| 259 | * Valid options: |
| 260 | * {@link VideoProfile#STATE_AUDIO_ONLY}, |
| 261 | * {@link VideoProfile#STATE_BIDIRECTIONAL}, |
| 262 | * {@link VideoProfile#STATE_RX_ENABLED}, |
| 263 | * {@link VideoProfile#STATE_TX_ENABLED}. |
| 264 | */ |
| 265 | public static final String EXTRA_INCOMING_VIDEO_STATE = |
| 266 | "android.telecom.extra.INCOMING_VIDEO_STATE"; |
| 267 | |
| 268 | /** |
Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 269 | * The extra used with an {@link android.content.Intent#ACTION_CALL} and |
| 270 | * {@link android.content.Intent#ACTION_DIAL} {@code Intent} to specify a |
| 271 | * {@link PhoneAccountHandle} to use when making the call. |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 272 | * <p class="note"> |
Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 273 | * Retrieve with {@link android.content.Intent#getParcelableExtra(String)}. |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 274 | */ |
Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 275 | public static final String EXTRA_PHONE_ACCOUNT_HANDLE = |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 276 | "android.telecom.extra.PHONE_ACCOUNT_HANDLE"; |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 277 | |
| 278 | /** |
Tyler Gunn | 335ff2e | 2015-07-30 14:18:33 -0700 | [diff] [blame] | 279 | * Optional extra for {@link android.content.Intent#ACTION_CALL} containing a string call |
| 280 | * subject which will be associated with an outgoing call. Should only be specified if the |
Shuo Qian | 3ed3883 | 2020-11-30 21:54:36 -0800 | [diff] [blame] | 281 | * {@link PhoneAccount} supports the capability {@link PhoneAccount#CAPABILITY_CALL_SUBJECT} |
| 282 | * or {@link PhoneAccount#CAPABILITY_CALL_COMPOSER}. |
Tyler Gunn | 335ff2e | 2015-07-30 14:18:33 -0700 | [diff] [blame] | 283 | */ |
| 284 | public static final String EXTRA_CALL_SUBJECT = "android.telecom.extra.CALL_SUBJECT"; |
| 285 | |
Shuo Qian | 3ed3883 | 2020-11-30 21:54:36 -0800 | [diff] [blame] | 286 | // Values for EXTRA_PRIORITY |
| 287 | /** |
| 288 | * Indicates the call composer call priority is normal. |
| 289 | * |
| 290 | * Reference: RCC.20 Section 2.4.4.2 |
| 291 | */ |
| 292 | public static final int PRIORITY_NORMAL = 0; |
| 293 | |
| 294 | /** |
| 295 | * Indicates the call composer call priority is urgent. |
| 296 | * |
| 297 | * Reference: RCC.20 Section 2.4.4.2 |
| 298 | */ |
| 299 | public static final int PRIORITY_URGENT = 1; |
| 300 | |
| 301 | /** |
| 302 | * Extra for the call composer call priority, either {@link #PRIORITY_NORMAL} or |
| 303 | * {@link #PRIORITY_URGENT}. |
| 304 | * |
| 305 | * Reference: RCC.20 Section 2.4.4.2 |
| 306 | */ |
| 307 | public static final String EXTRA_PRIORITY = "android.telecom.extra.PRIORITY"; |
| 308 | |
| 309 | /** |
| 310 | * Extra for the call composer call location, an {@link android.location.Location} parcelable |
| 311 | * class to represent the geolocation as a latitude and longitude pair. |
| 312 | * |
| 313 | * Reference: RCC.20 Section 2.4.3.2 |
| 314 | */ |
| 315 | public static final String EXTRA_LOCATION = "android.telecom.extra.LOCATION"; |
| 316 | |
| 317 | /** |
| 318 | * A boolean extra set on incoming calls to indicate that the call has a picture specified. |
| 319 | * Given that image download could take a (short) time, the EXTRA is set immediately upon |
| 320 | * adding the call to the Dialer app, this allows the Dialer app to reserve space for an image |
| 321 | * if one is expected. The EXTRA may be unset if the image download ends up failing for some |
| 322 | * reason. |
| 323 | */ |
| 324 | public static final String EXTRA_HAS_PICTURE = "android.telecom.extra.HAS_PICTURE"; |
| 325 | |
| 326 | /** |
Hall Liu | 48c3c14 | 2021-03-11 16:14:22 -0800 | [diff] [blame] | 327 | * A {@link Uri} representing the picture that was downloaded when a call is received or |
| 328 | * uploaded when a call is placed. |
Hall Liu | 8fee7ea | 2021-01-21 16:37:51 -0800 | [diff] [blame] | 329 | * |
Shuo Qian | 3ed3883 | 2020-11-30 21:54:36 -0800 | [diff] [blame] | 330 | * This is a content URI within the call log provider which can be used to open a file |
| 331 | * descriptor. This could be set a short time after a call is added to the Dialer app if the |
Hall Liu | 8fee7ea | 2021-01-21 16:37:51 -0800 | [diff] [blame] | 332 | * download/upload is delayed for some reason. The Dialer app will receive a callback via |
Shuo Qian | 3ed3883 | 2020-11-30 21:54:36 -0800 | [diff] [blame] | 333 | * {@link Call.Callback#onDetailsChanged} when this value has changed. |
| 334 | * |
| 335 | * Reference: RCC.20 Section 2.4.3.2 |
| 336 | */ |
Hall Liu | 8fee7ea | 2021-01-21 16:37:51 -0800 | [diff] [blame] | 337 | public static final String EXTRA_PICTURE_URI = "android.telecom.extra.PICTURE_URI"; |
Shuo Qian | 3ed3883 | 2020-11-30 21:54:36 -0800 | [diff] [blame] | 338 | |
Shuo Qian | 3ed3883 | 2020-11-30 21:54:36 -0800 | [diff] [blame] | 339 | /** |
| 340 | * A ParcelUuid used as a token to represent a picture that was uploaded prior to the call |
Hall Liu | a749abc | 2021-01-21 10:05:43 -0800 | [diff] [blame] | 341 | * being placed. The value of this extra should be set using the {@link android.os.ParcelUuid} |
| 342 | * obtained from the callback in {@link TelephonyManager#uploadCallComposerPicture}. |
Shuo Qian | 3ed3883 | 2020-11-30 21:54:36 -0800 | [diff] [blame] | 343 | */ |
| 344 | public static final String EXTRA_OUTGOING_PICTURE = "android.telecom.extra.OUTGOING_PICTURE"; |
| 345 | |
Tyler Gunn | 335ff2e | 2015-07-30 14:18:33 -0700 | [diff] [blame] | 346 | /** |
Yorke Lee | 04ea7d3 | 2015-06-05 15:59:18 -0700 | [diff] [blame] | 347 | * The extra used by a {@link ConnectionService} to provide the handle of the caller that |
| 348 | * has initiated a new incoming call. |
| 349 | */ |
Yorke Lee | 02fb5bc | 2015-06-09 12:27:36 -0700 | [diff] [blame] | 350 | public static final String EXTRA_INCOMING_CALL_ADDRESS = |
| 351 | "android.telecom.extra.INCOMING_CALL_ADDRESS"; |
Yorke Lee | 04ea7d3 | 2015-06-05 15:59:18 -0700 | [diff] [blame] | 352 | |
| 353 | /** |
Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 354 | * Optional extra for {@link #ACTION_INCOMING_CALL} containing a {@link Bundle} which contains |
| 355 | * metadata about the call. This {@link Bundle} will be returned to the |
| 356 | * {@link ConnectionService}. |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 357 | */ |
| 358 | public static final String EXTRA_INCOMING_CALL_EXTRAS = |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 359 | "android.telecom.extra.INCOMING_CALL_EXTRAS"; |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 360 | |
| 361 | /** |
Roopa Sattiraju | 98c76c4 | 2022-01-30 13:35:59 -0800 | [diff] [blame] | 362 | * Optional extra for {@link #addNewIncomingCall(PhoneAccountHandle, Bundle)} used to indicate |
| 363 | * that a call has an in-band ringtone associated with it. This is used when the device is |
| 364 | * acting as an HFP headset and the Bluetooth stack has received an in-band ringtone from the |
| 365 | * the HFP host which must be played instead of any local ringtone the device would otherwise |
| 366 | * have generated. |
| 367 | * |
Joseph Pirozzo | 40ea5ee | 2018-01-02 16:15:23 -0800 | [diff] [blame] | 368 | * @hide |
| 369 | */ |
Roopa Sattiraju | 98c76c4 | 2022-01-30 13:35:59 -0800 | [diff] [blame] | 370 | @SystemApi |
| 371 | public static final String EXTRA_CALL_HAS_IN_BAND_RINGTONE = |
| 372 | "android.telecom.extra.CALL_HAS_IN_BAND_RINGTONE"; |
Joseph Pirozzo | 40ea5ee | 2018-01-02 16:15:23 -0800 | [diff] [blame] | 373 | |
| 374 | /** |
Nancy Chen | 10798dc | 2014-08-08 14:00:25 -0700 | [diff] [blame] | 375 | * Optional extra for {@link android.content.Intent#ACTION_CALL} and |
| 376 | * {@link android.content.Intent#ACTION_DIAL} {@code Intent} containing a {@link Bundle} |
| 377 | * 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] | 378 | * {@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] | 379 | */ |
| 380 | public static final String EXTRA_OUTGOING_CALL_EXTRAS = |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 381 | "android.telecom.extra.OUTGOING_CALL_EXTRAS"; |
Nancy Chen | 10798dc | 2014-08-08 14:00:25 -0700 | [diff] [blame] | 382 | |
| 383 | /** |
sqian | 6d9e745 | 2019-02-08 21:42:15 -0800 | [diff] [blame] | 384 | * An optional boolean extra on {@link android.content.Intent#ACTION_CALL_EMERGENCY} to tell |
| 385 | * whether the user's dial intent is emergency; this is required to specify when the dialed |
| 386 | * number is ambiguous, identified as both emergency number and any other non-emergency number; |
| 387 | * e.g. in some situation, 611 could be both an emergency number in a country and a |
| 388 | * non-emergency number of a carrier's customer service hotline. |
| 389 | * |
| 390 | * @hide |
| 391 | */ |
| 392 | @SystemApi |
| 393 | public static final String EXTRA_IS_USER_INTENT_EMERGENCY_CALL = |
| 394 | "android.telecom.extra.IS_USER_INTENT_EMERGENCY_CALL"; |
| 395 | |
| 396 | /** |
Hall Liu | ba820bd | 2020-01-22 17:17:13 -0800 | [diff] [blame] | 397 | * A mandatory extra containing a {@link Uri} to be passed in when calling |
| 398 | * {@link #addNewUnknownCall(PhoneAccountHandle, Bundle)}. The {@link Uri} value indicates |
| 399 | * the remote handle of the new call. |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 400 | * @hide |
| 401 | */ |
Hall Liu | 2ef0411 | 2020-09-14 18:34:10 -0700 | [diff] [blame] | 402 | @SystemApi |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 403 | public static final String EXTRA_UNKNOWN_CALL_HANDLE = |
| 404 | "android.telecom.extra.UNKNOWN_CALL_HANDLE"; |
| 405 | |
| 406 | /** |
Sailesh Nepal | da6bb38 | 2016-04-14 19:51:46 -0700 | [diff] [blame] | 407 | * Optional extra for incoming and outgoing calls containing a long which specifies the time the |
| 408 | * call was created. This value is in milliseconds since boot. |
Hall Liu | dbb17f1 | 2020-03-10 18:28:58 -0700 | [diff] [blame] | 409 | * @hide |
Sailesh Nepal | da6bb38 | 2016-04-14 19:51:46 -0700 | [diff] [blame] | 410 | */ |
| 411 | public static final String EXTRA_CALL_CREATED_TIME_MILLIS = |
| 412 | "android.telecom.extra.CALL_CREATED_TIME_MILLIS"; |
| 413 | |
| 414 | /** |
Jack Yu | 1e1ff94 | 2019-12-23 15:19:56 -0800 | [diff] [blame] | 415 | * Optional extra for incoming and outgoing calls containing a long which specifies the Epoch |
| 416 | * time the call was created. |
| 417 | * @hide |
| 418 | */ |
| 419 | public static final String EXTRA_CALL_CREATED_EPOCH_TIME_MILLIS = |
| 420 | "android.telecom.extra.CALL_CREATED_EPOCH_TIME_MILLIS"; |
| 421 | |
| 422 | /** |
Sailesh Nepal | da6bb38 | 2016-04-14 19:51:46 -0700 | [diff] [blame] | 423 | * Optional extra for incoming and outgoing calls containing a long which specifies the time |
| 424 | * telecom began routing the call. This value is in milliseconds since boot. |
| 425 | * @hide |
| 426 | */ |
| 427 | public static final String EXTRA_CALL_TELECOM_ROUTING_START_TIME_MILLIS = |
| 428 | "android.telecom.extra.CALL_TELECOM_ROUTING_START_TIME_MILLIS"; |
| 429 | |
| 430 | /** |
| 431 | * Optional extra for incoming and outgoing calls containing a long which specifies the time |
| 432 | * telecom finished routing the call. This value is in milliseconds since boot. |
| 433 | * @hide |
| 434 | */ |
| 435 | public static final String EXTRA_CALL_TELECOM_ROUTING_END_TIME_MILLIS = |
| 436 | "android.telecom.extra.CALL_TELECOM_ROUTING_END_TIME_MILLIS"; |
| 437 | |
| 438 | /** |
Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 439 | * Optional extra for {@link android.telephony.TelephonyManager#ACTION_PHONE_STATE_CHANGED} |
| 440 | * containing the disconnect code. |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 441 | */ |
| 442 | public static final String EXTRA_CALL_DISCONNECT_CAUSE = |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 443 | "android.telecom.extra.CALL_DISCONNECT_CAUSE"; |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 444 | |
| 445 | /** |
Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 446 | * Optional extra for {@link android.telephony.TelephonyManager#ACTION_PHONE_STATE_CHANGED} |
| 447 | * containing the disconnect message. |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 448 | */ |
| 449 | public static final String EXTRA_CALL_DISCONNECT_MESSAGE = |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 450 | "android.telecom.extra.CALL_DISCONNECT_MESSAGE"; |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 451 | |
| 452 | /** |
radhika | 0dd9065 | 2020-11-04 11:12:51 -0800 | [diff] [blame] | 453 | * A string value for {@link #EXTRA_CALL_DISCONNECT_MESSAGE}, indicates the call was dropped by |
| 454 | * lower layers |
| 455 | * @hide |
| 456 | */ |
| 457 | public static final String CALL_AUTO_DISCONNECT_MESSAGE_STRING = |
| 458 | "Call dropped by lower layers"; |
| 459 | |
| 460 | /** |
Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 461 | * Optional extra for {@link android.telephony.TelephonyManager#ACTION_PHONE_STATE_CHANGED} |
| 462 | * containing the component name of the associated connection service. |
Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 463 | * @hide |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 464 | */ |
Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 465 | @SystemApi |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 466 | public static final String EXTRA_CONNECTION_SERVICE = |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 467 | "android.telecom.extra.CONNECTION_SERVICE"; |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 468 | |
| 469 | /** |
Hall Liu | ba820bd | 2020-01-22 17:17:13 -0800 | [diff] [blame] | 470 | * Optional extra for communicating the call technology used by a {@link ConnectionService} |
| 471 | * to Telecom. Valid values are: |
| 472 | * <ul> |
| 473 | * <li>{@link TelephonyManager#PHONE_TYPE_CDMA}</li> |
| 474 | * <li>{@link TelephonyManager#PHONE_TYPE_GSM}</li> |
| 475 | * <li>{@link TelephonyManager#PHONE_TYPE_IMS}</li> |
| 476 | * <li>{@link TelephonyManager#PHONE_TYPE_THIRD_PARTY}</li> |
| 477 | * <li>{@link TelephonyManager#PHONE_TYPE_SIP}</li> |
| 478 | * </ul> |
Hall Liu | 90f6290 | 2015-11-19 16:19:24 -0800 | [diff] [blame] | 479 | * @hide |
| 480 | */ |
Hall Liu | 2ef0411 | 2020-09-14 18:34:10 -0700 | [diff] [blame] | 481 | @SystemApi |
Hall Liu | 90f6290 | 2015-11-19 16:19:24 -0800 | [diff] [blame] | 482 | public static final String EXTRA_CALL_TECHNOLOGY_TYPE = |
| 483 | "android.telecom.extra.CALL_TECHNOLOGY_TYPE"; |
| 484 | |
| 485 | /** |
Wei Huang | 7f7f72e | 2018-05-30 19:21:36 +0800 | [diff] [blame] | 486 | * Optional extra for communicating the call network technology used by a |
| 487 | * {@link android.telecom.Connection} to Telecom and InCallUI. |
| 488 | * |
Andrew Sapperstein | 8fe35e5 | 2020-04-28 12:29:20 -0700 | [diff] [blame] | 489 | * {@code NETWORK_TYPE_*} in {@link android.telephony.TelephonyManager}. |
Wei Huang | 7f7f72e | 2018-05-30 19:21:36 +0800 | [diff] [blame] | 490 | */ |
| 491 | public static final String EXTRA_CALL_NETWORK_TYPE = |
| 492 | "android.telecom.extra.CALL_NETWORK_TYPE"; |
| 493 | |
| 494 | /** |
Nancy Chen | 7ab1dc4 | 2014-09-09 18:18:26 -0700 | [diff] [blame] | 495 | * An optional {@link android.content.Intent#ACTION_CALL} intent extra denoting the |
| 496 | * package name of the app specifying an alternative gateway for the call. |
| 497 | * The value is a string. |
| 498 | * |
| 499 | * (The following comment corresponds to the all GATEWAY_* extras) |
| 500 | * An app which sends the {@link android.content.Intent#ACTION_CALL} intent can specify an |
| 501 | * alternative address to dial which is different from the one specified and displayed to |
| 502 | * the user. This alternative address is referred to as the gateway address. |
| 503 | */ |
| 504 | public static final String GATEWAY_PROVIDER_PACKAGE = |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 505 | "android.telecom.extra.GATEWAY_PROVIDER_PACKAGE"; |
Nancy Chen | 7ab1dc4 | 2014-09-09 18:18:26 -0700 | [diff] [blame] | 506 | |
| 507 | /** |
| 508 | * An optional {@link android.content.Intent#ACTION_CALL} intent extra corresponding to the |
| 509 | * original address to dial for the call. This is used when an alternative gateway address is |
| 510 | * provided to recall the original address. |
| 511 | * The value is a {@link android.net.Uri}. |
| 512 | * |
| 513 | * (See {@link #GATEWAY_PROVIDER_PACKAGE} for details) |
| 514 | */ |
| 515 | public static final String GATEWAY_ORIGINAL_ADDRESS = |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 516 | "android.telecom.extra.GATEWAY_ORIGINAL_ADDRESS"; |
Nancy Chen | 7ab1dc4 | 2014-09-09 18:18:26 -0700 | [diff] [blame] | 517 | |
| 518 | /** |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 519 | * The number which the party on the other side of the line will see (and use to return the |
| 520 | * call). |
| 521 | * <p> |
Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 522 | * {@link ConnectionService}s which interact with {@link RemoteConnection}s should only populate |
| 523 | * this if the {@link android.telephony.TelephonyManager#getLine1Number()} value, as that is the |
| 524 | * user's expected caller ID. |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 525 | */ |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 526 | 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] | 527 | |
| 528 | /** |
Hall Liu | 8f613fb | 2017-02-14 18:11:11 -0800 | [diff] [blame] | 529 | * The number of milliseconds that Telecom should wait after disconnecting a call via the |
| 530 | * ACTION_NEW_OUTGOING_CALL broadcast, in order to wait for the app which cancelled the call |
| 531 | * to make a new one. |
| 532 | * @hide |
| 533 | */ |
| 534 | public static final String EXTRA_NEW_OUTGOING_CALL_CANCEL_TIMEOUT = |
| 535 | "android.telecom.extra.NEW_OUTGOING_CALL_CANCEL_TIMEOUT"; |
| 536 | |
| 537 | /** |
Tyler Gunn | 9f6f047 | 2017-04-17 18:25:22 -0700 | [diff] [blame] | 538 | * 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] | 539 | * existing call from the user's device to a different {@link PhoneAccount}. |
| 540 | * <p> |
Tyler Gunn | 9f6f047 | 2017-04-17 18:25:22 -0700 | [diff] [blame] | 541 | * Used when calling {@link #addNewIncomingCall(PhoneAccountHandle, Bundle)} |
| 542 | * to indicate to Telecom that the purpose of adding a new incoming call is to handover an |
| 543 | * existing call from the user's device to a different {@link PhoneAccount}. This occurs on |
| 544 | * the receiving side of a handover. |
| 545 | * <p> |
| 546 | * Used when Telecom calls |
| 547 | * {@link ConnectionService#onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)} |
| 548 | * to indicate that the purpose of Telecom requesting a new outgoing connection it to request |
| 549 | * a handover to this {@link ConnectionService} from an ongoing call on the user's device. This |
| 550 | * occurs on the initiating side of a handover. |
| 551 | * <p> |
Tyler Gunn | 727c6bd | 2017-04-11 09:51:40 -0700 | [diff] [blame] | 552 | * 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] | 553 | * @hide |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 554 | * @deprecated Use the public handover APIs. See |
| 555 | * {@link Call#handoverTo(PhoneAccountHandle, int, Bundle)} for more information. |
Tyler Gunn | 8bf7657 | 2017-04-06 15:30:08 -0700 | [diff] [blame] | 556 | */ |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 557 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 119305590) |
Tyler Gunn | 8bf7657 | 2017-04-06 15:30:08 -0700 | [diff] [blame] | 558 | public static final String EXTRA_IS_HANDOVER = "android.telecom.extra.IS_HANDOVER"; |
| 559 | |
| 560 | /** |
Tyler Gunn | 79bc1ec | 2018-01-22 15:17:54 -0800 | [diff] [blame] | 561 | * When {@code true} indicates that a request to create a new connection is for the purpose of |
| 562 | * a handover. Note: This is used with the |
| 563 | * {@link android.telecom.Call#handoverTo(PhoneAccountHandle, int, Bundle)} API as part of the |
| 564 | * internal communication mechanism with the {@link android.telecom.ConnectionService}. It is |
| 565 | * not the same as the legacy {@link #EXTRA_IS_HANDOVER} extra. |
| 566 | * @hide |
| 567 | */ |
| 568 | public static final String EXTRA_IS_HANDOVER_CONNECTION = |
| 569 | "android.telecom.extra.IS_HANDOVER_CONNECTION"; |
| 570 | |
| 571 | /** |
Tyler Gunn | 3af3869 | 2017-05-26 13:30:09 -0700 | [diff] [blame] | 572 | * Parcelable extra used with {@link #EXTRA_IS_HANDOVER} to indicate the source |
| 573 | * {@link PhoneAccountHandle} when initiating a handover which {@link ConnectionService} |
| 574 | * the handover is from. |
| 575 | * @hide |
| 576 | */ |
| 577 | public static final String EXTRA_HANDOVER_FROM_PHONE_ACCOUNT = |
| 578 | "android.telecom.extra.HANDOVER_FROM_PHONE_ACCOUNT"; |
| 579 | |
| 580 | /** |
Tyler Gunn | 9f6f047 | 2017-04-17 18:25:22 -0700 | [diff] [blame] | 581 | * Extra key specified in the {@link ConnectionRequest#getExtras()} when Telecom calls |
| 582 | * {@link ConnectionService#onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)} |
| 583 | * to inform the {@link ConnectionService} what the initial {@link CallAudioState} of the |
| 584 | * {@link Connection} will be. |
| 585 | * @hide |
| 586 | */ |
| 587 | public static final String EXTRA_CALL_AUDIO_STATE = "android.telecom.extra.CALL_AUDIO_STATE"; |
| 588 | |
| 589 | /** |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 590 | * A boolean extra, which when set on the {@link Intent#ACTION_CALL} intent or on the bundle |
| 591 | * passed into {@link #placeCall(Uri, Bundle)}, indicates that the call should be initiated with |
| 592 | * an RTT session open. See {@link android.telecom.Call.RttCall} for more information on RTT. |
| 593 | */ |
| 594 | public static final String EXTRA_START_CALL_WITH_RTT = |
| 595 | "android.telecom.extra.START_CALL_WITH_RTT"; |
| 596 | |
| 597 | /** |
Grace Jia | 91cec6e | 2019-12-16 14:23:05 -0800 | [diff] [blame] | 598 | * Start an activity indicating that the completion of an outgoing call or an incoming call |
| 599 | * which was not blocked by the {@link CallScreeningService}, and which was NOT terminated |
| 600 | * while the call was in {@link Call#STATE_AUDIO_PROCESSING}. |
| 601 | * |
| 602 | * The {@link Uri} extra {@link #EXTRA_HANDLE} will contain the uri handle(phone number) for the |
| 603 | * call which completed. |
| 604 | * |
| 605 | * The integer extra {@link #EXTRA_DISCONNECT_CAUSE} will indicate the reason for the call |
| 606 | * disconnection. See {@link #EXTRA_DISCONNECT_CAUSE} for more information. |
| 607 | * |
| 608 | * The integer extra {@link #EXTRA_CALL_DURATION} will indicate the duration of the call. See |
| 609 | * {@link #EXTRA_CALL_DURATION} for more information. |
| 610 | */ |
| 611 | public static final String ACTION_POST_CALL = "android.telecom.action.POST_CALL"; |
| 612 | |
| 613 | /** |
| 614 | * A {@link Uri} extra, which when set on the {@link #ACTION_POST_CALL} intent, indicates the |
| 615 | * uri handle(phone number) of the completed call. |
| 616 | */ |
| 617 | public static final String EXTRA_HANDLE = "android.telecom.extra.HANDLE"; |
| 618 | |
| 619 | /** |
| 620 | * A integer value provided for completed calls to indicate the reason for the call |
| 621 | * disconnection. |
| 622 | * <p> |
| 623 | * Allowed values: |
| 624 | * <ul> |
| 625 | * <li>{@link DisconnectCause#UNKNOWN}</li> |
| 626 | * <li>{@link DisconnectCause#LOCAL}</li> |
| 627 | * <li>{@link DisconnectCause#REMOTE}</li> |
| 628 | * <li>{@link DisconnectCause#REJECTED}</li> |
| 629 | * <li>{@link DisconnectCause#MISSED}</li> |
| 630 | * </ul> |
| 631 | * </p> |
| 632 | */ |
| 633 | public static final String EXTRA_DISCONNECT_CAUSE = "android.telecom.extra.DISCONNECT_CAUSE"; |
| 634 | |
| 635 | /** |
| 636 | * A integer value provided for completed calls to indicate the duration of the call. |
| 637 | * <p> |
| 638 | * Allowed values: |
| 639 | * <ul> |
| 640 | * <li>{@link #DURATION_VERY_SHORT}</li> |
| 641 | * <li>{@link #DURATION_SHORT}</li> |
| 642 | * <li>{@link #DURATION_MEDIUM}</li> |
| 643 | * <li>{@link #DURATION_LONG}</li> |
| 644 | * </ul> |
| 645 | * </p> |
| 646 | */ |
| 647 | public static final String EXTRA_CALL_DURATION = "android.telecom.extra.CALL_DURATION"; |
| 648 | |
| 649 | /** |
| 650 | * A integer value for {@link #EXTRA_CALL_DURATION}, indicates the duration of the completed |
| 651 | * call was < 3 seconds. |
| 652 | */ |
| 653 | public static final int DURATION_VERY_SHORT = 0; |
| 654 | |
| 655 | /** |
| 656 | * A integer value for {@link #EXTRA_CALL_DURATION}, indicates the duration of the completed |
| 657 | * call was >= 3 seconds and < 60 seconds. |
| 658 | */ |
| 659 | public static final int DURATION_SHORT = 1; |
| 660 | |
| 661 | /** |
| 662 | * A integer value for {@link #EXTRA_CALL_DURATION}, indicates the duration of the completed |
| 663 | * call was >= 60 seconds and < 120 seconds. |
| 664 | */ |
| 665 | public static final int DURATION_MEDIUM = 2; |
| 666 | |
| 667 | /** |
| 668 | * A integer value for {@link #EXTRA_CALL_DURATION}, indicates the duration of the completed |
| 669 | * call was >= 120 seconds. |
| 670 | */ |
| 671 | public static final int DURATION_LONG = 3; |
| 672 | |
| 673 | /** |
| 674 | * The threshold between {@link #DURATION_VERY_SHORT} calls and {@link #DURATION_SHORT} calls in |
| 675 | * milliseconds. |
| 676 | * @hide |
| 677 | */ |
| 678 | public static final long VERY_SHORT_CALL_TIME_MS = 3000; |
| 679 | |
| 680 | /** |
| 681 | * The threshold between {@link #DURATION_SHORT} calls and {@link #DURATION_MEDIUM} calls in |
| 682 | * milliseconds. |
| 683 | * @hide |
| 684 | */ |
| 685 | public static final long SHORT_CALL_TIME_MS = 60000; |
| 686 | |
| 687 | /** |
| 688 | * The threshold between {@link #DURATION_MEDIUM} calls and {@link #DURATION_LONG} calls in |
| 689 | * milliseconds. |
| 690 | * @hide |
| 691 | */ |
| 692 | public static final long MEDIUM_CALL_TIME_MS = 120000; |
| 693 | |
| 694 | /** |
Santos Cordon | f2600eb | 2015-06-22 15:02:20 -0700 | [diff] [blame] | 695 | * A boolean meta-data value indicating whether an {@link InCallService} implements an |
| 696 | * in-call user interface. Dialer implementations (see {@link #getDefaultDialerPackage()}) which |
| 697 | * would also like to replace the in-call interface should set this meta-data to {@code true} in |
| 698 | * the manifest registration of their {@link InCallService}. |
| 699 | */ |
| 700 | public static final String METADATA_IN_CALL_SERVICE_UI = "android.telecom.IN_CALL_SERVICE_UI"; |
| 701 | |
| 702 | /** |
Santos Cordon | 8888155 | 2015-12-10 17:29:54 -0800 | [diff] [blame] | 703 | * A boolean meta-data value indicating whether an {@link InCallService} implements an |
| 704 | * 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] | 705 | * {@link android.content.res.Configuration#UI_MODE_TYPE_CAR}). |
Santos Cordon | 8888155 | 2015-12-10 17:29:54 -0800 | [diff] [blame] | 706 | */ |
| 707 | public static final String METADATA_IN_CALL_SERVICE_CAR_MODE_UI = |
| 708 | "android.telecom.IN_CALL_SERVICE_CAR_MODE_UI"; |
| 709 | |
| 710 | /** |
Sailesh Nepal | 9c2618b | 2016-01-23 16:28:22 -0800 | [diff] [blame] | 711 | * A boolean meta-data value indicating whether an {@link InCallService} implements ringing. |
| 712 | * Dialer implementations (see {@link #getDefaultDialerPackage()}) which would also like to |
| 713 | * override the system provided ringing should set this meta-data to {@code true} in the |
| 714 | * manifest registration of their {@link InCallService}. |
Tyler Gunn | 556d240 | 2019-04-10 08:59:43 -0700 | [diff] [blame] | 715 | * <p> |
| 716 | * When {@code true}, it is the {@link InCallService}'s responsibility to play a ringtone for |
| 717 | * all incoming calls. |
Sailesh Nepal | 9c2618b | 2016-01-23 16:28:22 -0800 | [diff] [blame] | 718 | */ |
| 719 | public static final String METADATA_IN_CALL_SERVICE_RINGING = |
| 720 | "android.telecom.IN_CALL_SERVICE_RINGING"; |
| 721 | |
| 722 | /** |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 723 | * A boolean meta-data value indicating whether an {@link InCallService} wants to be informed of |
| 724 | * calls which have the {@link Call.Details#PROPERTY_IS_EXTERNAL_CALL} property. An external |
| 725 | * call is one which a {@link ConnectionService} knows about, but is not connected to directly. |
| 726 | * Dialer implementations (see {@link #getDefaultDialerPackage()}) which would like to be |
| 727 | * informed of external calls should set this meta-data to {@code true} in the manifest |
| 728 | * registration of their {@link InCallService}. By default, the {@link InCallService} will NOT |
| 729 | * be informed of external calls. |
| 730 | */ |
| 731 | public static final String METADATA_INCLUDE_EXTERNAL_CALLS = |
| 732 | "android.telecom.INCLUDE_EXTERNAL_CALLS"; |
| 733 | |
| 734 | /** |
Tyler Gunn | 24e1833 | 2017-02-10 09:42:49 -0800 | [diff] [blame] | 735 | * A boolean meta-data value indicating whether an {@link InCallService} wants to be informed of |
| 736 | * calls which have the {@link Call.Details#PROPERTY_SELF_MANAGED} property. A self-managed |
| 737 | * call is one which originates from a self-managed {@link ConnectionService} which has chosen |
| 738 | * to implement its own call user interface. An {@link InCallService} implementation which |
| 739 | * would like to be informed of external calls should set this meta-data to {@code true} in the |
| 740 | * manifest registration of their {@link InCallService}. By default, the {@link InCallService} |
| 741 | * will NOT be informed about self-managed calls. |
| 742 | * <p> |
| 743 | * An {@link InCallService} which receives self-managed calls is free to view and control the |
| 744 | * 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] | 745 | * exposing these calls to an automotive device via its companion app. |
| 746 | * <p> |
| 747 | * This meta-data can only be set for an {@link InCallService} which also sets |
| 748 | * {@link #METADATA_IN_CALL_SERVICE_UI}. Only the default phone/dialer app, or a car-mode |
| 749 | * {@link InCallService} can see self-managed calls. |
Tyler Gunn | 24e1833 | 2017-02-10 09:42:49 -0800 | [diff] [blame] | 750 | * <p> |
| 751 | * See also {@link Connection#PROPERTY_SELF_MANAGED}. |
| 752 | */ |
| 753 | public static final String METADATA_INCLUDE_SELF_MANAGED_CALLS = |
| 754 | "android.telecom.INCLUDE_SELF_MANAGED_CALLS"; |
| 755 | |
| 756 | /** |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 757 | * The dual tone multi-frequency signaling character sent to indicate the dialing system should |
| 758 | * pause for a predefined period. |
| 759 | */ |
| 760 | public static final char DTMF_CHARACTER_PAUSE = ','; |
| 761 | |
| 762 | /** |
| 763 | * The dual-tone multi-frequency signaling character sent to indicate the dialing system should |
| 764 | * wait for user confirmation before proceeding. |
| 765 | */ |
| 766 | public static final char DTMF_CHARACTER_WAIT = ';'; |
| 767 | |
| 768 | /** |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 769 | * @hide |
| 770 | */ |
| 771 | @IntDef(prefix = { "TTY_MODE_" }, |
| 772 | value = {TTY_MODE_OFF, TTY_MODE_FULL, TTY_MODE_HCO, TTY_MODE_VCO}) |
| 773 | @Retention(RetentionPolicy.SOURCE) |
| 774 | public @interface TtyMode {} |
| 775 | |
| 776 | /** |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 777 | * TTY (teletypewriter) mode is off. |
| 778 | * |
| 779 | * @hide |
| 780 | */ |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 781 | @SystemApi |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 782 | public static final int TTY_MODE_OFF = 0; |
| 783 | |
| 784 | /** |
| 785 | * TTY (teletypewriter) mode is on. The speaker is off and the microphone is muted. The user |
| 786 | * will communicate with the remote party by sending and receiving text messages. |
| 787 | * |
| 788 | * @hide |
| 789 | */ |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 790 | @SystemApi |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 791 | public static final int TTY_MODE_FULL = 1; |
| 792 | |
| 793 | /** |
| 794 | * TTY (teletypewriter) mode is in hearing carryover mode (HCO). The microphone is muted but the |
| 795 | * speaker is on. The user will communicate with the remote party by sending text messages and |
| 796 | * hearing an audible reply. |
| 797 | * |
| 798 | * @hide |
| 799 | */ |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 800 | @SystemApi |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 801 | public static final int TTY_MODE_HCO = 2; |
| 802 | |
| 803 | /** |
| 804 | * TTY (teletypewriter) mode is in voice carryover mode (VCO). The speaker is off but the |
| 805 | * microphone is still on. User will communicate with the remote party by speaking and receiving |
| 806 | * text message replies. |
| 807 | * |
| 808 | * @hide |
| 809 | */ |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 810 | @SystemApi |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 811 | public static final int TTY_MODE_VCO = 3; |
| 812 | |
| 813 | /** |
Hall Liu | 2ef0411 | 2020-09-14 18:34:10 -0700 | [diff] [blame] | 814 | * Broadcast intent action indicating that the current TTY mode has changed. |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 815 | * |
Hall Liu | 2ef0411 | 2020-09-14 18:34:10 -0700 | [diff] [blame] | 816 | * This intent will contain {@link #EXTRA_CURRENT_TTY_MODE} as an intent extra, giving the new |
| 817 | * TTY mode. |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 818 | * @hide |
| 819 | */ |
Hall Liu | 2ef0411 | 2020-09-14 18:34:10 -0700 | [diff] [blame] | 820 | @SystemApi |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 821 | public static final String ACTION_CURRENT_TTY_MODE_CHANGED = |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 822 | "android.telecom.action.CURRENT_TTY_MODE_CHANGED"; |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 823 | |
| 824 | /** |
Hall Liu | 2ef0411 | 2020-09-14 18:34:10 -0700 | [diff] [blame] | 825 | * Integer extra key that indicates the current TTY mode. |
| 826 | * |
| 827 | * Used with {@link #ACTION_CURRENT_TTY_MODE_CHANGED}. |
| 828 | * |
| 829 | * Valid modes are: |
| 830 | * <ul> |
| 831 | * <li>{@link #TTY_MODE_OFF}</li> |
| 832 | * <li>{@link #TTY_MODE_FULL}</li> |
| 833 | * <li>{@link #TTY_MODE_HCO}</li> |
| 834 | * <li>{@link #TTY_MODE_VCO}</li> |
| 835 | * </ul> |
| 836 | * |
| 837 | * This TTY mode is distinct from the one sent via {@link #ACTION_TTY_PREFERRED_MODE_CHANGED}, |
| 838 | * since the current TTY mode will always be {@link #TTY_MODE_OFF}unless a TTY terminal is |
| 839 | * plugged into the device. |
| 840 | * @hide |
| 841 | */ |
Hall Liu | 2ef0411 | 2020-09-14 18:34:10 -0700 | [diff] [blame] | 842 | @SystemApi |
| 843 | public static final String EXTRA_CURRENT_TTY_MODE = |
| 844 | "android.telecom.extra.CURRENT_TTY_MODE"; |
| 845 | |
| 846 | /** |
| 847 | * Broadcast intent action indicating that the TTY preferred operating mode has changed. |
| 848 | * |
| 849 | * This intent will contain {@link #EXTRA_TTY_PREFERRED_MODE} as an intent extra, giving the new |
| 850 | * preferred TTY mode. |
| 851 | * @hide |
| 852 | */ |
Hall Liu | 2ef0411 | 2020-09-14 18:34:10 -0700 | [diff] [blame] | 853 | @SystemApi |
| 854 | public static final String ACTION_TTY_PREFERRED_MODE_CHANGED = |
| 855 | "android.telecom.action.TTY_PREFERRED_MODE_CHANGED"; |
| 856 | |
| 857 | /** |
| 858 | * Integer extra key that indicates the preferred TTY mode. |
| 859 | * |
| 860 | * Used with {@link #ACTION_TTY_PREFERRED_MODE_CHANGED}. |
| 861 | * |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 862 | * Valid modes are: |
Hall Liu | ba820bd | 2020-01-22 17:17:13 -0800 | [diff] [blame] | 863 | * <ul> |
| 864 | * <li>{@link #TTY_MODE_OFF}</li> |
| 865 | * <li>{@link #TTY_MODE_FULL}</li> |
| 866 | * <li>{@link #TTY_MODE_HCO}</li> |
| 867 | * <li>{@link #TTY_MODE_VCO}</li> |
| 868 | * </ul> |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 869 | * @hide |
| 870 | */ |
Hall Liu | 2ef0411 | 2020-09-14 18:34:10 -0700 | [diff] [blame] | 871 | @SystemApi |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 872 | public static final String EXTRA_TTY_PREFERRED_MODE = |
Hall Liu | ba820bd | 2020-01-22 17:17:13 -0800 | [diff] [blame] | 873 | "android.telecom.extra.TTY_PREFERRED_MODE"; |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 874 | |
Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 875 | /** |
Bryce Lee | 5e4dd3e | 2015-08-03 16:59:10 -0700 | [diff] [blame] | 876 | * 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] | 877 | * notification. If no custom component exists then this is sent to the default dialer which |
| 878 | * should post a missed-call notification. |
Bryce Lee | 5e4dd3e | 2015-08-03 16:59:10 -0700 | [diff] [blame] | 879 | */ |
Bryce Lee | 5e4dd3e | 2015-08-03 16:59:10 -0700 | [diff] [blame] | 880 | public static final String ACTION_SHOW_MISSED_CALLS_NOTIFICATION = |
| 881 | "android.telecom.action.SHOW_MISSED_CALLS_NOTIFICATION"; |
| 882 | |
| 883 | /** |
Sailesh Nepal | be15ad9 | 2016-01-21 19:26:20 -0800 | [diff] [blame] | 884 | * The number of calls associated with the notification. If the number is zero then the missed |
| 885 | * call notification should be dismissed. |
Bryce Lee | 5e4dd3e | 2015-08-03 16:59:10 -0700 | [diff] [blame] | 886 | */ |
Bryce Lee | 5e4dd3e | 2015-08-03 16:59:10 -0700 | [diff] [blame] | 887 | public static final String EXTRA_NOTIFICATION_COUNT = |
| 888 | "android.telecom.extra.NOTIFICATION_COUNT"; |
| 889 | |
| 890 | /** |
| 891 | * The number associated with the missed calls. This number is only relevant |
| 892 | * when EXTRA_NOTIFICATION_COUNT is 1. |
Bryce Lee | 5e4dd3e | 2015-08-03 16:59:10 -0700 | [diff] [blame] | 893 | */ |
Bryce Lee | 5e4dd3e | 2015-08-03 16:59:10 -0700 | [diff] [blame] | 894 | public static final String EXTRA_NOTIFICATION_PHONE_NUMBER = |
| 895 | "android.telecom.extra.NOTIFICATION_PHONE_NUMBER"; |
| 896 | |
| 897 | /** |
Bryce Lee | 8d41d1d | 2015-08-10 07:40:42 -0700 | [diff] [blame] | 898 | * The intent to clear missed calls. |
| 899 | * @hide |
| 900 | */ |
| 901 | @SystemApi |
| 902 | public static final String EXTRA_CLEAR_MISSED_CALLS_INTENT = |
| 903 | "android.telecom.extra.CLEAR_MISSED_CALLS_INTENT"; |
| 904 | |
| 905 | /** |
| 906 | * The intent to call back a missed call. |
| 907 | * @hide |
| 908 | */ |
| 909 | @SystemApi |
| 910 | public static final String EXTRA_CALL_BACK_INTENT = |
| 911 | "android.telecom.extra.CALL_BACK_INTENT"; |
| 912 | |
| 913 | /** |
Charles He | 858f132 | 2017-11-27 17:11:04 -0800 | [diff] [blame] | 914 | * The dialer activity responsible for placing emergency calls from, for example, a locked |
| 915 | * keyguard. |
| 916 | * @hide |
| 917 | */ |
| 918 | public static final ComponentName EMERGENCY_DIALER_COMPONENT = |
| 919 | ComponentName.createRelative("com.android.phone", ".EmergencyDialer"); |
| 920 | |
| 921 | /** |
Eric Erfanian | 62706c5 | 2017-12-06 16:27:53 -0800 | [diff] [blame] | 922 | * The boolean indicated by this extra controls whether or not a call is eligible to undergo |
| 923 | * assisted dialing. This extra is stored under {@link #EXTRA_OUTGOING_CALL_EXTRAS}. |
Tyler Gunn | 00d737b | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 924 | * <p> |
| 925 | * The call initiator can use this extra to indicate that a call used assisted dialing to help |
| 926 | * place the call. This is most commonly used by a Dialer app which provides the ability to |
| 927 | * automatically add dialing prefixes when placing international calls. |
| 928 | * <p> |
| 929 | * Setting this extra on the outgoing call extras will cause the |
Tyler Gunn | 754493b | 2020-01-27 10:30:51 -0800 | [diff] [blame] | 930 | * {@link Connection#PROPERTY_ASSISTED_DIALING} property and |
| 931 | * {@link Call.Details#PROPERTY_ASSISTED_DIALING} property to be set on the |
Tyler Gunn | 00d737b | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 932 | * {@link Connection}/{@link Call} in question. When the call is logged to the call log, the |
| 933 | * {@link android.provider.CallLog.Calls#FEATURES_ASSISTED_DIALING_USED} call feature is set to |
| 934 | * indicate that assisted dialing was used for the call. |
Eric Erfanian | 62706c5 | 2017-12-06 16:27:53 -0800 | [diff] [blame] | 935 | */ |
| 936 | public static final String EXTRA_USE_ASSISTED_DIALING = |
| 937 | "android.telecom.extra.USE_ASSISTED_DIALING"; |
| 938 | |
| 939 | /** |
Shaotang Li | 8cec25c | 2018-07-19 17:29:39 +0800 | [diff] [blame] | 940 | * Optional extra for {@link #placeCall(Uri, Bundle)} containing an integer that specifies |
| 941 | * the source where user initiated this call. This data is used in metrics. |
Hall Liu | ba820bd | 2020-01-22 17:17:13 -0800 | [diff] [blame] | 942 | * Valid sources are: |
| 943 | * {@link TelecomManager#CALL_SOURCE_UNSPECIFIED}, |
| 944 | * {@link TelecomManager#CALL_SOURCE_EMERGENCY_DIALPAD}, |
| 945 | * {@link TelecomManager#CALL_SOURCE_EMERGENCY_SHORTCUT}. |
Shaotang Li | 8cec25c | 2018-07-19 17:29:39 +0800 | [diff] [blame] | 946 | * |
Hall Liu | 2ef0411 | 2020-09-14 18:34:10 -0700 | [diff] [blame] | 947 | * Intended for use with the platform emergency dialer only. |
Shaotang Li | 8cec25c | 2018-07-19 17:29:39 +0800 | [diff] [blame] | 948 | * @hide |
| 949 | */ |
Hall Liu | 2ef0411 | 2020-09-14 18:34:10 -0700 | [diff] [blame] | 950 | @SystemApi |
Shaotang Li | 8cec25c | 2018-07-19 17:29:39 +0800 | [diff] [blame] | 951 | public static final String EXTRA_CALL_SOURCE = "android.telecom.extra.CALL_SOURCE"; |
| 952 | |
| 953 | /** |
Hall Liu | ba820bd | 2020-01-22 17:17:13 -0800 | [diff] [blame] | 954 | * Indicating the call is initiated via emergency dialer's shortcut button. |
| 955 | * |
| 956 | * @hide |
| 957 | */ |
Hall Liu | 2ef0411 | 2020-09-14 18:34:10 -0700 | [diff] [blame] | 958 | @SystemApi |
Hall Liu | ba820bd | 2020-01-22 17:17:13 -0800 | [diff] [blame] | 959 | public static final int CALL_SOURCE_EMERGENCY_SHORTCUT = 2; |
| 960 | |
| 961 | /** |
| 962 | * Indicating the call is initiated via emergency dialer's dialpad. |
| 963 | * |
| 964 | * @hide |
| 965 | */ |
Hall Liu | 2ef0411 | 2020-09-14 18:34:10 -0700 | [diff] [blame] | 966 | @SystemApi |
Hall Liu | ba820bd | 2020-01-22 17:17:13 -0800 | [diff] [blame] | 967 | public static final int CALL_SOURCE_EMERGENCY_DIALPAD = 1; |
| 968 | |
| 969 | /** |
| 970 | * Indicating the call source is not specified. |
| 971 | * |
| 972 | * @hide |
| 973 | */ |
Hall Liu | 2ef0411 | 2020-09-14 18:34:10 -0700 | [diff] [blame] | 974 | @SystemApi |
Hall Liu | ba820bd | 2020-01-22 17:17:13 -0800 | [diff] [blame] | 975 | public static final int CALL_SOURCE_UNSPECIFIED = 0; |
| 976 | |
| 977 | /** |
Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 978 | * The following 4 constants define how properties such as phone numbers and names are |
| 979 | * displayed to the user. |
| 980 | */ |
| 981 | |
Santos Cordon | ed769ae | 2015-05-13 18:47:38 -0700 | [diff] [blame] | 982 | /** |
| 983 | * 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] | 984 | */ |
Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 985 | public static final int PRESENTATION_ALLOWED = 1; |
| 986 | |
Santos Cordon | ed769ae | 2015-05-13 18:47:38 -0700 | [diff] [blame] | 987 | /** |
| 988 | * Indicates that the address or number of a call is blocked by the other party. |
| 989 | */ |
Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 990 | public static final int PRESENTATION_RESTRICTED = 2; |
| 991 | |
Santos Cordon | ed769ae | 2015-05-13 18:47:38 -0700 | [diff] [blame] | 992 | /** |
| 993 | * Indicates that the address or number of a call is not specified or known by the carrier. |
| 994 | */ |
Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 995 | public static final int PRESENTATION_UNKNOWN = 3; |
| 996 | |
Santos Cordon | ed769ae | 2015-05-13 18:47:38 -0700 | [diff] [blame] | 997 | /** |
| 998 | * Indicates that the address or number of a call belongs to a pay phone. |
| 999 | */ |
Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 1000 | public static final int PRESENTATION_PAYPHONE = 4; |
| 1001 | |
Grace Jia | cc16b04 | 2021-08-09 09:06:11 -0700 | [diff] [blame] | 1002 | /** |
| 1003 | * Indicates that the address or number of a call is unavailable. |
| 1004 | */ |
| 1005 | public static final int PRESENTATION_UNAVAILABLE = 5; |
| 1006 | |
Hall Liu | 4a9fde1 | 2020-01-16 17:38:46 -0800 | [diff] [blame] | 1007 | |
| 1008 | /* |
| 1009 | * Values for the adb property "persist.radio.videocall.audio.output" |
| 1010 | */ |
| 1011 | /** @hide */ |
| 1012 | public static final int AUDIO_OUTPUT_ENABLE_SPEAKER = 0; |
| 1013 | /** @hide */ |
| 1014 | public static final int AUDIO_OUTPUT_DISABLE_SPEAKER = 1; |
| 1015 | /** @hide */ |
| 1016 | public static final int AUDIO_OUTPUT_DEFAULT = AUDIO_OUTPUT_ENABLE_SPEAKER; |
| 1017 | |
Tyler Gunn | 00d737b | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 1018 | /** @hide */ |
| 1019 | @Retention(RetentionPolicy.SOURCE) |
| 1020 | @IntDef( |
| 1021 | prefix = { "PRESENTATION_" }, |
| 1022 | value = {PRESENTATION_ALLOWED, PRESENTATION_RESTRICTED, PRESENTATION_UNKNOWN, |
Grace Jia | cc16b04 | 2021-08-09 09:06:11 -0700 | [diff] [blame] | 1023 | PRESENTATION_PAYPHONE, PRESENTATION_UNAVAILABLE}) |
Tyler Gunn | 00d737b | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 1024 | public @interface Presentation {} |
| 1025 | |
Brad Ebinger | a8366ae | 2021-03-23 21:01:51 +0000 | [diff] [blame] | 1026 | |
| 1027 | /** |
| 1028 | * Enable READ_PHONE_STATE protection on APIs querying and notifying call state, such as |
| 1029 | * {@code TelecomManager#getCallState}, {@link TelephonyManager#getCallStateForSubscription()}, |
| 1030 | * and {@link android.telephony.TelephonyCallback.CallStateListener}. |
Brad Ebinger | d081263 | 2021-04-17 16:11:42 -0700 | [diff] [blame] | 1031 | * @hide |
Brad Ebinger | a8366ae | 2021-03-23 21:01:51 +0000 | [diff] [blame] | 1032 | */ |
| 1033 | @ChangeId |
| 1034 | @EnabledSince(targetSdkVersion = Build.VERSION_CODES.S) |
| 1035 | // this magic number is a bug ID |
| 1036 | public static final long ENABLE_GET_CALL_STATE_PERMISSION_PROTECTION = 157233955L; |
| 1037 | |
Grace Jia | b13eb2c | 2021-04-21 14:13:26 -0700 | [diff] [blame] | 1038 | /** |
| 1039 | * Enable READ_PHONE_NUMBERS or READ_PRIVILEGED_PHONE_STATE protections on |
| 1040 | * {@link TelecomManager#getPhoneAccount(PhoneAccountHandle)}. |
| 1041 | * @hide |
| 1042 | */ |
| 1043 | @ChangeId |
| 1044 | @EnabledSince(targetSdkVersion = Build.VERSION_CODES.S) |
| 1045 | // bug ID |
| 1046 | public static final long ENABLE_GET_PHONE_ACCOUNT_PERMISSION_PROTECTION = 183407956L; |
| 1047 | |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1048 | private static final String TAG = "TelecomManager"; |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 1049 | |
Kevin Jeon | 767cda3 | 2020-11-17 01:40:16 +0000 | [diff] [blame] | 1050 | |
| 1051 | /** Cached service handles, cleared by resetServiceCache() at death */ |
| 1052 | private static final Object CACHE_LOCK = new Object(); |
| 1053 | |
| 1054 | @GuardedBy("CACHE_LOCK") |
| 1055 | private static ITelecomService sTelecomService; |
| 1056 | @GuardedBy("CACHE_LOCK") |
| 1057 | private static final DeathRecipient SERVICE_DEATH = new DeathRecipient(); |
| 1058 | |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 1059 | private final Context mContext; |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 1060 | |
Hall Liu | e1bc2ec | 2015-10-09 15:58:37 -0700 | [diff] [blame] | 1061 | private final ITelecomService mTelecomServiceOverride; |
| 1062 | |
Thomas Stuart | 9bfb243 | 2022-09-27 15:02:07 -0700 | [diff] [blame^] | 1063 | /** @hide **/ |
| 1064 | private final ClientTransactionalServiceRepository mTransactionalServiceRepository = |
| 1065 | new ClientTransactionalServiceRepository(); |
| 1066 | /** @hide **/ |
| 1067 | public static final int TELECOM_TRANSACTION_SUCCESS = 0; |
| 1068 | /** @hide **/ |
| 1069 | public static final String TRANSACTION_CALL_ID_KEY = "TelecomCallId"; |
| 1070 | |
Santos Cordon | 6c7a388 | 2014-06-25 15:30:08 -0700 | [diff] [blame] | 1071 | /** |
| 1072 | * @hide |
| 1073 | */ |
Chen Xu | 4c0b06d | 2018-10-22 16:54:39 +0000 | [diff] [blame] | 1074 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1075 | public static TelecomManager from(Context context) { |
| 1076 | return (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE); |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 1077 | } |
Santos Cordon | 6c7a388 | 2014-06-25 15:30:08 -0700 | [diff] [blame] | 1078 | |
| 1079 | /** |
| 1080 | * @hide |
| 1081 | */ |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1082 | public TelecomManager(Context context) { |
Hall Liu | e1bc2ec | 2015-10-09 15:58:37 -0700 | [diff] [blame] | 1083 | this(context, null); |
| 1084 | } |
| 1085 | |
| 1086 | /** |
| 1087 | * @hide |
| 1088 | */ |
| 1089 | public TelecomManager(Context context, ITelecomService telecomServiceImpl) { |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1090 | Context appContext = context.getApplicationContext(); |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame] | 1091 | if (appContext != null && Objects.equals(context.getAttributionTag(), |
| 1092 | appContext.getAttributionTag())) { |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1093 | mContext = appContext; |
| 1094 | } else { |
| 1095 | mContext = context; |
| 1096 | } |
Hall Liu | e1bc2ec | 2015-10-09 15:58:37 -0700 | [diff] [blame] | 1097 | mTelecomServiceOverride = telecomServiceImpl; |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1098 | } |
| 1099 | |
| 1100 | /** |
Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 1101 | * Return the {@link PhoneAccount} which will be used to place outgoing calls to addresses with |
| 1102 | * the specified {@code uriScheme}. This {@link PhoneAccount} will always be a member of the |
| 1103 | * list which is returned from invoking {@link #getCallCapablePhoneAccounts()}. The specific |
| 1104 | * account returned depends on the following priorities: |
| 1105 | * <ul> |
| 1106 | * <li> If the user-selected default {@link PhoneAccount} supports the specified scheme, it will |
| 1107 | * be returned. |
| 1108 | * </li> |
| 1109 | * <li> If there exists only one {@link PhoneAccount} that supports the specified scheme, it |
| 1110 | * will be returned. |
| 1111 | * </li> |
| 1112 | * </ul> |
Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 1113 | * <p> |
Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 1114 | * If no {@link PhoneAccount} fits the criteria above, this method will return {@code null}. |
| 1115 | * |
Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 1116 | * @param uriScheme The URI scheme. |
Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 1117 | * @return The {@link PhoneAccountHandle} corresponding to the account to be used. |
Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 1118 | */ |
Yorke Lee | c61d1366 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 1119 | @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) |
Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 1120 | public PhoneAccountHandle getDefaultOutgoingPhoneAccount(String uriScheme) { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1121 | ITelecomService service = getTelecomService(); |
| 1122 | if (service != null) { |
| 1123 | try { |
| 1124 | return service.getDefaultOutgoingPhoneAccount(uriScheme, |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame] | 1125 | mContext.getOpPackageName(), mContext.getAttributionTag()); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1126 | } catch (RemoteException e) { |
| 1127 | Log.e(TAG, "Error calling ITelecomService#getDefaultOutgoingPhoneAccount", e); |
Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 1128 | } |
Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 1129 | } |
| 1130 | return null; |
| 1131 | } |
| 1132 | |
| 1133 | /** |
Andrew Lee | d4abbfb | 2014-09-03 14:58:27 -0700 | [diff] [blame] | 1134 | * Return the {@link PhoneAccount} which is the user-chosen default for making outgoing phone |
| 1135 | * 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] | 1136 | * calling {@link #getCallCapablePhoneAccounts()} |
Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 1137 | * <p> |
Andrew Lee | d4abbfb | 2014-09-03 14:58:27 -0700 | [diff] [blame] | 1138 | * Apps must be prepared for this method to return {@code null}, indicating that there currently |
| 1139 | * exists no user-chosen default {@code PhoneAccount}. |
Tyler Gunn | 36c50ed | 2018-11-15 07:29:49 -0800 | [diff] [blame] | 1140 | * <p> |
| 1141 | * The default dialer has access to use this method. |
Andrew Lee | d4abbfb | 2014-09-03 14:58:27 -0700 | [diff] [blame] | 1142 | * |
Slava Shklyaev | e65e401 | 2019-03-04 16:02:34 +0000 | [diff] [blame] | 1143 | * @return The user outgoing phone account selected by the user, or {@code null} if there is no |
| 1144 | * user selected outgoing {@link PhoneAccountHandle}. |
Andrew Lee | d4abbfb | 2014-09-03 14:58:27 -0700 | [diff] [blame] | 1145 | */ |
Tyler Gunn | 36c50ed | 2018-11-15 07:29:49 -0800 | [diff] [blame] | 1146 | @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) |
Slava Shklyaev | e65e401 | 2019-03-04 16:02:34 +0000 | [diff] [blame] | 1147 | public @Nullable PhoneAccountHandle getUserSelectedOutgoingPhoneAccount() { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1148 | ITelecomService service = getTelecomService(); |
| 1149 | if (service != null) { |
| 1150 | try { |
| 1151 | return service.getUserSelectedOutgoingPhoneAccount( |
Tyler Gunn | 36c50ed | 2018-11-15 07:29:49 -0800 | [diff] [blame] | 1152 | mContext.getOpPackageName()); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1153 | } catch (RemoteException e) { |
| 1154 | Log.e(TAG, "Error calling ITelecomService#getUserSelectedOutgoingPhoneAccount", e); |
Andrew Lee | d4abbfb | 2014-09-03 14:58:27 -0700 | [diff] [blame] | 1155 | } |
Andrew Lee | d4abbfb | 2014-09-03 14:58:27 -0700 | [diff] [blame] | 1156 | } |
| 1157 | return null; |
| 1158 | } |
| 1159 | |
| 1160 | /** |
Tyler Gunn | 36c50ed | 2018-11-15 07:29:49 -0800 | [diff] [blame] | 1161 | * Sets the user-chosen default {@link PhoneAccountHandle} for making outgoing phone calls. |
| 1162 | * |
| 1163 | * @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] | 1164 | * outgoing voice calls, or {@code null} if no default is specified (the |
| 1165 | * 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] | 1166 | * @hide |
| 1167 | */ |
Tyler Gunn | 36c50ed | 2018-11-15 07:29:49 -0800 | [diff] [blame] | 1168 | @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) |
| 1169 | @SystemApi |
Slava Shklyaev | e65e401 | 2019-03-04 16:02:34 +0000 | [diff] [blame] | 1170 | public void setUserSelectedOutgoingPhoneAccount(@Nullable PhoneAccountHandle accountHandle) { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1171 | ITelecomService service = getTelecomService(); |
| 1172 | if (service != null) { |
| 1173 | try { |
| 1174 | service.setUserSelectedOutgoingPhoneAccount(accountHandle); |
| 1175 | } catch (RemoteException e) { |
| 1176 | Log.e(TAG, "Error calling ITelecomService#setUserSelectedOutgoingPhoneAccount"); |
Andrew Lee | 59cac3a | 2014-08-28 16:50:10 -0700 | [diff] [blame] | 1177 | } |
Andrew Lee | 59cac3a | 2014-08-28 16:50:10 -0700 | [diff] [blame] | 1178 | } |
| 1179 | } |
| 1180 | |
| 1181 | /** |
Andrew Lee | 59cac3a | 2014-08-28 16:50:10 -0700 | [diff] [blame] | 1182 | * 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] | 1183 | * {@code null}, indicating that there currently exists no SIM call manager {@link PhoneAccount} |
| 1184 | * for the default voice subscription. |
Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 1185 | * |
Brad Ebinger | e783331 | 2019-05-07 10:55:55 -0700 | [diff] [blame] | 1186 | * @return The phone account handle of the current sim call manager for the default voice |
| 1187 | * subscription. |
| 1188 | * @see SubscriptionManager#getDefaultVoiceSubscriptionId() |
Andrew Lee | 59cac3a | 2014-08-28 16:50:10 -0700 | [diff] [blame] | 1189 | */ |
| 1190 | public PhoneAccountHandle getSimCallManager() { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1191 | ITelecomService service = getTelecomService(); |
| 1192 | if (service != null) { |
| 1193 | try { |
| 1194 | return service.getSimCallManager( |
Thomas Stuart | bc724ef | 2022-01-27 21:16:11 +0000 | [diff] [blame] | 1195 | SubscriptionManager.getDefaultSubscriptionId(), mContext.getPackageName()); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1196 | } catch (RemoteException e) { |
| 1197 | Log.e(TAG, "Error calling ITelecomService#getSimCallManager"); |
Andrew Lee | 59cac3a | 2014-08-28 16:50:10 -0700 | [diff] [blame] | 1198 | } |
Andrew Lee | 59cac3a | 2014-08-28 16:50:10 -0700 | [diff] [blame] | 1199 | } |
| 1200 | return null; |
| 1201 | } |
| 1202 | |
| 1203 | /** |
Brad Ebinger | e783331 | 2019-05-07 10:55:55 -0700 | [diff] [blame] | 1204 | * Returns current SIM call manager for the Telephony Subscription ID specified. Apps must be |
| 1205 | * prepared for this method to return {@code null}, indicating that there currently exists no |
| 1206 | * SIM call manager {@link PhoneAccount} for the subscription specified. |
| 1207 | * |
| 1208 | * @param subscriptionId The Telephony Subscription ID that the SIM call manager should be |
| 1209 | * queried for. |
| 1210 | * @return The phone account handle of the current sim call manager. |
| 1211 | * @see SubscriptionManager#getActiveSubscriptionInfoList() |
Brad Ebinger | e783331 | 2019-05-07 10:55:55 -0700 | [diff] [blame] | 1212 | */ |
Tyler Gunn | 00d737b | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 1213 | public @Nullable PhoneAccountHandle getSimCallManagerForSubscription(int subscriptionId) { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1214 | ITelecomService service = getTelecomService(); |
| 1215 | if (service != null) { |
| 1216 | try { |
Thomas Stuart | bc724ef | 2022-01-27 21:16:11 +0000 | [diff] [blame] | 1217 | return service.getSimCallManager(subscriptionId, mContext.getPackageName()); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1218 | } catch (RemoteException e) { |
| 1219 | Log.e(TAG, "Error calling ITelecomService#getSimCallManager"); |
Brad Ebinger | e783331 | 2019-05-07 10:55:55 -0700 | [diff] [blame] | 1220 | } |
Brad Ebinger | e783331 | 2019-05-07 10:55:55 -0700 | [diff] [blame] | 1221 | } |
| 1222 | return null; |
| 1223 | } |
| 1224 | |
| 1225 | /** |
| 1226 | * Returns the current SIM call manager for the user-chosen default Telephony Subscription ID |
| 1227 | * (see {@link SubscriptionManager#getDefaultSubscriptionId()}) and the specified user. Apps |
| 1228 | * must be prepared for this method to return {@code null}, indicating that there currently |
| 1229 | * exists no SIM call manager {@link PhoneAccount} for the default voice subscription. |
Sailesh Nepal | cf85562 | 2015-07-28 19:22:14 -0700 | [diff] [blame] | 1230 | * |
| 1231 | * @return The phone account handle of the current sim call manager. |
| 1232 | * |
| 1233 | * @hide |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 1234 | * @deprecated Use {@link #getSimCallManager()}. |
Sailesh Nepal | cf85562 | 2015-07-28 19:22:14 -0700 | [diff] [blame] | 1235 | */ |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 1236 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 119305590) |
Sailesh Nepal | cf85562 | 2015-07-28 19:22:14 -0700 | [diff] [blame] | 1237 | public PhoneAccountHandle getSimCallManager(int userId) { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1238 | ITelecomService service = getTelecomService(); |
| 1239 | if (service != null) { |
| 1240 | try { |
Thomas Stuart | bc724ef | 2022-01-27 21:16:11 +0000 | [diff] [blame] | 1241 | return service.getSimCallManagerForUser(userId, mContext.getPackageName()); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1242 | } catch (RemoteException e) { |
| 1243 | Log.e(TAG, "Error calling ITelecomService#getSimCallManagerForUser"); |
Sailesh Nepal | cf85562 | 2015-07-28 19:22:14 -0700 | [diff] [blame] | 1244 | } |
Sailesh Nepal | cf85562 | 2015-07-28 19:22:14 -0700 | [diff] [blame] | 1245 | } |
| 1246 | return null; |
| 1247 | } |
| 1248 | |
| 1249 | /** |
Evan Charlton | eb0a8d56 | 2014-09-04 12:03:34 -0700 | [diff] [blame] | 1250 | * 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] | 1251 | * {@code null}, indicating that there currently exists no Connection Manager |
| 1252 | * {@link PhoneAccount} for the default voice subscription. |
Evan Charlton | eb0a8d56 | 2014-09-04 12:03:34 -0700 | [diff] [blame] | 1253 | * |
| 1254 | * @return The phone account handle of the current connection manager. |
Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 1255 | * @hide |
Evan Charlton | eb0a8d56 | 2014-09-04 12:03:34 -0700 | [diff] [blame] | 1256 | */ |
Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 1257 | @SystemApi |
Evan Charlton | eb0a8d56 | 2014-09-04 12:03:34 -0700 | [diff] [blame] | 1258 | public PhoneAccountHandle getConnectionManager() { |
| 1259 | return getSimCallManager(); |
| 1260 | } |
| 1261 | |
| 1262 | /** |
Nancy Chen | 210ef03 | 2014-09-15 17:58:42 -0700 | [diff] [blame] | 1263 | * Returns a list of the {@link PhoneAccountHandle}s which can be used to make and receive phone |
| 1264 | * calls which support the specified URI scheme. |
Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 1265 | * <P> |
| 1266 | * For example, invoking with {@code "tel"} will find all {@link PhoneAccountHandle}s which |
| 1267 | * support telephone calls (e.g. URIs such as {@code tel:555-555-1212}). Invoking with |
| 1268 | * {@code "sip"} will find all {@link PhoneAccountHandle}s which support SIP calls (e.g. URIs |
| 1269 | * such as {@code sip:example@sipexample.com}). |
| 1270 | * |
| 1271 | * @param uriScheme The URI scheme. |
| 1272 | * @return A list of {@code PhoneAccountHandle} objects supporting the URI scheme. |
Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 1273 | * @hide |
Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 1274 | */ |
Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 1275 | @SystemApi |
Jeff Sharkey | bfc4fcd | 2017-06-05 17:38:17 -0600 | [diff] [blame] | 1276 | @RequiresPermission(anyOf = { |
Tyler Gunn | 00d737b | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 1277 | READ_PRIVILEGED_PHONE_STATE, |
Jeff Sharkey | bfc4fcd | 2017-06-05 17:38:17 -0600 | [diff] [blame] | 1278 | android.Manifest.permission.READ_PHONE_STATE |
| 1279 | }) |
Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 1280 | public List<PhoneAccountHandle> getPhoneAccountsSupportingScheme(String uriScheme) { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1281 | ITelecomService service = getTelecomService(); |
| 1282 | if (service != null) { |
| 1283 | try { |
| 1284 | return service.getPhoneAccountsSupportingScheme(uriScheme, |
Thomas Stuart | 81fe8f3 | 2022-06-23 14:27:43 -0700 | [diff] [blame] | 1285 | mContext.getOpPackageName()).getList(); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1286 | } catch (RemoteException e) { |
| 1287 | Log.e(TAG, "Error calling ITelecomService#getPhoneAccountsSupportingScheme", e); |
Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 1288 | } |
Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 1289 | } |
| 1290 | return new ArrayList<>(); |
| 1291 | } |
| 1292 | |
Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 1293 | |
| 1294 | /** |
Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 1295 | * Returns a list of {@link PhoneAccountHandle}s which can be used to make and receive phone |
| 1296 | * calls. The returned list includes only those accounts which have been explicitly enabled |
| 1297 | * by the user. |
Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 1298 | * |
| 1299 | * @see #EXTRA_PHONE_ACCOUNT_HANDLE |
| 1300 | * @return A list of {@code PhoneAccountHandle} objects. |
Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 1301 | */ |
Yorke Lee | c61d1366 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 1302 | @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) |
Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 1303 | public List<PhoneAccountHandle> getCallCapablePhoneAccounts() { |
Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 1304 | return getCallCapablePhoneAccounts(false); |
| 1305 | } |
| 1306 | |
| 1307 | /** |
Thomas Stuart | 510f49a | 2022-01-28 23:06:57 +0000 | [diff] [blame] | 1308 | * Returns a list of {@link PhoneAccountHandle}s for all self-managed |
| 1309 | * {@link ConnectionService}s owned by the calling {@link UserHandle}. |
Tyler Gunn | 8931707 | 2017-04-07 14:57:37 -0700 | [diff] [blame] | 1310 | * <p> |
| 1311 | * Self-Managed {@link ConnectionService}s have a {@link PhoneAccount} with |
| 1312 | * {@link PhoneAccount#CAPABILITY_SELF_MANAGED}. |
| 1313 | * <p> |
| 1314 | * Requires permission {@link android.Manifest.permission#READ_PHONE_STATE}, or that the caller |
Thomas Stuart | 510f49a | 2022-01-28 23:06:57 +0000 | [diff] [blame] | 1315 | * is the default dialer app. |
Tyler Gunn | 8931707 | 2017-04-07 14:57:37 -0700 | [diff] [blame] | 1316 | * <p> |
Thomas Stuart | 510f49a | 2022-01-28 23:06:57 +0000 | [diff] [blame] | 1317 | * A {@link SecurityException} will be thrown if a called is not the default dialer, or lacks |
| 1318 | * the {@link android.Manifest.permission#READ_PHONE_STATE} permission. |
Tyler Gunn | 8931707 | 2017-04-07 14:57:37 -0700 | [diff] [blame] | 1319 | * |
| 1320 | * @return A list of {@code PhoneAccountHandle} objects. |
| 1321 | */ |
Thomas Stuart | 510f49a | 2022-01-28 23:06:57 +0000 | [diff] [blame] | 1322 | @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) |
| 1323 | public @NonNull List<PhoneAccountHandle> getSelfManagedPhoneAccounts() { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1324 | ITelecomService service = getTelecomService(); |
| 1325 | if (service != null) { |
| 1326 | try { |
| 1327 | return service.getSelfManagedPhoneAccounts(mContext.getOpPackageName(), |
Thomas Stuart | 81fe8f3 | 2022-06-23 14:27:43 -0700 | [diff] [blame] | 1328 | mContext.getAttributionTag()).getList(); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1329 | } catch (RemoteException e) { |
| 1330 | Log.e(TAG, "Error calling ITelecomService#getSelfManagedPhoneAccounts()", e); |
Tyler Gunn | 8931707 | 2017-04-07 14:57:37 -0700 | [diff] [blame] | 1331 | } |
Tyler Gunn | 8931707 | 2017-04-07 14:57:37 -0700 | [diff] [blame] | 1332 | } |
| 1333 | return new ArrayList<>(); |
| 1334 | } |
| 1335 | |
| 1336 | /** |
Thomas Stuart | 510f49a | 2022-01-28 23:06:57 +0000 | [diff] [blame] | 1337 | * Returns a list of {@link PhoneAccountHandle}s owned by the calling self-managed |
| 1338 | * {@link ConnectionService}. |
| 1339 | * <p> |
| 1340 | * Self-Managed {@link ConnectionService}s have a {@link PhoneAccount} with |
| 1341 | * {@link PhoneAccount#CAPABILITY_SELF_MANAGED}. |
| 1342 | * <p> |
| 1343 | * Requires permission {@link android.Manifest.permission#MANAGE_OWN_CALLS} |
| 1344 | * <p> |
| 1345 | * A {@link SecurityException} will be thrown if a caller lacks the |
| 1346 | * {@link android.Manifest.permission#MANAGE_OWN_CALLS} permission. |
| 1347 | * |
| 1348 | * @return A list of {@code PhoneAccountHandle} objects. |
| 1349 | */ |
| 1350 | @RequiresPermission(Manifest.permission.MANAGE_OWN_CALLS) |
| 1351 | public @NonNull List<PhoneAccountHandle> getOwnSelfManagedPhoneAccounts() { |
| 1352 | ITelecomService service = getTelecomService(); |
| 1353 | if (service != null) { |
| 1354 | try { |
| 1355 | return service.getOwnSelfManagedPhoneAccounts(mContext.getOpPackageName(), |
Thomas Stuart | 81fe8f3 | 2022-06-23 14:27:43 -0700 | [diff] [blame] | 1356 | mContext.getAttributionTag()).getList(); |
Thomas Stuart | 510f49a | 2022-01-28 23:06:57 +0000 | [diff] [blame] | 1357 | } catch (RemoteException e) { |
| 1358 | throw e.rethrowFromSystemServer(); |
| 1359 | } |
| 1360 | } |
| 1361 | throw new IllegalStateException("Telecom is not available"); |
| 1362 | } |
| 1363 | |
| 1364 | /** |
Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 1365 | * Returns a list of {@link PhoneAccountHandle}s including those which have not been enabled |
| 1366 | * by the user. |
| 1367 | * |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 1368 | * @param includeDisabledAccounts When {@code true}, disabled phone accounts will be included, |
Hall Liu | b230624 | 2019-11-15 17:13:05 -0800 | [diff] [blame] | 1369 | * when {@code false}, only enabled phone accounts will be |
| 1370 | * included. |
Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 1371 | * @return A list of {@code PhoneAccountHandle} objects. |
| 1372 | * @hide |
| 1373 | */ |
Hall Liu | b230624 | 2019-11-15 17:13:05 -0800 | [diff] [blame] | 1374 | @SystemApi |
Hall Liu | b230624 | 2019-11-15 17:13:05 -0800 | [diff] [blame] | 1375 | @RequiresPermission(READ_PRIVILEGED_PHONE_STATE) |
| 1376 | public @NonNull List<PhoneAccountHandle> getCallCapablePhoneAccounts( |
| 1377 | boolean includeDisabledAccounts) { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1378 | ITelecomService service = getTelecomService(); |
| 1379 | if (service != null) { |
| 1380 | try { |
| 1381 | return service.getCallCapablePhoneAccounts(includeDisabledAccounts, |
Thomas Stuart | 81fe8f3 | 2022-06-23 14:27:43 -0700 | [diff] [blame] | 1382 | mContext.getOpPackageName(), mContext.getAttributionTag()).getList(); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1383 | } catch (RemoteException e) { |
| 1384 | Log.e(TAG, "Error calling ITelecomService#getCallCapablePhoneAccounts(" |
| 1385 | + includeDisabledAccounts + ")", e); |
Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 1386 | } |
Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 1387 | } |
| 1388 | return new ArrayList<>(); |
| 1389 | } |
| 1390 | |
Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 1391 | /** |
Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 1392 | * Returns a list of all {@link PhoneAccount}s registered for the calling package. |
| 1393 | * |
Grace Jia | 0128b3c | 2020-06-23 12:53:17 -0700 | [diff] [blame] | 1394 | * @deprecated Use {@link #getSelfManagedPhoneAccounts()} instead to get only self-managed |
| 1395 | * {@link PhoneAccountHandle} for the calling package. |
Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 1396 | * @return A list of {@code PhoneAccountHandle} objects. |
Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 1397 | * @hide |
Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 1398 | */ |
Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 1399 | @SystemApi |
Aurimas Liutikas | 1394a01 | 2020-11-12 18:26:09 -0800 | [diff] [blame] | 1400 | @SuppressLint("RequiresPermission") |
Grace Jia | 0128b3c | 2020-06-23 12:53:17 -0700 | [diff] [blame] | 1401 | @Deprecated |
Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 1402 | public List<PhoneAccountHandle> getPhoneAccountsForPackage() { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1403 | ITelecomService service = getTelecomService(); |
| 1404 | if (service != null) { |
| 1405 | try { |
Thomas Stuart | 81fe8f3 | 2022-06-23 14:27:43 -0700 | [diff] [blame] | 1406 | return service.getPhoneAccountsForPackage(mContext.getPackageName()).getList(); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1407 | } catch (RemoteException e) { |
| 1408 | Log.e(TAG, "Error calling ITelecomService#getPhoneAccountsForPackage", e); |
Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 1409 | } |
Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 1410 | } |
| 1411 | return null; |
| 1412 | } |
| 1413 | |
| 1414 | /** |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 1415 | * Return the {@link PhoneAccount} for a specified {@link PhoneAccountHandle}. Object includes |
| 1416 | * resources which can be used in a user interface. |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1417 | * |
Grace Jia | b13eb2c | 2021-04-21 14:13:26 -0700 | [diff] [blame] | 1418 | * Requires Permission: |
| 1419 | * {@link android.Manifest.permission#READ_PHONE_NUMBERS} for applications targeting API |
| 1420 | * level 31+. |
Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 1421 | * @param account The {@link PhoneAccountHandle}. |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 1422 | * @return The {@link PhoneAccount} object. |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1423 | */ |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 1424 | public PhoneAccount getPhoneAccount(PhoneAccountHandle account) { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1425 | ITelecomService service = getTelecomService(); |
| 1426 | if (service != null) { |
| 1427 | try { |
Grace Jia | b13eb2c | 2021-04-21 14:13:26 -0700 | [diff] [blame] | 1428 | return service.getPhoneAccount(account, mContext.getPackageName()); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1429 | } catch (RemoteException e) { |
| 1430 | Log.e(TAG, "Error calling ITelecomService#getPhoneAccount", e); |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1431 | } |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1432 | } |
| 1433 | return null; |
| 1434 | } |
| 1435 | |
| 1436 | /** |
Nancy Chen | 210ef03 | 2014-09-15 17:58:42 -0700 | [diff] [blame] | 1437 | * Returns a count of all {@link PhoneAccount}s. |
Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 1438 | * |
Nancy Chen | 210ef03 | 2014-09-15 17:58:42 -0700 | [diff] [blame] | 1439 | * @return The count of {@link PhoneAccount}s. |
Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 1440 | * @hide |
| 1441 | */ |
| 1442 | @SystemApi |
| 1443 | public int getAllPhoneAccountsCount() { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1444 | ITelecomService service = getTelecomService(); |
| 1445 | if (service != null) { |
| 1446 | try { |
| 1447 | return service.getAllPhoneAccountsCount(); |
| 1448 | } catch (RemoteException e) { |
| 1449 | Log.e(TAG, "Error calling ITelecomService#getAllPhoneAccountsCount", e); |
Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 1450 | } |
Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 1451 | } |
| 1452 | return 0; |
| 1453 | } |
| 1454 | |
| 1455 | /** |
| 1456 | * Returns a list of all {@link PhoneAccount}s. |
| 1457 | * |
| 1458 | * @return All {@link PhoneAccount}s. |
| 1459 | * @hide |
| 1460 | */ |
| 1461 | @SystemApi |
| 1462 | public List<PhoneAccount> getAllPhoneAccounts() { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1463 | ITelecomService service = getTelecomService(); |
| 1464 | if (service != null) { |
| 1465 | try { |
Thomas Stuart | 81fe8f3 | 2022-06-23 14:27:43 -0700 | [diff] [blame] | 1466 | return service.getAllPhoneAccounts().getList(); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1467 | } catch (RemoteException e) { |
| 1468 | Log.e(TAG, "Error calling ITelecomService#getAllPhoneAccounts", e); |
Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 1469 | } |
Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 1470 | } |
| 1471 | return Collections.EMPTY_LIST; |
| 1472 | } |
| 1473 | |
| 1474 | /** |
| 1475 | * Returns a list of all {@link PhoneAccountHandle}s. |
| 1476 | * |
| 1477 | * @return All {@link PhoneAccountHandle}s. |
| 1478 | * @hide |
| 1479 | */ |
| 1480 | @SystemApi |
| 1481 | public List<PhoneAccountHandle> getAllPhoneAccountHandles() { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1482 | ITelecomService service = getTelecomService(); |
| 1483 | if (service != null) { |
| 1484 | try { |
Thomas Stuart | 81fe8f3 | 2022-06-23 14:27:43 -0700 | [diff] [blame] | 1485 | return service.getAllPhoneAccountHandles().getList(); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1486 | } catch (RemoteException e) { |
| 1487 | Log.e(TAG, "Error calling ITelecomService#getAllPhoneAccountHandles", e); |
Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 1488 | } |
Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 1489 | } |
| 1490 | return Collections.EMPTY_LIST; |
| 1491 | } |
| 1492 | |
| 1493 | /** |
Brad Ebinger | ec0d334 | 2016-01-29 15:40:43 -0800 | [diff] [blame] | 1494 | * Register a {@link PhoneAccount} for use by the system that will be stored in Device Encrypted |
| 1495 | * storage. When registering {@link PhoneAccount}s, existing registrations will be overwritten |
| 1496 | * 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] | 1497 | * registered. Once registered, the {@link PhoneAccount} is listed to the user as an option |
| 1498 | * when placing calls. The user may still need to enable the {@link PhoneAccount} within |
| 1499 | * the phone app settings before the account is usable. |
| 1500 | * <p> |
Thomas Stuart | e041621 | 2022-01-31 20:31:42 +0000 | [diff] [blame] | 1501 | * Note: Each package is limited to 10 {@link PhoneAccount} registrations. |
| 1502 | * <p> |
Santos Cordon | d9e614f | 2014-10-28 13:10:36 -0700 | [diff] [blame] | 1503 | * A {@link SecurityException} will be thrown if an app tries to register a |
| 1504 | * {@link PhoneAccountHandle} where the package name specified within |
| 1505 | * {@link PhoneAccountHandle#getComponentName()} does not match the package name of the app. |
Thomas Stuart | e041621 | 2022-01-31 20:31:42 +0000 | [diff] [blame] | 1506 | * <p> |
| 1507 | * A {@link IllegalArgumentException} will be thrown if an app tries to register a |
| 1508 | * {@link PhoneAccount} when the upper bound limit, 10, has already been reached. |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1509 | * |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 1510 | * @param account The complete {@link PhoneAccount}. |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1511 | */ |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 1512 | public void registerPhoneAccount(PhoneAccount account) { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1513 | ITelecomService service = getTelecomService(); |
| 1514 | if (service != null) { |
| 1515 | try { |
Thomas Stuart | bc724ef | 2022-01-27 21:16:11 +0000 | [diff] [blame] | 1516 | service.registerPhoneAccount(account, mContext.getPackageName()); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1517 | } catch (RemoteException e) { |
| 1518 | Log.e(TAG, "Error calling ITelecomService#registerPhoneAccount", e); |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1519 | } |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1520 | } |
| 1521 | } |
| 1522 | |
| 1523 | /** |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 1524 | * Remove a {@link PhoneAccount} registration from the system. |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1525 | * |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 1526 | * @param accountHandle A {@link PhoneAccountHandle} for the {@link PhoneAccount} to unregister. |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1527 | */ |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 1528 | public void unregisterPhoneAccount(PhoneAccountHandle accountHandle) { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1529 | ITelecomService service = getTelecomService(); |
| 1530 | if (service != null) { |
| 1531 | try { |
Thomas Stuart | bc724ef | 2022-01-27 21:16:11 +0000 | [diff] [blame] | 1532 | service.unregisterPhoneAccount(accountHandle, mContext.getPackageName()); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1533 | } catch (RemoteException e) { |
| 1534 | Log.e(TAG, "Error calling ITelecomService#unregisterPhoneAccount", e); |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1535 | } |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1536 | } |
| 1537 | } |
| 1538 | |
| 1539 | /** |
Nancy Chen | 7ab1dc4 | 2014-09-09 18:18:26 -0700 | [diff] [blame] | 1540 | * Remove all Accounts that belong to the calling package from the system. |
Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 1541 | * @hide |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1542 | */ |
Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 1543 | @SystemApi |
Aurimas Liutikas | 1394a01 | 2020-11-12 18:26:09 -0800 | [diff] [blame] | 1544 | @SuppressLint("RequiresPermission") |
Yorke Lee | 0604427 | 2015-04-14 15:16:59 -0700 | [diff] [blame] | 1545 | public void clearPhoneAccounts() { |
| 1546 | clearAccounts(); |
| 1547 | } |
| 1548 | /** |
| 1549 | * Remove all Accounts that belong to the calling package from the system. |
| 1550 | * @deprecated Use {@link #clearPhoneAccounts()} instead. |
| 1551 | * @hide |
| 1552 | */ |
| 1553 | @SystemApi |
Aurimas Liutikas | 1394a01 | 2020-11-12 18:26:09 -0800 | [diff] [blame] | 1554 | @SuppressLint("RequiresPermission") |
Nancy Chen | 7ab1dc4 | 2014-09-09 18:18:26 -0700 | [diff] [blame] | 1555 | public void clearAccounts() { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1556 | ITelecomService service = getTelecomService(); |
| 1557 | if (service != null) { |
| 1558 | try { |
| 1559 | service.clearAccounts(mContext.getPackageName()); |
| 1560 | } catch (RemoteException e) { |
| 1561 | Log.e(TAG, "Error calling ITelecomService#clearAccounts", e); |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1562 | } |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1563 | } |
| 1564 | } |
| 1565 | |
| 1566 | /** |
Anthony Lee | 6727926 | 2014-10-27 11:28:40 -0700 | [diff] [blame] | 1567 | * Remove all Accounts that belong to the specified package from the system. |
| 1568 | * @hide |
| 1569 | */ |
| 1570 | public void clearAccountsForPackage(String packageName) { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1571 | ITelecomService service = getTelecomService(); |
| 1572 | if (service != null) { |
| 1573 | try { |
| 1574 | if (!TextUtils.isEmpty(packageName)) { |
| 1575 | service.clearAccounts(packageName); |
| 1576 | } |
| 1577 | } catch (RemoteException e) { |
| 1578 | Log.e(TAG, "Error calling ITelecomService#clearAccountsForPackage", e); |
Anthony Lee | 6727926 | 2014-10-27 11:28:40 -0700 | [diff] [blame] | 1579 | } |
Anthony Lee | 6727926 | 2014-10-27 11:28:40 -0700 | [diff] [blame] | 1580 | } |
| 1581 | } |
| 1582 | |
Yorke Lee | 1011f48 | 2015-04-23 15:58:27 -0700 | [diff] [blame] | 1583 | |
Anthony Lee | 6727926 | 2014-10-27 11:28:40 -0700 | [diff] [blame] | 1584 | /** |
Yorke Lee | 1011f48 | 2015-04-23 15:58:27 -0700 | [diff] [blame] | 1585 | * @deprecated - Use {@link TelecomManager#getDefaultDialerPackage} to directly access |
| 1586 | * the default dialer's package name instead. |
Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1587 | * @hide |
| 1588 | */ |
Santos Cordon | 6c7a388 | 2014-06-25 15:30:08 -0700 | [diff] [blame] | 1589 | @SystemApi |
Aurimas Liutikas | 1394a01 | 2020-11-12 18:26:09 -0800 | [diff] [blame] | 1590 | @SuppressLint("RequiresPermission") |
Santos Cordon | 6c7a388 | 2014-06-25 15:30:08 -0700 | [diff] [blame] | 1591 | public ComponentName getDefaultPhoneApp() { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1592 | ITelecomService service = getTelecomService(); |
| 1593 | if (service != null) { |
| 1594 | try { |
| 1595 | return service.getDefaultPhoneApp(); |
| 1596 | } catch (RemoteException e) { |
| 1597 | Log.e(TAG, "RemoteException attempting to get the default phone app.", e); |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1598 | } |
Santos Cordon | 6c7a388 | 2014-06-25 15:30:08 -0700 | [diff] [blame] | 1599 | } |
| 1600 | return null; |
| 1601 | } |
| 1602 | |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1603 | /** |
Yorke Lee | 1011f48 | 2015-04-23 15:58:27 -0700 | [diff] [blame] | 1604 | * Used to determine the currently selected default dialer package. |
| 1605 | * |
| 1606 | * @return package name for the default dialer package or null if no package has been |
| 1607 | * selected as the default dialer. |
| 1608 | */ |
| 1609 | public String getDefaultDialerPackage() { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1610 | ITelecomService service = getTelecomService(); |
| 1611 | if (service != null) { |
| 1612 | try { |
Thomas Stuart | bc724ef | 2022-01-27 21:16:11 +0000 | [diff] [blame] | 1613 | return service.getDefaultDialerPackage(mContext.getPackageName()); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1614 | } catch (RemoteException e) { |
| 1615 | Log.e(TAG, "RemoteException attempting to get the default dialer package name.", e); |
Yorke Lee | 1011f48 | 2015-04-23 15:58:27 -0700 | [diff] [blame] | 1616 | } |
Yorke Lee | 1011f48 | 2015-04-23 15:58:27 -0700 | [diff] [blame] | 1617 | } |
| 1618 | return null; |
| 1619 | } |
| 1620 | |
| 1621 | /** |
Tyler Gunn | 00d737b | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 1622 | * Used to determine the currently selected default dialer package for a specific user. |
| 1623 | * |
Tyler Gunn | 754493b | 2020-01-27 10:30:51 -0800 | [diff] [blame] | 1624 | * @param userHandle the user id to query the default dialer package for. |
Tyler Gunn | 00d737b | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 1625 | * @return package name for the default dialer package or null if no package has been |
| 1626 | * selected as the default dialer. |
| 1627 | * @hide |
| 1628 | */ |
| 1629 | @SystemApi |
Tyler Gunn | 00d737b | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 1630 | @RequiresPermission(READ_PRIVILEGED_PHONE_STATE) |
Tyler Gunn | 754493b | 2020-01-27 10:30:51 -0800 | [diff] [blame] | 1631 | public @Nullable String getDefaultDialerPackage(@NonNull UserHandle userHandle) { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1632 | ITelecomService service = getTelecomService(); |
| 1633 | if (service != null) { |
| 1634 | try { |
| 1635 | return service.getDefaultDialerPackageForUser( |
Tyler Gunn | 754493b | 2020-01-27 10:30:51 -0800 | [diff] [blame] | 1636 | userHandle.getIdentifier()); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1637 | } catch (RemoteException e) { |
| 1638 | Log.e(TAG, "RemoteException attempting to get the default dialer package name.", e); |
Tyler Gunn | 00d737b | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 1639 | } |
Tyler Gunn | 00d737b | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 1640 | } |
| 1641 | return null; |
| 1642 | } |
| 1643 | |
| 1644 | /** |
Yorke Lee | 107c4ce | 2015-06-15 12:08:24 -0700 | [diff] [blame] | 1645 | * Used to set the default dialer package. |
| 1646 | * |
Slava Shklyaev | e65e401 | 2019-03-04 16:02:34 +0000 | [diff] [blame] | 1647 | * @param packageName to set the default dialer to, or {@code null} if the system provided |
| 1648 | * dialer should be used instead. |
Yorke Lee | 107c4ce | 2015-06-15 12:08:24 -0700 | [diff] [blame] | 1649 | * |
| 1650 | * @result {@code true} if the default dialer was successfully changed, {@code false} if |
| 1651 | * the specified package does not correspond to an installed dialer, or is already |
| 1652 | * the default dialer. |
| 1653 | * |
Yorke Lee | 107c4ce | 2015-06-15 12:08:24 -0700 | [diff] [blame] | 1654 | * @hide |
Tyler Gunn | 7e45b72 | 2018-12-04 12:56:45 -0800 | [diff] [blame] | 1655 | * @deprecated Use |
Hai Zhang | f5e8ccd | 2019-03-06 20:12:24 -0800 | [diff] [blame] | 1656 | * {@link android.app.role.RoleManager#addRoleHolderAsUser(String, String, int, UserHandle, |
| 1657 | * Executor, java.util.function.Consumer)} instead. |
Suprabh Shukla | 169bed7 | 2019-05-13 13:54:58 -0700 | [diff] [blame] | 1658 | * @removed |
Yorke Lee | 107c4ce | 2015-06-15 12:08:24 -0700 | [diff] [blame] | 1659 | */ |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 1660 | @SystemApi |
Tyler Gunn | 7e45b72 | 2018-12-04 12:56:45 -0800 | [diff] [blame] | 1661 | @Deprecated |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 1662 | @RequiresPermission(allOf = { |
| 1663 | android.Manifest.permission.MODIFY_PHONE_STATE, |
| 1664 | android.Manifest.permission.WRITE_SECURE_SETTINGS}) |
Slava Shklyaev | e65e401 | 2019-03-04 16:02:34 +0000 | [diff] [blame] | 1665 | public boolean setDefaultDialer(@Nullable String packageName) { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1666 | ITelecomService service = getTelecomService(); |
| 1667 | if (service != null) { |
| 1668 | try { |
| 1669 | return service.setDefaultDialer(packageName); |
| 1670 | } catch (RemoteException e) { |
| 1671 | Log.e(TAG, "RemoteException attempting to set the default dialer.", e); |
Yorke Lee | 107c4ce | 2015-06-15 12:08:24 -0700 | [diff] [blame] | 1672 | } |
Yorke Lee | 107c4ce | 2015-06-15 12:08:24 -0700 | [diff] [blame] | 1673 | } |
| 1674 | return false; |
| 1675 | } |
| 1676 | |
| 1677 | /** |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 1678 | * Determines the package name of the system-provided default phone app. |
Yorke Lee | 1011f48 | 2015-04-23 15:58:27 -0700 | [diff] [blame] | 1679 | * |
Slava Shklyaev | e65e401 | 2019-03-04 16:02:34 +0000 | [diff] [blame] | 1680 | * @return package name for the system dialer package or {@code null} if no system dialer is |
| 1681 | * preloaded. |
Yorke Lee | 1011f48 | 2015-04-23 15:58:27 -0700 | [diff] [blame] | 1682 | */ |
Slava Shklyaev | e65e401 | 2019-03-04 16:02:34 +0000 | [diff] [blame] | 1683 | public @Nullable String getSystemDialerPackage() { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1684 | ITelecomService service = getTelecomService(); |
| 1685 | if (service != null) { |
| 1686 | try { |
Thomas Stuart | bc724ef | 2022-01-27 21:16:11 +0000 | [diff] [blame] | 1687 | return service.getSystemDialerPackage(mContext.getPackageName()); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1688 | } catch (RemoteException e) { |
| 1689 | Log.e(TAG, "RemoteException attempting to get the system dialer package name.", e); |
Yorke Lee | 1011f48 | 2015-04-23 15:58:27 -0700 | [diff] [blame] | 1690 | } |
Yorke Lee | 1011f48 | 2015-04-23 15:58:27 -0700 | [diff] [blame] | 1691 | } |
| 1692 | return null; |
| 1693 | } |
| 1694 | |
| 1695 | /** |
Nancy Chen | 443e501 | 2014-10-15 15:48:21 -0700 | [diff] [blame] | 1696 | * Return whether a given phone number is the configured voicemail number for a |
| 1697 | * particular phone account. |
| 1698 | * |
| 1699 | * @param accountHandle The handle for the account to check the voicemail number against |
| 1700 | * @param number The number to look up. |
Nancy Chen | 443e501 | 2014-10-15 15:48:21 -0700 | [diff] [blame] | 1701 | */ |
Yorke Lee | c61d1366 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 1702 | @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) |
Nancy Chen | 443e501 | 2014-10-15 15:48:21 -0700 | [diff] [blame] | 1703 | public boolean isVoiceMailNumber(PhoneAccountHandle accountHandle, String number) { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1704 | ITelecomService service = getTelecomService(); |
| 1705 | if (service != null) { |
| 1706 | try { |
| 1707 | return service.isVoiceMailNumber(accountHandle, number, |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame] | 1708 | mContext.getOpPackageName(), mContext.getAttributionTag()); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1709 | } catch (RemoteException e) { |
| 1710 | Log.e(TAG, "RemoteException calling ITelecomService#isVoiceMailNumber.", e); |
Nancy Chen | 443e501 | 2014-10-15 15:48:21 -0700 | [diff] [blame] | 1711 | } |
Nancy Chen | 443e501 | 2014-10-15 15:48:21 -0700 | [diff] [blame] | 1712 | } |
| 1713 | return false; |
| 1714 | } |
| 1715 | |
| 1716 | /** |
Yorke Lee | 49e2d46 | 2015-04-15 16:14:22 -0700 | [diff] [blame] | 1717 | * Return the voicemail number for a given phone account. |
Nancy Chen | 8c066f7c | 2014-12-03 15:18:08 -0800 | [diff] [blame] | 1718 | * |
Yorke Lee | 49e2d46 | 2015-04-15 16:14:22 -0700 | [diff] [blame] | 1719 | * @param accountHandle The handle for the phone account. |
| 1720 | * @return The voicemail number for the phone account, and {@code null} if one has not been |
| 1721 | * configured. |
Nancy Chen | 8c066f7c | 2014-12-03 15:18:08 -0800 | [diff] [blame] | 1722 | */ |
Yorke Lee | c61d1366 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 1723 | @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) |
Yorke Lee | 49e2d46 | 2015-04-15 16:14:22 -0700 | [diff] [blame] | 1724 | public String getVoiceMailNumber(PhoneAccountHandle accountHandle) { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1725 | ITelecomService service = getTelecomService(); |
| 1726 | if (service != null) { |
| 1727 | try { |
| 1728 | return service.getVoiceMailNumber(accountHandle, |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame] | 1729 | mContext.getOpPackageName(), mContext.getAttributionTag()); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1730 | } catch (RemoteException e) { |
| 1731 | Log.e(TAG, "RemoteException calling ITelecomService#hasVoiceMailNumber.", e); |
Nancy Chen | 8c066f7c | 2014-12-03 15:18:08 -0800 | [diff] [blame] | 1732 | } |
Nancy Chen | 8c066f7c | 2014-12-03 15:18:08 -0800 | [diff] [blame] | 1733 | } |
Yorke Lee | 49e2d46 | 2015-04-15 16:14:22 -0700 | [diff] [blame] | 1734 | return null; |
Nancy Chen | 8c066f7c | 2014-12-03 15:18:08 -0800 | [diff] [blame] | 1735 | } |
| 1736 | |
| 1737 | /** |
Nancy Chen | 5cf2784 | 2015-01-24 23:30:27 -0800 | [diff] [blame] | 1738 | * Return the line 1 phone number for given phone account. |
| 1739 | * |
Michael Groover | 08490f1 | 2020-03-24 14:08:14 -0700 | [diff] [blame] | 1740 | * <p>Requires Permission: |
| 1741 | * {@link android.Manifest.permission#READ_SMS READ_SMS}, |
| 1742 | * {@link android.Manifest.permission#READ_PHONE_NUMBERS READ_PHONE_NUMBERS}, |
| 1743 | * or that the caller is the default SMS app for any API level. |
| 1744 | * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} |
| 1745 | * for apps targeting SDK API level 29 and below. |
Yorke Lee | c61d1366 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 1746 | * |
Nancy Chen | 5cf2784 | 2015-01-24 23:30:27 -0800 | [diff] [blame] | 1747 | * @param accountHandle The handle for the account retrieve a number for. |
| 1748 | * @return A string representation of the line 1 phone number. |
Meng Wang | 8665b51 | 2021-11-18 15:13:43 -0800 | [diff] [blame] | 1749 | * @deprecated use {@link SubscriptionManager#getPhoneNumber(int)} instead, which takes a |
| 1750 | * Telephony Subscription ID that can be retrieved with the {@code accountHandle} |
| 1751 | * from {@link TelephonyManager#getSubscriptionId(PhoneAccountHandle)}. |
Nancy Chen | 5cf2784 | 2015-01-24 23:30:27 -0800 | [diff] [blame] | 1752 | */ |
Meng Wang | 8665b51 | 2021-11-18 15:13:43 -0800 | [diff] [blame] | 1753 | @Deprecated |
Michael Groover | 08490f1 | 2020-03-24 14:08:14 -0700 | [diff] [blame] | 1754 | @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges or default SMS app |
| 1755 | @RequiresPermission(anyOf = { |
| 1756 | android.Manifest.permission.READ_PHONE_STATE, |
| 1757 | android.Manifest.permission.READ_SMS, |
| 1758 | android.Manifest.permission.READ_PHONE_NUMBERS |
| 1759 | }, conditional = true) |
Nancy Chen | 5cf2784 | 2015-01-24 23:30:27 -0800 | [diff] [blame] | 1760 | public String getLine1Number(PhoneAccountHandle accountHandle) { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1761 | ITelecomService service = getTelecomService(); |
| 1762 | if (service != null) { |
| 1763 | try { |
| 1764 | return service.getLine1Number(accountHandle, |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame] | 1765 | mContext.getOpPackageName(), mContext.getAttributionTag()); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1766 | } catch (RemoteException e) { |
| 1767 | Log.e(TAG, "RemoteException calling ITelecomService#getLine1Number.", e); |
Nancy Chen | 5cf2784 | 2015-01-24 23:30:27 -0800 | [diff] [blame] | 1768 | } |
Nancy Chen | 5cf2784 | 2015-01-24 23:30:27 -0800 | [diff] [blame] | 1769 | } |
| 1770 | return null; |
| 1771 | } |
| 1772 | |
| 1773 | /** |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1774 | * 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] | 1775 | * states) originating from either a manager or self-managed {@link ConnectionService}. |
Tyler Gunn | 24e1833 | 2017-02-10 09:42:49 -0800 | [diff] [blame] | 1776 | * |
| 1777 | * @return {@code true} if there is an ongoing call in either a managed or self-managed |
| 1778 | * {@link ConnectionService}, {@code false} otherwise. |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1779 | */ |
Yorke Lee | c61d1366 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 1780 | @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1781 | public boolean isInCall() { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1782 | ITelecomService service = getTelecomService(); |
| 1783 | if (service != null) { |
| 1784 | try { |
| 1785 | return service.isInCall(mContext.getOpPackageName(), |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame] | 1786 | mContext.getAttributionTag()); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1787 | } catch (RemoteException e) { |
| 1788 | Log.e(TAG, "RemoteException calling isInCall().", e); |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1789 | } |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1790 | } |
| 1791 | return false; |
| 1792 | } |
| 1793 | |
| 1794 | /** |
Shuo Qian | 93273fd | 2021-02-10 15:12:09 -0800 | [diff] [blame] | 1795 | * Returns whether the caller has {@link android.Manifest.permission#MANAGE_ONGOING_CALLS} |
| 1796 | * permission. The permission can be obtained by associating with a physical wearable device |
| 1797 | * via the {@link android.companion.CompanionDeviceManager} API as a companion app. If the |
| 1798 | * caller app has the permission, it has {@link InCallService} access to manage ongoing calls. |
Shuo Qian | 4d06526 | 2020-10-20 11:04:28 -0700 | [diff] [blame] | 1799 | * |
| 1800 | * @return {@code true} if the caller has {@link InCallService} access for |
| 1801 | * companion app; {@code false} otherwise. |
| 1802 | */ |
Shuo Qian | 93273fd | 2021-02-10 15:12:09 -0800 | [diff] [blame] | 1803 | public boolean hasManageOngoingCallsPermission() { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1804 | ITelecomService service = getTelecomService(); |
| 1805 | if (service != null) { |
| 1806 | try { |
Shuo Qian | 93273fd | 2021-02-10 15:12:09 -0800 | [diff] [blame] | 1807 | return service.hasManageOngoingCallsPermission( |
Shuo Qian | 4d06526 | 2020-10-20 11:04:28 -0700 | [diff] [blame] | 1808 | mContext.getOpPackageName()); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1809 | } catch (RemoteException e) { |
Shuo Qian | 93273fd | 2021-02-10 15:12:09 -0800 | [diff] [blame] | 1810 | Log.e(TAG, "RemoteException calling hasManageOngoingCallsPermission().", e); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1811 | if (!isSystemProcess()) { |
| 1812 | e.rethrowAsRuntimeException(); |
| 1813 | } |
Shuo Qian | 4d06526 | 2020-10-20 11:04:28 -0700 | [diff] [blame] | 1814 | } |
| 1815 | } |
| 1816 | return false; |
| 1817 | } |
| 1818 | |
| 1819 | /** |
Tyler Gunn | 24e1833 | 2017-02-10 09:42:49 -0800 | [diff] [blame] | 1820 | * Returns whether there is an ongoing call originating from a managed |
| 1821 | * {@link ConnectionService}. An ongoing call can be in dialing, ringing, active or holding |
| 1822 | * states. |
| 1823 | * <p> |
| 1824 | * If you also need to know if there are ongoing self-managed calls, use {@link #isInCall()} |
| 1825 | * instead. |
Tyler Gunn | 24e1833 | 2017-02-10 09:42:49 -0800 | [diff] [blame] | 1826 | * |
| 1827 | * @return {@code true} if there is an ongoing call in a managed {@link ConnectionService}, |
| 1828 | * {@code false} otherwise. |
| 1829 | */ |
| 1830 | @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) |
| 1831 | public boolean isInManagedCall() { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1832 | ITelecomService service = getTelecomService(); |
| 1833 | if (service != null) { |
| 1834 | try { |
| 1835 | return service.isInManagedCall(mContext.getOpPackageName(), |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame] | 1836 | mContext.getAttributionTag()); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1837 | } catch (RemoteException e) { |
| 1838 | Log.e(TAG, "RemoteException calling isInManagedCall().", e); |
Tyler Gunn | 24e1833 | 2017-02-10 09:42:49 -0800 | [diff] [blame] | 1839 | } |
Tyler Gunn | 24e1833 | 2017-02-10 09:42:49 -0800 | [diff] [blame] | 1840 | } |
| 1841 | return false; |
| 1842 | } |
| 1843 | |
| 1844 | /** |
Yorke Lee | 2ae312e | 2014-09-12 17:58:48 -0700 | [diff] [blame] | 1845 | * Returns one of the following constants that represents the current state of Telecom: |
| 1846 | * |
| 1847 | * {@link TelephonyManager#CALL_STATE_RINGING} |
| 1848 | * {@link TelephonyManager#CALL_STATE_OFFHOOK} |
| 1849 | * {@link TelephonyManager#CALL_STATE_IDLE} |
Yorke Lee | 7c72c2d | 2014-10-28 14:12:02 -0700 | [diff] [blame] | 1850 | * |
Tyler Gunn | 24e1833 | 2017-02-10 09:42:49 -0800 | [diff] [blame] | 1851 | * Takes into consideration both managed and self-managed calls. |
Brad Ebinger | a8366ae | 2021-03-23 21:01:51 +0000 | [diff] [blame] | 1852 | * <p> |
| 1853 | * Requires Permission: |
| 1854 | * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} for applications |
| 1855 | * targeting API level 31+. |
Tyler Gunn | 24e1833 | 2017-02-10 09:42:49 -0800 | [diff] [blame] | 1856 | * |
Yorke Lee | 2ae312e | 2014-09-12 17:58:48 -0700 | [diff] [blame] | 1857 | * @hide |
| 1858 | */ |
Brad Ebinger | a8366ae | 2021-03-23 21:01:51 +0000 | [diff] [blame] | 1859 | @RequiresPermission(anyOf = {READ_PRIVILEGED_PHONE_STATE, |
| 1860 | android.Manifest.permission.READ_PHONE_STATE}, conditional = true) |
Yorke Lee | 2ae312e | 2014-09-12 17:58:48 -0700 | [diff] [blame] | 1861 | @SystemApi |
Chen Xu | c9d4ee1 | 2019-09-26 16:11:59 -0700 | [diff] [blame] | 1862 | public @CallState int getCallState() { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1863 | ITelecomService service = getTelecomService(); |
| 1864 | if (service != null) { |
| 1865 | try { |
Thomas Stuart | de1f1f2 | 2022-11-16 22:17:42 +0000 | [diff] [blame] | 1866 | return service.getCallStateUsingPackage(mContext.getOpPackageName(), |
Brad Ebinger | a8366ae | 2021-03-23 21:01:51 +0000 | [diff] [blame] | 1867 | mContext.getAttributionTag()); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1868 | } catch (RemoteException e) { |
| 1869 | Log.d(TAG, "RemoteException calling getCallState().", e); |
Yorke Lee | 2ae312e | 2014-09-12 17:58:48 -0700 | [diff] [blame] | 1870 | } |
Yorke Lee | 2ae312e | 2014-09-12 17:58:48 -0700 | [diff] [blame] | 1871 | } |
| 1872 | return TelephonyManager.CALL_STATE_IDLE; |
| 1873 | } |
| 1874 | |
| 1875 | /** |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1876 | * Returns whether there currently exists is a ringing incoming-call. |
| 1877 | * |
Tyler Gunn | 24e1833 | 2017-02-10 09:42:49 -0800 | [diff] [blame] | 1878 | * @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] | 1879 | * @hide |
| 1880 | */ |
| 1881 | @SystemApi |
Jeff Sharkey | bfc4fcd | 2017-06-05 17:38:17 -0600 | [diff] [blame] | 1882 | @RequiresPermission(anyOf = { |
Tyler Gunn | 00d737b | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 1883 | READ_PRIVILEGED_PHONE_STATE, |
Jeff Sharkey | bfc4fcd | 2017-06-05 17:38:17 -0600 | [diff] [blame] | 1884 | android.Manifest.permission.READ_PHONE_STATE |
| 1885 | }) |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1886 | public boolean isRinging() { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1887 | ITelecomService service = getTelecomService(); |
| 1888 | if (service != null) { |
| 1889 | try { |
| 1890 | return service.isRinging(mContext.getOpPackageName()); |
| 1891 | } catch (RemoteException e) { |
| 1892 | Log.e(TAG, "RemoteException attempting to get ringing state of phone app.", e); |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1893 | } |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1894 | } |
| 1895 | return false; |
| 1896 | } |
| 1897 | |
| 1898 | /** |
Tyler Gunn | e1aa26c | 2018-05-02 13:23:48 -0700 | [diff] [blame] | 1899 | * Ends the foreground call on the device. |
| 1900 | * <p> |
| 1901 | * If there is a ringing call, calling this method rejects the ringing call. Otherwise the |
| 1902 | * foreground call is ended. |
| 1903 | * <p> |
Tyler Gunn | f18ee4c | 2019-05-14 11:08:06 -0700 | [diff] [blame] | 1904 | * Note: this method CANNOT be used to end ongoing emergency calls and will return {@code false} |
| 1905 | * if an attempt is made to end an emergency call. |
Tyler Gunn | e1aa26c | 2018-05-02 13:23:48 -0700 | [diff] [blame] | 1906 | * |
| 1907 | * @return {@code true} if there is a call which will be rejected or terminated, {@code false} |
| 1908 | * otherwise. |
Tyler Gunn | 9bd8db4 | 2019-01-31 10:54:03 -0800 | [diff] [blame] | 1909 | * @deprecated Companion apps for wearable devices should use the {@link InCallService} API |
| 1910 | * instead. Apps performing call screening should use the {@link CallScreeningService} API |
| 1911 | * instead. |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1912 | */ |
Tyler Gunn | e1aa26c | 2018-05-02 13:23:48 -0700 | [diff] [blame] | 1913 | @RequiresPermission(Manifest.permission.ANSWER_PHONE_CALLS) |
Tyler Gunn | 9bd8db4 | 2019-01-31 10:54:03 -0800 | [diff] [blame] | 1914 | @Deprecated |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1915 | public boolean endCall() { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1916 | ITelecomService service = getTelecomService(); |
| 1917 | if (service != null) { |
| 1918 | try { |
| 1919 | return service.endCall(mContext.getPackageName()); |
| 1920 | } catch (RemoteException e) { |
| 1921 | Log.e(TAG, "Error calling ITelecomService#endCall", e); |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1922 | } |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1923 | } |
| 1924 | return false; |
| 1925 | } |
| 1926 | |
| 1927 | /** |
| 1928 | * 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] | 1929 | * |
Tyler Gunn | 6676bb5 | 2015-10-23 14:39:49 -0700 | [diff] [blame] | 1930 | * If the incoming call is a video call, the call will be answered with the same video state as |
| 1931 | * the incoming call requests. This means, for example, that an incoming call requesting |
| 1932 | * {@link VideoProfile#STATE_BIDIRECTIONAL} will be answered, accepting that state. |
Eugene Susla | cae3d3e | 2017-01-31 11:08:11 -0800 | [diff] [blame] | 1933 | * |
Tyler Gunn | 9bd8db4 | 2019-01-31 10:54:03 -0800 | [diff] [blame] | 1934 | * @deprecated Companion apps for wearable devices should use the {@link InCallService} API |
| 1935 | * instead. |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1936 | */ |
Eugene Susla | cae3d3e | 2017-01-31 11:08:11 -0800 | [diff] [blame] | 1937 | //TODO: L-release - need to convert all invocation of ITelecmmService#answerRingingCall to use |
| 1938 | // this method (clockwork & gearhead). |
| 1939 | @RequiresPermission(anyOf = |
| 1940 | {Manifest.permission.ANSWER_PHONE_CALLS, Manifest.permission.MODIFY_PHONE_STATE}) |
Tyler Gunn | 9bd8db4 | 2019-01-31 10:54:03 -0800 | [diff] [blame] | 1941 | @Deprecated |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1942 | public void acceptRingingCall() { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1943 | ITelecomService service = getTelecomService(); |
| 1944 | if (service != null) { |
| 1945 | try { |
| 1946 | service.acceptRingingCall(mContext.getPackageName()); |
| 1947 | } catch (RemoteException e) { |
| 1948 | Log.e(TAG, "Error calling ITelecomService#acceptRingingCall", e); |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1949 | } |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1950 | } |
| 1951 | } |
| 1952 | |
| 1953 | /** |
Tyler Gunn | 6676bb5 | 2015-10-23 14:39:49 -0700 | [diff] [blame] | 1954 | * If there is a ringing incoming call, this method accepts the call on behalf of the user, |
| 1955 | * with the specified video state. |
| 1956 | * |
| 1957 | * @param videoState The desired video state to answer the call with. |
Tyler Gunn | 9bd8db4 | 2019-01-31 10:54:03 -0800 | [diff] [blame] | 1958 | * @deprecated Companion apps for wearable devices should use the {@link InCallService} API |
| 1959 | * instead. |
Tyler Gunn | 6676bb5 | 2015-10-23 14:39:49 -0700 | [diff] [blame] | 1960 | */ |
Eugene Susla | cae3d3e | 2017-01-31 11:08:11 -0800 | [diff] [blame] | 1961 | @RequiresPermission(anyOf = |
| 1962 | {Manifest.permission.ANSWER_PHONE_CALLS, Manifest.permission.MODIFY_PHONE_STATE}) |
Tyler Gunn | 9bd8db4 | 2019-01-31 10:54:03 -0800 | [diff] [blame] | 1963 | @Deprecated |
Tyler Gunn | 6676bb5 | 2015-10-23 14:39:49 -0700 | [diff] [blame] | 1964 | public void acceptRingingCall(int videoState) { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1965 | ITelecomService service = getTelecomService(); |
| 1966 | if (service != null) { |
| 1967 | try { |
| 1968 | service.acceptRingingCallWithVideoState( |
Eugene Susla | cae3d3e | 2017-01-31 11:08:11 -0800 | [diff] [blame] | 1969 | mContext.getPackageName(), videoState); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1970 | } catch (RemoteException e) { |
| 1971 | Log.e(TAG, "Error calling ITelecomService#acceptRingingCallWithVideoState", e); |
Tyler Gunn | 6676bb5 | 2015-10-23 14:39:49 -0700 | [diff] [blame] | 1972 | } |
Tyler Gunn | 6676bb5 | 2015-10-23 14:39:49 -0700 | [diff] [blame] | 1973 | } |
| 1974 | } |
| 1975 | |
| 1976 | /** |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1977 | * Silences the ringer if a ringing call exists. |
Tyler Gunn | 556d240 | 2019-04-10 08:59:43 -0700 | [diff] [blame] | 1978 | * <p> |
| 1979 | * This method can only be relied upon to stop the ringtone for a call if the ringtone has |
| 1980 | * already started playing. It is intended to handle use-cases such as silencing a ringing call |
| 1981 | * when the user presses the volume button during ringing. |
| 1982 | * <p> |
| 1983 | * If this method is called prior to when the ringtone begins playing, the ringtone will not be |
| 1984 | * silenced. As such it is not intended as a means to avoid playing of a ringtone. |
| 1985 | * <p> |
| 1986 | * A dialer app which wants to have more control over ringtone playing should declare |
| 1987 | * {@link TelecomManager#METADATA_IN_CALL_SERVICE_RINGING} in the manifest entry for their |
| 1988 | * {@link InCallService} implementation to indicate that the app wants to be responsible for |
| 1989 | * playing the ringtone for all incoming calls. |
| 1990 | * <p> |
| 1991 | * Requires permission: {@link android.Manifest.permission#MODIFY_PHONE_STATE} or that the |
| 1992 | * app fills the dialer role (see {@link #getDefaultDialerPackage()}). |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1993 | */ |
Yorke Lee | c61d1366 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 1994 | @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1995 | public void silenceRinger() { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 1996 | ITelecomService service = getTelecomService(); |
| 1997 | if (service != null) { |
| 1998 | try { |
| 1999 | service.silenceRinger(mContext.getOpPackageName()); |
| 2000 | } catch (RemoteException e) { |
| 2001 | Log.e(TAG, "Error calling ITelecomService#silenceRinger", e); |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 2002 | } |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 2003 | } |
| 2004 | } |
| 2005 | |
Sailesh Nepal | 001bbbb | 2014-07-15 14:40:39 -0700 | [diff] [blame] | 2006 | /** |
| 2007 | * Returns whether TTY is supported on this device. |
Sailesh Nepal | 001bbbb | 2014-07-15 14:40:39 -0700 | [diff] [blame] | 2008 | */ |
Jeff Sharkey | bfc4fcd | 2017-06-05 17:38:17 -0600 | [diff] [blame] | 2009 | @RequiresPermission(anyOf = { |
Tyler Gunn | 00d737b | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 2010 | READ_PRIVILEGED_PHONE_STATE, |
Jeff Sharkey | bfc4fcd | 2017-06-05 17:38:17 -0600 | [diff] [blame] | 2011 | android.Manifest.permission.READ_PHONE_STATE |
| 2012 | }) |
Sailesh Nepal | 001bbbb | 2014-07-15 14:40:39 -0700 | [diff] [blame] | 2013 | public boolean isTtySupported() { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 2014 | ITelecomService service = getTelecomService(); |
| 2015 | if (service != null) { |
| 2016 | try { |
| 2017 | return service.isTtySupported(mContext.getOpPackageName(), |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame] | 2018 | mContext.getAttributionTag()); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 2019 | } catch (RemoteException e) { |
| 2020 | Log.e(TAG, "RemoteException attempting to get TTY supported state.", e); |
Sailesh Nepal | 001bbbb | 2014-07-15 14:40:39 -0700 | [diff] [blame] | 2021 | } |
Sailesh Nepal | 001bbbb | 2014-07-15 14:40:39 -0700 | [diff] [blame] | 2022 | } |
| 2023 | return false; |
| 2024 | } |
| 2025 | |
| 2026 | /** |
| 2027 | * 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] | 2028 | * settings and have a wired headset plugged in. |
| 2029 | * Valid modes are: |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2030 | * - {@link TelecomManager#TTY_MODE_OFF} |
| 2031 | * - {@link TelecomManager#TTY_MODE_FULL} |
| 2032 | * - {@link TelecomManager#TTY_MODE_HCO} |
| 2033 | * - {@link TelecomManager#TTY_MODE_VCO} |
Sailesh Nepal | 001bbbb | 2014-07-15 14:40:39 -0700 | [diff] [blame] | 2034 | * @hide |
| 2035 | */ |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 2036 | @SystemApi |
Tyler Gunn | 00d737b | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 2037 | @RequiresPermission(READ_PRIVILEGED_PHONE_STATE) |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 2038 | public @TtyMode int getCurrentTtyMode() { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 2039 | ITelecomService service = getTelecomService(); |
| 2040 | if (service != null) { |
| 2041 | try { |
| 2042 | return service.getCurrentTtyMode(mContext.getOpPackageName(), |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame] | 2043 | mContext.getAttributionTag()); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 2044 | } catch (RemoteException e) { |
| 2045 | Log.e(TAG, "RemoteException attempting to get the current TTY mode.", e); |
Sailesh Nepal | 001bbbb | 2014-07-15 14:40:39 -0700 | [diff] [blame] | 2046 | } |
Sailesh Nepal | 001bbbb | 2014-07-15 14:40:39 -0700 | [diff] [blame] | 2047 | } |
Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 2048 | return TTY_MODE_OFF; |
Sailesh Nepal | 001bbbb | 2014-07-15 14:40:39 -0700 | [diff] [blame] | 2049 | } |
| 2050 | |
Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 2051 | /** |
| 2052 | * 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] | 2053 | * has an incoming call. For managed {@link ConnectionService}s, the specified |
| 2054 | * {@link PhoneAccountHandle} must have been registered with {@link #registerPhoneAccount} and |
| 2055 | * the user must have enabled the corresponding {@link PhoneAccount}. This can be checked using |
| 2056 | * {@link #getPhoneAccount}. Self-managed {@link ConnectionService}s must have |
| 2057 | * {@link android.Manifest.permission#MANAGE_OWN_CALLS} to add a new incoming call. |
| 2058 | * <p> |
Tyler Gunn | 3765356 | 2017-03-13 18:15:15 -0700 | [diff] [blame] | 2059 | * The incoming call you are adding is assumed to have a video state of |
| 2060 | * {@link VideoProfile#STATE_AUDIO_ONLY}, unless the extra value |
| 2061 | * {@link #EXTRA_INCOMING_VIDEO_STATE} is specified. |
| 2062 | * <p> |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 2063 | * Once invoked, this method will cause the system to bind to the {@link ConnectionService} |
| 2064 | * associated with the {@link PhoneAccountHandle} and request additional information about the |
| 2065 | * call (See {@link ConnectionService#onCreateIncomingConnection}) before starting the incoming |
Brad Ebinger | ec0d334 | 2016-01-29 15:40:43 -0800 | [diff] [blame] | 2066 | * call UI. |
| 2067 | * <p> |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 2068 | * For a managed {@link ConnectionService}, a {@link SecurityException} will be thrown if either |
| 2069 | * the {@link PhoneAccountHandle} does not correspond to a registered {@link PhoneAccount} or |
| 2070 | * the associated {@link PhoneAccount} is not currently enabled by the user. |
| 2071 | * <p> |
| 2072 | * For a self-managed {@link ConnectionService}, a {@link SecurityException} will be thrown if |
| 2073 | * the {@link PhoneAccount} has {@link PhoneAccount#CAPABILITY_SELF_MANAGED} and the calling app |
| 2074 | * does not have {@link android.Manifest.permission#MANAGE_OWN_CALLS}. |
| 2075 | * |
Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 2076 | * @param phoneAccount A {@link PhoneAccountHandle} registered with |
| 2077 | * {@link #registerPhoneAccount}. |
| 2078 | * @param extras A bundle that will be passed through to |
| 2079 | * {@link ConnectionService#onCreateIncomingConnection}. |
| 2080 | */ |
| 2081 | public void addNewIncomingCall(PhoneAccountHandle phoneAccount, Bundle extras) { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 2082 | ITelecomService service = getTelecomService(); |
| 2083 | if (service != null) { |
| 2084 | try { |
Sanket Padawe | f6a9e5b | 2018-01-05 14:26:16 -0800 | [diff] [blame] | 2085 | if (extras != null && extras.getBoolean(EXTRA_IS_HANDOVER) && |
| 2086 | mContext.getApplicationContext().getApplicationInfo().targetSdkVersion > |
| 2087 | Build.VERSION_CODES.O_MR1) { |
| 2088 | Log.e("TAG", "addNewIncomingCall failed. Use public api " + |
| 2089 | "acceptHandover for API > O-MR1"); |
Tyler Gunn | 9ae6db8 | 2019-02-13 13:51:18 -0800 | [diff] [blame] | 2090 | return; |
Sanket Padawe | f6a9e5b | 2018-01-05 14:26:16 -0800 | [diff] [blame] | 2091 | } |
Thomas Stuart | bc724ef | 2022-01-27 21:16:11 +0000 | [diff] [blame] | 2092 | service.addNewIncomingCall(phoneAccount, extras == null ? new Bundle() : extras, |
| 2093 | mContext.getPackageName()); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 2094 | } catch (RemoteException e) { |
| 2095 | Log.e(TAG, "RemoteException adding a new incoming call: " + phoneAccount, e); |
Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 2096 | } |
Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 2097 | } |
| 2098 | } |
| 2099 | |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 2100 | /** |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame] | 2101 | * Registers a new incoming conference. A {@link ConnectionService} should invoke this method |
Grace Jia | 8587ee5 | 2020-07-10 15:42:32 -0700 | [diff] [blame] | 2102 | * when it has an incoming conference. An incoming {@link Conference} is an adhoc conference |
| 2103 | * call initiated on another device which the user is being invited to join in. For managed |
| 2104 | * {@link ConnectionService}s, the specified {@link PhoneAccountHandle} must have been |
| 2105 | * registered with {@link #registerPhoneAccount} and the user must have enabled the |
| 2106 | * corresponding {@link PhoneAccount}. This can be checked using |
| 2107 | * {@link #getPhoneAccount(PhoneAccountHandle)}. Self-managed {@link ConnectionService}s must |
| 2108 | * have {@link android.Manifest.permission#MANAGE_OWN_CALLS} to add a new incoming call. |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame] | 2109 | * <p> |
| 2110 | * The incoming conference you are adding is assumed to have a video state of |
| 2111 | * {@link VideoProfile#STATE_AUDIO_ONLY}, unless the extra value |
| 2112 | * {@link #EXTRA_INCOMING_VIDEO_STATE} is specified. |
| 2113 | * <p> |
| 2114 | * Once invoked, this method will cause the system to bind to the {@link ConnectionService} |
| 2115 | * associated with the {@link PhoneAccountHandle} and request additional information about the |
Grace Jia | 8587ee5 | 2020-07-10 15:42:32 -0700 | [diff] [blame] | 2116 | * call (See |
| 2117 | * {@link ConnectionService#onCreateIncomingConference(PhoneAccountHandle, ConnectionRequest)}) |
| 2118 | * before starting the incoming call UI. |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame] | 2119 | * <p> |
| 2120 | * For a managed {@link ConnectionService}, a {@link SecurityException} will be thrown if either |
| 2121 | * the {@link PhoneAccountHandle} does not correspond to a registered {@link PhoneAccount} or |
| 2122 | * the associated {@link PhoneAccount} is not currently enabled by the user. |
| 2123 | * |
| 2124 | * @param phoneAccount A {@link PhoneAccountHandle} registered with |
| 2125 | * {@link #registerPhoneAccount}. |
| 2126 | * @param extras A bundle that will be passed through to |
| 2127 | * {@link ConnectionService#onCreateIncomingConference}. |
| 2128 | */ |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame] | 2129 | public void addNewIncomingConference(@NonNull PhoneAccountHandle phoneAccount, |
| 2130 | @NonNull Bundle extras) { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 2131 | ITelecomService service = getTelecomService(); |
| 2132 | if (service != null) { |
| 2133 | try { |
| 2134 | service.addNewIncomingConference( |
Thomas Stuart | bc724ef | 2022-01-27 21:16:11 +0000 | [diff] [blame] | 2135 | phoneAccount, extras == null ? new Bundle() : extras, |
| 2136 | mContext.getPackageName()); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 2137 | } catch (RemoteException e) { |
| 2138 | Log.e(TAG, "RemoteException adding a new incoming conference: " + phoneAccount, e); |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame] | 2139 | } |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame] | 2140 | } |
| 2141 | } |
| 2142 | |
| 2143 | /** |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 2144 | * Registers a new unknown call with Telecom. This can only be called by the system Telephony |
| 2145 | * service. This is invoked when Telephony detects a new unknown connection that was neither |
| 2146 | * a new incoming call, nor an user-initiated outgoing call. |
| 2147 | * |
| 2148 | * @param phoneAccount A {@link PhoneAccountHandle} registered with |
| 2149 | * {@link #registerPhoneAccount}. |
| 2150 | * @param extras A bundle that will be passed through to |
| 2151 | * {@link ConnectionService#onCreateIncomingConnection}. |
| 2152 | * @hide |
| 2153 | */ |
| 2154 | @SystemApi |
| 2155 | public void addNewUnknownCall(PhoneAccountHandle phoneAccount, Bundle extras) { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 2156 | ITelecomService service = getTelecomService(); |
| 2157 | if (service != null) { |
| 2158 | try { |
| 2159 | service.addNewUnknownCall( |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 2160 | phoneAccount, extras == null ? new Bundle() : extras); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 2161 | } catch (RemoteException e) { |
| 2162 | Log.e(TAG, "RemoteException adding a new unknown call: " + phoneAccount, e); |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 2163 | } |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 2164 | } |
| 2165 | } |
| 2166 | |
| 2167 | /** |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 2168 | * Processes the specified dial string as an MMI code. |
| 2169 | * MMI codes are any sequence of characters entered into the dialpad that contain a "*" or "#". |
| 2170 | * Some of these sequences launch special behavior through handled by Telephony. |
Nancy Chen | 95e8a67 | 2014-10-16 18:38:21 -0700 | [diff] [blame] | 2171 | * This method uses the default subscription. |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 2172 | * <p> |
| 2173 | * Requires that the method-caller be set as the system dialer app. |
| 2174 | * </p> |
| 2175 | * |
| 2176 | * @param dialString The digits to dial. |
| 2177 | * @return True if the digits were processed as an MMI code, false otherwise. |
| 2178 | */ |
Yorke Lee | c61d1366 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 2179 | @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 2180 | public boolean handleMmi(String dialString) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2181 | ITelecomService service = getTelecomService(); |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 2182 | if (service != null) { |
| 2183 | try { |
Yorke Lee | f1a349b | 2015-04-29 16:16:50 -0700 | [diff] [blame] | 2184 | return service.handlePinMmi(dialString, mContext.getOpPackageName()); |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 2185 | } catch (RemoteException e) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2186 | Log.e(TAG, "Error calling ITelecomService#handlePinMmi", e); |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 2187 | } |
| 2188 | } |
| 2189 | return false; |
| 2190 | } |
| 2191 | |
| 2192 | /** |
Nancy Chen | 95e8a67 | 2014-10-16 18:38:21 -0700 | [diff] [blame] | 2193 | * Processes the specified dial string as an MMI code. |
| 2194 | * MMI codes are any sequence of characters entered into the dialpad that contain a "*" or "#". |
| 2195 | * Some of these sequences launch special behavior through handled by Telephony. |
| 2196 | * <p> |
| 2197 | * Requires that the method-caller be set as the system dialer app. |
| 2198 | * </p> |
| 2199 | * |
| 2200 | * @param accountHandle The handle for the account the MMI code should apply to. |
| 2201 | * @param dialString The digits to dial. |
| 2202 | * @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] | 2203 | */ |
Yorke Lee | c61d1366 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 2204 | @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) |
Yorke Lee | 0604427 | 2015-04-14 15:16:59 -0700 | [diff] [blame] | 2205 | public boolean handleMmi(String dialString, PhoneAccountHandle accountHandle) { |
Nancy Chen | 95e8a67 | 2014-10-16 18:38:21 -0700 | [diff] [blame] | 2206 | ITelecomService service = getTelecomService(); |
| 2207 | if (service != null) { |
| 2208 | try { |
Yorke Lee | f1a349b | 2015-04-29 16:16:50 -0700 | [diff] [blame] | 2209 | return service.handlePinMmiForPhoneAccount(accountHandle, dialString, |
| 2210 | mContext.getOpPackageName()); |
Nancy Chen | 95e8a67 | 2014-10-16 18:38:21 -0700 | [diff] [blame] | 2211 | } catch (RemoteException e) { |
| 2212 | Log.e(TAG, "Error calling ITelecomService#handlePinMmi", e); |
| 2213 | } |
| 2214 | } |
| 2215 | return false; |
| 2216 | } |
| 2217 | |
| 2218 | /** |
Tyler Gunn | 1a4f040 | 2020-11-06 09:48:16 -0800 | [diff] [blame] | 2219 | * Returns a URI (with the content:// scheme) specific to the specified {@link PhoneAccount} |
| 2220 | * for ADN content retrieval. |
Nancy Chen | b2299c1 | 2014-10-29 18:22:11 -0700 | [diff] [blame] | 2221 | * @param accountHandle The handle for the account to derive an adn query URI for or |
| 2222 | * {@code null} to return a URI which will use the default account. |
| 2223 | * @return The URI (with the content:// scheme) specific to the specified {@link PhoneAccount} |
| 2224 | * for the the content retrieve. |
| 2225 | */ |
Yorke Lee | c61d1366 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 2226 | @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) |
Nancy Chen | b2299c1 | 2014-10-29 18:22:11 -0700 | [diff] [blame] | 2227 | public Uri getAdnUriForPhoneAccount(PhoneAccountHandle accountHandle) { |
| 2228 | ITelecomService service = getTelecomService(); |
| 2229 | if (service != null && accountHandle != null) { |
| 2230 | try { |
Yorke Lee | f1a349b | 2015-04-29 16:16:50 -0700 | [diff] [blame] | 2231 | return service.getAdnUriForPhoneAccount(accountHandle, mContext.getOpPackageName()); |
Nancy Chen | b2299c1 | 2014-10-29 18:22:11 -0700 | [diff] [blame] | 2232 | } catch (RemoteException e) { |
| 2233 | Log.e(TAG, "Error calling ITelecomService#getAdnUriForPhoneAccount", e); |
| 2234 | } |
| 2235 | } |
| 2236 | return Uri.parse("content://icc/adn"); |
| 2237 | } |
| 2238 | |
| 2239 | /** |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 2240 | * Removes the missed-call notification if one is present. |
| 2241 | * <p> |
| 2242 | * Requires that the method-caller be set as the system dialer app. |
| 2243 | * </p> |
| 2244 | */ |
Yorke Lee | c61d1366 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 2245 | @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 2246 | public void cancelMissedCallsNotification() { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2247 | ITelecomService service = getTelecomService(); |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 2248 | if (service != null) { |
| 2249 | try { |
Yorke Lee | f1a349b | 2015-04-29 16:16:50 -0700 | [diff] [blame] | 2250 | service.cancelMissedCallsNotification(mContext.getOpPackageName()); |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 2251 | } catch (RemoteException e) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2252 | Log.e(TAG, "Error calling ITelecomService#cancelMissedCallsNotification", e); |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 2253 | } |
| 2254 | } |
| 2255 | } |
| 2256 | |
| 2257 | /** |
| 2258 | * Brings the in-call screen to the foreground if there is an ongoing call. If there is |
| 2259 | * currently no ongoing call, then this method does nothing. |
| 2260 | * <p> |
| 2261 | * Requires that the method-caller be set as the system dialer app or have the |
| 2262 | * {@link android.Manifest.permission#READ_PHONE_STATE} permission. |
| 2263 | * </p> |
| 2264 | * |
| 2265 | * @param showDialpad Brings up the in-call dialpad as part of showing the in-call screen. |
| 2266 | */ |
Yorke Lee | c61d1366 | 2015-09-21 17:25:25 -0700 | [diff] [blame] | 2267 | @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 2268 | public void showInCallScreen(boolean showDialpad) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2269 | ITelecomService service = getTelecomService(); |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 2270 | if (service != null) { |
| 2271 | try { |
Philip P. Moltmann | 00cf9fb | 2020-01-06 16:41:38 -0800 | [diff] [blame] | 2272 | service.showInCallScreen(showDialpad, mContext.getOpPackageName(), |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame] | 2273 | mContext.getAttributionTag()); |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 2274 | } catch (RemoteException e) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2275 | Log.e(TAG, "Error calling ITelecomService#showCallScreen", e); |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 2276 | } |
| 2277 | } |
| 2278 | } |
| 2279 | |
Yorke Lee | 3e56ba1 | 2015-04-23 12:32:36 -0700 | [diff] [blame] | 2280 | /** |
| 2281 | * Places a new outgoing call to the provided address using the system telecom service with |
| 2282 | * the specified extras. |
| 2283 | * |
| 2284 | * This method is equivalent to placing an outgoing call using {@link Intent#ACTION_CALL}, |
| 2285 | * except that the outgoing call will always be sent via the system telecom service. If |
| 2286 | * method-caller is either the user selected default dialer app or preloaded system dialer |
| 2287 | * app, then emergency calls will also be allowed. |
| 2288 | * |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 2289 | * Placing a call via a managed {@link ConnectionService} requires permission: |
| 2290 | * {@link android.Manifest.permission#CALL_PHONE} |
Yorke Lee | 3e56ba1 | 2015-04-23 12:32:36 -0700 | [diff] [blame] | 2291 | * |
| 2292 | * Usage example: |
| 2293 | * <pre> |
| 2294 | * Uri uri = Uri.fromParts("tel", "12345", null); |
| 2295 | * Bundle extras = new Bundle(); |
| 2296 | * extras.putBoolean(TelecomManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, true); |
| 2297 | * telecomManager.placeCall(uri, extras); |
| 2298 | * </pre> |
| 2299 | * |
Santos Cordon | 7a060d5 | 2015-06-19 14:52:04 -0700 | [diff] [blame] | 2300 | * The following keys are supported in the supplied extras. |
| 2301 | * <ul> |
| 2302 | * <li>{@link #EXTRA_OUTGOING_CALL_EXTRAS}</li> |
| 2303 | * <li>{@link #EXTRA_PHONE_ACCOUNT_HANDLE}</li> |
| 2304 | * <li>{@link #EXTRA_START_CALL_WITH_SPEAKERPHONE}</li> |
| 2305 | * <li>{@link #EXTRA_START_CALL_WITH_VIDEO_STATE}</li> |
| 2306 | * </ul> |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 2307 | * <p> |
| 2308 | * An app which implements the self-managed {@link ConnectionService} API uses |
| 2309 | * {@link #placeCall(Uri, Bundle)} to inform Telecom of a new outgoing call. A self-managed |
| 2310 | * {@link ConnectionService} must include {@link #EXTRA_PHONE_ACCOUNT_HANDLE} to specify its |
| 2311 | * associated {@link android.telecom.PhoneAccountHandle}. |
| 2312 | * |
| 2313 | * Self-managed {@link ConnectionService}s require permission |
| 2314 | * {@link android.Manifest.permission#MANAGE_OWN_CALLS}. |
Santos Cordon | 7a060d5 | 2015-06-19 14:52:04 -0700 | [diff] [blame] | 2315 | * |
Brad Ebinger | 3636d74 | 2019-05-21 15:28:19 -0700 | [diff] [blame] | 2316 | * <p class="note"><strong>Note:</strong> If this method is used to place an emergency call, it |
| 2317 | * is not guaranteed that the call will be placed on the {@link PhoneAccount} provided in |
| 2318 | * the {@link #EXTRA_PHONE_ACCOUNT_HANDLE} extra (if specified) and may be placed on another |
| 2319 | * {@link PhoneAccount} with the {@link PhoneAccount#CAPABILITY_PLACE_EMERGENCY_CALLS} |
| 2320 | * capability, depending on external factors, such as network conditions and Modem/SIM status. |
| 2321 | * </p> |
| 2322 | * |
Yorke Lee | 3e56ba1 | 2015-04-23 12:32:36 -0700 | [diff] [blame] | 2323 | * @param address The address to make the call to. |
| 2324 | * @param extras Bundle of extras to use with the call. |
| 2325 | */ |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 2326 | @RequiresPermission(anyOf = {android.Manifest.permission.CALL_PHONE, |
| 2327 | android.Manifest.permission.MANAGE_OWN_CALLS}) |
Yorke Lee | 3e56ba1 | 2015-04-23 12:32:36 -0700 | [diff] [blame] | 2328 | public void placeCall(Uri address, Bundle extras) { |
| 2329 | ITelecomService service = getTelecomService(); |
| 2330 | if (service != null) { |
Yorke Lee | a5d5c1d | 2015-05-05 16:25:55 -0700 | [diff] [blame] | 2331 | if (address == null) { |
| 2332 | Log.w(TAG, "Cannot place call to empty address."); |
| 2333 | } |
Yorke Lee | 3e56ba1 | 2015-04-23 12:32:36 -0700 | [diff] [blame] | 2334 | try { |
Yorke Lee | a5d5c1d | 2015-05-05 16:25:55 -0700 | [diff] [blame] | 2335 | service.placeCall(address, extras == null ? new Bundle() : extras, |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame] | 2336 | mContext.getOpPackageName(), mContext.getAttributionTag()); |
Yorke Lee | 3e56ba1 | 2015-04-23 12:32:36 -0700 | [diff] [blame] | 2337 | } catch (RemoteException e) { |
| 2338 | Log.e(TAG, "Error calling ITelecomService#placeCall", e); |
| 2339 | } |
| 2340 | } |
| 2341 | } |
| 2342 | |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame] | 2343 | |
| 2344 | /** |
Grace Jia | 8587ee5 | 2020-07-10 15:42:32 -0700 | [diff] [blame] | 2345 | * Place a new adhoc conference call with the provided participants using the system telecom |
| 2346 | * service. This method doesn't support placing of emergency calls. |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame] | 2347 | * |
| 2348 | * An adhoc conference call is established by providing a list of addresses to |
| 2349 | * {@code TelecomManager#startConference(List<Uri>, int videoState)} where the |
| 2350 | * {@link ConnectionService} is responsible for connecting all indicated participants |
| 2351 | * to a conference simultaneously. |
| 2352 | * This is in contrast to conferences formed by merging calls together (e.g. using |
| 2353 | * {@link android.telecom.Call#mergeConference()}). |
| 2354 | * |
| 2355 | * The following keys are supported in the supplied extras. |
| 2356 | * <ul> |
| 2357 | * <li>{@link #EXTRA_PHONE_ACCOUNT_HANDLE}</li> |
| 2358 | * <li>{@link #EXTRA_START_CALL_WITH_SPEAKERPHONE}</li> |
| 2359 | * <li>{@link #EXTRA_START_CALL_WITH_VIDEO_STATE}</li> |
| 2360 | * </ul> |
| 2361 | * |
| 2362 | * @param participants List of participants to start conference with |
| 2363 | * @param extras Bundle of extras to use with the call |
| 2364 | */ |
| 2365 | @RequiresPermission(android.Manifest.permission.CALL_PHONE) |
| 2366 | public void startConference(@NonNull List<Uri> participants, |
| 2367 | @NonNull Bundle extras) { |
| 2368 | ITelecomService service = getTelecomService(); |
| 2369 | if (service != null) { |
| 2370 | try { |
| 2371 | service.startConference(participants, extras, |
| 2372 | mContext.getOpPackageName()); |
| 2373 | } catch (RemoteException e) { |
| 2374 | Log.e(TAG, "Error calling ITelecomService#placeCall", e); |
| 2375 | } |
| 2376 | } |
| 2377 | } |
| 2378 | |
Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 2379 | /** |
| 2380 | * Enables and disables specified phone account. |
| 2381 | * |
| 2382 | * @param handle Handle to the phone account. |
| 2383 | * @param isEnabled Enable state of the phone account. |
| 2384 | * @hide |
| 2385 | */ |
| 2386 | @SystemApi |
Jeff Sharkey | bfc4fcd | 2017-06-05 17:38:17 -0600 | [diff] [blame] | 2387 | @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) |
Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 2388 | public void enablePhoneAccount(PhoneAccountHandle handle, boolean isEnabled) { |
| 2389 | ITelecomService service = getTelecomService(); |
| 2390 | if (service != null) { |
| 2391 | try { |
| 2392 | service.enablePhoneAccount(handle, isEnabled); |
| 2393 | } catch (RemoteException e) { |
| 2394 | Log.e(TAG, "Error enablePhoneAbbount", e); |
| 2395 | } |
| 2396 | } |
| 2397 | } |
| 2398 | |
Hall Liu | 0464b9b | 2016-01-12 15:32:58 -0800 | [diff] [blame] | 2399 | /** |
| 2400 | * Dumps telecom analytics for uploading. |
| 2401 | * |
| 2402 | * @return |
| 2403 | * @hide |
| 2404 | */ |
| 2405 | @SystemApi |
| 2406 | @RequiresPermission(Manifest.permission.DUMP) |
Hall Liu | 057def5 | 2016-05-05 17:17:07 -0700 | [diff] [blame] | 2407 | public TelecomAnalytics dumpAnalytics() { |
Hall Liu | 0464b9b | 2016-01-12 15:32:58 -0800 | [diff] [blame] | 2408 | ITelecomService service = getTelecomService(); |
Hall Liu | 057def5 | 2016-05-05 17:17:07 -0700 | [diff] [blame] | 2409 | TelecomAnalytics result = null; |
Hall Liu | 0464b9b | 2016-01-12 15:32:58 -0800 | [diff] [blame] | 2410 | if (service != null) { |
| 2411 | try { |
| 2412 | result = service.dumpCallAnalytics(); |
| 2413 | } catch (RemoteException e) { |
| 2414 | Log.e(TAG, "Error dumping call analytics", e); |
| 2415 | } |
| 2416 | } |
| 2417 | return result; |
| 2418 | } |
| 2419 | |
Abhijith Shastry | 1908cb84 | 2016-02-02 11:10:19 -0800 | [diff] [blame] | 2420 | /** |
Abhijith Shastry | a26fe99 | 2016-02-29 11:40:24 -0800 | [diff] [blame] | 2421 | * Creates the {@link Intent} which can be used with {@link Context#startActivity(Intent)} to |
| 2422 | * launch the activity to manage blocked numbers. |
Abhijith Shastry | ec30d2f | 2016-03-04 16:46:08 -0800 | [diff] [blame] | 2423 | * <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] | 2424 | * {@link android.provider.BlockedNumberContract#canCurrentUserBlockNumbers(Context)} returns |
| 2425 | * {@code true} for the current user. |
| 2426 | */ |
| 2427 | public Intent createManageBlockedNumbersIntent() { |
| 2428 | ITelecomService service = getTelecomService(); |
| 2429 | Intent result = null; |
| 2430 | if (service != null) { |
| 2431 | try { |
Thomas Stuart | bc724ef | 2022-01-27 21:16:11 +0000 | [diff] [blame] | 2432 | result = service.createManageBlockedNumbersIntent(mContext.getPackageName()); |
Nan Wu | c51fd76 | 2022-08-01 21:08:23 +0000 | [diff] [blame] | 2433 | if (result != null) { |
| 2434 | result.prepareToEnterProcess(LOCAL_FLAG_FROM_SYSTEM, |
| 2435 | mContext.getAttributionSource()); |
| 2436 | } |
Abhijith Shastry | a26fe99 | 2016-02-29 11:40:24 -0800 | [diff] [blame] | 2437 | } catch (RemoteException e) { |
| 2438 | Log.e(TAG, "Error calling ITelecomService#createManageBlockedNumbersIntent", e); |
| 2439 | } |
| 2440 | } |
| 2441 | return result; |
| 2442 | } |
| 2443 | |
Fan Zhang | 5431ef5 | 2019-10-14 13:43:46 -0700 | [diff] [blame] | 2444 | |
| 2445 | /** |
| 2446 | * Creates the {@link Intent} which can be used with {@link Context#startActivity(Intent)} to |
| 2447 | * launch the activity for emergency dialer. |
| 2448 | * |
| 2449 | * @param number Optional number to call in emergency dialer |
| 2450 | * @hide |
| 2451 | */ |
| 2452 | @SystemApi |
| 2453 | @NonNull |
| 2454 | public Intent createLaunchEmergencyDialerIntent(@Nullable String number) { |
| 2455 | ITelecomService service = getTelecomService(); |
Fan Zhang | 5431ef5 | 2019-10-14 13:43:46 -0700 | [diff] [blame] | 2456 | if (service != null) { |
| 2457 | try { |
Nan Wu | c51fd76 | 2022-08-01 21:08:23 +0000 | [diff] [blame] | 2458 | Intent result = service.createLaunchEmergencyDialerIntent(number); |
| 2459 | if (result != null) { |
| 2460 | result.prepareToEnterProcess(LOCAL_FLAG_FROM_SYSTEM, |
| 2461 | mContext.getAttributionSource()); |
| 2462 | } |
| 2463 | return result; |
Fan Zhang | 5431ef5 | 2019-10-14 13:43:46 -0700 | [diff] [blame] | 2464 | } catch (RemoteException e) { |
| 2465 | Log.e(TAG, "Error createLaunchEmergencyDialerIntent", e); |
| 2466 | } |
Tyler Gunn | 753aa10 | 2020-04-23 10:16:26 -0700 | [diff] [blame] | 2467 | } else { |
| 2468 | Log.w(TAG, "createLaunchEmergencyDialerIntent - Telecom service not available."); |
Fan Zhang | 5431ef5 | 2019-10-14 13:43:46 -0700 | [diff] [blame] | 2469 | } |
Tyler Gunn | 753aa10 | 2020-04-23 10:16:26 -0700 | [diff] [blame] | 2470 | |
| 2471 | // Telecom service knows the package name of the expected emergency dialer package; if it |
| 2472 | // is not available, then fallback to not targeting a specific package. |
| 2473 | Intent intent = new Intent(Intent.ACTION_DIAL_EMERGENCY); |
| 2474 | if (!TextUtils.isEmpty(number) && TextUtils.isDigitsOnly(number)) { |
| 2475 | intent.setData(Uri.fromParts(PhoneAccount.SCHEME_TEL, number, null)); |
| 2476 | } |
| 2477 | return intent; |
Fan Zhang | 5431ef5 | 2019-10-14 13:43:46 -0700 | [diff] [blame] | 2478 | } |
| 2479 | |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 2480 | /** |
| 2481 | * Determines whether Telecom would permit an incoming call to be added via the |
| 2482 | * {@link #addNewIncomingCall(PhoneAccountHandle, Bundle)} API for the specified |
| 2483 | * {@link PhoneAccountHandle}. |
| 2484 | * <p> |
| 2485 | * A {@link ConnectionService} may not add a call for the specified {@link PhoneAccountHandle} |
| 2486 | * in the following situations: |
| 2487 | * <ul> |
| 2488 | * <li>{@link PhoneAccount} does not have property |
| 2489 | * {@link PhoneAccount#CAPABILITY_SELF_MANAGED} set (i.e. it is a managed |
| 2490 | * {@link ConnectionService}), and the active or held call limit has |
| 2491 | * been reached.</li> |
| 2492 | * <li>There is an ongoing emergency call.</li> |
| 2493 | * </ul> |
| 2494 | * |
| 2495 | * @param phoneAccountHandle The {@link PhoneAccountHandle} the call will be added for. |
| 2496 | * @return {@code true} if telecom will permit an incoming call to be added, {@code false} |
| 2497 | * otherwise. |
| 2498 | */ |
| 2499 | public boolean isIncomingCallPermitted(PhoneAccountHandle phoneAccountHandle) { |
Tyler Gunn | 44e0191 | 2017-01-31 10:49:05 -0800 | [diff] [blame] | 2500 | if (phoneAccountHandle == null) { |
| 2501 | return false; |
| 2502 | } |
| 2503 | |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 2504 | ITelecomService service = getTelecomService(); |
| 2505 | if (service != null) { |
| 2506 | try { |
Shuo Qian | 911d464 | 2021-07-13 17:39:12 -0700 | [diff] [blame] | 2507 | return service.isIncomingCallPermitted(phoneAccountHandle, |
| 2508 | mContext.getOpPackageName()); |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 2509 | } catch (RemoteException e) { |
| 2510 | Log.e(TAG, "Error isIncomingCallPermitted", e); |
| 2511 | } |
| 2512 | } |
| 2513 | return false; |
| 2514 | } |
| 2515 | |
| 2516 | /** |
| 2517 | * Determines whether Telecom would permit an outgoing call to be placed via the |
| 2518 | * {@link #placeCall(Uri, Bundle)} API for the specified {@link PhoneAccountHandle}. |
| 2519 | * <p> |
| 2520 | * A {@link ConnectionService} may not place a call for the specified {@link PhoneAccountHandle} |
| 2521 | * in the following situations: |
| 2522 | * <ul> |
| 2523 | * <li>{@link PhoneAccount} does not have property |
| 2524 | * {@link PhoneAccount#CAPABILITY_SELF_MANAGED} set (i.e. it is a managed |
| 2525 | * {@link ConnectionService}), and the active, held or ringing call limit has |
| 2526 | * been reached.</li> |
| 2527 | * <li>{@link PhoneAccount} has property {@link PhoneAccount#CAPABILITY_SELF_MANAGED} set |
| 2528 | * (i.e. it is a self-managed {@link ConnectionService} and there is an ongoing call in |
| 2529 | * another {@link ConnectionService}.</li> |
| 2530 | * <li>There is an ongoing emergency call.</li> |
| 2531 | * </ul> |
| 2532 | * |
| 2533 | * @param phoneAccountHandle The {@link PhoneAccountHandle} the call will be added for. |
| 2534 | * @return {@code true} if telecom will permit an outgoing call to be placed, {@code false} |
| 2535 | * otherwise. |
| 2536 | */ |
| 2537 | public boolean isOutgoingCallPermitted(PhoneAccountHandle phoneAccountHandle) { |
| 2538 | ITelecomService service = getTelecomService(); |
| 2539 | if (service != null) { |
| 2540 | try { |
Shuo Qian | 911d464 | 2021-07-13 17:39:12 -0700 | [diff] [blame] | 2541 | return service.isOutgoingCallPermitted(phoneAccountHandle, |
| 2542 | mContext.getOpPackageName()); |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 2543 | } catch (RemoteException e) { |
| 2544 | Log.e(TAG, "Error isOutgoingCallPermitted", e); |
| 2545 | } |
| 2546 | } |
| 2547 | return false; |
| 2548 | } |
| 2549 | |
Sanket Padawe | a8eddd4 | 2017-11-03 11:07:35 -0700 | [diff] [blame] | 2550 | /** |
Tyler Gunn | 9d12773 | 2018-03-02 15:45:51 -0800 | [diff] [blame] | 2551 | * Called by an app to indicate that it wishes to accept the handover of an ongoing call to a |
| 2552 | * {@link PhoneAccountHandle} it defines. |
| 2553 | * <p> |
| 2554 | * A call handover is the process where an ongoing call is transferred from one app (i.e. |
| 2555 | * {@link ConnectionService} to another app. The user could, for example, choose to continue a |
| 2556 | * mobile network call in a video calling app. The mobile network call via the Telephony stack |
| 2557 | * is referred to as the source of the handover, and the video calling app is referred to as the |
| 2558 | * destination. |
| 2559 | * <p> |
| 2560 | * When considering a handover scenario the <em>initiating</em> device is where a user initiated |
| 2561 | * the handover process (e.g. by calling {@link android.telecom.Call#handoverTo( |
| 2562 | * PhoneAccountHandle, int, Bundle)}, and the other device is considered the <em>receiving</em> |
| 2563 | * device. |
| 2564 | * <p> |
| 2565 | * For a full discussion of the handover process and the APIs involved, see |
| 2566 | * {@link android.telecom.Call#handoverTo(PhoneAccountHandle, int, Bundle)}. |
| 2567 | * <p> |
| 2568 | * This method is called from the <em>receiving</em> side of a handover to indicate a desire to |
| 2569 | * 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] | 2570 | * {@link PhoneAccountHandle} destAcct. For managed {@link ConnectionService}s, the specified |
| 2571 | * {@link PhoneAccountHandle} must have been registered with {@link #registerPhoneAccount} and |
| 2572 | * the user must have enabled the corresponding {@link PhoneAccount}. This can be checked using |
| 2573 | * {@link #getPhoneAccount}. Self-managed {@link ConnectionService}s must have |
| 2574 | * {@link android.Manifest.permission#MANAGE_OWN_CALLS} to handover a call to it. |
| 2575 | * <p> |
| 2576 | * Once invoked, this method will cause the system to bind to the {@link ConnectionService} |
| 2577 | * associated with the {@link PhoneAccountHandle} destAcct and call |
| 2578 | * (See {@link ConnectionService#onCreateIncomingHandoverConnection}). |
| 2579 | * <p> |
| 2580 | * For a managed {@link ConnectionService}, a {@link SecurityException} will be thrown if either |
| 2581 | * the {@link PhoneAccountHandle} destAcct does not correspond to a registered |
| 2582 | * {@link PhoneAccount} or the associated {@link PhoneAccount} is not currently enabled by the |
| 2583 | * user. |
| 2584 | * <p> |
| 2585 | * For a self-managed {@link ConnectionService}, a {@link SecurityException} will be thrown if |
| 2586 | * the calling app does not have {@link android.Manifest.permission#MANAGE_OWN_CALLS}. |
| 2587 | * |
| 2588 | * @param srcAddr The {@link android.net.Uri} of the ongoing call to handover to the caller’s |
| 2589 | * {@link ConnectionService}. |
| 2590 | * @param videoState Video state after the handover. |
| 2591 | * @param destAcct The {@link PhoneAccountHandle} registered to the calling package. |
| 2592 | */ |
Tyler Gunn | 9d12773 | 2018-03-02 15:45:51 -0800 | [diff] [blame] | 2593 | public void acceptHandover(Uri srcAddr, @VideoProfile.VideoState int videoState, |
| 2594 | PhoneAccountHandle destAcct) { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 2595 | ITelecomService service = getTelecomService(); |
| 2596 | if (service != null) { |
| 2597 | try { |
Thomas Stuart | bc724ef | 2022-01-27 21:16:11 +0000 | [diff] [blame] | 2598 | service.acceptHandover(srcAddr, videoState, destAcct, mContext.getPackageName()); |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 2599 | } catch (RemoteException e) { |
| 2600 | Log.e(TAG, "RemoteException acceptHandover: " + e); |
Sanket Padawe | a8eddd4 | 2017-11-03 11:07:35 -0700 | [diff] [blame] | 2601 | } |
Sanket Padawe | a8eddd4 | 2017-11-03 11:07:35 -0700 | [diff] [blame] | 2602 | } |
| 2603 | } |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 2604 | |
Tyler Gunn | 5bd9085 | 2018-09-21 09:37:07 -0700 | [diff] [blame] | 2605 | /** |
| 2606 | * Determines if there is an ongoing emergency call. This can be either an outgoing emergency |
| 2607 | * call, as identified by the dialed number, or because a call was identified by the network |
| 2608 | * as an emergency call. |
| 2609 | * @return {@code true} if there is an ongoing emergency call, {@code false} otherwise. |
| 2610 | * @hide |
| 2611 | */ |
| 2612 | @SystemApi |
| 2613 | @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) |
| 2614 | public boolean isInEmergencyCall() { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 2615 | ITelecomService service = getTelecomService(); |
| 2616 | if (service != null) { |
| 2617 | try { |
| 2618 | return service.isInEmergencyCall(); |
| 2619 | } catch (RemoteException e) { |
| 2620 | Log.e(TAG, "RemoteException isInEmergencyCall: " + e); |
| 2621 | return false; |
Tyler Gunn | 5bd9085 | 2018-09-21 09:37:07 -0700 | [diff] [blame] | 2622 | } |
Tyler Gunn | 5bd9085 | 2018-09-21 09:37:07 -0700 | [diff] [blame] | 2623 | } |
| 2624 | return false; |
| 2625 | } |
| 2626 | |
Tyler Gunn | c37445c | 2018-09-28 16:16:20 -0700 | [diff] [blame] | 2627 | /** |
Tyler Gunn | 27bf434 | 2022-03-25 14:17:52 -0700 | [diff] [blame] | 2628 | * Determines whether there are any ongoing {@link PhoneAccount#CAPABILITY_SELF_MANAGED} |
| 2629 | * calls for a given {@code packageName} and {@code userHandle}. |
| 2630 | * |
| 2631 | * @param packageName the package name of the app to check calls for. |
| 2632 | * @param userHandle the user handle on which to check for calls. |
| 2633 | * @return {@code true} if there are ongoing calls, {@code false} otherwise. |
| 2634 | * @hide |
| 2635 | */ |
| 2636 | @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) |
| 2637 | public boolean isInSelfManagedCall(@NonNull String packageName, |
| 2638 | @NonNull UserHandle userHandle) { |
| 2639 | ITelecomService service = getTelecomService(); |
| 2640 | if (service != null) { |
| 2641 | try { |
| 2642 | return service.isInSelfManagedCall(packageName, userHandle, |
| 2643 | mContext.getOpPackageName()); |
| 2644 | } catch (RemoteException e) { |
| 2645 | Log.e(TAG, "RemoteException isInSelfManagedCall: " + e); |
| 2646 | e.rethrowFromSystemServer(); |
| 2647 | return false; |
| 2648 | } |
| 2649 | } else { |
| 2650 | throw new IllegalStateException("Telecom service is not present"); |
| 2651 | } |
| 2652 | } |
| 2653 | |
| 2654 | /** |
Thomas Stuart | 9bfb243 | 2022-09-27 15:02:07 -0700 | [diff] [blame^] | 2655 | * Adds a new call with the specified {@link CallAttributes} to the telecom service. This method |
| 2656 | * can be used to add both incoming and outgoing calls. |
| 2657 | * |
| 2658 | * <p> |
| 2659 | * The difference between this API call and {@link TelecomManager#placeCall(Uri, Bundle)} or |
| 2660 | * {@link TelecomManager#addNewIncomingCall(PhoneAccountHandle, Bundle)} is that this API |
| 2661 | * will asynchronously provide an update on whether the new call was added successfully via |
| 2662 | * an {@link OutcomeReceiver}. Additionally, callbacks will run on the executor thread that was |
| 2663 | * passed in. |
| 2664 | * |
| 2665 | * <p> |
| 2666 | * Note: Only packages that register with |
| 2667 | * {@link PhoneAccount#CAPABILITY_SUPPORTS_TRANSACTIONAL_OPERATIONS} |
| 2668 | * can utilize this API. {@link PhoneAccount}s that set the capabilities |
| 2669 | * {@link PhoneAccount#CAPABILITY_SIM_SUBSCRIPTION}, |
| 2670 | * {@link PhoneAccount#CAPABILITY_CALL_PROVIDER}, |
| 2671 | * {@link PhoneAccount#CAPABILITY_CONNECTION_MANAGER} |
| 2672 | * are not supported and will cause an exception to be thrown. |
| 2673 | * |
| 2674 | * <p> |
| 2675 | * Usage example: |
| 2676 | * <pre> |
| 2677 | * |
| 2678 | * // An app should first define their own construct of a Call that overrides all the |
| 2679 | * // {@link CallEventCallback}s |
| 2680 | * private class MyVoipCall implements CallEventCallback { |
| 2681 | * // override all the {@link CallEventCallback}s |
| 2682 | * } |
| 2683 | * |
| 2684 | * PhoneAccountHandle handle = new PhoneAccountHandle( |
| 2685 | * new ComponentName("com.example.voip.app", |
| 2686 | * "com.example.voip.app.NewCallActivity"), "123"); |
| 2687 | * |
| 2688 | * CallAttributes callAttributes = new CallAttributes.Builder(handle, |
| 2689 | * CallAttributes.DIRECTION_OUTGOING, |
| 2690 | * "John Smith", Uri.fromParts("tel", "123", null)) |
| 2691 | * .build(); |
| 2692 | * |
| 2693 | * telecomManager.addCall(callAttributes, Runnable::run, new OutcomeReceiver() { |
| 2694 | * public void onResult(CallControl callControl) { |
| 2695 | * // The call has been added successfully |
| 2696 | * } |
| 2697 | * }, new MyVoipCall()); |
| 2698 | * </pre> |
| 2699 | * |
| 2700 | * @param callAttributes attributes of the new call (incoming or outgoing, address, etc. ) |
| 2701 | * @param executor thread to run background CallEventCallback updates on |
| 2702 | * @param pendingControl OutcomeReceiver that receives the result of addCall transaction |
| 2703 | * @param callEventCallback object that overrides CallEventCallback |
| 2704 | */ |
| 2705 | @RequiresPermission(android.Manifest.permission.MANAGE_OWN_CALLS) |
| 2706 | @SuppressLint("SamShouldBeLast") |
| 2707 | public void addCall(@NonNull CallAttributes callAttributes, |
| 2708 | @NonNull @CallbackExecutor Executor executor, |
| 2709 | @NonNull OutcomeReceiver<CallControl, CallException> pendingControl, |
| 2710 | @NonNull CallEventCallback callEventCallback) { |
| 2711 | Objects.requireNonNull(callAttributes); |
| 2712 | Objects.requireNonNull(executor); |
| 2713 | Objects.requireNonNull(pendingControl); |
| 2714 | Objects.requireNonNull(callEventCallback); |
| 2715 | |
| 2716 | ITelecomService service = getTelecomService(); |
| 2717 | if (service != null) { |
| 2718 | try { |
| 2719 | // create or add the new call to a service wrapper w/ the same phoneAccountHandle |
| 2720 | ClientTransactionalServiceWrapper transactionalServiceWrapper = |
| 2721 | mTransactionalServiceRepository.addNewCallForTransactionalServiceWrapper( |
| 2722 | callAttributes.getPhoneAccountHandle()); |
| 2723 | |
| 2724 | // couple all the args passed by the client |
| 2725 | String newCallId = transactionalServiceWrapper.trackCall(callAttributes, executor, |
| 2726 | pendingControl, callEventCallback); |
| 2727 | |
| 2728 | // send args to server to process new call |
| 2729 | service.addCall(callAttributes, transactionalServiceWrapper.getCallEventCallback(), |
| 2730 | newCallId, mContext.getOpPackageName()); |
| 2731 | } catch (RemoteException e) { |
| 2732 | Log.e(TAG, "RemoteException addCall: " + e); |
| 2733 | e.rethrowFromSystemServer(); |
| 2734 | } |
| 2735 | } else { |
| 2736 | throw new IllegalStateException("Telecom service is not present"); |
| 2737 | } |
| 2738 | } |
| 2739 | |
| 2740 | /** |
Tyler Gunn | c37445c | 2018-09-28 16:16:20 -0700 | [diff] [blame] | 2741 | * Handles {@link Intent#ACTION_CALL} intents trampolined from UserCallActivity. |
| 2742 | * @param intent The {@link Intent#ACTION_CALL} intent to handle. |
Brad Ebinger | a9a33e1 | 2019-09-27 16:55:35 -0700 | [diff] [blame] | 2743 | * @param callingPackageProxy The original package that called this before it was trampolined. |
Tyler Gunn | c37445c | 2018-09-28 16:16:20 -0700 | [diff] [blame] | 2744 | * @hide |
| 2745 | */ |
Brad Ebinger | a9a33e1 | 2019-09-27 16:55:35 -0700 | [diff] [blame] | 2746 | public void handleCallIntent(Intent intent, String callingPackageProxy) { |
Kevin Jeon | eddcb1b | 2020-11-11 00:07:39 +0000 | [diff] [blame] | 2747 | ITelecomService service = getTelecomService(); |
| 2748 | if (service != null) { |
| 2749 | try { |
| 2750 | service.handleCallIntent(intent, callingPackageProxy); |
| 2751 | } catch (RemoteException e) { |
| 2752 | Log.e(TAG, "RemoteException handleCallIntent: " + e); |
Tyler Gunn | c37445c | 2018-09-28 16:16:20 -0700 | [diff] [blame] | 2753 | } |
Tyler Gunn | c37445c | 2018-09-28 16:16:20 -0700 | [diff] [blame] | 2754 | } |
Tyler Gunn | c37445c | 2018-09-28 16:16:20 -0700 | [diff] [blame] | 2755 | } |
| 2756 | |
Shuo Qian | 4d06526 | 2020-10-20 11:04:28 -0700 | [diff] [blame] | 2757 | private boolean isSystemProcess() { |
| 2758 | return Process.myUid() == Process.SYSTEM_UID; |
| 2759 | } |
| 2760 | |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2761 | private ITelecomService getTelecomService() { |
Hall Liu | e1bc2ec | 2015-10-09 15:58:37 -0700 | [diff] [blame] | 2762 | if (mTelecomServiceOverride != null) { |
| 2763 | return mTelecomServiceOverride; |
| 2764 | } |
Kevin Jeon | 767cda3 | 2020-11-17 01:40:16 +0000 | [diff] [blame] | 2765 | if (sTelecomService == null) { |
| 2766 | ITelecomService temp = ITelecomService.Stub.asInterface( |
| 2767 | ServiceManager.getService(Context.TELECOM_SERVICE)); |
| 2768 | synchronized (CACHE_LOCK) { |
| 2769 | if (sTelecomService == null && temp != null) { |
| 2770 | try { |
| 2771 | sTelecomService = temp; |
| 2772 | sTelecomService.asBinder().linkToDeath(SERVICE_DEATH, 0); |
| 2773 | } catch (Exception e) { |
| 2774 | sTelecomService = null; |
| 2775 | } |
| 2776 | } |
| 2777 | } |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 2778 | } |
Kevin Jeon | 767cda3 | 2020-11-17 01:40:16 +0000 | [diff] [blame] | 2779 | return sTelecomService; |
| 2780 | } |
| 2781 | |
| 2782 | private static class DeathRecipient implements IBinder.DeathRecipient { |
| 2783 | @Override |
| 2784 | public void binderDied() { |
| 2785 | resetServiceCache(); |
| 2786 | } |
| 2787 | } |
| 2788 | |
| 2789 | private static void resetServiceCache() { |
| 2790 | synchronized (CACHE_LOCK) { |
| 2791 | if (sTelecomService != null) { |
| 2792 | sTelecomService.asBinder().unlinkToDeath(SERVICE_DEATH, 0); |
| 2793 | sTelecomService = null; |
| 2794 | } |
| 2795 | } |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 2796 | } |
Evan Charlton | 235c159 | 2014-09-05 15:41:23 +0000 | [diff] [blame] | 2797 | } |