| 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 | |
| Santos Cordon | 6c7a388 | 2014-06-25 15:30:08 -0700 | [diff] [blame] | 17 | import android.annotation.SystemApi; |
| 18 | import android.content.ComponentName; |
| Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 19 | import android.content.Context; |
| Yorke Lee | 3e56ba1 | 2015-04-23 12:32:36 -0700 | [diff] [blame] | 20 | import android.content.Intent; |
| Nancy Chen | b2299c1 | 2014-10-29 18:22:11 -0700 | [diff] [blame] | 21 | import android.net.Uri; |
| Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 22 | import android.os.Bundle; |
| Santos Cordon | 6c7a388 | 2014-06-25 15:30:08 -0700 | [diff] [blame] | 23 | import android.os.RemoteException; |
| 24 | import android.os.ServiceManager; |
| Yorke Lee | 2ae312e | 2014-09-12 17:58:48 -0700 | [diff] [blame] | 25 | import android.telephony.TelephonyManager; |
| Anthony Lee | 6727926 | 2014-10-27 11:28:40 -0700 | [diff] [blame] | 26 | import android.text.TextUtils; |
| Santos Cordon | 6c7a388 | 2014-06-25 15:30:08 -0700 | [diff] [blame] | 27 | import android.util.Log; |
| Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 28 | |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 29 | import com.android.internal.telecom.ITelecomService; |
| Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 30 | |
| Jay Shrauner | 7746a94 | 2014-08-26 12:15:15 -0700 | [diff] [blame] | 31 | import java.util.ArrayList; |
| Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 32 | import java.util.Collections; |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 33 | import java.util.List; |
| 34 | |
| Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 35 | /** |
| Santos Cordon | d9e614f | 2014-10-28 13:10:36 -0700 | [diff] [blame] | 36 | * Provides access to information about active calls and registration/call-management functionality. |
| Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 37 | * 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] | 38 | * <p> |
| 39 | * Apps do not instantiate this class directly; instead, they retrieve a reference to an instance |
| 40 | * through {@link Context#getSystemService Context.getSystemService(Context.TELECOM_SERVICE)}. |
| 41 | * <p> |
| 42 | * Note that access to some telecom information is permission-protected. Your app cannot access the |
| 43 | * protected information or gain access to protected functionality unless it has the appropriate |
| 44 | * permissions declared in its manifest file. Where permissions apply, they are noted in the method |
| 45 | * descriptions. |
| Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 46 | */ |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 47 | public class TelecomManager { |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 48 | |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 49 | /** |
| Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 50 | * 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] | 51 | * UI by notifying the Telecom system that an incoming call exists for a specific call service |
| 52 | * (see {@link android.telecom.ConnectionService}). Telecom reads the Intent extras to find |
| 53 | * and bind to the appropriate {@link android.telecom.ConnectionService} which Telecom will |
| Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 54 | * ultimately use to control and get information about the call. |
| 55 | * <p> |
| 56 | * 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] | 57 | * {@link android.telecom.ConnectionService} that Telecom should bind to. Telecom will then |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 58 | * ask the connection service for more information about the call prior to showing any UI. |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 59 | */ |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 60 | public static final String ACTION_INCOMING_CALL = "android.telecom.action.INCOMING_CALL"; |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 61 | |
| 62 | /** |
| Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 63 | * Similar to {@link #ACTION_INCOMING_CALL}, but is used only by Telephony to add a new |
| 64 | * sim-initiated MO call for carrier testing. |
| 65 | * @hide |
| 66 | */ |
| 67 | public static final String ACTION_NEW_UNKNOWN_CALL = "android.telecom.action.NEW_UNKNOWN_CALL"; |
| 68 | |
| 69 | /** |
| Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 70 | * The {@link android.content.Intent} action used to configure a |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 71 | * {@link android.telecom.ConnectionService}. |
| Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 72 | * @hide |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 73 | */ |
| Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 74 | @SystemApi |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 75 | public static final String ACTION_CONNECTION_SERVICE_CONFIGURE = |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 76 | "android.telecom.action.CONNECTION_SERVICE_CONFIGURE"; |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 77 | |
| 78 | /** |
| Andrew Lee | 873cfbf | 2015-02-26 15:22:00 -0800 | [diff] [blame] | 79 | * The {@link android.content.Intent} action used to show the call accessibility settings page. |
| 80 | */ |
| 81 | public static final String ACTION_SHOW_CALL_ACCESSIBILITY_SETTINGS = |
| 82 | "android.telecom.action.SHOW_CALL_ACCESSIBILITY_SETTINGS"; |
| 83 | |
| 84 | /** |
| Yorke Lee | 3818a892 | 2014-07-21 15:57:17 -0700 | [diff] [blame] | 85 | * The {@link android.content.Intent} action used to show the call settings page. |
| 86 | */ |
| 87 | public static final String ACTION_SHOW_CALL_SETTINGS = |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 88 | "android.telecom.action.SHOW_CALL_SETTINGS"; |
| Yorke Lee | 3818a892 | 2014-07-21 15:57:17 -0700 | [diff] [blame] | 89 | |
| 90 | /** |
| Andrew Lee | 866080f | 2015-02-19 12:05:33 -0800 | [diff] [blame] | 91 | * The {@link android.content.Intent} action used to show the respond via SMS settings page. |
| 92 | */ |
| 93 | public static final String ACTION_SHOW_RESPOND_VIA_SMS_SETTINGS = |
| 94 | "android.telecom.action.SHOW_RESPOND_VIA_SMS_SETTINGS"; |
| 95 | |
| 96 | /** |
| Evan Charlton | 6d8604f | 2014-09-04 12:38:17 -0700 | [diff] [blame] | 97 | * The {@link android.content.Intent} action used to show the settings page used to configure |
| 98 | * {@link PhoneAccount} preferences. |
| 99 | */ |
| 100 | public static final String ACTION_CHANGE_PHONE_ACCOUNTS = |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 101 | "android.telecom.action.CHANGE_PHONE_ACCOUNTS"; |
| Evan Charlton | 6d8604f | 2014-09-04 12:38:17 -0700 | [diff] [blame] | 102 | |
| 103 | /** |
| Santos Cordon | c66f3ba | 2015-02-27 15:22:07 -0800 | [diff] [blame] | 104 | * The {@link android.content.Intent} action used indicate that a new phone account was |
| 105 | * just registered. |
| 106 | * @hide |
| 107 | */ |
| 108 | @SystemApi |
| 109 | public static final String ACTION_PHONE_ACCOUNT_REGISTERED = |
| 110 | "android.telecom.action.PHONE_ACCOUNT_REGISTERED"; |
| 111 | |
| 112 | /** |
| Yorke Lee | 1011f48 | 2015-04-23 15:58:27 -0700 | [diff] [blame] | 113 | * Activity action: Shows a dialog asking the user whether or not they want to replace the |
| 114 | * current default Dialer with the one specified in |
| 115 | * {@link #EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME}. |
| 116 | * |
| 117 | * Usage example: |
| 118 | * <pre> |
| 119 | * Intent intent = new Intent(TelecomManager.ACTION_CHANGE_DEFAULT_DIALER); |
| 120 | * intent.putExtra(TelecomManager.EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME, |
| 121 | * getActivity().getPackageName()); |
| 122 | * startActivity(intent); |
| 123 | * </pre> |
| 124 | */ |
| 125 | public static final String ACTION_CHANGE_DEFAULT_DIALER = |
| 126 | "android.telecom.action.CHANGE_DEFAULT_DIALER"; |
| 127 | |
| 128 | /** |
| Santos Cordon | d8faf70 | 2015-05-20 16:55:59 -0700 | [diff] [blame] | 129 | * Activity action: Opens the settings screen where a user can enable and disable which |
| 130 | * {@link PhoneAccount}s are allows to make and receive calls. Because a user must |
| 131 | * explicitly enable an account before the system will use it, an app may want to send the |
| 132 | * user to this setting after registering a {@link PhoneAccount}. |
| 133 | * <p> |
| 134 | * Input: get*Extra field {@link #EXTRA_PHONE_ACCOUNT_DESCRIPTION} contains a string-based |
| 135 | * reference to the {@link PhoneAccountHandle} you want to enable. get*Extra field |
| 136 | * {@link #EXTRA_ENABLE_PHONE_ACCOUNT_VALUE} contains a boolean value indicated whether |
| 137 | * the account should be enabled or disabled. |
| 138 | * <p> |
| 139 | * Requires permission: {@link android.Manifest.permission#MODIFY_PHONE_STATE} |
| 140 | * @hide |
| 141 | */ |
| 142 | public static final String ACTION_ENABLE_PHONE_ACCOUNT_SETTING = |
| 143 | "android.telecom.action.ENABLE_PHONE_ACCOUNT_SETTING"; |
| 144 | |
| 145 | /** |
| Yorke Lee | 1011f48 | 2015-04-23 15:58:27 -0700 | [diff] [blame] | 146 | * Extra value used to provide the package name for {@link #ACTION_CHANGE_DEFAULT_DIALER}. |
| 147 | */ |
| 148 | public static final String EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME = |
| 149 | "android.telecom.extra.CHANGE_DEFAULT_DIALER_PACKAGE_NAME"; |
| 150 | |
| 151 | /** |
| Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 152 | * Optional extra for {@link android.content.Intent#ACTION_CALL} containing a boolean that |
| 153 | * 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] | 154 | */ |
| 155 | public static final String EXTRA_START_CALL_WITH_SPEAKERPHONE = |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 156 | "android.telecom.extra.START_CALL_WITH_SPEAKERPHONE"; |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 157 | |
| 158 | /** |
| Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 159 | * Optional extra for {@link android.content.Intent#ACTION_CALL} containing an integer that |
| 160 | * determines the desired video state for an outgoing call. |
| Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 161 | * Valid options: |
| Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 162 | * {@link VideoProfile#STATE_AUDIO_ONLY}, |
| 163 | * {@link VideoProfile#STATE_BIDIRECTIONAL}, |
| 164 | * {@link VideoProfile#STATE_RX_ENABLED}, |
| 165 | * {@link VideoProfile#STATE_TX_ENABLED}. |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 166 | */ |
| 167 | public static final String EXTRA_START_CALL_WITH_VIDEO_STATE = |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 168 | "android.telecom.extra.START_CALL_WITH_VIDEO_STATE"; |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 169 | |
| 170 | /** |
| Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 171 | * The extra used with an {@link android.content.Intent#ACTION_CALL} and |
| 172 | * {@link android.content.Intent#ACTION_DIAL} {@code Intent} to specify a |
| 173 | * {@link PhoneAccountHandle} to use when making the call. |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 174 | * <p class="note"> |
| Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 175 | * Retrieve with {@link android.content.Intent#getParcelableExtra(String)}. |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 176 | */ |
| Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 177 | public static final String EXTRA_PHONE_ACCOUNT_HANDLE = |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 178 | "android.telecom.extra.PHONE_ACCOUNT_HANDLE"; |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 179 | |
| 180 | /** |
| Santos Cordon | d8faf70 | 2015-05-20 16:55:59 -0700 | [diff] [blame] | 181 | * The extra used with {@link #ACTION_ENABLE_PHONE_ACCOUNT_SETTING} to specify a phone account |
| 182 | * as a string value. The value is of the form: "A;B" where A is the component name of the |
| 183 | * {@link PhoneAccount} (e.g., |
| 184 | * com.android.phone/com.android.services.telephony.TelephonyConnectionService) and B is the |
| 185 | * {@link PhoneAccount} ID. |
| 186 | * @hide |
| 187 | */ |
| 188 | public static final String EXTRA_PHONE_ACCOUNT_DESCRIPTION = |
| 189 | "android.telecom.extra.PHONE_ACCOUNT_DESCRIPTION"; |
| 190 | |
| 191 | /** |
| 192 | * Boolean extra used to specify a value for enabling and disabling a phone account. |
| 193 | * Used with {@link #ACTION_ENABLE_PHONE_ACCOUNT_SETTING}. |
| 194 | * @hide |
| 195 | */ |
| 196 | public static final String EXTRA_ENABLE_PHONE_ACCOUNT_VALUE = |
| 197 | "android.telecom.extra.ENABLE_PHONE_ACCOUNT_VALUE"; |
| 198 | |
| 199 | /** |
| Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 200 | * Optional extra for {@link #ACTION_INCOMING_CALL} containing a {@link Bundle} which contains |
| 201 | * metadata about the call. This {@link Bundle} will be returned to the |
| 202 | * {@link ConnectionService}. |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 203 | */ |
| 204 | public static final String EXTRA_INCOMING_CALL_EXTRAS = |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 205 | "android.telecom.extra.INCOMING_CALL_EXTRAS"; |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 206 | |
| 207 | /** |
| Nancy Chen | 10798dc | 2014-08-08 14:00:25 -0700 | [diff] [blame] | 208 | * Optional extra for {@link android.content.Intent#ACTION_CALL} and |
| 209 | * {@link android.content.Intent#ACTION_DIAL} {@code Intent} containing a {@link Bundle} |
| 210 | * which contains metadata about the call. This {@link Bundle} will be saved into |
| 211 | * {@code Call.Details}. |
| Nancy Chen | 10798dc | 2014-08-08 14:00:25 -0700 | [diff] [blame] | 212 | */ |
| 213 | public static final String EXTRA_OUTGOING_CALL_EXTRAS = |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 214 | "android.telecom.extra.OUTGOING_CALL_EXTRAS"; |
| Nancy Chen | 10798dc | 2014-08-08 14:00:25 -0700 | [diff] [blame] | 215 | |
| 216 | /** |
| Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 217 | * @hide |
| 218 | */ |
| 219 | public static final String EXTRA_UNKNOWN_CALL_HANDLE = |
| 220 | "android.telecom.extra.UNKNOWN_CALL_HANDLE"; |
| 221 | |
| 222 | /** |
| Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 223 | * Optional extra for {@link android.telephony.TelephonyManager#ACTION_PHONE_STATE_CHANGED} |
| 224 | * containing the disconnect code. |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 225 | */ |
| 226 | public static final String EXTRA_CALL_DISCONNECT_CAUSE = |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 227 | "android.telecom.extra.CALL_DISCONNECT_CAUSE"; |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 228 | |
| 229 | /** |
| Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 230 | * Optional extra for {@link android.telephony.TelephonyManager#ACTION_PHONE_STATE_CHANGED} |
| 231 | * containing the disconnect message. |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 232 | */ |
| 233 | public static final String EXTRA_CALL_DISCONNECT_MESSAGE = |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 234 | "android.telecom.extra.CALL_DISCONNECT_MESSAGE"; |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 235 | |
| 236 | /** |
| Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 237 | * Optional extra for {@link android.telephony.TelephonyManager#ACTION_PHONE_STATE_CHANGED} |
| 238 | * containing the component name of the associated connection service. |
| Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 239 | * @hide |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 240 | */ |
| Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 241 | @SystemApi |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 242 | public static final String EXTRA_CONNECTION_SERVICE = |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 243 | "android.telecom.extra.CONNECTION_SERVICE"; |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 244 | |
| 245 | /** |
| Nancy Chen | 7ab1dc4 | 2014-09-09 18:18:26 -0700 | [diff] [blame] | 246 | * An optional {@link android.content.Intent#ACTION_CALL} intent extra denoting the |
| 247 | * package name of the app specifying an alternative gateway for the call. |
| 248 | * The value is a string. |
| 249 | * |
| 250 | * (The following comment corresponds to the all GATEWAY_* extras) |
| 251 | * An app which sends the {@link android.content.Intent#ACTION_CALL} intent can specify an |
| 252 | * alternative address to dial which is different from the one specified and displayed to |
| 253 | * the user. This alternative address is referred to as the gateway address. |
| 254 | */ |
| 255 | public static final String GATEWAY_PROVIDER_PACKAGE = |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 256 | "android.telecom.extra.GATEWAY_PROVIDER_PACKAGE"; |
| Nancy Chen | 7ab1dc4 | 2014-09-09 18:18:26 -0700 | [diff] [blame] | 257 | |
| 258 | /** |
| 259 | * An optional {@link android.content.Intent#ACTION_CALL} intent extra corresponding to the |
| 260 | * original address to dial for the call. This is used when an alternative gateway address is |
| 261 | * provided to recall the original address. |
| 262 | * The value is a {@link android.net.Uri}. |
| 263 | * |
| 264 | * (See {@link #GATEWAY_PROVIDER_PACKAGE} for details) |
| 265 | */ |
| 266 | public static final String GATEWAY_ORIGINAL_ADDRESS = |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 267 | "android.telecom.extra.GATEWAY_ORIGINAL_ADDRESS"; |
| Nancy Chen | 7ab1dc4 | 2014-09-09 18:18:26 -0700 | [diff] [blame] | 268 | |
| 269 | /** |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 270 | * The number which the party on the other side of the line will see (and use to return the |
| 271 | * call). |
| 272 | * <p> |
| Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 273 | * {@link ConnectionService}s which interact with {@link RemoteConnection}s should only populate |
| 274 | * this if the {@link android.telephony.TelephonyManager#getLine1Number()} value, as that is the |
| 275 | * user's expected caller ID. |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 276 | */ |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 277 | 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] | 278 | |
| 279 | /** |
| 280 | * The dual tone multi-frequency signaling character sent to indicate the dialing system should |
| 281 | * pause for a predefined period. |
| 282 | */ |
| 283 | public static final char DTMF_CHARACTER_PAUSE = ','; |
| 284 | |
| 285 | /** |
| 286 | * The dual-tone multi-frequency signaling character sent to indicate the dialing system should |
| 287 | * wait for user confirmation before proceeding. |
| 288 | */ |
| 289 | public static final char DTMF_CHARACTER_WAIT = ';'; |
| 290 | |
| 291 | /** |
| 292 | * TTY (teletypewriter) mode is off. |
| 293 | * |
| 294 | * @hide |
| 295 | */ |
| 296 | public static final int TTY_MODE_OFF = 0; |
| 297 | |
| 298 | /** |
| 299 | * TTY (teletypewriter) mode is on. The speaker is off and the microphone is muted. The user |
| 300 | * will communicate with the remote party by sending and receiving text messages. |
| 301 | * |
| 302 | * @hide |
| 303 | */ |
| 304 | public static final int TTY_MODE_FULL = 1; |
| 305 | |
| 306 | /** |
| 307 | * TTY (teletypewriter) mode is in hearing carryover mode (HCO). The microphone is muted but the |
| 308 | * speaker is on. The user will communicate with the remote party by sending text messages and |
| 309 | * hearing an audible reply. |
| 310 | * |
| 311 | * @hide |
| 312 | */ |
| 313 | public static final int TTY_MODE_HCO = 2; |
| 314 | |
| 315 | /** |
| 316 | * TTY (teletypewriter) mode is in voice carryover mode (VCO). The speaker is off but the |
| 317 | * microphone is still on. User will communicate with the remote party by speaking and receiving |
| 318 | * text message replies. |
| 319 | * |
| 320 | * @hide |
| 321 | */ |
| 322 | public static final int TTY_MODE_VCO = 3; |
| 323 | |
| 324 | /** |
| 325 | * Broadcast intent action indicating that the current TTY mode has changed. An intent extra |
| 326 | * provides this state as an int. |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 327 | * |
| Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 328 | * @see #EXTRA_CURRENT_TTY_MODE |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 329 | * @hide |
| 330 | */ |
| 331 | public static final String ACTION_CURRENT_TTY_MODE_CHANGED = |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 332 | "android.telecom.action.CURRENT_TTY_MODE_CHANGED"; |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 333 | |
| 334 | /** |
| 335 | * The lookup key for an int that indicates the current TTY mode. |
| 336 | * Valid modes are: |
| 337 | * - {@link #TTY_MODE_OFF} |
| 338 | * - {@link #TTY_MODE_FULL} |
| 339 | * - {@link #TTY_MODE_HCO} |
| 340 | * - {@link #TTY_MODE_VCO} |
| 341 | * |
| 342 | * @hide |
| 343 | */ |
| 344 | public static final String EXTRA_CURRENT_TTY_MODE = |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 345 | "android.telecom.intent.extra.CURRENT_TTY_MODE"; |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 346 | |
| 347 | /** |
| Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 348 | * Broadcast intent action indicating that the TTY preferred operating mode has changed. An |
| 349 | * intent extra provides the new mode as an int. |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 350 | * |
| Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 351 | * @see #EXTRA_TTY_PREFERRED_MODE |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 352 | * @hide |
| 353 | */ |
| 354 | public static final String ACTION_TTY_PREFERRED_MODE_CHANGED = |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 355 | "android.telecom.action.TTY_PREFERRED_MODE_CHANGED"; |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 356 | |
| 357 | /** |
| Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 358 | * The lookup key for an int that indicates preferred TTY mode. Valid modes are: - |
| 359 | * {@link #TTY_MODE_OFF} - {@link #TTY_MODE_FULL} - {@link #TTY_MODE_HCO} - |
| 360 | * {@link #TTY_MODE_VCO} |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 361 | * |
| 362 | * @hide |
| 363 | */ |
| 364 | public static final String EXTRA_TTY_PREFERRED_MODE = |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 365 | "android.telecom.intent.extra.TTY_PREFERRED"; |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 366 | |
| Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 367 | /** |
| 368 | * The following 4 constants define how properties such as phone numbers and names are |
| 369 | * displayed to the user. |
| 370 | */ |
| 371 | |
| Santos Cordon | ed769ae | 2015-05-13 18:47:38 -0700 | [diff] [blame] | 372 | /** |
| 373 | * Indicates that the address or number of a call is allowed to be displayed for caller ID. |
| 374 | */ |
| Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 375 | public static final int PRESENTATION_ALLOWED = 1; |
| 376 | |
| Santos Cordon | ed769ae | 2015-05-13 18:47:38 -0700 | [diff] [blame] | 377 | /** |
| 378 | * Indicates that the address or number of a call is blocked by the other party. |
| 379 | */ |
| Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 380 | public static final int PRESENTATION_RESTRICTED = 2; |
| 381 | |
| Santos Cordon | ed769ae | 2015-05-13 18:47:38 -0700 | [diff] [blame] | 382 | /** |
| 383 | * Indicates that the address or number of a call is not specified or known by the carrier. |
| 384 | */ |
| Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 385 | public static final int PRESENTATION_UNKNOWN = 3; |
| 386 | |
| Santos Cordon | ed769ae | 2015-05-13 18:47:38 -0700 | [diff] [blame] | 387 | /** |
| 388 | * Indicates that the address or number of a call belongs to a pay phone. |
| 389 | */ |
| Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 390 | public static final int PRESENTATION_PAYPHONE = 4; |
| 391 | |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 392 | private static final String TAG = "TelecomManager"; |
| Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 393 | |
| 394 | private final Context mContext; |
| Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 395 | |
| Santos Cordon | 6c7a388 | 2014-06-25 15:30:08 -0700 | [diff] [blame] | 396 | /** |
| 397 | * @hide |
| 398 | */ |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 399 | public static TelecomManager from(Context context) { |
| 400 | return (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE); |
| Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 401 | } |
| Santos Cordon | 6c7a388 | 2014-06-25 15:30:08 -0700 | [diff] [blame] | 402 | |
| 403 | /** |
| 404 | * @hide |
| 405 | */ |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 406 | public TelecomManager(Context context) { |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 407 | Context appContext = context.getApplicationContext(); |
| 408 | if (appContext != null) { |
| 409 | mContext = appContext; |
| 410 | } else { |
| 411 | mContext = context; |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | /** |
| Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 416 | * Return the {@link PhoneAccount} which will be used to place outgoing calls to addresses with |
| 417 | * the specified {@code uriScheme}. This {@link PhoneAccount} will always be a member of the |
| 418 | * list which is returned from invoking {@link #getCallCapablePhoneAccounts()}. The specific |
| 419 | * account returned depends on the following priorities: |
| 420 | * <ul> |
| 421 | * <li> If the user-selected default {@link PhoneAccount} supports the specified scheme, it will |
| 422 | * be returned. |
| 423 | * </li> |
| 424 | * <li> If there exists only one {@link PhoneAccount} that supports the specified scheme, it |
| 425 | * will be returned. |
| 426 | * </li> |
| 427 | * </ul> |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 428 | * <p> |
| Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 429 | * If no {@link PhoneAccount} fits the criteria above, this method will return {@code null}. |
| 430 | * |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 431 | * @param uriScheme The URI scheme. |
| Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 432 | * @return The {@link PhoneAccountHandle} corresponding to the account to be used. |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 433 | */ |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 434 | public PhoneAccountHandle getDefaultOutgoingPhoneAccount(String uriScheme) { |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 435 | try { |
| 436 | if (isServiceConnected()) { |
| Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 437 | return getTelecomService().getDefaultOutgoingPhoneAccount(uriScheme, |
| 438 | mContext.getOpPackageName()); |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 439 | } |
| 440 | } catch (RemoteException e) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 441 | Log.e(TAG, "Error calling ITelecomService#getDefaultOutgoingPhoneAccount", e); |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 442 | } |
| 443 | return null; |
| 444 | } |
| 445 | |
| 446 | /** |
| Andrew Lee | d4abbfb | 2014-09-03 14:58:27 -0700 | [diff] [blame] | 447 | * Return the {@link PhoneAccount} which is the user-chosen default for making outgoing phone |
| 448 | * 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] | 449 | * calling {@link #getCallCapablePhoneAccounts()} |
| Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 450 | * <p> |
| Andrew Lee | d4abbfb | 2014-09-03 14:58:27 -0700 | [diff] [blame] | 451 | * Apps must be prepared for this method to return {@code null}, indicating that there currently |
| 452 | * exists no user-chosen default {@code PhoneAccount}. |
| 453 | * |
| 454 | * @return The user outgoing phone account selected by the user. |
| Jay Shrauner | 225ccad | 2015-04-15 15:51:15 -0700 | [diff] [blame] | 455 | * @hide |
| Andrew Lee | d4abbfb | 2014-09-03 14:58:27 -0700 | [diff] [blame] | 456 | */ |
| 457 | public PhoneAccountHandle getUserSelectedOutgoingPhoneAccount() { |
| 458 | try { |
| 459 | if (isServiceConnected()) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 460 | return getTelecomService().getUserSelectedOutgoingPhoneAccount(); |
| Andrew Lee | d4abbfb | 2014-09-03 14:58:27 -0700 | [diff] [blame] | 461 | } |
| 462 | } catch (RemoteException e) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 463 | Log.e(TAG, "Error calling ITelecomService#getUserSelectedOutgoingPhoneAccount", e); |
| Andrew Lee | d4abbfb | 2014-09-03 14:58:27 -0700 | [diff] [blame] | 464 | } |
| 465 | return null; |
| 466 | } |
| 467 | |
| 468 | /** |
| Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 469 | * Sets the user-chosen default for making outgoing phone calls. |
| Andrew Lee | 59cac3a | 2014-08-28 16:50:10 -0700 | [diff] [blame] | 470 | * @hide |
| 471 | */ |
| Andrew Lee | d4abbfb | 2014-09-03 14:58:27 -0700 | [diff] [blame] | 472 | public void setUserSelectedOutgoingPhoneAccount(PhoneAccountHandle accountHandle) { |
| Andrew Lee | 59cac3a | 2014-08-28 16:50:10 -0700 | [diff] [blame] | 473 | try { |
| 474 | if (isServiceConnected()) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 475 | getTelecomService().setUserSelectedOutgoingPhoneAccount(accountHandle); |
| Andrew Lee | 59cac3a | 2014-08-28 16:50:10 -0700 | [diff] [blame] | 476 | } |
| 477 | } catch (RemoteException e) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 478 | Log.e(TAG, "Error calling ITelecomService#setUserSelectedOutgoingPhoneAccount"); |
| Andrew Lee | 59cac3a | 2014-08-28 16:50:10 -0700 | [diff] [blame] | 479 | } |
| 480 | } |
| 481 | |
| 482 | /** |
| Andrew Lee | 59cac3a | 2014-08-28 16:50:10 -0700 | [diff] [blame] | 483 | * Returns the current SIM call manager. Apps must be prepared for this method to return |
| 484 | * {@code null}, indicating that there currently exists no user-chosen default |
| 485 | * {@code PhoneAccount}. |
| Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 486 | * |
| Andrew Lee | 59cac3a | 2014-08-28 16:50:10 -0700 | [diff] [blame] | 487 | * @return The phone account handle of the current sim call manager. |
| Andrew Lee | 59cac3a | 2014-08-28 16:50:10 -0700 | [diff] [blame] | 488 | */ |
| 489 | public PhoneAccountHandle getSimCallManager() { |
| 490 | try { |
| 491 | if (isServiceConnected()) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 492 | return getTelecomService().getSimCallManager(); |
| Andrew Lee | 59cac3a | 2014-08-28 16:50:10 -0700 | [diff] [blame] | 493 | } |
| 494 | } catch (RemoteException e) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 495 | Log.e(TAG, "Error calling ITelecomService#getSimCallManager"); |
| Andrew Lee | 59cac3a | 2014-08-28 16:50:10 -0700 | [diff] [blame] | 496 | } |
| 497 | return null; |
| 498 | } |
| 499 | |
| 500 | /** |
| 501 | * Sets the SIM call manager to the specified phone account. |
| Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 502 | * |
| Andrew Lee | 59cac3a | 2014-08-28 16:50:10 -0700 | [diff] [blame] | 503 | * @param accountHandle The phone account handle of the account to set as the sim call manager. |
| 504 | * @hide |
| 505 | */ |
| 506 | public void setSimCallManager(PhoneAccountHandle accountHandle) { |
| 507 | try { |
| 508 | if (isServiceConnected()) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 509 | getTelecomService().setSimCallManager(accountHandle); |
| Andrew Lee | 59cac3a | 2014-08-28 16:50:10 -0700 | [diff] [blame] | 510 | } |
| 511 | } catch (RemoteException e) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 512 | Log.e(TAG, "Error calling ITelecomService#setSimCallManager"); |
| Andrew Lee | 59cac3a | 2014-08-28 16:50:10 -0700 | [diff] [blame] | 513 | } |
| 514 | } |
| 515 | |
| 516 | /** |
| 517 | * Returns the list of registered SIM call managers. |
| Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 518 | * |
| Andrew Lee | 59cac3a | 2014-08-28 16:50:10 -0700 | [diff] [blame] | 519 | * @return List of registered SIM call managers. |
| 520 | * @hide |
| 521 | */ |
| 522 | public List<PhoneAccountHandle> getSimCallManagers() { |
| 523 | try { |
| 524 | if (isServiceConnected()) { |
| Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 525 | return getTelecomService().getSimCallManagers(mContext.getOpPackageName()); |
| Andrew Lee | 59cac3a | 2014-08-28 16:50:10 -0700 | [diff] [blame] | 526 | } |
| 527 | } catch (RemoteException e) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 528 | Log.e(TAG, "Error calling ITelecomService#getSimCallManagers"); |
| Andrew Lee | 59cac3a | 2014-08-28 16:50:10 -0700 | [diff] [blame] | 529 | } |
| 530 | return new ArrayList<>(); |
| 531 | } |
| 532 | |
| 533 | /** |
| Evan Charlton | eb0a8d56 | 2014-09-04 12:03:34 -0700 | [diff] [blame] | 534 | * Returns the current connection manager. Apps must be prepared for this method to return |
| 535 | * {@code null}, indicating that there currently exists no user-chosen default |
| 536 | * {@code PhoneAccount}. |
| 537 | * |
| 538 | * @return The phone account handle of the current connection manager. |
| Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 539 | * @hide |
| Evan Charlton | eb0a8d56 | 2014-09-04 12:03:34 -0700 | [diff] [blame] | 540 | */ |
| Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 541 | @SystemApi |
| Evan Charlton | eb0a8d56 | 2014-09-04 12:03:34 -0700 | [diff] [blame] | 542 | public PhoneAccountHandle getConnectionManager() { |
| 543 | return getSimCallManager(); |
| 544 | } |
| 545 | |
| 546 | /** |
| Nancy Chen | 210ef03 | 2014-09-15 17:58:42 -0700 | [diff] [blame] | 547 | * Returns a list of the {@link PhoneAccountHandle}s which can be used to make and receive phone |
| 548 | * calls which support the specified URI scheme. |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 549 | * <P> |
| 550 | * For example, invoking with {@code "tel"} will find all {@link PhoneAccountHandle}s which |
| 551 | * support telephone calls (e.g. URIs such as {@code tel:555-555-1212}). Invoking with |
| 552 | * {@code "sip"} will find all {@link PhoneAccountHandle}s which support SIP calls (e.g. URIs |
| 553 | * such as {@code sip:example@sipexample.com}). |
| 554 | * |
| 555 | * @param uriScheme The URI scheme. |
| 556 | * @return A list of {@code PhoneAccountHandle} objects supporting the URI scheme. |
| Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 557 | * @hide |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 558 | */ |
| Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 559 | @SystemApi |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 560 | public List<PhoneAccountHandle> getPhoneAccountsSupportingScheme(String uriScheme) { |
| 561 | try { |
| 562 | if (isServiceConnected()) { |
| Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 563 | return getTelecomService().getPhoneAccountsSupportingScheme(uriScheme, |
| 564 | mContext.getOpPackageName()); |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 565 | } |
| 566 | } catch (RemoteException e) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 567 | Log.e(TAG, "Error calling ITelecomService#getPhoneAccountsSupportingScheme", e); |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 568 | } |
| 569 | return new ArrayList<>(); |
| 570 | } |
| 571 | |
| Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 572 | |
| 573 | /** |
| Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 574 | * Returns a list of {@link PhoneAccountHandle}s which can be used to make and receive phone |
| 575 | * calls. The returned list includes only those accounts which have been explicitly enabled |
| 576 | * by the user. |
| Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 577 | * |
| 578 | * @see #EXTRA_PHONE_ACCOUNT_HANDLE |
| 579 | * @return A list of {@code PhoneAccountHandle} objects. |
| Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 580 | */ |
| 581 | public List<PhoneAccountHandle> getCallCapablePhoneAccounts() { |
| Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 582 | return getCallCapablePhoneAccounts(false); |
| 583 | } |
| 584 | |
| 585 | /** |
| 586 | * Returns a list of {@link PhoneAccountHandle}s including those which have not been enabled |
| 587 | * by the user. |
| 588 | * |
| 589 | * @return A list of {@code PhoneAccountHandle} objects. |
| 590 | * @hide |
| 591 | */ |
| 592 | public List<PhoneAccountHandle> getCallCapablePhoneAccounts(boolean includeDisabledAccounts) { |
| Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 593 | try { |
| 594 | if (isServiceConnected()) { |
| Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 595 | return getTelecomService().getCallCapablePhoneAccounts( |
| 596 | includeDisabledAccounts, mContext.getOpPackageName()); |
| Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 597 | } |
| 598 | } catch (RemoteException e) { |
| Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 599 | Log.e(TAG, "Error calling ITelecomService#getCallCapablePhoneAccounts(" + |
| 600 | includeDisabledAccounts + ")", e); |
| Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 601 | } |
| 602 | return new ArrayList<>(); |
| 603 | } |
| 604 | |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 605 | /** |
| Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 606 | * Returns a list of all {@link PhoneAccount}s registered for the calling package. |
| 607 | * |
| 608 | * @return A list of {@code PhoneAccountHandle} objects. |
| Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 609 | * @hide |
| Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 610 | */ |
| Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 611 | @SystemApi |
| Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 612 | public List<PhoneAccountHandle> getPhoneAccountsForPackage() { |
| 613 | try { |
| 614 | if (isServiceConnected()) { |
| 615 | return getTelecomService().getPhoneAccountsForPackage(mContext.getPackageName()); |
| 616 | } |
| 617 | } catch (RemoteException e) { |
| 618 | Log.e(TAG, "Error calling ITelecomService#getPhoneAccountsForPackage", e); |
| 619 | } |
| 620 | return null; |
| 621 | } |
| 622 | |
| 623 | /** |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 624 | * Return the {@link PhoneAccount} for a specified {@link PhoneAccountHandle}. Object includes |
| 625 | * resources which can be used in a user interface. |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 626 | * |
| Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 627 | * @param account The {@link PhoneAccountHandle}. |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 628 | * @return The {@link PhoneAccount} object. |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 629 | */ |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 630 | public PhoneAccount getPhoneAccount(PhoneAccountHandle account) { |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 631 | try { |
| 632 | if (isServiceConnected()) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 633 | return getTelecomService().getPhoneAccount(account); |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 634 | } |
| 635 | } catch (RemoteException e) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 636 | Log.e(TAG, "Error calling ITelecomService#getPhoneAccount", e); |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 637 | } |
| 638 | return null; |
| 639 | } |
| 640 | |
| 641 | /** |
| Nancy Chen | 210ef03 | 2014-09-15 17:58:42 -0700 | [diff] [blame] | 642 | * Returns a count of all {@link PhoneAccount}s. |
| Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 643 | * |
| Nancy Chen | 210ef03 | 2014-09-15 17:58:42 -0700 | [diff] [blame] | 644 | * @return The count of {@link PhoneAccount}s. |
| Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 645 | * @hide |
| 646 | */ |
| 647 | @SystemApi |
| 648 | public int getAllPhoneAccountsCount() { |
| 649 | try { |
| 650 | if (isServiceConnected()) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 651 | return getTelecomService().getAllPhoneAccountsCount(); |
| Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 652 | } |
| 653 | } catch (RemoteException e) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 654 | Log.e(TAG, "Error calling ITelecomService#getAllPhoneAccountsCount", e); |
| Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 655 | } |
| 656 | return 0; |
| 657 | } |
| 658 | |
| 659 | /** |
| 660 | * Returns a list of all {@link PhoneAccount}s. |
| 661 | * |
| 662 | * @return All {@link PhoneAccount}s. |
| 663 | * @hide |
| 664 | */ |
| 665 | @SystemApi |
| 666 | public List<PhoneAccount> getAllPhoneAccounts() { |
| 667 | try { |
| 668 | if (isServiceConnected()) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 669 | return getTelecomService().getAllPhoneAccounts(); |
| Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 670 | } |
| 671 | } catch (RemoteException e) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 672 | Log.e(TAG, "Error calling ITelecomService#getAllPhoneAccounts", e); |
| Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 673 | } |
| 674 | return Collections.EMPTY_LIST; |
| 675 | } |
| 676 | |
| 677 | /** |
| 678 | * Returns a list of all {@link PhoneAccountHandle}s. |
| 679 | * |
| 680 | * @return All {@link PhoneAccountHandle}s. |
| 681 | * @hide |
| 682 | */ |
| 683 | @SystemApi |
| 684 | public List<PhoneAccountHandle> getAllPhoneAccountHandles() { |
| 685 | try { |
| 686 | if (isServiceConnected()) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 687 | return getTelecomService().getAllPhoneAccountHandles(); |
| Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 688 | } |
| 689 | } catch (RemoteException e) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 690 | Log.e(TAG, "Error calling ITelecomService#getAllPhoneAccountHandles", e); |
| Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 691 | } |
| 692 | return Collections.EMPTY_LIST; |
| 693 | } |
| 694 | |
| 695 | /** |
| Santos Cordon | d9e614f | 2014-10-28 13:10:36 -0700 | [diff] [blame] | 696 | * Register a {@link PhoneAccount} for use by the system. When registering |
| 697 | * {@link PhoneAccount}s, existing registrations will be overwritten if the |
| 698 | * {@link PhoneAccountHandle} matches that of a {@link PhoneAccount} which is already |
| 699 | * registered. Once registered, the {@link PhoneAccount} is listed to the user as an option |
| 700 | * when placing calls. The user may still need to enable the {@link PhoneAccount} within |
| 701 | * the phone app settings before the account is usable. |
| 702 | * <p> |
| 703 | * A {@link SecurityException} will be thrown if an app tries to register a |
| 704 | * {@link PhoneAccountHandle} where the package name specified within |
| 705 | * {@link PhoneAccountHandle#getComponentName()} does not match the package name of the app. |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 706 | * |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 707 | * @param account The complete {@link PhoneAccount}. |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 708 | */ |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 709 | public void registerPhoneAccount(PhoneAccount account) { |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 710 | try { |
| 711 | if (isServiceConnected()) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 712 | getTelecomService().registerPhoneAccount(account); |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 713 | } |
| 714 | } catch (RemoteException e) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 715 | Log.e(TAG, "Error calling ITelecomService#registerPhoneAccount", e); |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 716 | } |
| 717 | } |
| 718 | |
| 719 | /** |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 720 | * Remove a {@link PhoneAccount} registration from the system. |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 721 | * |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 722 | * @param accountHandle A {@link PhoneAccountHandle} for the {@link PhoneAccount} to unregister. |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 723 | */ |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 724 | public void unregisterPhoneAccount(PhoneAccountHandle accountHandle) { |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 725 | try { |
| 726 | if (isServiceConnected()) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 727 | getTelecomService().unregisterPhoneAccount(accountHandle); |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 728 | } |
| 729 | } catch (RemoteException e) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 730 | Log.e(TAG, "Error calling ITelecomService#unregisterPhoneAccount", e); |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 731 | } |
| 732 | } |
| 733 | |
| 734 | /** |
| Nancy Chen | 7ab1dc4 | 2014-09-09 18:18:26 -0700 | [diff] [blame] | 735 | * Remove all Accounts that belong to the calling package from the system. |
| Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 736 | * @hide |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 737 | */ |
| Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 738 | @SystemApi |
| Yorke Lee | 0604427 | 2015-04-14 15:16:59 -0700 | [diff] [blame] | 739 | public void clearPhoneAccounts() { |
| 740 | clearAccounts(); |
| 741 | } |
| 742 | /** |
| 743 | * Remove all Accounts that belong to the calling package from the system. |
| 744 | * @deprecated Use {@link #clearPhoneAccounts()} instead. |
| 745 | * @hide |
| 746 | */ |
| 747 | @SystemApi |
| Nancy Chen | 7ab1dc4 | 2014-09-09 18:18:26 -0700 | [diff] [blame] | 748 | public void clearAccounts() { |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 749 | try { |
| 750 | if (isServiceConnected()) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 751 | getTelecomService().clearAccounts(mContext.getPackageName()); |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 752 | } |
| 753 | } catch (RemoteException e) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 754 | Log.e(TAG, "Error calling ITelecomService#clearAccounts", e); |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 755 | } |
| 756 | } |
| 757 | |
| 758 | /** |
| Anthony Lee | 6727926 | 2014-10-27 11:28:40 -0700 | [diff] [blame] | 759 | * Remove all Accounts that belong to the specified package from the system. |
| 760 | * @hide |
| 761 | */ |
| 762 | public void clearAccountsForPackage(String packageName) { |
| 763 | try { |
| 764 | if (isServiceConnected() && !TextUtils.isEmpty(packageName)) { |
| 765 | getTelecomService().clearAccounts(packageName); |
| 766 | } |
| 767 | } catch (RemoteException e) { |
| Nancy Chen | 5cf2784 | 2015-01-24 23:30:27 -0800 | [diff] [blame] | 768 | Log.e(TAG, "Error calling ITelecomService#clearAccountsForPackage", e); |
| Anthony Lee | 6727926 | 2014-10-27 11:28:40 -0700 | [diff] [blame] | 769 | } |
| 770 | } |
| 771 | |
| Yorke Lee | 1011f48 | 2015-04-23 15:58:27 -0700 | [diff] [blame] | 772 | |
| Anthony Lee | 6727926 | 2014-10-27 11:28:40 -0700 | [diff] [blame] | 773 | /** |
| Yorke Lee | 1011f48 | 2015-04-23 15:58:27 -0700 | [diff] [blame] | 774 | * @deprecated - Use {@link TelecomManager#getDefaultDialerPackage} to directly access |
| 775 | * the default dialer's package name instead. |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 776 | * @hide |
| 777 | */ |
| Santos Cordon | 6c7a388 | 2014-06-25 15:30:08 -0700 | [diff] [blame] | 778 | @SystemApi |
| 779 | public ComponentName getDefaultPhoneApp() { |
| 780 | try { |
| Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 781 | if (isServiceConnected()) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 782 | return getTelecomService().getDefaultPhoneApp(); |
| Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 783 | } |
| Santos Cordon | 6c7a388 | 2014-06-25 15:30:08 -0700 | [diff] [blame] | 784 | } catch (RemoteException e) { |
| 785 | Log.e(TAG, "RemoteException attempting to get the default phone app.", e); |
| 786 | } |
| 787 | return null; |
| 788 | } |
| 789 | |
| Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 790 | /** |
| Yorke Lee | 1011f48 | 2015-04-23 15:58:27 -0700 | [diff] [blame] | 791 | * Used to determine the currently selected default dialer package. |
| 792 | * |
| 793 | * @return package name for the default dialer package or null if no package has been |
| 794 | * selected as the default dialer. |
| 795 | */ |
| 796 | public String getDefaultDialerPackage() { |
| 797 | try { |
| 798 | if (isServiceConnected()) { |
| 799 | return getTelecomService().getDefaultDialerPackage(); |
| 800 | } |
| 801 | } catch (RemoteException e) { |
| 802 | Log.e(TAG, "RemoteException attempting to get the default dialer package name.", e); |
| 803 | } |
| 804 | return null; |
| 805 | } |
| 806 | |
| 807 | /** |
| 808 | * Used to determine the dialer package that is preloaded on the system partition. |
| 809 | * |
| 810 | * @return package name for the system dialer package or null if no system dialer is preloaded. |
| 811 | * @hide |
| 812 | */ |
| 813 | public String getSystemDialerPackage() { |
| 814 | try { |
| 815 | if (isServiceConnected()) { |
| 816 | return getTelecomService().getSystemDialerPackage(); |
| 817 | } |
| 818 | } catch (RemoteException e) { |
| 819 | Log.e(TAG, "RemoteException attempting to get the system dialer package name.", e); |
| 820 | } |
| 821 | return null; |
| 822 | } |
| 823 | |
| 824 | /** |
| Nancy Chen | 443e501 | 2014-10-15 15:48:21 -0700 | [diff] [blame] | 825 | * Return whether a given phone number is the configured voicemail number for a |
| 826 | * particular phone account. |
| 827 | * |
| 828 | * @param accountHandle The handle for the account to check the voicemail number against |
| 829 | * @param number The number to look up. |
| Nancy Chen | 443e501 | 2014-10-15 15:48:21 -0700 | [diff] [blame] | 830 | */ |
| Nancy Chen | 443e501 | 2014-10-15 15:48:21 -0700 | [diff] [blame] | 831 | public boolean isVoiceMailNumber(PhoneAccountHandle accountHandle, String number) { |
| 832 | try { |
| 833 | if (isServiceConnected()) { |
| Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 834 | return getTelecomService().isVoiceMailNumber(accountHandle, number, |
| 835 | mContext.getOpPackageName()); |
| Nancy Chen | 443e501 | 2014-10-15 15:48:21 -0700 | [diff] [blame] | 836 | } |
| 837 | } catch (RemoteException e) { |
| Nancy Chen | 5cf2784 | 2015-01-24 23:30:27 -0800 | [diff] [blame] | 838 | Log.e(TAG, "RemoteException calling ITelecomService#isVoiceMailNumber.", e); |
| Nancy Chen | 443e501 | 2014-10-15 15:48:21 -0700 | [diff] [blame] | 839 | } |
| 840 | return false; |
| 841 | } |
| 842 | |
| 843 | /** |
| Yorke Lee | 49e2d46 | 2015-04-15 16:14:22 -0700 | [diff] [blame] | 844 | * Return the voicemail number for a given phone account. |
| Nancy Chen | 8c066f7c | 2014-12-03 15:18:08 -0800 | [diff] [blame] | 845 | * |
| Yorke Lee | 49e2d46 | 2015-04-15 16:14:22 -0700 | [diff] [blame] | 846 | * @param accountHandle The handle for the phone account. |
| 847 | * @return The voicemail number for the phone account, and {@code null} if one has not been |
| 848 | * configured. |
| Nancy Chen | 8c066f7c | 2014-12-03 15:18:08 -0800 | [diff] [blame] | 849 | */ |
| Yorke Lee | 49e2d46 | 2015-04-15 16:14:22 -0700 | [diff] [blame] | 850 | public String getVoiceMailNumber(PhoneAccountHandle accountHandle) { |
| Nancy Chen | 8c066f7c | 2014-12-03 15:18:08 -0800 | [diff] [blame] | 851 | try { |
| 852 | if (isServiceConnected()) { |
| Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 853 | return getTelecomService().getVoiceMailNumber(accountHandle, |
| 854 | mContext.getOpPackageName()); |
| Nancy Chen | 8c066f7c | 2014-12-03 15:18:08 -0800 | [diff] [blame] | 855 | } |
| 856 | } catch (RemoteException e) { |
| Nancy Chen | 5cf2784 | 2015-01-24 23:30:27 -0800 | [diff] [blame] | 857 | Log.e(TAG, "RemoteException calling ITelecomService#hasVoiceMailNumber.", e); |
| Nancy Chen | 8c066f7c | 2014-12-03 15:18:08 -0800 | [diff] [blame] | 858 | } |
| Yorke Lee | 49e2d46 | 2015-04-15 16:14:22 -0700 | [diff] [blame] | 859 | return null; |
| Nancy Chen | 8c066f7c | 2014-12-03 15:18:08 -0800 | [diff] [blame] | 860 | } |
| 861 | |
| 862 | /** |
| Nancy Chen | 5cf2784 | 2015-01-24 23:30:27 -0800 | [diff] [blame] | 863 | * Return the line 1 phone number for given phone account. |
| 864 | * |
| 865 | * @param accountHandle The handle for the account retrieve a number for. |
| 866 | * @return A string representation of the line 1 phone number. |
| Nancy Chen | 5cf2784 | 2015-01-24 23:30:27 -0800 | [diff] [blame] | 867 | */ |
| Nancy Chen | 5cf2784 | 2015-01-24 23:30:27 -0800 | [diff] [blame] | 868 | public String getLine1Number(PhoneAccountHandle accountHandle) { |
| 869 | try { |
| 870 | if (isServiceConnected()) { |
| Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 871 | return getTelecomService().getLine1Number(accountHandle, |
| 872 | mContext.getOpPackageName()); |
| Nancy Chen | 5cf2784 | 2015-01-24 23:30:27 -0800 | [diff] [blame] | 873 | } |
| 874 | } catch (RemoteException e) { |
| 875 | Log.e(TAG, "RemoteException calling ITelecomService#getLine1Number.", e); |
| 876 | } |
| 877 | return null; |
| 878 | } |
| 879 | |
| 880 | /** |
| Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 881 | * Returns whether there is an ongoing phone call (can be in dialing, ringing, active or holding |
| 882 | * states). |
| Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 883 | * <p> |
| 884 | * Requires permission: {@link android.Manifest.permission#READ_PHONE_STATE} |
| 885 | * </p> |
| Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 886 | */ |
| Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 887 | public boolean isInCall() { |
| Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 888 | try { |
| 889 | if (isServiceConnected()) { |
| Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 890 | return getTelecomService().isInCall(mContext.getOpPackageName()); |
| Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 891 | } |
| 892 | } catch (RemoteException e) { |
| Yorke Lee | 2ae312e | 2014-09-12 17:58:48 -0700 | [diff] [blame] | 893 | Log.e(TAG, "RemoteException calling isInCall().", e); |
| Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 894 | } |
| 895 | return false; |
| 896 | } |
| 897 | |
| 898 | /** |
| Yorke Lee | 2ae312e | 2014-09-12 17:58:48 -0700 | [diff] [blame] | 899 | * Returns one of the following constants that represents the current state of Telecom: |
| 900 | * |
| 901 | * {@link TelephonyManager#CALL_STATE_RINGING} |
| 902 | * {@link TelephonyManager#CALL_STATE_OFFHOOK} |
| 903 | * {@link TelephonyManager#CALL_STATE_IDLE} |
| Yorke Lee | 7c72c2d | 2014-10-28 14:12:02 -0700 | [diff] [blame] | 904 | * |
| 905 | * Note that this API does not require the |
| 906 | * {@link android.Manifest.permission#READ_PHONE_STATE} permission. This is intentional, to |
| 907 | * preserve the behavior of {@link TelephonyManager#getCallState()}, which also did not require |
| 908 | * the permission. |
| Yorke Lee | 2ae312e | 2014-09-12 17:58:48 -0700 | [diff] [blame] | 909 | * @hide |
| 910 | */ |
| 911 | @SystemApi |
| 912 | public int getCallState() { |
| 913 | try { |
| 914 | if (isServiceConnected()) { |
| 915 | return getTelecomService().getCallState(); |
| 916 | } |
| 917 | } catch (RemoteException e) { |
| 918 | Log.d(TAG, "RemoteException calling getCallState().", e); |
| 919 | } |
| 920 | return TelephonyManager.CALL_STATE_IDLE; |
| 921 | } |
| 922 | |
| 923 | /** |
| Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 924 | * Returns whether there currently exists is a ringing incoming-call. |
| 925 | * |
| 926 | * @hide |
| 927 | */ |
| 928 | @SystemApi |
| 929 | public boolean isRinging() { |
| 930 | try { |
| 931 | if (isServiceConnected()) { |
| Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 932 | return getTelecomService().isRinging(mContext.getOpPackageName()); |
| Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 933 | } |
| 934 | } catch (RemoteException e) { |
| 935 | Log.e(TAG, "RemoteException attempting to get ringing state of phone app.", e); |
| 936 | } |
| 937 | return false; |
| 938 | } |
| 939 | |
| 940 | /** |
| Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 941 | * Ends an ongoing call. |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 942 | * TODO: L-release - need to convert all invocations of ITelecomService#endCall to use this |
| Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 943 | * method (clockwork & gearhead). |
| Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 944 | * @hide |
| 945 | */ |
| 946 | @SystemApi |
| 947 | public boolean endCall() { |
| 948 | try { |
| 949 | if (isServiceConnected()) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 950 | return getTelecomService().endCall(); |
| Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 951 | } |
| 952 | } catch (RemoteException e) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 953 | Log.e(TAG, "Error calling ITelecomService#endCall", e); |
| Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 954 | } |
| 955 | return false; |
| 956 | } |
| 957 | |
| 958 | /** |
| 959 | * If there is a ringing incoming call, this method accepts the call on behalf of the user. |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 960 | * TODO: L-release - need to convert all invocation of ITelecmmService#answerRingingCall to use |
| Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 961 | * this method (clockwork & gearhead). |
| Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 962 | * |
| 963 | * @hide |
| 964 | */ |
| 965 | @SystemApi |
| 966 | public void acceptRingingCall() { |
| 967 | try { |
| 968 | if (isServiceConnected()) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 969 | getTelecomService().acceptRingingCall(); |
| Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 970 | } |
| 971 | } catch (RemoteException e) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 972 | Log.e(TAG, "Error calling ITelecomService#acceptRingingCall", e); |
| Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 973 | } |
| 974 | } |
| 975 | |
| 976 | /** |
| 977 | * Silences the ringer if a ringing call exists. |
| Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 978 | */ |
| Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 979 | public void silenceRinger() { |
| 980 | try { |
| 981 | if (isServiceConnected()) { |
| Yorke Lee | f1a349b | 2015-04-29 16:16:50 -0700 | [diff] [blame] | 982 | getTelecomService().silenceRinger(mContext.getOpPackageName()); |
| Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 983 | } |
| 984 | } catch (RemoteException e) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 985 | Log.e(TAG, "Error calling ITelecomService#silenceRinger", e); |
| Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 986 | } |
| 987 | } |
| 988 | |
| Sailesh Nepal | 001bbbb | 2014-07-15 14:40:39 -0700 | [diff] [blame] | 989 | /** |
| 990 | * Returns whether TTY is supported on this device. |
| 991 | * |
| 992 | * @hide |
| 993 | */ |
| 994 | @SystemApi |
| 995 | public boolean isTtySupported() { |
| 996 | try { |
| 997 | if (isServiceConnected()) { |
| Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 998 | return getTelecomService().isTtySupported(mContext.getOpPackageName()); |
| Sailesh Nepal | 001bbbb | 2014-07-15 14:40:39 -0700 | [diff] [blame] | 999 | } |
| 1000 | } catch (RemoteException e) { |
| 1001 | Log.e(TAG, "RemoteException attempting to get TTY supported state.", e); |
| 1002 | } |
| 1003 | return false; |
| 1004 | } |
| 1005 | |
| 1006 | /** |
| 1007 | * 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] | 1008 | * settings and have a wired headset plugged in. |
| 1009 | * Valid modes are: |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1010 | * - {@link TelecomManager#TTY_MODE_OFF} |
| 1011 | * - {@link TelecomManager#TTY_MODE_FULL} |
| 1012 | * - {@link TelecomManager#TTY_MODE_HCO} |
| 1013 | * - {@link TelecomManager#TTY_MODE_VCO} |
| Sailesh Nepal | 001bbbb | 2014-07-15 14:40:39 -0700 | [diff] [blame] | 1014 | * @hide |
| 1015 | */ |
| 1016 | public int getCurrentTtyMode() { |
| 1017 | try { |
| 1018 | if (isServiceConnected()) { |
| Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 1019 | return getTelecomService().getCurrentTtyMode(mContext.getOpPackageName()); |
| Sailesh Nepal | 001bbbb | 2014-07-15 14:40:39 -0700 | [diff] [blame] | 1020 | } |
| 1021 | } catch (RemoteException e) { |
| 1022 | Log.e(TAG, "RemoteException attempting to get the current TTY mode.", e); |
| 1023 | } |
| Evan Charlton | 1019719 | 2014-07-19 15:00:29 -0700 | [diff] [blame] | 1024 | return TTY_MODE_OFF; |
| Sailesh Nepal | 001bbbb | 2014-07-15 14:40:39 -0700 | [diff] [blame] | 1025 | } |
| 1026 | |
| Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 1027 | /** |
| 1028 | * Registers a new incoming call. A {@link ConnectionService} should invoke this method when it |
| 1029 | * has an incoming call. The specified {@link PhoneAccountHandle} must have been registered |
| Nancy Chen | 210ef03 | 2014-09-15 17:58:42 -0700 | [diff] [blame] | 1030 | * with {@link #registerPhoneAccount}. Once invoked, this method will cause the system to bind |
| 1031 | * to the {@link ConnectionService} associated with the {@link PhoneAccountHandle} and request |
| Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 1032 | * additional information about the call (See |
| 1033 | * {@link ConnectionService#onCreateIncomingConnection}) before starting the incoming call UI. |
| 1034 | * |
| 1035 | * @param phoneAccount A {@link PhoneAccountHandle} registered with |
| 1036 | * {@link #registerPhoneAccount}. |
| 1037 | * @param extras A bundle that will be passed through to |
| 1038 | * {@link ConnectionService#onCreateIncomingConnection}. |
| 1039 | */ |
| 1040 | public void addNewIncomingCall(PhoneAccountHandle phoneAccount, Bundle extras) { |
| 1041 | try { |
| 1042 | if (isServiceConnected()) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1043 | getTelecomService().addNewIncomingCall( |
| Santos Cordon | 96efb48 | 2014-07-19 14:57:05 -0700 | [diff] [blame] | 1044 | phoneAccount, extras == null ? new Bundle() : extras); |
| 1045 | } |
| 1046 | } catch (RemoteException e) { |
| 1047 | Log.e(TAG, "RemoteException adding a new incoming call: " + phoneAccount, e); |
| 1048 | } |
| 1049 | } |
| 1050 | |
| Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1051 | /** |
| Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 1052 | * Registers a new unknown call with Telecom. This can only be called by the system Telephony |
| 1053 | * service. This is invoked when Telephony detects a new unknown connection that was neither |
| 1054 | * a new incoming call, nor an user-initiated outgoing call. |
| 1055 | * |
| 1056 | * @param phoneAccount A {@link PhoneAccountHandle} registered with |
| 1057 | * {@link #registerPhoneAccount}. |
| 1058 | * @param extras A bundle that will be passed through to |
| 1059 | * {@link ConnectionService#onCreateIncomingConnection}. |
| 1060 | * @hide |
| 1061 | */ |
| 1062 | @SystemApi |
| 1063 | public void addNewUnknownCall(PhoneAccountHandle phoneAccount, Bundle extras) { |
| 1064 | try { |
| 1065 | if (isServiceConnected()) { |
| 1066 | getTelecomService().addNewUnknownCall( |
| 1067 | phoneAccount, extras == null ? new Bundle() : extras); |
| 1068 | } |
| 1069 | } catch (RemoteException e) { |
| 1070 | Log.e(TAG, "RemoteException adding a new unknown call: " + phoneAccount, e); |
| 1071 | } |
| 1072 | } |
| 1073 | |
| 1074 | /** |
| Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1075 | * Processes the specified dial string as an MMI code. |
| 1076 | * MMI codes are any sequence of characters entered into the dialpad that contain a "*" or "#". |
| 1077 | * Some of these sequences launch special behavior through handled by Telephony. |
| Nancy Chen | 95e8a67 | 2014-10-16 18:38:21 -0700 | [diff] [blame] | 1078 | * This method uses the default subscription. |
| Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1079 | * <p> |
| 1080 | * Requires that the method-caller be set as the system dialer app. |
| 1081 | * </p> |
| 1082 | * |
| 1083 | * @param dialString The digits to dial. |
| 1084 | * @return True if the digits were processed as an MMI code, false otherwise. |
| 1085 | */ |
| 1086 | public boolean handleMmi(String dialString) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1087 | ITelecomService service = getTelecomService(); |
| Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1088 | if (service != null) { |
| 1089 | try { |
| Yorke Lee | f1a349b | 2015-04-29 16:16:50 -0700 | [diff] [blame] | 1090 | return service.handlePinMmi(dialString, mContext.getOpPackageName()); |
| Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1091 | } catch (RemoteException e) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1092 | Log.e(TAG, "Error calling ITelecomService#handlePinMmi", e); |
| Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1093 | } |
| 1094 | } |
| 1095 | return false; |
| 1096 | } |
| 1097 | |
| 1098 | /** |
| Nancy Chen | 95e8a67 | 2014-10-16 18:38:21 -0700 | [diff] [blame] | 1099 | * Processes the specified dial string as an MMI code. |
| 1100 | * MMI codes are any sequence of characters entered into the dialpad that contain a "*" or "#". |
| 1101 | * Some of these sequences launch special behavior through handled by Telephony. |
| 1102 | * <p> |
| 1103 | * Requires that the method-caller be set as the system dialer app. |
| 1104 | * </p> |
| 1105 | * |
| 1106 | * @param accountHandle The handle for the account the MMI code should apply to. |
| 1107 | * @param dialString The digits to dial. |
| 1108 | * @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] | 1109 | */ |
| Yorke Lee | 0604427 | 2015-04-14 15:16:59 -0700 | [diff] [blame] | 1110 | public boolean handleMmi(String dialString, PhoneAccountHandle accountHandle) { |
| Nancy Chen | 95e8a67 | 2014-10-16 18:38:21 -0700 | [diff] [blame] | 1111 | ITelecomService service = getTelecomService(); |
| 1112 | if (service != null) { |
| 1113 | try { |
| Yorke Lee | f1a349b | 2015-04-29 16:16:50 -0700 | [diff] [blame] | 1114 | return service.handlePinMmiForPhoneAccount(accountHandle, dialString, |
| 1115 | mContext.getOpPackageName()); |
| Nancy Chen | 95e8a67 | 2014-10-16 18:38:21 -0700 | [diff] [blame] | 1116 | } catch (RemoteException e) { |
| 1117 | Log.e(TAG, "Error calling ITelecomService#handlePinMmi", e); |
| 1118 | } |
| 1119 | } |
| 1120 | return false; |
| 1121 | } |
| 1122 | |
| 1123 | /** |
| Nancy Chen | b2299c1 | 2014-10-29 18:22:11 -0700 | [diff] [blame] | 1124 | * @param accountHandle The handle for the account to derive an adn query URI for or |
| 1125 | * {@code null} to return a URI which will use the default account. |
| 1126 | * @return The URI (with the content:// scheme) specific to the specified {@link PhoneAccount} |
| 1127 | * for the the content retrieve. |
| 1128 | */ |
| 1129 | public Uri getAdnUriForPhoneAccount(PhoneAccountHandle accountHandle) { |
| 1130 | ITelecomService service = getTelecomService(); |
| 1131 | if (service != null && accountHandle != null) { |
| 1132 | try { |
| Yorke Lee | f1a349b | 2015-04-29 16:16:50 -0700 | [diff] [blame] | 1133 | return service.getAdnUriForPhoneAccount(accountHandle, mContext.getOpPackageName()); |
| Nancy Chen | b2299c1 | 2014-10-29 18:22:11 -0700 | [diff] [blame] | 1134 | } catch (RemoteException e) { |
| 1135 | Log.e(TAG, "Error calling ITelecomService#getAdnUriForPhoneAccount", e); |
| 1136 | } |
| 1137 | } |
| 1138 | return Uri.parse("content://icc/adn"); |
| 1139 | } |
| 1140 | |
| 1141 | /** |
| Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1142 | * Removes the missed-call notification if one is present. |
| 1143 | * <p> |
| 1144 | * Requires that the method-caller be set as the system dialer app. |
| 1145 | * </p> |
| 1146 | */ |
| 1147 | public void cancelMissedCallsNotification() { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1148 | ITelecomService service = getTelecomService(); |
| Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1149 | if (service != null) { |
| 1150 | try { |
| Yorke Lee | f1a349b | 2015-04-29 16:16:50 -0700 | [diff] [blame] | 1151 | service.cancelMissedCallsNotification(mContext.getOpPackageName()); |
| Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1152 | } catch (RemoteException e) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1153 | Log.e(TAG, "Error calling ITelecomService#cancelMissedCallsNotification", e); |
| Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1154 | } |
| 1155 | } |
| 1156 | } |
| 1157 | |
| 1158 | /** |
| 1159 | * Brings the in-call screen to the foreground if there is an ongoing call. If there is |
| 1160 | * currently no ongoing call, then this method does nothing. |
| 1161 | * <p> |
| 1162 | * Requires that the method-caller be set as the system dialer app or have the |
| 1163 | * {@link android.Manifest.permission#READ_PHONE_STATE} permission. |
| 1164 | * </p> |
| 1165 | * |
| 1166 | * @param showDialpad Brings up the in-call dialpad as part of showing the in-call screen. |
| 1167 | */ |
| 1168 | public void showInCallScreen(boolean showDialpad) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1169 | ITelecomService service = getTelecomService(); |
| Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1170 | if (service != null) { |
| 1171 | try { |
| Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 1172 | service.showInCallScreen(showDialpad, mContext.getOpPackageName()); |
| Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1173 | } catch (RemoteException e) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1174 | Log.e(TAG, "Error calling ITelecomService#showCallScreen", e); |
| Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 1175 | } |
| 1176 | } |
| 1177 | } |
| 1178 | |
| Yorke Lee | 3e56ba1 | 2015-04-23 12:32:36 -0700 | [diff] [blame] | 1179 | /** |
| 1180 | * Places a new outgoing call to the provided address using the system telecom service with |
| 1181 | * the specified extras. |
| 1182 | * |
| 1183 | * This method is equivalent to placing an outgoing call using {@link Intent#ACTION_CALL}, |
| 1184 | * except that the outgoing call will always be sent via the system telecom service. If |
| 1185 | * method-caller is either the user selected default dialer app or preloaded system dialer |
| 1186 | * app, then emergency calls will also be allowed. |
| 1187 | * |
| 1188 | * Requires permission: {@link android.Manifest.permission#CALL_PHONE} |
| 1189 | * |
| 1190 | * Usage example: |
| 1191 | * <pre> |
| 1192 | * Uri uri = Uri.fromParts("tel", "12345", null); |
| 1193 | * Bundle extras = new Bundle(); |
| 1194 | * extras.putBoolean(TelecomManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, true); |
| 1195 | * telecomManager.placeCall(uri, extras); |
| 1196 | * </pre> |
| 1197 | * |
| 1198 | * @param address The address to make the call to. |
| 1199 | * @param extras Bundle of extras to use with the call. |
| 1200 | */ |
| 1201 | public void placeCall(Uri address, Bundle extras) { |
| 1202 | ITelecomService service = getTelecomService(); |
| 1203 | if (service != null) { |
| Yorke Lee | a5d5c1d | 2015-05-05 16:25:55 -0700 | [diff] [blame] | 1204 | if (address == null) { |
| 1205 | Log.w(TAG, "Cannot place call to empty address."); |
| 1206 | } |
| Yorke Lee | 3e56ba1 | 2015-04-23 12:32:36 -0700 | [diff] [blame] | 1207 | try { |
| Yorke Lee | a5d5c1d | 2015-05-05 16:25:55 -0700 | [diff] [blame] | 1208 | service.placeCall(address, extras == null ? new Bundle() : extras, |
| 1209 | mContext.getOpPackageName()); |
| Yorke Lee | 3e56ba1 | 2015-04-23 12:32:36 -0700 | [diff] [blame] | 1210 | } catch (RemoteException e) { |
| 1211 | Log.e(TAG, "Error calling ITelecomService#placeCall", e); |
| 1212 | } |
| 1213 | } |
| 1214 | } |
| 1215 | |
| Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 1216 | /** |
| 1217 | * Enables and disables specified phone account. |
| 1218 | * |
| 1219 | * @param handle Handle to the phone account. |
| 1220 | * @param isEnabled Enable state of the phone account. |
| 1221 | * @hide |
| 1222 | */ |
| 1223 | @SystemApi |
| 1224 | public void enablePhoneAccount(PhoneAccountHandle handle, boolean isEnabled) { |
| 1225 | ITelecomService service = getTelecomService(); |
| 1226 | if (service != null) { |
| 1227 | try { |
| 1228 | service.enablePhoneAccount(handle, isEnabled); |
| 1229 | } catch (RemoteException e) { |
| 1230 | Log.e(TAG, "Error enablePhoneAbbount", e); |
| 1231 | } |
| 1232 | } |
| 1233 | } |
| 1234 | |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1235 | private ITelecomService getTelecomService() { |
| 1236 | return ITelecomService.Stub.asInterface(ServiceManager.getService(Context.TELECOM_SERVICE)); |
| Santos Cordon | 6c7a388 | 2014-06-25 15:30:08 -0700 | [diff] [blame] | 1237 | } |
| Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1238 | |
| 1239 | private boolean isServiceConnected() { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1240 | boolean isConnected = getTelecomService() != null; |
| Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1241 | if (!isConnected) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1242 | Log.w(TAG, "Telecom Service not found."); |
| Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 1243 | } |
| 1244 | return isConnected; |
| 1245 | } |
| Evan Charlton | 235c159 | 2014-09-05 15:41:23 +0000 | [diff] [blame] | 1246 | } |