blob: 845a1033c123f79204166ca4181c085ad5733c42 [file] [log] [blame]
Ihab Awad807fe0a2014-07-09 12:30:52 -07001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Tyler Gunnef9f6f92014-09-12 22:16:17 -070017package android.telecom;
Ihab Awad807fe0a2014-07-09 12:30:52 -070018
Evan Charlton0e094d92014-11-08 15:49:16 -080019import android.annotation.SystemApi;
Santos Cordoncad84a22015-05-13 11:17:25 -070020import android.graphics.drawable.Icon;
Ihab Awad94cf4bf2014-07-17 11:21:19 -070021import android.net.Uri;
Tyler Gunn25ed2d72015-10-05 14:14:38 -070022import android.os.Bundle;
Ihab Awad807fe0a2014-07-09 12:30:52 -070023import android.os.Parcel;
24import android.os.Parcelable;
Tyler Gunnf5b29dc2014-09-03 09:09:12 -070025import android.text.TextUtils;
Ihab Awad807fe0a2014-07-09 12:30:52 -070026
Tyler Gunnf5b29dc2014-09-03 09:09:12 -070027import java.lang.String;
28import java.util.ArrayList;
29import java.util.Collections;
30import java.util.List;
Ihab Awad807fe0a2014-07-09 12:30:52 -070031
32/**
Santos Cordon32c65a52014-10-27 14:57:49 -070033 * Represents a distinct method to place or receive a phone call. Apps which can place calls and
34 * want those calls to be integrated into the dialer and in-call UI should build an instance of
Brian Attwellad147f42014-12-19 11:37:16 -080035 * this class and register it with the system using {@link TelecomManager}.
Santos Cordon32c65a52014-10-27 14:57:49 -070036 * <p>
37 * {@link TelecomManager} uses registered {@link PhoneAccount}s to present the user with
38 * alternative options when placing a phone call. When building a {@link PhoneAccount}, the app
Brian Attwellad147f42014-12-19 11:37:16 -080039 * should supply a valid {@link PhoneAccountHandle} that references the connection service
Santos Cordon32c65a52014-10-27 14:57:49 -070040 * implementation Telecom will use to interact with the app.
Ihab Awad807fe0a2014-07-09 12:30:52 -070041 */
Yorke Lee400470f2015-05-12 13:31:25 -070042public final class PhoneAccount implements Parcelable {
Ihab Awad94cf4bf2014-07-17 11:21:19 -070043
44 /**
Tyler Gunnd426b202015-10-13 13:33:53 -070045 * {@link PhoneAccount} extras key (see {@link PhoneAccount#getExtras()}) which determines the
46 * maximum permitted length of a call subject specified via the
47 * {@link TelecomManager#EXTRA_CALL_SUBJECT} extra on an
48 * {@link android.content.Intent#ACTION_CALL} intent. Ultimately a {@link ConnectionService} is
49 * responsible for enforcing the maximum call subject length when sending the message, however
50 * this extra is provided so that the user interface can proactively limit the length of the
51 * call subject as the user types it.
52 */
53 public static final String EXTRA_CALL_SUBJECT_MAX_LENGTH =
54 "android.telecom.extra.CALL_SUBJECT_MAX_LENGTH";
55
56 /**
57 * {@link PhoneAccount} extras key (see {@link PhoneAccount#getExtras()}) which determines the
58 * character encoding to be used when determining the length of messages.
59 * The user interface can use this when determining the number of characters the user may type
60 * in a call subject. If empty-string, the call subject message size limit will be enforced on
61 * a 1:1 basis. That is, each character will count towards the messages size limit as a single
62 * character. If a character encoding is specified, the message size limit will be based on the
63 * number of bytes in the message per the specified encoding. See
64 * {@link #EXTRA_CALL_SUBJECT_MAX_LENGTH} for more information on the call subject maximum
65 * length.
66 */
67 public static final String EXTRA_CALL_SUBJECT_CHARACTER_ENCODING =
68 "android.telecom.extra.CALL_SUBJECT_CHARACTER_ENCODING";
69
70 /**
Ihab Awadf8b69882014-07-25 15:14:01 -070071 * Flag indicating that this {@code PhoneAccount} can act as a connection manager for
72 * other connections. The {@link ConnectionService} associated with this {@code PhoneAccount}
73 * will be allowed to manage phone calls including using its own proprietary phone-call
74 * implementation (like VoIP calling) to make calls instead of the telephony stack.
75 * <p>
Ihab Awadb19a0bc2014-08-07 19:46:01 -070076 * When a user opts to place a call using the SIM-based telephony stack, the
77 * {@link ConnectionService} associated with this {@code PhoneAccount} will be attempted first
78 * if the user has explicitly selected it to be used as the default connection manager.
Ihab Awad94cf4bf2014-07-17 11:21:19 -070079 * <p>
80 * See {@link #getCapabilities}
81 */
Ihab Awadf8b69882014-07-25 15:14:01 -070082 public static final int CAPABILITY_CONNECTION_MANAGER = 0x1;
Ihab Awad94cf4bf2014-07-17 11:21:19 -070083
84 /**
Evan Charlton8c8a0622014-07-20 12:31:00 -070085 * Flag indicating that this {@code PhoneAccount} can make phone calls in place of
Evan Charlton6eb262c2014-07-19 18:18:19 -070086 * traditional SIM-based telephony calls. This account will be treated as a distinct method
87 * for placing calls alongside the traditional SIM-based telephony stack. This flag is
Ihab Awadf8b69882014-07-25 15:14:01 -070088 * distinct from {@link #CAPABILITY_CONNECTION_MANAGER} in that it is not allowed to manage
Santos Cordon32c65a52014-10-27 14:57:49 -070089 * or place calls from the built-in telephony stack.
Ihab Awad94cf4bf2014-07-17 11:21:19 -070090 * <p>
91 * See {@link #getCapabilities}
Ihab Awadb19a0bc2014-08-07 19:46:01 -070092 * <p>
Ihab Awad94cf4bf2014-07-17 11:21:19 -070093 */
94 public static final int CAPABILITY_CALL_PROVIDER = 0x2;
95
Ihab Awad7522bbd2014-07-18 15:53:17 -070096 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -070097 * Flag indicating that this {@code PhoneAccount} represents a built-in PSTN SIM
Evan Charlton6eb262c2014-07-19 18:18:19 -070098 * subscription.
Ihab Awad7522bbd2014-07-18 15:53:17 -070099 * <p>
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700100 * Only the Android framework can register a {@code PhoneAccount} having this capability.
101 * <p>
102 * See {@link #getCapabilities}
Ihab Awad7522bbd2014-07-18 15:53:17 -0700103 */
104 public static final int CAPABILITY_SIM_SUBSCRIPTION = 0x4;
105
Ihab Awadf8b69882014-07-25 15:14:01 -0700106 /**
Tyler Gunn58cbd7a2016-11-11 11:31:28 -0800107 * Flag indicating that this {@code PhoneAccount} is currently able to place video calls.
108 * <p>
109 * See also {@link #CAPABILITY_SUPPORTS_VIDEO_CALLING} which indicates whether the
110 * {@code PhoneAccount} supports placing video calls.
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700111 * <p>
112 * See {@link #getCapabilities}
Ihab Awadf8b69882014-07-25 15:14:01 -0700113 */
114 public static final int CAPABILITY_VIDEO_CALLING = 0x8;
115
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700116 /**
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700117 * Flag indicating that this {@code PhoneAccount} is capable of placing emergency calls.
118 * By default all PSTN {@code PhoneAccount}s are capable of placing emergency calls.
119 * <p>
120 * See {@link #getCapabilities}
121 */
122 public static final int CAPABILITY_PLACE_EMERGENCY_CALLS = 0x10;
123
124 /**
Evan Charlton134dd682014-11-25 14:12:57 -0800125 * Flag indicating that this {@code PhoneAccount} is capable of being used by all users. This
126 * should only be used by system apps (and will be ignored for all other apps trying to use it).
127 * <p>
128 * See {@link #getCapabilities}
129 * @hide
130 */
Brian Attwellad147f42014-12-19 11:37:16 -0800131 @SystemApi
Evan Charlton134dd682014-11-25 14:12:57 -0800132 public static final int CAPABILITY_MULTI_USER = 0x20;
133
134 /**
Tyler Gunn65a3d342015-07-27 16:06:16 -0700135 * Flag indicating that this {@code PhoneAccount} supports a subject for Calls. This means a
136 * caller is able to specify a short subject line for an outgoing call. A capable receiving
137 * device displays the call subject on the incoming call screen.
138 * <p>
139 * See {@link #getCapabilities}
140 */
141 public static final int CAPABILITY_CALL_SUBJECT = 0x40;
142
143 /**
Bryce Leeb96d89c2015-10-14 16:48:40 -0700144 * Flag indicating that this {@code PhoneAccount} should only be used for emergency calls.
145 * <p>
146 * See {@link #getCapabilities}
147 * @hide
148 */
149 public static final int CAPABILITY_EMERGENCY_CALLS_ONLY = 0x80;
150
151 /**
Tyler Gunn9a365752015-12-09 15:00:18 -0800152 * Flag indicating that for this {@code PhoneAccount}, the ability to make a video call to a
153 * number relies on presence. Should only be set if the {@code PhoneAccount} also has
154 * {@link #CAPABILITY_VIDEO_CALLING}.
155 * <p>
156 * When set, the {@link ConnectionService} is responsible for toggling the
157 * {@link android.provider.ContactsContract.Data#CARRIER_PRESENCE_VT_CAPABLE} bit on the
158 * {@link android.provider.ContactsContract.Data#CARRIER_PRESENCE} column to indicate whether
159 * a contact's phone number supports video calling.
160 * <p>
161 * See {@link #getCapabilities}
162 */
163 public static final int CAPABILITY_VIDEO_CALLING_RELIES_ON_PRESENCE = 0x100;
164
165 /**
Tyler Gunncee9ea62016-03-24 11:45:43 -0700166 * Flag indicating that for this {@link PhoneAccount}, emergency video calling is allowed.
167 * <p>
168 * When set, Telecom will allow emergency video calls to be placed. When not set, Telecom will
169 * convert all outgoing video calls to emergency numbers to audio-only.
170 * @hide
171 */
172 public static final int CAPABILITY_EMERGENCY_VIDEO_CALLING = 0x200;
173
174 /**
Tyler Gunn58cbd7a2016-11-11 11:31:28 -0800175 * Flag indicating that this {@link PhoneAccount} supports video calling.
176 * This is not an indication that the {@link PhoneAccount} is currently able to make a video
177 * call, but rather that it has the ability to make video calls (but not necessarily at this
178 * time).
179 * <p>
180 * Whether a {@link PhoneAccount} can make a video call is ultimately controlled by
181 * {@link #CAPABILITY_VIDEO_CALLING}, which indicates whether the {@link PhoneAccount} is
182 * currently capable of making a video call. Consider a case where, for example, a
183 * {@link PhoneAccount} supports making video calls (e.g.
184 * {@link #CAPABILITY_SUPPORTS_VIDEO_CALLING}), but a current lack of network connectivity
185 * prevents video calls from being made (e.g. {@link #CAPABILITY_VIDEO_CALLING}).
186 * <p>
187 * See {@link #getCapabilities}
188 */
189 public static final int CAPABILITY_SUPPORTS_VIDEO_CALLING = 0x400;
190
191 /**
Tyler Gunnf5035432017-01-09 09:43:12 -0800192 * Flag indicating that this {@link PhoneAccount} is responsible for managing its own
193 * {@link Connection}s. This type of {@link PhoneAccount} is ideal for use with standalone
194 * calling apps which do not wish to use the default phone app for {@link Connection} UX,
195 * but which want to leverage the call and audio routing capabilities of the Telecom framework.
196 * <p>
197 * When set, {@link Connection}s created by the self-managed {@link ConnectionService} will not
198 * be surfaced to implementations of the {@link InCallService} API. Thus it is the
199 * responsibility of a self-managed {@link ConnectionService} to provide a user interface for
200 * its {@link Connection}s.
201 * <p>
202 * Self-managed {@link Connection}s will, however, be displayed on connected Bluetooth devices.
203 */
204 public static final int CAPABILITY_SELF_MANAGED = 0x800;
205
206 /**
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700207 * URI scheme for telephone number URIs.
208 */
209 public static final String SCHEME_TEL = "tel";
210
211 /**
212 * URI scheme for voicemail URIs.
213 */
214 public static final String SCHEME_VOICEMAIL = "voicemail";
215
216 /**
217 * URI scheme for SIP URIs.
218 */
219 public static final String SCHEME_SIP = "sip";
220
Nancy Chen3ace54b2014-10-22 17:45:26 -0700221 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800222 * Indicating no icon tint is set.
Santos Cordoncad84a22015-05-13 11:17:25 -0700223 * @hide
Nancy Chen3ace54b2014-10-22 17:45:26 -0700224 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800225 public static final int NO_ICON_TINT = 0;
226
227 /**
228 * Indicating no hightlight color is set.
229 */
230 public static final int NO_HIGHLIGHT_COLOR = 0;
Nancy Chen3ace54b2014-10-22 17:45:26 -0700231
Ihab Awad476cc832014-11-03 09:47:51 -0800232 /**
233 * Indicating no resource ID is set.
234 */
235 public static final int NO_RESOURCE_ID = -1;
236
Evan Charlton8c8a0622014-07-20 12:31:00 -0700237 private final PhoneAccountHandle mAccountHandle;
Andrew Lee3085a6c2014-09-04 10:59:13 -0700238 private final Uri mAddress;
239 private final Uri mSubscriptionAddress;
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700240 private final int mCapabilities;
Ihab Awad476cc832014-11-03 09:47:51 -0800241 private final int mHighlightColor;
Santos Cordon146a3e32014-07-21 00:00:44 -0700242 private final CharSequence mLabel;
243 private final CharSequence mShortDescription;
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700244 private final List<String> mSupportedUriSchemes;
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800245 private final int mSupportedAudioRoutes;
Santos Cordoncad84a22015-05-13 11:17:25 -0700246 private final Icon mIcon;
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700247 private final Bundle mExtras;
Santos Cordon91371dc2015-05-08 13:52:09 -0700248 private boolean mIsEnabled;
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700249 private String mGroupId;
Ihab Awad807fe0a2014-07-09 12:30:52 -0700250
Santos Cordon32c65a52014-10-27 14:57:49 -0700251 /**
252 * Helper class for creating a {@link PhoneAccount}.
253 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700254 public static class Builder {
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800255
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700256 private PhoneAccountHandle mAccountHandle;
Andrew Lee3085a6c2014-09-04 10:59:13 -0700257 private Uri mAddress;
258 private Uri mSubscriptionAddress;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700259 private int mCapabilities;
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800260 private int mSupportedAudioRoutes = CallAudioState.ROUTE_ALL;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800261 private int mHighlightColor = NO_HIGHLIGHT_COLOR;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700262 private CharSequence mLabel;
263 private CharSequence mShortDescription;
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700264 private List<String> mSupportedUriSchemes = new ArrayList<String>();
Santos Cordoncad84a22015-05-13 11:17:25 -0700265 private Icon mIcon;
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700266 private Bundle mExtras;
Santos Cordon91371dc2015-05-08 13:52:09 -0700267 private boolean mIsEnabled = false;
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700268 private String mGroupId = "";
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700269
Santos Cordon32c65a52014-10-27 14:57:49 -0700270 /**
271 * Creates a builder with the specified {@link PhoneAccountHandle} and label.
272 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700273 public Builder(PhoneAccountHandle accountHandle, CharSequence label) {
274 this.mAccountHandle = accountHandle;
275 this.mLabel = label;
276 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700277
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700278 /**
279 * Creates an instance of the {@link PhoneAccount.Builder} from an existing
280 * {@link PhoneAccount}.
281 *
282 * @param phoneAccount The {@link PhoneAccount} used to initialize the builder.
283 */
284 public Builder(PhoneAccount phoneAccount) {
285 mAccountHandle = phoneAccount.getAccountHandle();
286 mAddress = phoneAccount.getAddress();
287 mSubscriptionAddress = phoneAccount.getSubscriptionAddress();
288 mCapabilities = phoneAccount.getCapabilities();
Ihab Awad476cc832014-11-03 09:47:51 -0800289 mHighlightColor = phoneAccount.getHighlightColor();
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700290 mLabel = phoneAccount.getLabel();
291 mShortDescription = phoneAccount.getShortDescription();
292 mSupportedUriSchemes.addAll(phoneAccount.getSupportedUriSchemes());
Santos Cordoncad84a22015-05-13 11:17:25 -0700293 mIcon = phoneAccount.getIcon();
Santos Cordon91371dc2015-05-08 13:52:09 -0700294 mIsEnabled = phoneAccount.isEnabled();
Tyler Gunnd426b202015-10-13 13:33:53 -0700295 mExtras = phoneAccount.getExtras();
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700296 mGroupId = phoneAccount.getGroupId();
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800297 mSupportedAudioRoutes = phoneAccount.getSupportedAudioRoutes();
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700298 }
299
Santos Cordon32c65a52014-10-27 14:57:49 -0700300 /**
301 * Sets the address. See {@link PhoneAccount#getAddress}.
302 *
303 * @param value The address of the phone account.
304 * @return The builder.
305 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700306 public Builder setAddress(Uri value) {
307 this.mAddress = value;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700308 return this;
309 }
310
Santos Cordon32c65a52014-10-27 14:57:49 -0700311 /**
312 * Sets the subscription address. See {@link PhoneAccount#getSubscriptionAddress}.
313 *
314 * @param value The subscription address.
315 * @return The builder.
316 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700317 public Builder setSubscriptionAddress(Uri value) {
318 this.mSubscriptionAddress = value;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700319 return this;
320 }
321
Santos Cordon32c65a52014-10-27 14:57:49 -0700322 /**
323 * Sets the capabilities. See {@link PhoneAccount#getCapabilities}.
324 *
325 * @param value The capabilities to set.
326 * @return The builder.
327 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700328 public Builder setCapabilities(int value) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700329 this.mCapabilities = value;
330 return this;
331 }
332
Santos Cordon32c65a52014-10-27 14:57:49 -0700333 /**
Santos Cordoncad84a22015-05-13 11:17:25 -0700334 * Sets the icon. See {@link PhoneAccount#getIcon}.
Santos Cordon32c65a52014-10-27 14:57:49 -0700335 *
Santos Cordoncad84a22015-05-13 11:17:25 -0700336 * @param icon The icon to set.
Santos Cordon32c65a52014-10-27 14:57:49 -0700337 */
Santos Cordoncad84a22015-05-13 11:17:25 -0700338 public Builder setIcon(Icon icon) {
339 mIcon = icon;
Ihab Awad074bf102014-10-24 11:42:32 -0700340 return this;
341 }
342
343 /**
Ihab Awad476cc832014-11-03 09:47:51 -0800344 * Sets the highlight color. See {@link PhoneAccount#getHighlightColor}.
Ihab Awad074bf102014-10-24 11:42:32 -0700345 *
Ihab Awad476cc832014-11-03 09:47:51 -0800346 * @param value The highlight color.
Ihab Awad074bf102014-10-24 11:42:32 -0700347 * @return The builder.
348 */
Ihab Awad476cc832014-11-03 09:47:51 -0800349 public Builder setHighlightColor(int value) {
350 this.mHighlightColor = value;
Nancy Chen3ace54b2014-10-22 17:45:26 -0700351 return this;
352 }
353
Santos Cordon32c65a52014-10-27 14:57:49 -0700354 /**
355 * Sets the short description. See {@link PhoneAccount#getShortDescription}.
356 *
357 * @param value The short description.
358 * @return The builder.
359 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700360 public Builder setShortDescription(CharSequence value) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700361 this.mShortDescription = value;
362 return this;
363 }
364
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700365 /**
366 * Specifies an additional URI scheme supported by the {@link PhoneAccount}.
367 *
368 * @param uriScheme The URI scheme.
Santos Cordon32c65a52014-10-27 14:57:49 -0700369 * @return The builder.
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700370 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700371 public Builder addSupportedUriScheme(String uriScheme) {
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700372 if (!TextUtils.isEmpty(uriScheme) && !mSupportedUriSchemes.contains(uriScheme)) {
373 this.mSupportedUriSchemes.add(uriScheme);
374 }
375 return this;
376 }
377
378 /**
Andrew Lee3085a6c2014-09-04 10:59:13 -0700379 * Specifies the URI schemes supported by the {@link PhoneAccount}.
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700380 *
381 * @param uriSchemes The URI schemes.
Santos Cordon32c65a52014-10-27 14:57:49 -0700382 * @return The builder.
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700383 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700384 public Builder setSupportedUriSchemes(List<String> uriSchemes) {
385 mSupportedUriSchemes.clear();
386
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700387 if (uriSchemes != null && !uriSchemes.isEmpty()) {
388 for (String uriScheme : uriSchemes) {
Andrew Lee3085a6c2014-09-04 10:59:13 -0700389 addSupportedUriScheme(uriScheme);
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700390 }
391 }
392 return this;
393 }
394
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700395 /**
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700396 * Specifies the extras associated with the {@link PhoneAccount}.
397 * <p>
398 * {@code PhoneAccount}s only support extra values of type: {@link String}, {@link Integer},
399 * and {@link Boolean}. Extras which are not of these types are ignored.
400 *
401 * @param extras
402 * @return
403 */
404 public Builder setExtras(Bundle extras) {
405 mExtras = extras;
406 return this;
407 }
408
409 /**
Santos Cordon91371dc2015-05-08 13:52:09 -0700410 * Sets the enabled state of the phone account.
411 *
412 * @param isEnabled The enabled state.
413 * @return The builder.
414 * @hide
415 */
416 public Builder setIsEnabled(boolean isEnabled) {
417 mIsEnabled = isEnabled;
418 return this;
419 }
420
421 /**
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700422 * Sets the group Id of the {@link PhoneAccount}. When a new {@link PhoneAccount} is
423 * registered to Telecom, it will replace another {@link PhoneAccount} that is already
424 * registered in Telecom and take on the current user defaults and enabled status. There can
425 * only be one {@link PhoneAccount} with a non-empty group number registered to Telecom at a
426 * time. By default, there is no group Id for a {@link PhoneAccount} (an empty String). Only
427 * grouped {@link PhoneAccount}s with the same {@link ConnectionService} can be replaced.
428 * @param groupId The group Id of the {@link PhoneAccount} that will replace any other
429 * registered {@link PhoneAccount} in Telecom with the same Group Id.
430 * @return The builder
431 * @hide
432 */
433 public Builder setGroupId(String groupId) {
434 if (groupId != null) {
435 mGroupId = groupId;
436 } else {
437 mGroupId = "";
438 }
439 return this;
440 }
441
442 /**
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800443 * Sets the audio routes supported by this {@link PhoneAccount}.
444 *
445 * @param routes bit mask of available routes.
446 * @return The builder.
447 * @hide
448 */
449 public Builder setSupportedAudioRoutes(int routes) {
450 mSupportedAudioRoutes = routes;
451 return this;
452 }
453
454 /**
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700455 * Creates an instance of a {@link PhoneAccount} based on the current builder settings.
456 *
457 * @return The {@link PhoneAccount}.
458 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700459 public PhoneAccount build() {
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700460 // If no supported URI schemes were defined, assume "tel" is supported.
461 if (mSupportedUriSchemes.isEmpty()) {
Andrew Lee3085a6c2014-09-04 10:59:13 -0700462 addSupportedUriScheme(SCHEME_TEL);
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700463 }
464
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700465 return new PhoneAccount(
466 mAccountHandle,
Andrew Lee3085a6c2014-09-04 10:59:13 -0700467 mAddress,
468 mSubscriptionAddress,
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700469 mCapabilities,
Santos Cordoncad84a22015-05-13 11:17:25 -0700470 mIcon,
Ihab Awad476cc832014-11-03 09:47:51 -0800471 mHighlightColor,
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700472 mLabel,
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700473 mShortDescription,
Santos Cordon91371dc2015-05-08 13:52:09 -0700474 mSupportedUriSchemes,
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700475 mExtras,
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800476 mSupportedAudioRoutes,
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700477 mIsEnabled,
478 mGroupId);
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700479 }
480 }
481
482 private PhoneAccount(
Evan Charlton6eb262c2014-07-19 18:18:19 -0700483 PhoneAccountHandle account,
Andrew Lee3085a6c2014-09-04 10:59:13 -0700484 Uri address,
485 Uri subscriptionAddress,
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700486 int capabilities,
Santos Cordoncad84a22015-05-13 11:17:25 -0700487 Icon icon,
Ihab Awad476cc832014-11-03 09:47:51 -0800488 int highlightColor,
Santos Cordon146a3e32014-07-21 00:00:44 -0700489 CharSequence label,
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700490 CharSequence shortDescription,
Santos Cordon91371dc2015-05-08 13:52:09 -0700491 List<String> supportedUriSchemes,
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700492 Bundle extras,
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800493 int supportedAudioRoutes,
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700494 boolean isEnabled,
495 String groupId) {
Evan Charlton8c8a0622014-07-20 12:31:00 -0700496 mAccountHandle = account;
Andrew Lee3085a6c2014-09-04 10:59:13 -0700497 mAddress = address;
498 mSubscriptionAddress = subscriptionAddress;
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700499 mCapabilities = capabilities;
Santos Cordoncad84a22015-05-13 11:17:25 -0700500 mIcon = icon;
Ihab Awad476cc832014-11-03 09:47:51 -0800501 mHighlightColor = highlightColor;
Ihab Awad807fe0a2014-07-09 12:30:52 -0700502 mLabel = label;
503 mShortDescription = shortDescription;
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700504 mSupportedUriSchemes = Collections.unmodifiableList(supportedUriSchemes);
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700505 mExtras = extras;
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800506 mSupportedAudioRoutes = supportedAudioRoutes;
Santos Cordon91371dc2015-05-08 13:52:09 -0700507 mIsEnabled = isEnabled;
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700508 mGroupId = groupId;
Ihab Awad807fe0a2014-07-09 12:30:52 -0700509 }
510
Andrew Lee3085a6c2014-09-04 10:59:13 -0700511 public static Builder builder(
512 PhoneAccountHandle accountHandle,
513 CharSequence label) {
514 return new Builder(accountHandle, label);
515 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700516
Ihab Awad807fe0a2014-07-09 12:30:52 -0700517 /**
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700518 * Returns a builder initialized with the current {@link PhoneAccount} instance.
519 *
520 * @return The builder.
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700521 */
522 public Builder toBuilder() { return new Builder(this); }
523
524 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700525 * The unique identifier of this {@code PhoneAccount}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700526 *
Evan Charlton6eb262c2014-07-19 18:18:19 -0700527 * @return A {@code PhoneAccountHandle}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700528 */
Evan Charlton8c8a0622014-07-20 12:31:00 -0700529 public PhoneAccountHandle getAccountHandle() {
530 return mAccountHandle;
Ihab Awad807fe0a2014-07-09 12:30:52 -0700531 }
532
533 /**
Andrew Lee3085a6c2014-09-04 10:59:13 -0700534 * The address (e.g., a phone number) associated with this {@code PhoneAccount}. This
Evan Charlton8c8a0622014-07-20 12:31:00 -0700535 * represents the destination from which outgoing calls using this {@code PhoneAccount}
Evan Charlton6eb262c2014-07-19 18:18:19 -0700536 * will appear to come, if applicable, and the destination to which incoming calls using this
Evan Charlton8c8a0622014-07-20 12:31:00 -0700537 * {@code PhoneAccount} may be addressed.
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700538 *
Andrew Lee3085a6c2014-09-04 10:59:13 -0700539 * @return A address expressed as a {@code Uri}, for example, a phone number.
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700540 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700541 public Uri getAddress() {
542 return mAddress;
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700543 }
544
545 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700546 * The raw callback number used for this {@code PhoneAccount}, as distinct from
Andrew Lee3085a6c2014-09-04 10:59:13 -0700547 * {@link #getAddress()}. For the majority of {@code PhoneAccount}s this should be registered
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700548 * as {@code null}. It is used by the system for SIM-based {@code PhoneAccount} registration
Junda Liuf52ac902014-09-25 17:36:48 +0000549 * where {@link android.telephony.TelephonyManager#setLine1NumberForDisplay(String, String)}
550 * has been used to alter the callback number.
551 * <p>
Evan Charlton222db5252014-07-17 16:59:18 -0700552 *
553 * @return The subscription number, suitable for display to the user.
554 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700555 public Uri getSubscriptionAddress() {
556 return mSubscriptionAddress;
Evan Charlton222db5252014-07-17 16:59:18 -0700557 }
558
559 /**
Evan Charlton8c8a0622014-07-20 12:31:00 -0700560 * The capabilities of this {@code PhoneAccount}.
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700561 *
Evan Charlton8c8a0622014-07-20 12:31:00 -0700562 * @return A bit field of flags describing this {@code PhoneAccount}'s capabilities.
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700563 */
564 public int getCapabilities() {
565 return mCapabilities;
566 }
567
568 /**
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700569 * Determines if this {@code PhoneAccount} has a capabilities specified by the passed in
570 * bit mask.
571 *
572 * @param capability The capabilities to check.
Santos Cordon895d4b82015-06-25 16:41:48 -0700573 * @return {@code true} if the phone account has the capability.
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700574 */
575 public boolean hasCapabilities(int capability) {
576 return (mCapabilities & capability) == capability;
577 }
578
579 /**
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800580 * Determines if this {@code PhoneAccount} has routes specified by the passed in bit mask.
581 *
582 * @param route The routes to check.
583 * @return {@code true} if the phone account has the routes.
584 * @hide
585 */
586 public boolean hasAudioRoutes(int routes) {
587 return (mSupportedAudioRoutes & routes) == routes;
588 }
589
590 /**
Santos Cordon146a3e32014-07-21 00:00:44 -0700591 * A short label describing a {@code PhoneAccount}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700592 *
Evan Charlton8c8a0622014-07-20 12:31:00 -0700593 * @return A label for this {@code PhoneAccount}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700594 */
Santos Cordon146a3e32014-07-21 00:00:44 -0700595 public CharSequence getLabel() {
Ihab Awad807fe0a2014-07-09 12:30:52 -0700596 return mLabel;
597 }
598
599 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700600 * A short paragraph describing this {@code PhoneAccount}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700601 *
Evan Charlton8c8a0622014-07-20 12:31:00 -0700602 * @return A description for this {@code PhoneAccount}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700603 */
Santos Cordon146a3e32014-07-21 00:00:44 -0700604 public CharSequence getShortDescription() {
Ihab Awad807fe0a2014-07-09 12:30:52 -0700605 return mShortDescription;
606 }
607
608 /**
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700609 * The URI schemes supported by this {@code PhoneAccount}.
610 *
611 * @return The URI schemes.
612 */
613 public List<String> getSupportedUriSchemes() {
614 return mSupportedUriSchemes;
615 }
616
617 /**
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700618 * The extras associated with this {@code PhoneAccount}.
619 * <p>
620 * A {@link ConnectionService} may provide implementation specific information about the
621 * {@link PhoneAccount} via the extras.
622 *
623 * @return The extras.
624 */
625 public Bundle getExtras() {
626 return mExtras;
627 }
628
629 /**
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800630 * The audio routes supported by this {@code PhoneAccount}.
631 *
632 * @hide
633 */
634 public int getSupportedAudioRoutes() {
635 return mSupportedAudioRoutes;
636 }
637
638 /**
Santos Cordoncad84a22015-05-13 11:17:25 -0700639 * The icon to represent this {@code PhoneAccount}.
640 *
641 * @return The icon.
642 */
643 public Icon getIcon() {
644 return mIcon;
645 }
646
647 /**
Santos Cordon895d4b82015-06-25 16:41:48 -0700648 * Indicates whether the user has enabled this {@code PhoneAccount} or not. This value is only
649 * populated for {@code PhoneAccount}s returned by {@link TelecomManager#getPhoneAccount}.
Santos Cordon91371dc2015-05-08 13:52:09 -0700650 *
Santos Cordon895d4b82015-06-25 16:41:48 -0700651 * @return {@code true} if the account is enabled by the user, {@code false} otherwise.
Santos Cordon91371dc2015-05-08 13:52:09 -0700652 */
653 public boolean isEnabled() {
654 return mIsEnabled;
655 }
656
657 /**
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700658 * A non-empty {@link String} representing the group that A {@link PhoneAccount} is in or an
659 * empty {@link String} if the {@link PhoneAccount} is not in a group. If this
660 * {@link PhoneAccount} is in a group, this new {@link PhoneAccount} will replace a registered
661 * {@link PhoneAccount} that is in the same group. When the {@link PhoneAccount} is replaced,
662 * its user defined defaults and enabled status will also pass to this new {@link PhoneAccount}.
663 * Only {@link PhoneAccount}s that share the same {@link ConnectionService} can be replaced.
664 *
665 * @return A non-empty String Id if this {@link PhoneAccount} belongs to a group.
666 * @hide
667 */
668 public String getGroupId() {
669 return mGroupId;
670 }
671
672 /**
Andrew Lee3085a6c2014-09-04 10:59:13 -0700673 * Determines if the {@link PhoneAccount} supports calls to/from addresses with a specified URI
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700674 * scheme.
675 *
676 * @param uriScheme The URI scheme to check.
Santos Cordon895d4b82015-06-25 16:41:48 -0700677 * @return {@code true} if the {@code PhoneAccount} supports calls to/from addresses with the
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700678 * specified URI scheme.
679 */
680 public boolean supportsUriScheme(String uriScheme) {
681 if (mSupportedUriSchemes == null || uriScheme == null) {
682 return false;
683 }
684
685 for (String scheme : mSupportedUriSchemes) {
686 if (scheme != null && scheme.equals(uriScheme)) {
687 return true;
688 }
689 }
690 return false;
691 }
692
693 /**
Ihab Awad476cc832014-11-03 09:47:51 -0800694 * A highlight color to use in displaying information about this {@code PhoneAccount}.
695 *
696 * @return A hexadecimal color value.
697 */
698 public int getHighlightColor() {
699 return mHighlightColor;
700 }
701
Santos Cordon91371dc2015-05-08 13:52:09 -0700702 /**
703 * Sets the enabled state of the phone account.
704 * @hide
705 */
706 public void setIsEnabled(boolean isEnabled) {
707 mIsEnabled = isEnabled;
708 }
709
Tyler Gunnf5035432017-01-09 09:43:12 -0800710 /**
711 * @return {@code true} if the {@link PhoneAccount} is self-managed, {@code false} otherwise.
712 * @hide
713 */
714 public boolean isSelfManaged() {
715 return (mCapabilities & CAPABILITY_SELF_MANAGED) == CAPABILITY_SELF_MANAGED;
716 }
717
Ihab Awad807fe0a2014-07-09 12:30:52 -0700718 //
719 // Parcelable implementation
720 //
721
722 @Override
723 public int describeContents() {
724 return 0;
725 }
726
727 @Override
728 public void writeToParcel(Parcel out, int flags) {
Ihab Awad476cc832014-11-03 09:47:51 -0800729 if (mAccountHandle == null) {
730 out.writeInt(0);
731 } else {
732 out.writeInt(1);
733 mAccountHandle.writeToParcel(out, flags);
734 }
735 if (mAddress == null) {
736 out.writeInt(0);
737 } else {
738 out.writeInt(1);
739 mAddress.writeToParcel(out, flags);
740 }
741 if (mSubscriptionAddress == null) {
742 out.writeInt(0);
743 } else {
744 out.writeInt(1);
745 mSubscriptionAddress.writeToParcel(out, flags);
746 }
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700747 out.writeInt(mCapabilities);
Ihab Awad476cc832014-11-03 09:47:51 -0800748 out.writeInt(mHighlightColor);
Santos Cordon146a3e32014-07-21 00:00:44 -0700749 out.writeCharSequence(mLabel);
750 out.writeCharSequence(mShortDescription);
Ihab Awad476cc832014-11-03 09:47:51 -0800751 out.writeStringList(mSupportedUriSchemes);
Santos Cordon91371dc2015-05-08 13:52:09 -0700752
Santos Cordoncad84a22015-05-13 11:17:25 -0700753 if (mIcon == null) {
754 out.writeInt(0);
755 } else {
756 out.writeInt(1);
757 mIcon.writeToParcel(out, flags);
758 }
Santos Cordon91371dc2015-05-08 13:52:09 -0700759 out.writeByte((byte) (mIsEnabled ? 1 : 0));
Tyler Gunnef829ec2015-10-08 09:46:23 -0700760 out.writeBundle(mExtras);
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700761 out.writeString(mGroupId);
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800762 out.writeInt(mSupportedAudioRoutes);
Ihab Awad807fe0a2014-07-09 12:30:52 -0700763 }
764
Evan Charlton8c8a0622014-07-20 12:31:00 -0700765 public static final Creator<PhoneAccount> CREATOR
766 = new Creator<PhoneAccount>() {
Ihab Awad807fe0a2014-07-09 12:30:52 -0700767 @Override
Evan Charlton8c8a0622014-07-20 12:31:00 -0700768 public PhoneAccount createFromParcel(Parcel in) {
769 return new PhoneAccount(in);
Ihab Awad807fe0a2014-07-09 12:30:52 -0700770 }
771
772 @Override
Evan Charlton8c8a0622014-07-20 12:31:00 -0700773 public PhoneAccount[] newArray(int size) {
774 return new PhoneAccount[size];
Ihab Awad807fe0a2014-07-09 12:30:52 -0700775 }
776 };
777
Evan Charlton8c8a0622014-07-20 12:31:00 -0700778 private PhoneAccount(Parcel in) {
Ihab Awad476cc832014-11-03 09:47:51 -0800779 if (in.readInt() > 0) {
780 mAccountHandle = PhoneAccountHandle.CREATOR.createFromParcel(in);
781 } else {
782 mAccountHandle = null;
783 }
784 if (in.readInt() > 0) {
785 mAddress = Uri.CREATOR.createFromParcel(in);
786 } else {
787 mAddress = null;
788 }
789 if (in.readInt() > 0) {
790 mSubscriptionAddress = Uri.CREATOR.createFromParcel(in);
791 } else {
792 mSubscriptionAddress = null;
793 }
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700794 mCapabilities = in.readInt();
Ihab Awad476cc832014-11-03 09:47:51 -0800795 mHighlightColor = in.readInt();
Santos Cordon146a3e32014-07-21 00:00:44 -0700796 mLabel = in.readCharSequence();
797 mShortDescription = in.readCharSequence();
Ihab Awad476cc832014-11-03 09:47:51 -0800798 mSupportedUriSchemes = Collections.unmodifiableList(in.createStringArrayList());
Santos Cordoncad84a22015-05-13 11:17:25 -0700799 if (in.readInt() > 0) {
800 mIcon = Icon.CREATOR.createFromParcel(in);
801 } else {
802 mIcon = null;
803 }
Santos Cordon91371dc2015-05-08 13:52:09 -0700804 mIsEnabled = in.readByte() == 1;
Tyler Gunnef829ec2015-10-08 09:46:23 -0700805 mExtras = in.readBundle();
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700806 mGroupId = in.readString();
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800807 mSupportedAudioRoutes = in.readInt();
Ihab Awad807fe0a2014-07-09 12:30:52 -0700808 }
Tyler Gunn76c01a52014-09-30 14:47:51 -0700809
810 @Override
811 public String toString() {
Santos Cordon91371dc2015-05-08 13:52:09 -0700812 StringBuilder sb = new StringBuilder().append("[[")
813 .append(mIsEnabled ? 'X' : ' ')
814 .append("] PhoneAccount: ")
Tyler Gunn76c01a52014-09-30 14:47:51 -0700815 .append(mAccountHandle)
816 .append(" Capabilities: ")
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800817 .append(capabilitiesToString())
818 .append(" Audio Routes: ")
819 .append(audioRoutesToString())
Tyler Gunn76c01a52014-09-30 14:47:51 -0700820 .append(" Schemes: ");
821 for (String scheme : mSupportedUriSchemes) {
822 sb.append(scheme)
823 .append(" ");
824 }
Tyler Gunnef829ec2015-10-08 09:46:23 -0700825 sb.append(" Extras: ");
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700826 sb.append(mExtras);
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700827 sb.append(" GroupId: ");
828 sb.append(Log.pii(mGroupId));
Tyler Gunn76c01a52014-09-30 14:47:51 -0700829 sb.append("]");
830 return sb.toString();
831 }
Tyler Gunn3e122f72016-01-11 19:25:00 -0800832
833 /**
834 * Generates a string representation of a capabilities bitmask.
835 *
836 * @param capabilities The capabilities bitmask.
837 * @return String representation of the capabilities bitmask.
838 */
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800839 private String capabilitiesToString() {
Tyler Gunn3e122f72016-01-11 19:25:00 -0800840 StringBuilder sb = new StringBuilder();
Tyler Gunnf5035432017-01-09 09:43:12 -0800841 if (hasCapabilities(CAPABILITY_SELF_MANAGED)) {
842 sb.append("SelfManaged ");
843 }
Tyler Gunn58cbd7a2016-11-11 11:31:28 -0800844 if (hasCapabilities(CAPABILITY_SUPPORTS_VIDEO_CALLING)) {
845 sb.append("SuppVideo ");
846 }
Tyler Gunn3e122f72016-01-11 19:25:00 -0800847 if (hasCapabilities(CAPABILITY_VIDEO_CALLING)) {
848 sb.append("Video ");
849 }
850 if (hasCapabilities(CAPABILITY_VIDEO_CALLING_RELIES_ON_PRESENCE)) {
851 sb.append("Presence ");
852 }
853 if (hasCapabilities(CAPABILITY_CALL_PROVIDER)) {
854 sb.append("CallProvider ");
855 }
856 if (hasCapabilities(CAPABILITY_CALL_SUBJECT)) {
857 sb.append("CallSubject ");
858 }
859 if (hasCapabilities(CAPABILITY_CONNECTION_MANAGER)) {
860 sb.append("ConnectionMgr ");
861 }
862 if (hasCapabilities(CAPABILITY_EMERGENCY_CALLS_ONLY)) {
863 sb.append("EmergOnly ");
864 }
865 if (hasCapabilities(CAPABILITY_MULTI_USER)) {
866 sb.append("MultiUser ");
867 }
868 if (hasCapabilities(CAPABILITY_PLACE_EMERGENCY_CALLS)) {
869 sb.append("PlaceEmerg ");
870 }
Tyler Gunncee9ea62016-03-24 11:45:43 -0700871 if (hasCapabilities(CAPABILITY_EMERGENCY_VIDEO_CALLING)) {
872 sb.append("EmergVideo ");
873 }
Tyler Gunn3e122f72016-01-11 19:25:00 -0800874 if (hasCapabilities(CAPABILITY_SIM_SUBSCRIPTION)) {
875 sb.append("SimSub ");
876 }
877 return sb.toString();
878 }
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800879
880 private String audioRoutesToString() {
881 StringBuilder sb = new StringBuilder();
882
883 if (hasAudioRoutes(CallAudioState.ROUTE_BLUETOOTH)) {
884 sb.append("B");
885 }
886 if (hasAudioRoutes(CallAudioState.ROUTE_EARPIECE)) {
887 sb.append("E");
888 }
889 if (hasAudioRoutes(CallAudioState.ROUTE_SPEAKER)) {
890 sb.append("S");
891 }
892 if (hasAudioRoutes(CallAudioState.ROUTE_WIRED_HEADSET)) {
893 sb.append("W");
894 }
895
896 return sb.toString();
897 }
Ihab Awad807fe0a2014-07-09 12:30:52 -0700898}