blob: 3926e201a5e35da4f561cb7d51ab1676b7ba2df5 [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 Awad7522bbd62014-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 Awad7522bbd62014-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 Awad7522bbd62014-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 /**
Hall Liu95d55872017-01-25 17:12:49 -0800207 * Flag indicating that this {@link PhoneAccount} is capable of making a call with an
208 * RTT (Real-time text) session.
209 * When set, Telecom will attempt to open an RTT session on outgoing calls that specify
210 * that they should be placed with an RTT session , and the in-call app will be displayed
211 * with text entry fields for RTT. Likewise, the in-call app can request that an RTT
212 * session be opened during a call if this bit is set.
213 */
214 public static final int CAPABILITY_RTT = 0x1000;
215
216 /* NEXT CAPABILITY: 0x2000 */
217
218 /**
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700219 * URI scheme for telephone number URIs.
220 */
221 public static final String SCHEME_TEL = "tel";
222
223 /**
224 * URI scheme for voicemail URIs.
225 */
226 public static final String SCHEME_VOICEMAIL = "voicemail";
227
228 /**
229 * URI scheme for SIP URIs.
230 */
231 public static final String SCHEME_SIP = "sip";
232
Nancy Chen3ace54b2014-10-22 17:45:26 -0700233 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800234 * Indicating no icon tint is set.
Santos Cordoncad84a22015-05-13 11:17:25 -0700235 * @hide
Nancy Chen3ace54b2014-10-22 17:45:26 -0700236 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800237 public static final int NO_ICON_TINT = 0;
238
239 /**
240 * Indicating no hightlight color is set.
241 */
242 public static final int NO_HIGHLIGHT_COLOR = 0;
Nancy Chen3ace54b2014-10-22 17:45:26 -0700243
Ihab Awad476cc832014-11-03 09:47:51 -0800244 /**
245 * Indicating no resource ID is set.
246 */
247 public static final int NO_RESOURCE_ID = -1;
248
Evan Charlton8c8a0622014-07-20 12:31:00 -0700249 private final PhoneAccountHandle mAccountHandle;
Andrew Lee3085a6c2014-09-04 10:59:13 -0700250 private final Uri mAddress;
251 private final Uri mSubscriptionAddress;
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700252 private final int mCapabilities;
Ihab Awad476cc832014-11-03 09:47:51 -0800253 private final int mHighlightColor;
Santos Cordon146a3e32014-07-21 00:00:44 -0700254 private final CharSequence mLabel;
255 private final CharSequence mShortDescription;
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700256 private final List<String> mSupportedUriSchemes;
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800257 private final int mSupportedAudioRoutes;
Santos Cordoncad84a22015-05-13 11:17:25 -0700258 private final Icon mIcon;
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700259 private final Bundle mExtras;
Santos Cordon91371dc02015-05-08 13:52:09 -0700260 private boolean mIsEnabled;
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700261 private String mGroupId;
Ihab Awad807fe0a2014-07-09 12:30:52 -0700262
Santos Cordon32c65a52014-10-27 14:57:49 -0700263 /**
264 * Helper class for creating a {@link PhoneAccount}.
265 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700266 public static class Builder {
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800267
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700268 private PhoneAccountHandle mAccountHandle;
Andrew Lee3085a6c2014-09-04 10:59:13 -0700269 private Uri mAddress;
270 private Uri mSubscriptionAddress;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700271 private int mCapabilities;
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800272 private int mSupportedAudioRoutes = CallAudioState.ROUTE_ALL;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800273 private int mHighlightColor = NO_HIGHLIGHT_COLOR;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700274 private CharSequence mLabel;
275 private CharSequence mShortDescription;
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700276 private List<String> mSupportedUriSchemes = new ArrayList<String>();
Santos Cordoncad84a22015-05-13 11:17:25 -0700277 private Icon mIcon;
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700278 private Bundle mExtras;
Santos Cordon91371dc02015-05-08 13:52:09 -0700279 private boolean mIsEnabled = false;
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700280 private String mGroupId = "";
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700281
Santos Cordon32c65a52014-10-27 14:57:49 -0700282 /**
283 * Creates a builder with the specified {@link PhoneAccountHandle} and label.
284 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700285 public Builder(PhoneAccountHandle accountHandle, CharSequence label) {
286 this.mAccountHandle = accountHandle;
287 this.mLabel = label;
288 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700289
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700290 /**
291 * Creates an instance of the {@link PhoneAccount.Builder} from an existing
292 * {@link PhoneAccount}.
293 *
294 * @param phoneAccount The {@link PhoneAccount} used to initialize the builder.
295 */
296 public Builder(PhoneAccount phoneAccount) {
297 mAccountHandle = phoneAccount.getAccountHandle();
298 mAddress = phoneAccount.getAddress();
299 mSubscriptionAddress = phoneAccount.getSubscriptionAddress();
300 mCapabilities = phoneAccount.getCapabilities();
Ihab Awad476cc832014-11-03 09:47:51 -0800301 mHighlightColor = phoneAccount.getHighlightColor();
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700302 mLabel = phoneAccount.getLabel();
303 mShortDescription = phoneAccount.getShortDescription();
304 mSupportedUriSchemes.addAll(phoneAccount.getSupportedUriSchemes());
Santos Cordoncad84a22015-05-13 11:17:25 -0700305 mIcon = phoneAccount.getIcon();
Santos Cordon91371dc02015-05-08 13:52:09 -0700306 mIsEnabled = phoneAccount.isEnabled();
Tyler Gunnd426b202015-10-13 13:33:53 -0700307 mExtras = phoneAccount.getExtras();
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700308 mGroupId = phoneAccount.getGroupId();
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800309 mSupportedAudioRoutes = phoneAccount.getSupportedAudioRoutes();
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700310 }
311
Santos Cordon32c65a52014-10-27 14:57:49 -0700312 /**
313 * Sets the address. See {@link PhoneAccount#getAddress}.
314 *
315 * @param value The address of the phone account.
316 * @return The builder.
317 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700318 public Builder setAddress(Uri value) {
319 this.mAddress = value;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700320 return this;
321 }
322
Santos Cordon32c65a52014-10-27 14:57:49 -0700323 /**
324 * Sets the subscription address. See {@link PhoneAccount#getSubscriptionAddress}.
325 *
326 * @param value The subscription address.
327 * @return The builder.
328 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700329 public Builder setSubscriptionAddress(Uri value) {
330 this.mSubscriptionAddress = value;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700331 return this;
332 }
333
Santos Cordon32c65a52014-10-27 14:57:49 -0700334 /**
335 * Sets the capabilities. See {@link PhoneAccount#getCapabilities}.
336 *
337 * @param value The capabilities to set.
338 * @return The builder.
339 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700340 public Builder setCapabilities(int value) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700341 this.mCapabilities = value;
342 return this;
343 }
344
Santos Cordon32c65a52014-10-27 14:57:49 -0700345 /**
Santos Cordoncad84a22015-05-13 11:17:25 -0700346 * Sets the icon. See {@link PhoneAccount#getIcon}.
Santos Cordon32c65a52014-10-27 14:57:49 -0700347 *
Santos Cordoncad84a22015-05-13 11:17:25 -0700348 * @param icon The icon to set.
Santos Cordon32c65a52014-10-27 14:57:49 -0700349 */
Santos Cordoncad84a22015-05-13 11:17:25 -0700350 public Builder setIcon(Icon icon) {
351 mIcon = icon;
Ihab Awad074bf102014-10-24 11:42:32 -0700352 return this;
353 }
354
355 /**
Ihab Awad476cc832014-11-03 09:47:51 -0800356 * Sets the highlight color. See {@link PhoneAccount#getHighlightColor}.
Ihab Awad074bf102014-10-24 11:42:32 -0700357 *
Ihab Awad476cc832014-11-03 09:47:51 -0800358 * @param value The highlight color.
Ihab Awad074bf102014-10-24 11:42:32 -0700359 * @return The builder.
360 */
Ihab Awad476cc832014-11-03 09:47:51 -0800361 public Builder setHighlightColor(int value) {
362 this.mHighlightColor = value;
Nancy Chen3ace54b2014-10-22 17:45:26 -0700363 return this;
364 }
365
Santos Cordon32c65a52014-10-27 14:57:49 -0700366 /**
367 * Sets the short description. See {@link PhoneAccount#getShortDescription}.
368 *
369 * @param value The short description.
370 * @return The builder.
371 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700372 public Builder setShortDescription(CharSequence value) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700373 this.mShortDescription = value;
374 return this;
375 }
376
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700377 /**
378 * Specifies an additional URI scheme supported by the {@link PhoneAccount}.
379 *
380 * @param uriScheme The URI scheme.
Santos Cordon32c65a52014-10-27 14:57:49 -0700381 * @return The builder.
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700382 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700383 public Builder addSupportedUriScheme(String uriScheme) {
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700384 if (!TextUtils.isEmpty(uriScheme) && !mSupportedUriSchemes.contains(uriScheme)) {
385 this.mSupportedUriSchemes.add(uriScheme);
386 }
387 return this;
388 }
389
390 /**
Andrew Lee3085a6c2014-09-04 10:59:13 -0700391 * Specifies the URI schemes supported by the {@link PhoneAccount}.
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700392 *
393 * @param uriSchemes The URI schemes.
Santos Cordon32c65a52014-10-27 14:57:49 -0700394 * @return The builder.
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700395 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700396 public Builder setSupportedUriSchemes(List<String> uriSchemes) {
397 mSupportedUriSchemes.clear();
398
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700399 if (uriSchemes != null && !uriSchemes.isEmpty()) {
400 for (String uriScheme : uriSchemes) {
Andrew Lee3085a6c2014-09-04 10:59:13 -0700401 addSupportedUriScheme(uriScheme);
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700402 }
403 }
404 return this;
405 }
406
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700407 /**
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700408 * Specifies the extras associated with the {@link PhoneAccount}.
409 * <p>
410 * {@code PhoneAccount}s only support extra values of type: {@link String}, {@link Integer},
411 * and {@link Boolean}. Extras which are not of these types are ignored.
412 *
413 * @param extras
414 * @return
415 */
416 public Builder setExtras(Bundle extras) {
417 mExtras = extras;
418 return this;
419 }
420
421 /**
Santos Cordon91371dc02015-05-08 13:52:09 -0700422 * Sets the enabled state of the phone account.
423 *
424 * @param isEnabled The enabled state.
425 * @return The builder.
426 * @hide
427 */
428 public Builder setIsEnabled(boolean isEnabled) {
429 mIsEnabled = isEnabled;
430 return this;
431 }
432
433 /**
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700434 * Sets the group Id of the {@link PhoneAccount}. When a new {@link PhoneAccount} is
435 * registered to Telecom, it will replace another {@link PhoneAccount} that is already
436 * registered in Telecom and take on the current user defaults and enabled status. There can
437 * only be one {@link PhoneAccount} with a non-empty group number registered to Telecom at a
438 * time. By default, there is no group Id for a {@link PhoneAccount} (an empty String). Only
439 * grouped {@link PhoneAccount}s with the same {@link ConnectionService} can be replaced.
440 * @param groupId The group Id of the {@link PhoneAccount} that will replace any other
441 * registered {@link PhoneAccount} in Telecom with the same Group Id.
442 * @return The builder
443 * @hide
444 */
445 public Builder setGroupId(String groupId) {
446 if (groupId != null) {
447 mGroupId = groupId;
448 } else {
449 mGroupId = "";
450 }
451 return this;
452 }
453
454 /**
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800455 * Sets the audio routes supported by this {@link PhoneAccount}.
456 *
457 * @param routes bit mask of available routes.
458 * @return The builder.
459 * @hide
460 */
461 public Builder setSupportedAudioRoutes(int routes) {
462 mSupportedAudioRoutes = routes;
463 return this;
464 }
465
466 /**
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700467 * Creates an instance of a {@link PhoneAccount} based on the current builder settings.
468 *
469 * @return The {@link PhoneAccount}.
470 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700471 public PhoneAccount build() {
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700472 // If no supported URI schemes were defined, assume "tel" is supported.
473 if (mSupportedUriSchemes.isEmpty()) {
Andrew Lee3085a6c2014-09-04 10:59:13 -0700474 addSupportedUriScheme(SCHEME_TEL);
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700475 }
476
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700477 return new PhoneAccount(
478 mAccountHandle,
Andrew Lee3085a6c2014-09-04 10:59:13 -0700479 mAddress,
480 mSubscriptionAddress,
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700481 mCapabilities,
Santos Cordoncad84a22015-05-13 11:17:25 -0700482 mIcon,
Ihab Awad476cc832014-11-03 09:47:51 -0800483 mHighlightColor,
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700484 mLabel,
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700485 mShortDescription,
Santos Cordon91371dc02015-05-08 13:52:09 -0700486 mSupportedUriSchemes,
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700487 mExtras,
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800488 mSupportedAudioRoutes,
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700489 mIsEnabled,
490 mGroupId);
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700491 }
492 }
493
494 private PhoneAccount(
Evan Charlton6eb262c2014-07-19 18:18:19 -0700495 PhoneAccountHandle account,
Andrew Lee3085a6c2014-09-04 10:59:13 -0700496 Uri address,
497 Uri subscriptionAddress,
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700498 int capabilities,
Santos Cordoncad84a22015-05-13 11:17:25 -0700499 Icon icon,
Ihab Awad476cc832014-11-03 09:47:51 -0800500 int highlightColor,
Santos Cordon146a3e32014-07-21 00:00:44 -0700501 CharSequence label,
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700502 CharSequence shortDescription,
Santos Cordon91371dc02015-05-08 13:52:09 -0700503 List<String> supportedUriSchemes,
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700504 Bundle extras,
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800505 int supportedAudioRoutes,
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700506 boolean isEnabled,
507 String groupId) {
Evan Charlton8c8a0622014-07-20 12:31:00 -0700508 mAccountHandle = account;
Andrew Lee3085a6c2014-09-04 10:59:13 -0700509 mAddress = address;
510 mSubscriptionAddress = subscriptionAddress;
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700511 mCapabilities = capabilities;
Santos Cordoncad84a22015-05-13 11:17:25 -0700512 mIcon = icon;
Ihab Awad476cc832014-11-03 09:47:51 -0800513 mHighlightColor = highlightColor;
Ihab Awad807fe0a2014-07-09 12:30:52 -0700514 mLabel = label;
515 mShortDescription = shortDescription;
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700516 mSupportedUriSchemes = Collections.unmodifiableList(supportedUriSchemes);
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700517 mExtras = extras;
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800518 mSupportedAudioRoutes = supportedAudioRoutes;
Santos Cordon91371dc02015-05-08 13:52:09 -0700519 mIsEnabled = isEnabled;
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700520 mGroupId = groupId;
Ihab Awad807fe0a2014-07-09 12:30:52 -0700521 }
522
Andrew Lee3085a6c2014-09-04 10:59:13 -0700523 public static Builder builder(
524 PhoneAccountHandle accountHandle,
525 CharSequence label) {
526 return new Builder(accountHandle, label);
527 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700528
Ihab Awad807fe0a2014-07-09 12:30:52 -0700529 /**
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700530 * Returns a builder initialized with the current {@link PhoneAccount} instance.
531 *
532 * @return The builder.
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700533 */
534 public Builder toBuilder() { return new Builder(this); }
535
536 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700537 * The unique identifier of this {@code PhoneAccount}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700538 *
Evan Charlton6eb262c2014-07-19 18:18:19 -0700539 * @return A {@code PhoneAccountHandle}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700540 */
Evan Charlton8c8a0622014-07-20 12:31:00 -0700541 public PhoneAccountHandle getAccountHandle() {
542 return mAccountHandle;
Ihab Awad807fe0a2014-07-09 12:30:52 -0700543 }
544
545 /**
Andrew Lee3085a6c2014-09-04 10:59:13 -0700546 * The address (e.g., a phone number) associated with this {@code PhoneAccount}. This
Evan Charlton8c8a0622014-07-20 12:31:00 -0700547 * represents the destination from which outgoing calls using this {@code PhoneAccount}
Evan Charlton6eb262c2014-07-19 18:18:19 -0700548 * will appear to come, if applicable, and the destination to which incoming calls using this
Evan Charlton8c8a0622014-07-20 12:31:00 -0700549 * {@code PhoneAccount} may be addressed.
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700550 *
Andrew Lee3085a6c2014-09-04 10:59:13 -0700551 * @return A address expressed as a {@code Uri}, for example, a phone number.
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700552 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700553 public Uri getAddress() {
554 return mAddress;
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700555 }
556
557 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700558 * The raw callback number used for this {@code PhoneAccount}, as distinct from
Andrew Lee3085a6c2014-09-04 10:59:13 -0700559 * {@link #getAddress()}. For the majority of {@code PhoneAccount}s this should be registered
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700560 * as {@code null}. It is used by the system for SIM-based {@code PhoneAccount} registration
Junda Liuf52ac902014-09-25 17:36:48 +0000561 * where {@link android.telephony.TelephonyManager#setLine1NumberForDisplay(String, String)}
562 * has been used to alter the callback number.
563 * <p>
Evan Charlton222db5252014-07-17 16:59:18 -0700564 *
565 * @return The subscription number, suitable for display to the user.
566 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700567 public Uri getSubscriptionAddress() {
568 return mSubscriptionAddress;
Evan Charlton222db5252014-07-17 16:59:18 -0700569 }
570
571 /**
Evan Charlton8c8a0622014-07-20 12:31:00 -0700572 * The capabilities of this {@code PhoneAccount}.
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700573 *
Evan Charlton8c8a0622014-07-20 12:31:00 -0700574 * @return A bit field of flags describing this {@code PhoneAccount}'s capabilities.
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700575 */
576 public int getCapabilities() {
577 return mCapabilities;
578 }
579
580 /**
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700581 * Determines if this {@code PhoneAccount} has a capabilities specified by the passed in
582 * bit mask.
583 *
584 * @param capability The capabilities to check.
Santos Cordon895d4b82015-06-25 16:41:48 -0700585 * @return {@code true} if the phone account has the capability.
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700586 */
587 public boolean hasCapabilities(int capability) {
588 return (mCapabilities & capability) == capability;
589 }
590
591 /**
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800592 * Determines if this {@code PhoneAccount} has routes specified by the passed in bit mask.
593 *
594 * @param route The routes to check.
595 * @return {@code true} if the phone account has the routes.
596 * @hide
597 */
598 public boolean hasAudioRoutes(int routes) {
599 return (mSupportedAudioRoutes & routes) == routes;
600 }
601
602 /**
Santos Cordon146a3e32014-07-21 00:00:44 -0700603 * A short label describing a {@code PhoneAccount}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700604 *
Evan Charlton8c8a0622014-07-20 12:31:00 -0700605 * @return A label for this {@code PhoneAccount}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700606 */
Santos Cordon146a3e32014-07-21 00:00:44 -0700607 public CharSequence getLabel() {
Ihab Awad807fe0a2014-07-09 12:30:52 -0700608 return mLabel;
609 }
610
611 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700612 * A short paragraph describing this {@code PhoneAccount}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700613 *
Evan Charlton8c8a0622014-07-20 12:31:00 -0700614 * @return A description for this {@code PhoneAccount}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700615 */
Santos Cordon146a3e32014-07-21 00:00:44 -0700616 public CharSequence getShortDescription() {
Ihab Awad807fe0a2014-07-09 12:30:52 -0700617 return mShortDescription;
618 }
619
620 /**
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700621 * The URI schemes supported by this {@code PhoneAccount}.
622 *
623 * @return The URI schemes.
624 */
625 public List<String> getSupportedUriSchemes() {
626 return mSupportedUriSchemes;
627 }
628
629 /**
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700630 * The extras associated with this {@code PhoneAccount}.
631 * <p>
632 * A {@link ConnectionService} may provide implementation specific information about the
633 * {@link PhoneAccount} via the extras.
634 *
635 * @return The extras.
636 */
637 public Bundle getExtras() {
638 return mExtras;
639 }
640
641 /**
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800642 * The audio routes supported by this {@code PhoneAccount}.
643 *
644 * @hide
645 */
646 public int getSupportedAudioRoutes() {
647 return mSupportedAudioRoutes;
648 }
649
650 /**
Santos Cordoncad84a22015-05-13 11:17:25 -0700651 * The icon to represent this {@code PhoneAccount}.
652 *
653 * @return The icon.
654 */
655 public Icon getIcon() {
656 return mIcon;
657 }
658
659 /**
Santos Cordon895d4b82015-06-25 16:41:48 -0700660 * Indicates whether the user has enabled this {@code PhoneAccount} or not. This value is only
661 * populated for {@code PhoneAccount}s returned by {@link TelecomManager#getPhoneAccount}.
Santos Cordon91371dc02015-05-08 13:52:09 -0700662 *
Santos Cordon895d4b82015-06-25 16:41:48 -0700663 * @return {@code true} if the account is enabled by the user, {@code false} otherwise.
Santos Cordon91371dc02015-05-08 13:52:09 -0700664 */
665 public boolean isEnabled() {
666 return mIsEnabled;
667 }
668
669 /**
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700670 * A non-empty {@link String} representing the group that A {@link PhoneAccount} is in or an
671 * empty {@link String} if the {@link PhoneAccount} is not in a group. If this
672 * {@link PhoneAccount} is in a group, this new {@link PhoneAccount} will replace a registered
673 * {@link PhoneAccount} that is in the same group. When the {@link PhoneAccount} is replaced,
674 * its user defined defaults and enabled status will also pass to this new {@link PhoneAccount}.
675 * Only {@link PhoneAccount}s that share the same {@link ConnectionService} can be replaced.
676 *
677 * @return A non-empty String Id if this {@link PhoneAccount} belongs to a group.
678 * @hide
679 */
680 public String getGroupId() {
681 return mGroupId;
682 }
683
684 /**
Andrew Lee3085a6c2014-09-04 10:59:13 -0700685 * Determines if the {@link PhoneAccount} supports calls to/from addresses with a specified URI
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700686 * scheme.
687 *
688 * @param uriScheme The URI scheme to check.
Santos Cordon895d4b82015-06-25 16:41:48 -0700689 * @return {@code true} if the {@code PhoneAccount} supports calls to/from addresses with the
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700690 * specified URI scheme.
691 */
692 public boolean supportsUriScheme(String uriScheme) {
693 if (mSupportedUriSchemes == null || uriScheme == null) {
694 return false;
695 }
696
697 for (String scheme : mSupportedUriSchemes) {
698 if (scheme != null && scheme.equals(uriScheme)) {
699 return true;
700 }
701 }
702 return false;
703 }
704
705 /**
Ihab Awad476cc832014-11-03 09:47:51 -0800706 * A highlight color to use in displaying information about this {@code PhoneAccount}.
707 *
708 * @return A hexadecimal color value.
709 */
710 public int getHighlightColor() {
711 return mHighlightColor;
712 }
713
Santos Cordon91371dc02015-05-08 13:52:09 -0700714 /**
715 * Sets the enabled state of the phone account.
716 * @hide
717 */
718 public void setIsEnabled(boolean isEnabled) {
719 mIsEnabled = isEnabled;
720 }
721
Tyler Gunnf5035432017-01-09 09:43:12 -0800722 /**
723 * @return {@code true} if the {@link PhoneAccount} is self-managed, {@code false} otherwise.
724 * @hide
725 */
726 public boolean isSelfManaged() {
727 return (mCapabilities & CAPABILITY_SELF_MANAGED) == CAPABILITY_SELF_MANAGED;
728 }
729
Ihab Awad807fe0a2014-07-09 12:30:52 -0700730 //
731 // Parcelable implementation
732 //
733
734 @Override
735 public int describeContents() {
736 return 0;
737 }
738
739 @Override
740 public void writeToParcel(Parcel out, int flags) {
Ihab Awad476cc832014-11-03 09:47:51 -0800741 if (mAccountHandle == null) {
742 out.writeInt(0);
743 } else {
744 out.writeInt(1);
745 mAccountHandle.writeToParcel(out, flags);
746 }
747 if (mAddress == null) {
748 out.writeInt(0);
749 } else {
750 out.writeInt(1);
751 mAddress.writeToParcel(out, flags);
752 }
753 if (mSubscriptionAddress == null) {
754 out.writeInt(0);
755 } else {
756 out.writeInt(1);
757 mSubscriptionAddress.writeToParcel(out, flags);
758 }
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700759 out.writeInt(mCapabilities);
Ihab Awad476cc832014-11-03 09:47:51 -0800760 out.writeInt(mHighlightColor);
Santos Cordon146a3e32014-07-21 00:00:44 -0700761 out.writeCharSequence(mLabel);
762 out.writeCharSequence(mShortDescription);
Ihab Awad476cc832014-11-03 09:47:51 -0800763 out.writeStringList(mSupportedUriSchemes);
Santos Cordon91371dc02015-05-08 13:52:09 -0700764
Santos Cordoncad84a22015-05-13 11:17:25 -0700765 if (mIcon == null) {
766 out.writeInt(0);
767 } else {
768 out.writeInt(1);
769 mIcon.writeToParcel(out, flags);
770 }
Santos Cordon91371dc02015-05-08 13:52:09 -0700771 out.writeByte((byte) (mIsEnabled ? 1 : 0));
Tyler Gunnef829ec2015-10-08 09:46:23 -0700772 out.writeBundle(mExtras);
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700773 out.writeString(mGroupId);
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800774 out.writeInt(mSupportedAudioRoutes);
Ihab Awad807fe0a2014-07-09 12:30:52 -0700775 }
776
Evan Charlton8c8a0622014-07-20 12:31:00 -0700777 public static final Creator<PhoneAccount> CREATOR
778 = new Creator<PhoneAccount>() {
Ihab Awad807fe0a2014-07-09 12:30:52 -0700779 @Override
Evan Charlton8c8a0622014-07-20 12:31:00 -0700780 public PhoneAccount createFromParcel(Parcel in) {
781 return new PhoneAccount(in);
Ihab Awad807fe0a2014-07-09 12:30:52 -0700782 }
783
784 @Override
Evan Charlton8c8a0622014-07-20 12:31:00 -0700785 public PhoneAccount[] newArray(int size) {
786 return new PhoneAccount[size];
Ihab Awad807fe0a2014-07-09 12:30:52 -0700787 }
788 };
789
Evan Charlton8c8a0622014-07-20 12:31:00 -0700790 private PhoneAccount(Parcel in) {
Ihab Awad476cc832014-11-03 09:47:51 -0800791 if (in.readInt() > 0) {
792 mAccountHandle = PhoneAccountHandle.CREATOR.createFromParcel(in);
793 } else {
794 mAccountHandle = null;
795 }
796 if (in.readInt() > 0) {
797 mAddress = Uri.CREATOR.createFromParcel(in);
798 } else {
799 mAddress = null;
800 }
801 if (in.readInt() > 0) {
802 mSubscriptionAddress = Uri.CREATOR.createFromParcel(in);
803 } else {
804 mSubscriptionAddress = null;
805 }
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700806 mCapabilities = in.readInt();
Ihab Awad476cc832014-11-03 09:47:51 -0800807 mHighlightColor = in.readInt();
Santos Cordon146a3e32014-07-21 00:00:44 -0700808 mLabel = in.readCharSequence();
809 mShortDescription = in.readCharSequence();
Ihab Awad476cc832014-11-03 09:47:51 -0800810 mSupportedUriSchemes = Collections.unmodifiableList(in.createStringArrayList());
Santos Cordoncad84a22015-05-13 11:17:25 -0700811 if (in.readInt() > 0) {
812 mIcon = Icon.CREATOR.createFromParcel(in);
813 } else {
814 mIcon = null;
815 }
Santos Cordon91371dc02015-05-08 13:52:09 -0700816 mIsEnabled = in.readByte() == 1;
Tyler Gunnef829ec2015-10-08 09:46:23 -0700817 mExtras = in.readBundle();
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700818 mGroupId = in.readString();
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800819 mSupportedAudioRoutes = in.readInt();
Ihab Awad807fe0a2014-07-09 12:30:52 -0700820 }
Tyler Gunn76c01a52014-09-30 14:47:51 -0700821
822 @Override
823 public String toString() {
Santos Cordon91371dc02015-05-08 13:52:09 -0700824 StringBuilder sb = new StringBuilder().append("[[")
825 .append(mIsEnabled ? 'X' : ' ')
826 .append("] PhoneAccount: ")
Tyler Gunn76c01a52014-09-30 14:47:51 -0700827 .append(mAccountHandle)
828 .append(" Capabilities: ")
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800829 .append(capabilitiesToString())
830 .append(" Audio Routes: ")
831 .append(audioRoutesToString())
Tyler Gunn76c01a52014-09-30 14:47:51 -0700832 .append(" Schemes: ");
833 for (String scheme : mSupportedUriSchemes) {
834 sb.append(scheme)
835 .append(" ");
836 }
Tyler Gunnef829ec2015-10-08 09:46:23 -0700837 sb.append(" Extras: ");
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700838 sb.append(mExtras);
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700839 sb.append(" GroupId: ");
840 sb.append(Log.pii(mGroupId));
Tyler Gunn76c01a52014-09-30 14:47:51 -0700841 sb.append("]");
842 return sb.toString();
843 }
Tyler Gunn3e122f72016-01-11 19:25:00 -0800844
845 /**
846 * Generates a string representation of a capabilities bitmask.
847 *
848 * @param capabilities The capabilities bitmask.
849 * @return String representation of the capabilities bitmask.
850 */
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800851 private String capabilitiesToString() {
Tyler Gunn3e122f72016-01-11 19:25:00 -0800852 StringBuilder sb = new StringBuilder();
Tyler Gunnf5035432017-01-09 09:43:12 -0800853 if (hasCapabilities(CAPABILITY_SELF_MANAGED)) {
854 sb.append("SelfManaged ");
855 }
Tyler Gunn58cbd7a2016-11-11 11:31:28 -0800856 if (hasCapabilities(CAPABILITY_SUPPORTS_VIDEO_CALLING)) {
857 sb.append("SuppVideo ");
858 }
Tyler Gunn3e122f72016-01-11 19:25:00 -0800859 if (hasCapabilities(CAPABILITY_VIDEO_CALLING)) {
860 sb.append("Video ");
861 }
862 if (hasCapabilities(CAPABILITY_VIDEO_CALLING_RELIES_ON_PRESENCE)) {
863 sb.append("Presence ");
864 }
865 if (hasCapabilities(CAPABILITY_CALL_PROVIDER)) {
866 sb.append("CallProvider ");
867 }
868 if (hasCapabilities(CAPABILITY_CALL_SUBJECT)) {
869 sb.append("CallSubject ");
870 }
871 if (hasCapabilities(CAPABILITY_CONNECTION_MANAGER)) {
872 sb.append("ConnectionMgr ");
873 }
874 if (hasCapabilities(CAPABILITY_EMERGENCY_CALLS_ONLY)) {
875 sb.append("EmergOnly ");
876 }
877 if (hasCapabilities(CAPABILITY_MULTI_USER)) {
878 sb.append("MultiUser ");
879 }
880 if (hasCapabilities(CAPABILITY_PLACE_EMERGENCY_CALLS)) {
881 sb.append("PlaceEmerg ");
882 }
Tyler Gunncee9ea62016-03-24 11:45:43 -0700883 if (hasCapabilities(CAPABILITY_EMERGENCY_VIDEO_CALLING)) {
884 sb.append("EmergVideo ");
885 }
Tyler Gunn3e122f72016-01-11 19:25:00 -0800886 if (hasCapabilities(CAPABILITY_SIM_SUBSCRIPTION)) {
887 sb.append("SimSub ");
888 }
889 return sb.toString();
890 }
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800891
892 private String audioRoutesToString() {
893 StringBuilder sb = new StringBuilder();
894
895 if (hasAudioRoutes(CallAudioState.ROUTE_BLUETOOTH)) {
896 sb.append("B");
897 }
898 if (hasAudioRoutes(CallAudioState.ROUTE_EARPIECE)) {
899 sb.append("E");
900 }
901 if (hasAudioRoutes(CallAudioState.ROUTE_SPEAKER)) {
902 sb.append("S");
903 }
904 if (hasAudioRoutes(CallAudioState.ROUTE_WIRED_HEADSET)) {
905 sb.append("W");
906 }
907
908 return sb.toString();
909 }
Ihab Awad807fe0a2014-07-09 12:30:52 -0700910}