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