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