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