blob: 481e4836829fa9777e997217f1a31be4bb8d6ba9 [file] [log] [blame]
Yorke Leeb4ce1432014-06-09 13:53:23 -07001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
Santos Cordon9eb45932014-06-27 12:28:43 -07004 * 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 Leeb4ce1432014-06-09 13:53:23 -07006 *
Santos Cordon9eb45932014-06-27 12:28:43 -07007 * http://www.apache.org/licenses/LICENSE-2.0
Yorke Leeb4ce1432014-06-09 13:53:23 -07008 *
Santos Cordon9eb45932014-06-27 12:28:43 -07009 * 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 Leeb4ce1432014-06-09 13:53:23 -070013 */
14
Tyler Gunnef9f6f92014-09-12 22:16:17 -070015package android.telecom;
Yorke Leeb4ce1432014-06-09 13:53:23 -070016
Santos Cordon6c7a3882014-06-25 15:30:08 -070017import android.annotation.SystemApi;
18import android.content.ComponentName;
Yorke Leeb4ce1432014-06-09 13:53:23 -070019import android.content.Context;
Santos Cordon96efb482014-07-19 14:57:05 -070020import android.os.Bundle;
Santos Cordon6c7a3882014-06-25 15:30:08 -070021import android.os.RemoteException;
22import android.os.ServiceManager;
Yorke Lee2ae312e2014-09-12 17:58:48 -070023import android.telephony.TelephonyManager;
Santos Cordon6c7a3882014-06-25 15:30:08 -070024import android.util.Log;
Yorke Leeb4ce1432014-06-09 13:53:23 -070025
Tyler Gunnef9f6f92014-09-12 22:16:17 -070026import com.android.internal.telecom.ITelecomService;
Yorke Leeb4ce1432014-06-09 13:53:23 -070027
Jay Shrauner7746a942014-08-26 12:15:15 -070028import java.util.ArrayList;
Tyler Gunna1ed7d12014-09-08 09:52:22 -070029import java.util.Collections;
Ihab Awad807fe0a2014-07-09 12:30:52 -070030import java.util.List;
31
Yorke Leeb4ce1432014-06-09 13:53:23 -070032/**
Tyler Gunnef9f6f92014-09-12 22:16:17 -070033 * Provides access to Telecom-related functionality.
Santos Cordon96efb482014-07-19 14:57:05 -070034 * TODO: Move this all into PhoneManager.
Yorke Leeb4ce1432014-06-09 13:53:23 -070035 */
Tyler Gunnef9f6f92014-09-12 22:16:17 -070036public class TelecomManager {
Ihab Awad807fe0a2014-07-09 12:30:52 -070037
Evan Charlton10197192014-07-19 15:00:29 -070038 /**
Santos Cordon96efb482014-07-19 14:57:05 -070039 * Activity action: Starts the UI for handing an incoming call. This intent starts the in-call
Tyler Gunnef9f6f92014-09-12 22:16:17 -070040 * 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 Cordon96efb482014-07-19 14:57:05 -070043 * 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 Gunnef9f6f92014-09-12 22:16:17 -070046 * {@link android.telecom.ConnectionService} that Telecom should bind to. Telecom will then
Evan Charlton10197192014-07-19 15:00:29 -070047 * ask the connection service for more information about the call prior to showing any UI.
48 *
Santos Cordon96efb482014-07-19 14:57:05 -070049 * @hide
Evan Charlton10197192014-07-19 15:00:29 -070050 */
Tyler Gunnef9f6f92014-09-12 22:16:17 -070051 public static final String ACTION_INCOMING_CALL = "android.telecom.action.INCOMING_CALL";
Evan Charlton10197192014-07-19 15:00:29 -070052
53 /**
Evan Charlton6eb262c2014-07-19 18:18:19 -070054 * The {@link android.content.Intent} action used to configure a
Tyler Gunnef9f6f92014-09-12 22:16:17 -070055 * {@link android.telecom.ConnectionService}.
Evan Charlton10197192014-07-19 15:00:29 -070056 */
57 public static final String ACTION_CONNECTION_SERVICE_CONFIGURE =
Tyler Gunnef9f6f92014-09-12 22:16:17 -070058 "android.telecom.action.CONNECTION_SERVICE_CONFIGURE";
Evan Charlton10197192014-07-19 15:00:29 -070059
60 /**
Yorke Lee3818a8922014-07-21 15:57:17 -070061 * The {@link android.content.Intent} action used to show the call settings page.
62 */
63 public static final String ACTION_SHOW_CALL_SETTINGS =
Tyler Gunnef9f6f92014-09-12 22:16:17 -070064 "android.telecom.action.SHOW_CALL_SETTINGS";
Yorke Lee3818a8922014-07-21 15:57:17 -070065
66 /**
Evan Charlton6d8604f2014-09-04 12:38:17 -070067 * The {@link android.content.Intent} action used to show the settings page used to configure
68 * {@link PhoneAccount} preferences.
69 */
70 public static final String ACTION_CHANGE_PHONE_ACCOUNTS =
Tyler Gunnef9f6f92014-09-12 22:16:17 -070071 "android.telecom.action.CHANGE_PHONE_ACCOUNTS";
Evan Charlton6d8604f2014-09-04 12:38:17 -070072
73 /**
Evan Charlton6eb262c2014-07-19 18:18:19 -070074 * Optional extra for {@link android.content.Intent#ACTION_CALL} containing a boolean that
75 * determines whether the speakerphone should be automatically turned on for an outgoing call.
Evan Charlton10197192014-07-19 15:00:29 -070076 */
77 public static final String EXTRA_START_CALL_WITH_SPEAKERPHONE =
Tyler Gunnef9f6f92014-09-12 22:16:17 -070078 "android.telecom.extra.START_CALL_WITH_SPEAKERPHONE";
Evan Charlton10197192014-07-19 15:00:29 -070079
80 /**
Evan Charlton6eb262c2014-07-19 18:18:19 -070081 * Optional extra for {@link android.content.Intent#ACTION_CALL} containing an integer that
82 * determines the desired video state for an outgoing call.
Santos Cordon96efb482014-07-19 14:57:05 -070083 * Valid options:
Ihab Awadb19a0bc2014-08-07 19:46:01 -070084 * {@link VideoProfile.VideoState#AUDIO_ONLY},
85 * {@link VideoProfile.VideoState#BIDIRECTIONAL},
86 * {@link VideoProfile.VideoState#RX_ENABLED},
87 * {@link VideoProfile.VideoState#TX_ENABLED}.
Tyler Gunn27d1e252014-08-21 16:38:40 -070088 * @hide
Evan Charlton10197192014-07-19 15:00:29 -070089 */
90 public static final String EXTRA_START_CALL_WITH_VIDEO_STATE =
Tyler Gunnef9f6f92014-09-12 22:16:17 -070091 "android.telecom.extra.START_CALL_WITH_VIDEO_STATE";
Evan Charlton10197192014-07-19 15:00:29 -070092
93 /**
Santos Cordon96efb482014-07-19 14:57:05 -070094 * The extra used with an {@link android.content.Intent#ACTION_CALL} and
95 * {@link android.content.Intent#ACTION_DIAL} {@code Intent} to specify a
96 * {@link PhoneAccountHandle} to use when making the call.
Evan Charlton10197192014-07-19 15:00:29 -070097 * <p class="note">
Santos Cordon96efb482014-07-19 14:57:05 -070098 * Retrieve with {@link android.content.Intent#getParcelableExtra(String)}.
Evan Charlton10197192014-07-19 15:00:29 -070099 */
Evan Charlton6eb262c2014-07-19 18:18:19 -0700100 public static final String EXTRA_PHONE_ACCOUNT_HANDLE =
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700101 "android.telecom.extra.PHONE_ACCOUNT_HANDLE";
Evan Charlton10197192014-07-19 15:00:29 -0700102
103 /**
Santos Cordon96efb482014-07-19 14:57:05 -0700104 * Optional extra for {@link #ACTION_INCOMING_CALL} containing a {@link Bundle} which contains
105 * metadata about the call. This {@link Bundle} will be returned to the
106 * {@link ConnectionService}.
107 *
108 * @hide
Evan Charlton10197192014-07-19 15:00:29 -0700109 */
110 public static final String EXTRA_INCOMING_CALL_EXTRAS =
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700111 "android.telecom.extra.INCOMING_CALL_EXTRAS";
Evan Charlton10197192014-07-19 15:00:29 -0700112
113 /**
Nancy Chen10798dc2014-08-08 14:00:25 -0700114 * Optional extra for {@link android.content.Intent#ACTION_CALL} and
115 * {@link android.content.Intent#ACTION_DIAL} {@code Intent} containing a {@link Bundle}
116 * which contains metadata about the call. This {@link Bundle} will be saved into
117 * {@code Call.Details}.
118 *
119 * @hide
120 */
121 public static final String EXTRA_OUTGOING_CALL_EXTRAS =
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700122 "android.telecom.extra.OUTGOING_CALL_EXTRAS";
Nancy Chen10798dc2014-08-08 14:00:25 -0700123
124 /**
Evan Charlton6eb262c2014-07-19 18:18:19 -0700125 * Optional extra for {@link android.telephony.TelephonyManager#ACTION_PHONE_STATE_CHANGED}
126 * containing the disconnect code.
Evan Charlton10197192014-07-19 15:00:29 -0700127 */
128 public static final String EXTRA_CALL_DISCONNECT_CAUSE =
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700129 "android.telecom.extra.CALL_DISCONNECT_CAUSE";
Evan Charlton10197192014-07-19 15:00:29 -0700130
131 /**
Evan Charlton6eb262c2014-07-19 18:18:19 -0700132 * Optional extra for {@link android.telephony.TelephonyManager#ACTION_PHONE_STATE_CHANGED}
133 * containing the disconnect message.
Evan Charlton10197192014-07-19 15:00:29 -0700134 */
135 public static final String EXTRA_CALL_DISCONNECT_MESSAGE =
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700136 "android.telecom.extra.CALL_DISCONNECT_MESSAGE";
Evan Charlton10197192014-07-19 15:00:29 -0700137
138 /**
Evan Charlton6eb262c2014-07-19 18:18:19 -0700139 * Optional extra for {@link android.telephony.TelephonyManager#ACTION_PHONE_STATE_CHANGED}
140 * containing the component name of the associated connection service.
Evan Charlton10197192014-07-19 15:00:29 -0700141 */
142 public static final String EXTRA_CONNECTION_SERVICE =
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700143 "android.telecom.extra.CONNECTION_SERVICE";
Evan Charlton10197192014-07-19 15:00:29 -0700144
145 /**
Nancy Chen7ab1dc42014-09-09 18:18:26 -0700146 * An optional {@link android.content.Intent#ACTION_CALL} intent extra denoting the
147 * package name of the app specifying an alternative gateway for the call.
148 * The value is a string.
149 *
150 * (The following comment corresponds to the all GATEWAY_* extras)
151 * An app which sends the {@link android.content.Intent#ACTION_CALL} intent can specify an
152 * alternative address to dial which is different from the one specified and displayed to
153 * the user. This alternative address is referred to as the gateway address.
154 */
155 public static final String GATEWAY_PROVIDER_PACKAGE =
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700156 "android.telecom.extra.GATEWAY_PROVIDER_PACKAGE";
Nancy Chen7ab1dc42014-09-09 18:18:26 -0700157
158 /**
159 * An optional {@link android.content.Intent#ACTION_CALL} intent extra corresponding to the
160 * original address to dial for the call. This is used when an alternative gateway address is
161 * provided to recall the original address.
162 * The value is a {@link android.net.Uri}.
163 *
164 * (See {@link #GATEWAY_PROVIDER_PACKAGE} for details)
165 */
166 public static final String GATEWAY_ORIGINAL_ADDRESS =
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700167 "android.telecom.extra.GATEWAY_ORIGINAL_ADDRESS";
Nancy Chen7ab1dc42014-09-09 18:18:26 -0700168
169 /**
Evan Charlton10197192014-07-19 15:00:29 -0700170 * The number which the party on the other side of the line will see (and use to return the
171 * call).
172 * <p>
Santos Cordon96efb482014-07-19 14:57:05 -0700173 * {@link ConnectionService}s which interact with {@link RemoteConnection}s should only populate
174 * this if the {@link android.telephony.TelephonyManager#getLine1Number()} value, as that is the
175 * user's expected caller ID.
Evan Charlton10197192014-07-19 15:00:29 -0700176 */
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700177 public static final String EXTRA_CALL_BACK_NUMBER = "android.telecom.extra.CALL_BACK_NUMBER";
Evan Charlton10197192014-07-19 15:00:29 -0700178
179 /**
180 * The dual tone multi-frequency signaling character sent to indicate the dialing system should
181 * pause for a predefined period.
182 */
183 public static final char DTMF_CHARACTER_PAUSE = ',';
184
185 /**
186 * The dual-tone multi-frequency signaling character sent to indicate the dialing system should
187 * wait for user confirmation before proceeding.
188 */
189 public static final char DTMF_CHARACTER_WAIT = ';';
190
191 /**
192 * TTY (teletypewriter) mode is off.
193 *
194 * @hide
195 */
196 public static final int TTY_MODE_OFF = 0;
197
198 /**
199 * TTY (teletypewriter) mode is on. The speaker is off and the microphone is muted. The user
200 * will communicate with the remote party by sending and receiving text messages.
201 *
202 * @hide
203 */
204 public static final int TTY_MODE_FULL = 1;
205
206 /**
207 * TTY (teletypewriter) mode is in hearing carryover mode (HCO). The microphone is muted but the
208 * speaker is on. The user will communicate with the remote party by sending text messages and
209 * hearing an audible reply.
210 *
211 * @hide
212 */
213 public static final int TTY_MODE_HCO = 2;
214
215 /**
216 * TTY (teletypewriter) mode is in voice carryover mode (VCO). The speaker is off but the
217 * microphone is still on. User will communicate with the remote party by speaking and receiving
218 * text message replies.
219 *
220 * @hide
221 */
222 public static final int TTY_MODE_VCO = 3;
223
224 /**
225 * Broadcast intent action indicating that the current TTY mode has changed. An intent extra
226 * provides this state as an int.
Evan Charlton10197192014-07-19 15:00:29 -0700227 *
Santos Cordon96efb482014-07-19 14:57:05 -0700228 * @see #EXTRA_CURRENT_TTY_MODE
Evan Charlton10197192014-07-19 15:00:29 -0700229 * @hide
230 */
231 public static final String ACTION_CURRENT_TTY_MODE_CHANGED =
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700232 "android.telecom.action.CURRENT_TTY_MODE_CHANGED";
Evan Charlton10197192014-07-19 15:00:29 -0700233
234 /**
235 * The lookup key for an int that indicates the current TTY mode.
236 * Valid modes are:
237 * - {@link #TTY_MODE_OFF}
238 * - {@link #TTY_MODE_FULL}
239 * - {@link #TTY_MODE_HCO}
240 * - {@link #TTY_MODE_VCO}
241 *
242 * @hide
243 */
244 public static final String EXTRA_CURRENT_TTY_MODE =
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700245 "android.telecom.intent.extra.CURRENT_TTY_MODE";
Evan Charlton10197192014-07-19 15:00:29 -0700246
247 /**
Santos Cordon96efb482014-07-19 14:57:05 -0700248 * Broadcast intent action indicating that the TTY preferred operating mode has changed. An
249 * intent extra provides the new mode as an int.
Evan Charlton10197192014-07-19 15:00:29 -0700250 *
Santos Cordon96efb482014-07-19 14:57:05 -0700251 * @see #EXTRA_TTY_PREFERRED_MODE
Evan Charlton10197192014-07-19 15:00:29 -0700252 * @hide
253 */
254 public static final String ACTION_TTY_PREFERRED_MODE_CHANGED =
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700255 "android.telecom.action.TTY_PREFERRED_MODE_CHANGED";
Evan Charlton10197192014-07-19 15:00:29 -0700256
257 /**
Santos Cordon96efb482014-07-19 14:57:05 -0700258 * The lookup key for an int that indicates preferred TTY mode. Valid modes are: -
259 * {@link #TTY_MODE_OFF} - {@link #TTY_MODE_FULL} - {@link #TTY_MODE_HCO} -
260 * {@link #TTY_MODE_VCO}
Evan Charlton10197192014-07-19 15:00:29 -0700261 *
262 * @hide
263 */
264 public static final String EXTRA_TTY_PREFERRED_MODE =
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700265 "android.telecom.intent.extra.TTY_PREFERRED";
Evan Charlton10197192014-07-19 15:00:29 -0700266
Nancy Chen9d568c02014-09-08 14:17:59 -0700267 /**
268 * The following 4 constants define how properties such as phone numbers and names are
269 * displayed to the user.
270 */
271
272 /** Property is displayed normally. */
273 public static final int PRESENTATION_ALLOWED = 1;
274
275 /** Property was blocked. */
276 public static final int PRESENTATION_RESTRICTED = 2;
277
278 /** Presentation was not specified or is unknown. */
279 public static final int PRESENTATION_UNKNOWN = 3;
280
281 /** Property should be displayed as a pay phone. */
282 public static final int PRESENTATION_PAYPHONE = 4;
283
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700284 private static final String TAG = "TelecomManager";
Yorke Leeb4ce1432014-06-09 13:53:23 -0700285
286 private final Context mContext;
Yorke Leeb4ce1432014-06-09 13:53:23 -0700287
Santos Cordon6c7a3882014-06-25 15:30:08 -0700288 /**
289 * @hide
290 */
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700291 public static TelecomManager from(Context context) {
292 return (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
Yorke Leeb4ce1432014-06-09 13:53:23 -0700293 }
Santos Cordon6c7a3882014-06-25 15:30:08 -0700294
295 /**
296 * @hide
297 */
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700298 public TelecomManager(Context context) {
Ihab Awad807fe0a2014-07-09 12:30:52 -0700299 Context appContext = context.getApplicationContext();
300 if (appContext != null) {
301 mContext = appContext;
302 } else {
303 mContext = context;
304 }
305 }
306
307 /**
Santos Cordon96efb482014-07-19 14:57:05 -0700308 * Return the {@link PhoneAccount} which is the user-chosen default for making outgoing phone
Nancy Chen513c8922014-09-17 14:47:20 -0700309 * calls with a specified URI scheme.
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700310 * <p>
Santos Cordon96efb482014-07-19 14:57:05 -0700311 * Apps must be prepared for this method to return {@code null}, indicating that there currently
Nancy Chen513c8922014-09-17 14:47:20 -0700312 * exists no user-chosen default {@code PhoneAccount}.
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700313 * <p>
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700314 * @param uriScheme The URI scheme.
Nancy Chen513c8922014-09-17 14:47:20 -0700315 * @return The {@link PhoneAccountHandle} corresponding to the user-chosen default for outgoing
316 * phone calls for a specified URI scheme.
317 *
318 * @hide
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700319 */
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700320 public PhoneAccountHandle getDefaultOutgoingPhoneAccount(String uriScheme) {
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700321 try {
322 if (isServiceConnected()) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700323 return getTelecomService().getDefaultOutgoingPhoneAccount(uriScheme);
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700324 }
325 } catch (RemoteException e) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700326 Log.e(TAG, "Error calling ITelecomService#getDefaultOutgoingPhoneAccount", e);
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700327 }
328 return null;
329 }
330
331 /**
Andrew Leed4abbfb2014-09-03 14:58:27 -0700332 * Return the {@link PhoneAccount} which is the user-chosen default for making outgoing phone
333 * calls. This {@code PhoneAccount} will always be a member of the list which is returned from
Nancy Chen210ef032014-09-15 17:58:42 -0700334 * calling {@link #getCallCapablePhoneAccounts()}
Andrew Leed4abbfb2014-09-03 14:58:27 -0700335 *
336 * Apps must be prepared for this method to return {@code null}, indicating that there currently
337 * exists no user-chosen default {@code PhoneAccount}.
338 *
339 * @return The user outgoing phone account selected by the user.
340 * @hide
341 */
342 public PhoneAccountHandle getUserSelectedOutgoingPhoneAccount() {
343 try {
344 if (isServiceConnected()) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700345 return getTelecomService().getUserSelectedOutgoingPhoneAccount();
Andrew Leed4abbfb2014-09-03 14:58:27 -0700346 }
347 } catch (RemoteException e) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700348 Log.e(TAG, "Error calling ITelecomService#getUserSelectedOutgoingPhoneAccount", e);
Andrew Leed4abbfb2014-09-03 14:58:27 -0700349 }
350 return null;
351 }
352
353 /**
Andrew Lee59cac3a2014-08-28 16:50:10 -0700354 * Sets the default account for making outgoing phone calls.
355 * @hide
356 */
Andrew Leed4abbfb2014-09-03 14:58:27 -0700357 public void setUserSelectedOutgoingPhoneAccount(PhoneAccountHandle accountHandle) {
Andrew Lee59cac3a2014-08-28 16:50:10 -0700358 try {
359 if (isServiceConnected()) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700360 getTelecomService().setUserSelectedOutgoingPhoneAccount(accountHandle);
Andrew Lee59cac3a2014-08-28 16:50:10 -0700361 }
362 } catch (RemoteException e) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700363 Log.e(TAG, "Error calling ITelecomService#setUserSelectedOutgoingPhoneAccount");
Andrew Lee59cac3a2014-08-28 16:50:10 -0700364 }
365 }
366
367 /**
Andrew Lee59cac3a2014-08-28 16:50:10 -0700368 * Returns the current SIM call manager. Apps must be prepared for this method to return
369 * {@code null}, indicating that there currently exists no user-chosen default
370 * {@code PhoneAccount}.
371 * @return The phone account handle of the current sim call manager.
372 * @hide
373 */
374 public PhoneAccountHandle getSimCallManager() {
375 try {
376 if (isServiceConnected()) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700377 return getTelecomService().getSimCallManager();
Andrew Lee59cac3a2014-08-28 16:50:10 -0700378 }
379 } catch (RemoteException e) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700380 Log.e(TAG, "Error calling ITelecomService#getSimCallManager");
Andrew Lee59cac3a2014-08-28 16:50:10 -0700381 }
382 return null;
383 }
384
385 /**
386 * Sets the SIM call manager to the specified phone account.
387 * @param accountHandle The phone account handle of the account to set as the sim call manager.
388 * @hide
389 */
390 public void setSimCallManager(PhoneAccountHandle accountHandle) {
391 try {
392 if (isServiceConnected()) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700393 getTelecomService().setSimCallManager(accountHandle);
Andrew Lee59cac3a2014-08-28 16:50:10 -0700394 }
395 } catch (RemoteException e) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700396 Log.e(TAG, "Error calling ITelecomService#setSimCallManager");
Andrew Lee59cac3a2014-08-28 16:50:10 -0700397 }
398 }
399
400 /**
401 * Returns the list of registered SIM call managers.
402 * @return List of registered SIM call managers.
403 * @hide
404 */
405 public List<PhoneAccountHandle> getSimCallManagers() {
406 try {
407 if (isServiceConnected()) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700408 return getTelecomService().getSimCallManagers();
Andrew Lee59cac3a2014-08-28 16:50:10 -0700409 }
410 } catch (RemoteException e) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700411 Log.e(TAG, "Error calling ITelecomService#getSimCallManagers");
Andrew Lee59cac3a2014-08-28 16:50:10 -0700412 }
413 return new ArrayList<>();
414 }
415
416 /**
Evan Charltoneb0a8d562014-09-04 12:03:34 -0700417 * Returns the current connection manager. Apps must be prepared for this method to return
418 * {@code null}, indicating that there currently exists no user-chosen default
419 * {@code PhoneAccount}.
420 *
421 * @return The phone account handle of the current connection manager.
422 */
423 public PhoneAccountHandle getConnectionManager() {
424 return getSimCallManager();
425 }
426
427 /**
Nancy Chen210ef032014-09-15 17:58:42 -0700428 * Returns a list of the {@link PhoneAccountHandle}s which can be used to make and receive phone
429 * calls which support the specified URI scheme.
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700430 * <P>
431 * For example, invoking with {@code "tel"} will find all {@link PhoneAccountHandle}s which
432 * support telephone calls (e.g. URIs such as {@code tel:555-555-1212}). Invoking with
433 * {@code "sip"} will find all {@link PhoneAccountHandle}s which support SIP calls (e.g. URIs
434 * such as {@code sip:example@sipexample.com}).
435 *
436 * @param uriScheme The URI scheme.
437 * @return A list of {@code PhoneAccountHandle} objects supporting the URI scheme.
Nancy Chen513c8922014-09-17 14:47:20 -0700438 *
439 * @hide
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700440 */
441 public List<PhoneAccountHandle> getPhoneAccountsSupportingScheme(String uriScheme) {
442 try {
443 if (isServiceConnected()) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700444 return getTelecomService().getPhoneAccountsSupportingScheme(uriScheme);
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700445 }
446 } catch (RemoteException e) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700447 Log.e(TAG, "Error calling ITelecomService#getPhoneAccountsSupportingScheme", e);
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700448 }
449 return new ArrayList<>();
450 }
451
Nancy Chen513c8922014-09-17 14:47:20 -0700452
453 /**
454 * Return a list of {@link PhoneAccountHandle}s which can be used to make and receive phone
455 * calls.
456 *
457 * @see #EXTRA_PHONE_ACCOUNT_HANDLE
458 * @return A list of {@code PhoneAccountHandle} objects.
459 *
460 * @hide
461 */
462 public List<PhoneAccountHandle> getCallCapablePhoneAccounts() {
463 try {
464 if (isServiceConnected()) {
465 return getTelecomService().getCallCapablePhoneAccounts();
466 }
467 } catch (RemoteException e) {
468 Log.e(TAG, "Error calling ITelecomService#getCallCapablePhoneAccounts", e);
469 }
470 return new ArrayList<>();
471 }
472
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700473 /**
Nancy Chen210ef032014-09-15 17:58:42 -0700474 * Determine whether the device has more than one account registered that can make and receive
475 * phone calls.
Nancy Chen60801182014-07-22 16:56:49 -0700476 *
Nancy Chen210ef032014-09-15 17:58:42 -0700477 * @return {@code true} if the device has more than one account registered and {@code false}
478 * otherwise.
Nancy Chen60801182014-07-22 16:56:49 -0700479 */
Nancy Chen210ef032014-09-15 17:58:42 -0700480 public boolean hasMultipleCallCapableAccounts() {
481 return getCallCapablePhoneAccounts().size() > 1;
Nancy Chen60801182014-07-22 16:56:49 -0700482 }
483
484 /**
Nancy Chen513c8922014-09-17 14:47:20 -0700485 * Returns a list of all {@link PhoneAccount}s registered for the calling package.
486 *
487 * @return A list of {@code PhoneAccountHandle} objects.
488 */
489 public List<PhoneAccountHandle> getPhoneAccountsForPackage() {
490 try {
491 if (isServiceConnected()) {
492 return getTelecomService().getPhoneAccountsForPackage(mContext.getPackageName());
493 }
494 } catch (RemoteException e) {
495 Log.e(TAG, "Error calling ITelecomService#getPhoneAccountsForPackage", e);
496 }
497 return null;
498 }
499
500 /**
Evan Charlton8c8a0622014-07-20 12:31:00 -0700501 * Return the {@link PhoneAccount} for a specified {@link PhoneAccountHandle}. Object includes
502 * resources which can be used in a user interface.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700503 *
Evan Charlton6eb262c2014-07-19 18:18:19 -0700504 * @param account The {@link PhoneAccountHandle}.
Evan Charlton8c8a0622014-07-20 12:31:00 -0700505 * @return The {@link PhoneAccount} object.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700506 */
Evan Charlton8c8a0622014-07-20 12:31:00 -0700507 public PhoneAccount getPhoneAccount(PhoneAccountHandle account) {
Ihab Awad807fe0a2014-07-09 12:30:52 -0700508 try {
509 if (isServiceConnected()) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700510 return getTelecomService().getPhoneAccount(account);
Ihab Awad807fe0a2014-07-09 12:30:52 -0700511 }
512 } catch (RemoteException e) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700513 Log.e(TAG, "Error calling ITelecomService#getPhoneAccount", e);
Ihab Awad807fe0a2014-07-09 12:30:52 -0700514 }
515 return null;
516 }
517
518 /**
Nancy Chen210ef032014-09-15 17:58:42 -0700519 * Returns a count of all {@link PhoneAccount}s.
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700520 *
Nancy Chen210ef032014-09-15 17:58:42 -0700521 * @return The count of {@link PhoneAccount}s.
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700522 * @hide
523 */
524 @SystemApi
525 public int getAllPhoneAccountsCount() {
526 try {
527 if (isServiceConnected()) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700528 return getTelecomService().getAllPhoneAccountsCount();
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700529 }
530 } catch (RemoteException e) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700531 Log.e(TAG, "Error calling ITelecomService#getAllPhoneAccountsCount", e);
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700532 }
533 return 0;
534 }
535
536 /**
537 * Returns a list of all {@link PhoneAccount}s.
538 *
539 * @return All {@link PhoneAccount}s.
540 * @hide
541 */
542 @SystemApi
543 public List<PhoneAccount> getAllPhoneAccounts() {
544 try {
545 if (isServiceConnected()) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700546 return getTelecomService().getAllPhoneAccounts();
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700547 }
548 } catch (RemoteException e) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700549 Log.e(TAG, "Error calling ITelecomService#getAllPhoneAccounts", e);
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700550 }
551 return Collections.EMPTY_LIST;
552 }
553
554 /**
555 * Returns a list of all {@link PhoneAccountHandle}s.
556 *
557 * @return All {@link PhoneAccountHandle}s.
558 * @hide
559 */
560 @SystemApi
561 public List<PhoneAccountHandle> getAllPhoneAccountHandles() {
562 try {
563 if (isServiceConnected()) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700564 return getTelecomService().getAllPhoneAccountHandles();
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700565 }
566 } catch (RemoteException e) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700567 Log.e(TAG, "Error calling ITelecomService#getAllPhoneAccountHandles", e);
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700568 }
569 return Collections.EMPTY_LIST;
570 }
571
572 /**
Evan Charlton8c8a0622014-07-20 12:31:00 -0700573 * Register a {@link PhoneAccount} for use by the system.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700574 *
Evan Charlton8c8a0622014-07-20 12:31:00 -0700575 * @param account The complete {@link PhoneAccount}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700576 */
Evan Charlton8c8a0622014-07-20 12:31:00 -0700577 public void registerPhoneAccount(PhoneAccount account) {
Ihab Awad807fe0a2014-07-09 12:30:52 -0700578 try {
579 if (isServiceConnected()) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700580 getTelecomService().registerPhoneAccount(account);
Ihab Awad807fe0a2014-07-09 12:30:52 -0700581 }
582 } catch (RemoteException e) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700583 Log.e(TAG, "Error calling ITelecomService#registerPhoneAccount", e);
Ihab Awad807fe0a2014-07-09 12:30:52 -0700584 }
585 }
586
587 /**
Evan Charlton8c8a0622014-07-20 12:31:00 -0700588 * Remove a {@link PhoneAccount} registration from the system.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700589 *
Evan Charlton8c8a0622014-07-20 12:31:00 -0700590 * @param accountHandle A {@link PhoneAccountHandle} for the {@link PhoneAccount} to unregister.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700591 */
Evan Charlton8c8a0622014-07-20 12:31:00 -0700592 public void unregisterPhoneAccount(PhoneAccountHandle accountHandle) {
Ihab Awad807fe0a2014-07-09 12:30:52 -0700593 try {
594 if (isServiceConnected()) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700595 getTelecomService().unregisterPhoneAccount(accountHandle);
Ihab Awad807fe0a2014-07-09 12:30:52 -0700596 }
597 } catch (RemoteException e) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700598 Log.e(TAG, "Error calling ITelecomService#unregisterPhoneAccount", e);
Ihab Awad807fe0a2014-07-09 12:30:52 -0700599 }
600 }
601
602 /**
Nancy Chen7ab1dc42014-09-09 18:18:26 -0700603 * Remove all Accounts that belong to the calling package from the system.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700604 */
605 @SystemApi
Nancy Chen7ab1dc42014-09-09 18:18:26 -0700606 public void clearAccounts() {
Ihab Awad807fe0a2014-07-09 12:30:52 -0700607 try {
608 if (isServiceConnected()) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700609 getTelecomService().clearAccounts(mContext.getPackageName());
Ihab Awad807fe0a2014-07-09 12:30:52 -0700610 }
611 } catch (RemoteException e) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700612 Log.e(TAG, "Error calling ITelecomService#clearAccounts", e);
Ihab Awad807fe0a2014-07-09 12:30:52 -0700613 }
614 }
615
616 /**
617 * @hide
618 */
Santos Cordon6c7a3882014-06-25 15:30:08 -0700619 @SystemApi
620 public ComponentName getDefaultPhoneApp() {
621 try {
Santos Cordon9eb45932014-06-27 12:28:43 -0700622 if (isServiceConnected()) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700623 return getTelecomService().getDefaultPhoneApp();
Santos Cordon9eb45932014-06-27 12:28:43 -0700624 }
Santos Cordon6c7a3882014-06-25 15:30:08 -0700625 } catch (RemoteException e) {
626 Log.e(TAG, "RemoteException attempting to get the default phone app.", e);
627 }
628 return null;
629 }
630
Santos Cordon9eb45932014-06-27 12:28:43 -0700631 /**
632 * Returns whether there is an ongoing phone call (can be in dialing, ringing, active or holding
633 * states).
Nancy Chen0eb1e402014-08-21 22:52:29 -0700634 * <p>
635 * Requires permission: {@link android.Manifest.permission#READ_PHONE_STATE}
636 * </p>
Santos Cordon9eb45932014-06-27 12:28:43 -0700637 */
638 @SystemApi
Nancy Chen0eb1e402014-08-21 22:52:29 -0700639 public boolean isInCall() {
Santos Cordon9eb45932014-06-27 12:28:43 -0700640 try {
641 if (isServiceConnected()) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700642 return getTelecomService().isInCall();
Santos Cordon9eb45932014-06-27 12:28:43 -0700643 }
644 } catch (RemoteException e) {
Yorke Lee2ae312e2014-09-12 17:58:48 -0700645 Log.e(TAG, "RemoteException calling isInCall().", e);
Santos Cordon9eb45932014-06-27 12:28:43 -0700646 }
647 return false;
648 }
649
650 /**
Yorke Lee2ae312e2014-09-12 17:58:48 -0700651 * Returns one of the following constants that represents the current state of Telecom:
652 *
653 * {@link TelephonyManager#CALL_STATE_RINGING}
654 * {@link TelephonyManager#CALL_STATE_OFFHOOK}
655 * {@link TelephonyManager#CALL_STATE_IDLE}
Yorke Lee2ae312e2014-09-12 17:58:48 -0700656 * @hide
657 */
658 @SystemApi
659 public int getCallState() {
660 try {
661 if (isServiceConnected()) {
662 return getTelecomService().getCallState();
663 }
664 } catch (RemoteException e) {
665 Log.d(TAG, "RemoteException calling getCallState().", e);
666 }
667 return TelephonyManager.CALL_STATE_IDLE;
668 }
669
670 /**
Santos Cordon9eb45932014-06-27 12:28:43 -0700671 * Returns whether there currently exists is a ringing incoming-call.
672 *
673 * @hide
674 */
675 @SystemApi
676 public boolean isRinging() {
677 try {
678 if (isServiceConnected()) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700679 return getTelecomService().isRinging();
Santos Cordon9eb45932014-06-27 12:28:43 -0700680 }
681 } catch (RemoteException e) {
682 Log.e(TAG, "RemoteException attempting to get ringing state of phone app.", e);
683 }
684 return false;
685 }
686
687 /**
Santos Cordon96efb482014-07-19 14:57:05 -0700688 * Ends an ongoing call.
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700689 * TODO: L-release - need to convert all invocations of ITelecomService#endCall to use this
Santos Cordon96efb482014-07-19 14:57:05 -0700690 * method (clockwork & gearhead).
Santos Cordon9eb45932014-06-27 12:28:43 -0700691 * @hide
692 */
693 @SystemApi
694 public boolean endCall() {
695 try {
696 if (isServiceConnected()) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700697 return getTelecomService().endCall();
Santos Cordon9eb45932014-06-27 12:28:43 -0700698 }
699 } catch (RemoteException e) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700700 Log.e(TAG, "Error calling ITelecomService#endCall", e);
Santos Cordon9eb45932014-06-27 12:28:43 -0700701 }
702 return false;
703 }
704
705 /**
706 * If there is a ringing incoming call, this method accepts the call on behalf of the user.
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700707 * TODO: L-release - need to convert all invocation of ITelecmmService#answerRingingCall to use
Santos Cordon96efb482014-07-19 14:57:05 -0700708 * this method (clockwork & gearhead).
Santos Cordon9eb45932014-06-27 12:28:43 -0700709 *
710 * @hide
711 */
712 @SystemApi
713 public void acceptRingingCall() {
714 try {
715 if (isServiceConnected()) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700716 getTelecomService().acceptRingingCall();
Santos Cordon9eb45932014-06-27 12:28:43 -0700717 }
718 } catch (RemoteException e) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700719 Log.e(TAG, "Error calling ITelecomService#acceptRingingCall", e);
Santos Cordon9eb45932014-06-27 12:28:43 -0700720 }
721 }
722
723 /**
724 * Silences the ringer if a ringing call exists.
725 *
726 * @hide
727 */
728 @SystemApi
729 public void silenceRinger() {
730 try {
731 if (isServiceConnected()) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700732 getTelecomService().silenceRinger();
Santos Cordon9eb45932014-06-27 12:28:43 -0700733 }
734 } catch (RemoteException e) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700735 Log.e(TAG, "Error calling ITelecomService#silenceRinger", e);
Santos Cordon9eb45932014-06-27 12:28:43 -0700736 }
737 }
738
Sailesh Nepal001bbbb2014-07-15 14:40:39 -0700739 /**
740 * Returns whether TTY is supported on this device.
741 *
742 * @hide
743 */
744 @SystemApi
745 public boolean isTtySupported() {
746 try {
747 if (isServiceConnected()) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700748 return getTelecomService().isTtySupported();
Sailesh Nepal001bbbb2014-07-15 14:40:39 -0700749 }
750 } catch (RemoteException e) {
751 Log.e(TAG, "RemoteException attempting to get TTY supported state.", e);
752 }
753 return false;
754 }
755
756 /**
757 * Returns the current TTY mode of the device. For TTY to be on the user must enable it in
Santos Cordon96efb482014-07-19 14:57:05 -0700758 * settings and have a wired headset plugged in.
759 * Valid modes are:
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700760 * - {@link TelecomManager#TTY_MODE_OFF}
761 * - {@link TelecomManager#TTY_MODE_FULL}
762 * - {@link TelecomManager#TTY_MODE_HCO}
763 * - {@link TelecomManager#TTY_MODE_VCO}
Sailesh Nepal001bbbb2014-07-15 14:40:39 -0700764 * @hide
765 */
766 public int getCurrentTtyMode() {
767 try {
768 if (isServiceConnected()) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700769 return getTelecomService().getCurrentTtyMode();
Sailesh Nepal001bbbb2014-07-15 14:40:39 -0700770 }
771 } catch (RemoteException e) {
772 Log.e(TAG, "RemoteException attempting to get the current TTY mode.", e);
773 }
Evan Charlton10197192014-07-19 15:00:29 -0700774 return TTY_MODE_OFF;
Sailesh Nepal001bbbb2014-07-15 14:40:39 -0700775 }
776
Santos Cordon96efb482014-07-19 14:57:05 -0700777 /**
778 * Registers a new incoming call. A {@link ConnectionService} should invoke this method when it
779 * has an incoming call. The specified {@link PhoneAccountHandle} must have been registered
Nancy Chen210ef032014-09-15 17:58:42 -0700780 * with {@link #registerPhoneAccount}. Once invoked, this method will cause the system to bind
781 * to the {@link ConnectionService} associated with the {@link PhoneAccountHandle} and request
Santos Cordon96efb482014-07-19 14:57:05 -0700782 * additional information about the call (See
783 * {@link ConnectionService#onCreateIncomingConnection}) before starting the incoming call UI.
784 *
785 * @param phoneAccount A {@link PhoneAccountHandle} registered with
786 * {@link #registerPhoneAccount}.
787 * @param extras A bundle that will be passed through to
788 * {@link ConnectionService#onCreateIncomingConnection}.
789 */
790 public void addNewIncomingCall(PhoneAccountHandle phoneAccount, Bundle extras) {
791 try {
792 if (isServiceConnected()) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700793 getTelecomService().addNewIncomingCall(
Santos Cordon96efb482014-07-19 14:57:05 -0700794 phoneAccount, extras == null ? new Bundle() : extras);
795 }
796 } catch (RemoteException e) {
797 Log.e(TAG, "RemoteException adding a new incoming call: " + phoneAccount, e);
798 }
799 }
800
Nancy Chen0eb1e402014-08-21 22:52:29 -0700801 /**
802 * Processes the specified dial string as an MMI code.
803 * MMI codes are any sequence of characters entered into the dialpad that contain a "*" or "#".
804 * Some of these sequences launch special behavior through handled by Telephony.
805 * <p>
806 * Requires that the method-caller be set as the system dialer app.
807 * </p>
808 *
809 * @param dialString The digits to dial.
810 * @return True if the digits were processed as an MMI code, false otherwise.
811 */
812 public boolean handleMmi(String dialString) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700813 ITelecomService service = getTelecomService();
Nancy Chen0eb1e402014-08-21 22:52:29 -0700814 if (service != null) {
815 try {
816 return service.handlePinMmi(dialString);
817 } catch (RemoteException e) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700818 Log.e(TAG, "Error calling ITelecomService#handlePinMmi", e);
Nancy Chen0eb1e402014-08-21 22:52:29 -0700819 }
820 }
821 return false;
822 }
823
824 /**
825 * Removes the missed-call notification if one is present.
826 * <p>
827 * Requires that the method-caller be set as the system dialer app.
828 * </p>
829 */
830 public void cancelMissedCallsNotification() {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700831 ITelecomService service = getTelecomService();
Nancy Chen0eb1e402014-08-21 22:52:29 -0700832 if (service != null) {
833 try {
834 service.cancelMissedCallsNotification();
835 } catch (RemoteException e) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700836 Log.e(TAG, "Error calling ITelecomService#cancelMissedCallsNotification", e);
Nancy Chen0eb1e402014-08-21 22:52:29 -0700837 }
838 }
839 }
840
841 /**
842 * Brings the in-call screen to the foreground if there is an ongoing call. If there is
843 * currently no ongoing call, then this method does nothing.
844 * <p>
845 * Requires that the method-caller be set as the system dialer app or have the
846 * {@link android.Manifest.permission#READ_PHONE_STATE} permission.
847 * </p>
848 *
849 * @param showDialpad Brings up the in-call dialpad as part of showing the in-call screen.
850 */
851 public void showInCallScreen(boolean showDialpad) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700852 ITelecomService service = getTelecomService();
Nancy Chen0eb1e402014-08-21 22:52:29 -0700853 if (service != null) {
854 try {
855 service.showInCallScreen(showDialpad);
856 } catch (RemoteException e) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700857 Log.e(TAG, "Error calling ITelecomService#showCallScreen", e);
Nancy Chen0eb1e402014-08-21 22:52:29 -0700858 }
859 }
860 }
861
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700862 private ITelecomService getTelecomService() {
863 return ITelecomService.Stub.asInterface(ServiceManager.getService(Context.TELECOM_SERVICE));
Santos Cordon6c7a3882014-06-25 15:30:08 -0700864 }
Santos Cordon9eb45932014-06-27 12:28:43 -0700865
866 private boolean isServiceConnected() {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700867 boolean isConnected = getTelecomService() != null;
Santos Cordon9eb45932014-06-27 12:28:43 -0700868 if (!isConnected) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700869 Log.w(TAG, "Telecom Service not found.");
Santos Cordon9eb45932014-06-27 12:28:43 -0700870 }
871 return isConnected;
872 }
Evan Charlton235c1592014-09-05 15:41:23 +0000873}