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