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