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