blob: 5530cb7b53e1fef1a13a673602c51f10f2cc8452 [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
Srikanth Chintala212102b2017-03-27 19:27:52 +053046 * sort order for {@link PhoneAccount}s from the same
47 * {@link android.telecom.ConnectionService}.
48 * @hide
49 */
50 public static final String EXTRA_SORT_ORDER =
51 "android.telecom.extra.SORT_ORDER";
52
53 /**
54 * {@link PhoneAccount} extras key (see {@link PhoneAccount#getExtras()}) which determines the
Tyler Gunnd426b202015-10-13 13:33:53 -070055 * maximum permitted length of a call subject specified via the
56 * {@link TelecomManager#EXTRA_CALL_SUBJECT} extra on an
57 * {@link android.content.Intent#ACTION_CALL} intent. Ultimately a {@link ConnectionService} is
58 * responsible for enforcing the maximum call subject length when sending the message, however
59 * this extra is provided so that the user interface can proactively limit the length of the
60 * call subject as the user types it.
61 */
62 public static final String EXTRA_CALL_SUBJECT_MAX_LENGTH =
63 "android.telecom.extra.CALL_SUBJECT_MAX_LENGTH";
64
65 /**
66 * {@link PhoneAccount} extras key (see {@link PhoneAccount#getExtras()}) which determines the
67 * character encoding to be used when determining the length of messages.
68 * The user interface can use this when determining the number of characters the user may type
69 * in a call subject. If empty-string, the call subject message size limit will be enforced on
70 * a 1:1 basis. That is, each character will count towards the messages size limit as a single
71 * character. If a character encoding is specified, the message size limit will be based on the
72 * number of bytes in the message per the specified encoding. See
73 * {@link #EXTRA_CALL_SUBJECT_MAX_LENGTH} for more information on the call subject maximum
74 * length.
75 */
76 public static final String EXTRA_CALL_SUBJECT_CHARACTER_ENCODING =
77 "android.telecom.extra.CALL_SUBJECT_CHARACTER_ENCODING";
78
79 /**
Ihab Awadf8b69882014-07-25 15:14:01 -070080 * Flag indicating that this {@code PhoneAccount} can act as a connection manager for
81 * other connections. The {@link ConnectionService} associated with this {@code PhoneAccount}
82 * will be allowed to manage phone calls including using its own proprietary phone-call
83 * implementation (like VoIP calling) to make calls instead of the telephony stack.
84 * <p>
Ihab Awadb19a0bc2014-08-07 19:46:01 -070085 * When a user opts to place a call using the SIM-based telephony stack, the
86 * {@link ConnectionService} associated with this {@code PhoneAccount} will be attempted first
87 * if the user has explicitly selected it to be used as the default connection manager.
Ihab Awad94cf4bf2014-07-17 11:21:19 -070088 * <p>
89 * See {@link #getCapabilities}
90 */
Ihab Awadf8b69882014-07-25 15:14:01 -070091 public static final int CAPABILITY_CONNECTION_MANAGER = 0x1;
Ihab Awad94cf4bf2014-07-17 11:21:19 -070092
93 /**
Evan Charlton8c8a0622014-07-20 12:31:00 -070094 * Flag indicating that this {@code PhoneAccount} can make phone calls in place of
Evan Charlton6eb262c2014-07-19 18:18:19 -070095 * traditional SIM-based telephony calls. This account will be treated as a distinct method
96 * for placing calls alongside the traditional SIM-based telephony stack. This flag is
Ihab Awadf8b69882014-07-25 15:14:01 -070097 * distinct from {@link #CAPABILITY_CONNECTION_MANAGER} in that it is not allowed to manage
Santos Cordon32c65a52014-10-27 14:57:49 -070098 * or place calls from the built-in telephony stack.
Ihab Awad94cf4bf2014-07-17 11:21:19 -070099 * <p>
100 * See {@link #getCapabilities}
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700101 * <p>
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700102 */
103 public static final int CAPABILITY_CALL_PROVIDER = 0x2;
104
Ihab Awad7522bbd2014-07-18 15:53:17 -0700105 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700106 * Flag indicating that this {@code PhoneAccount} represents a built-in PSTN SIM
Evan Charlton6eb262c2014-07-19 18:18:19 -0700107 * subscription.
Ihab Awad7522bbd2014-07-18 15:53:17 -0700108 * <p>
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700109 * Only the Android framework can register a {@code PhoneAccount} having this capability.
110 * <p>
111 * See {@link #getCapabilities}
Ihab Awad7522bbd2014-07-18 15:53:17 -0700112 */
113 public static final int CAPABILITY_SIM_SUBSCRIPTION = 0x4;
114
Ihab Awadf8b69882014-07-25 15:14:01 -0700115 /**
Tyler Gunn58cbd7a2016-11-11 11:31:28 -0800116 * Flag indicating that this {@code PhoneAccount} is currently able to place video calls.
117 * <p>
118 * See also {@link #CAPABILITY_SUPPORTS_VIDEO_CALLING} which indicates whether the
119 * {@code PhoneAccount} supports placing video calls.
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700120 * <p>
121 * See {@link #getCapabilities}
Ihab Awadf8b69882014-07-25 15:14:01 -0700122 */
123 public static final int CAPABILITY_VIDEO_CALLING = 0x8;
124
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700125 /**
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700126 * Flag indicating that this {@code PhoneAccount} is capable of placing emergency calls.
127 * By default all PSTN {@code PhoneAccount}s are capable of placing emergency calls.
128 * <p>
129 * See {@link #getCapabilities}
130 */
131 public static final int CAPABILITY_PLACE_EMERGENCY_CALLS = 0x10;
132
133 /**
Evan Charlton134dd682014-11-25 14:12:57 -0800134 * Flag indicating that this {@code PhoneAccount} is capable of being used by all users. This
135 * should only be used by system apps (and will be ignored for all other apps trying to use it).
136 * <p>
137 * See {@link #getCapabilities}
138 * @hide
139 */
Brian Attwellad147f42014-12-19 11:37:16 -0800140 @SystemApi
Evan Charlton134dd682014-11-25 14:12:57 -0800141 public static final int CAPABILITY_MULTI_USER = 0x20;
142
143 /**
Tyler Gunn65a3d342015-07-27 16:06:16 -0700144 * Flag indicating that this {@code PhoneAccount} supports a subject for Calls. This means a
145 * caller is able to specify a short subject line for an outgoing call. A capable receiving
146 * device displays the call subject on the incoming call screen.
147 * <p>
148 * See {@link #getCapabilities}
149 */
150 public static final int CAPABILITY_CALL_SUBJECT = 0x40;
151
152 /**
Bryce Leeb96d89c2015-10-14 16:48:40 -0700153 * Flag indicating that this {@code PhoneAccount} should only be used for emergency calls.
154 * <p>
155 * See {@link #getCapabilities}
156 * @hide
157 */
158 public static final int CAPABILITY_EMERGENCY_CALLS_ONLY = 0x80;
159
160 /**
Tyler Gunn9a365752015-12-09 15:00:18 -0800161 * Flag indicating that for this {@code PhoneAccount}, the ability to make a video call to a
162 * number relies on presence. Should only be set if the {@code PhoneAccount} also has
163 * {@link #CAPABILITY_VIDEO_CALLING}.
164 * <p>
165 * When set, the {@link ConnectionService} is responsible for toggling the
166 * {@link android.provider.ContactsContract.Data#CARRIER_PRESENCE_VT_CAPABLE} bit on the
167 * {@link android.provider.ContactsContract.Data#CARRIER_PRESENCE} column to indicate whether
168 * a contact's phone number supports video calling.
169 * <p>
170 * See {@link #getCapabilities}
171 */
172 public static final int CAPABILITY_VIDEO_CALLING_RELIES_ON_PRESENCE = 0x100;
173
174 /**
Tyler Gunncee9ea62016-03-24 11:45:43 -0700175 * Flag indicating that for this {@link PhoneAccount}, emergency video calling is allowed.
176 * <p>
177 * When set, Telecom will allow emergency video calls to be placed. When not set, Telecom will
178 * convert all outgoing video calls to emergency numbers to audio-only.
179 * @hide
180 */
181 public static final int CAPABILITY_EMERGENCY_VIDEO_CALLING = 0x200;
182
183 /**
Tyler Gunn58cbd7a2016-11-11 11:31:28 -0800184 * Flag indicating that this {@link PhoneAccount} supports video calling.
185 * This is not an indication that the {@link PhoneAccount} is currently able to make a video
186 * call, but rather that it has the ability to make video calls (but not necessarily at this
187 * time).
188 * <p>
189 * Whether a {@link PhoneAccount} can make a video call is ultimately controlled by
190 * {@link #CAPABILITY_VIDEO_CALLING}, which indicates whether the {@link PhoneAccount} is
191 * currently capable of making a video call. Consider a case where, for example, a
192 * {@link PhoneAccount} supports making video calls (e.g.
193 * {@link #CAPABILITY_SUPPORTS_VIDEO_CALLING}), but a current lack of network connectivity
194 * prevents video calls from being made (e.g. {@link #CAPABILITY_VIDEO_CALLING}).
195 * <p>
196 * See {@link #getCapabilities}
197 */
198 public static final int CAPABILITY_SUPPORTS_VIDEO_CALLING = 0x400;
199
200 /**
Tyler Gunnf5035432017-01-09 09:43:12 -0800201 * Flag indicating that this {@link PhoneAccount} is responsible for managing its own
202 * {@link Connection}s. This type of {@link PhoneAccount} is ideal for use with standalone
203 * calling apps which do not wish to use the default phone app for {@link Connection} UX,
204 * but which want to leverage the call and audio routing capabilities of the Telecom framework.
205 * <p>
206 * When set, {@link Connection}s created by the self-managed {@link ConnectionService} will not
207 * be surfaced to implementations of the {@link InCallService} API. Thus it is the
208 * responsibility of a self-managed {@link ConnectionService} to provide a user interface for
209 * its {@link Connection}s.
210 * <p>
211 * Self-managed {@link Connection}s will, however, be displayed on connected Bluetooth devices.
212 */
213 public static final int CAPABILITY_SELF_MANAGED = 0x800;
214
215 /**
Hall Liu95d55872017-01-25 17:12:49 -0800216 * Flag indicating that this {@link PhoneAccount} is capable of making a call with an
217 * RTT (Real-time text) session.
218 * When set, Telecom will attempt to open an RTT session on outgoing calls that specify
219 * that they should be placed with an RTT session , and the in-call app will be displayed
220 * with text entry fields for RTT. Likewise, the in-call app can request that an RTT
221 * session be opened during a call if this bit is set.
222 */
223 public static final int CAPABILITY_RTT = 0x1000;
224
225 /* NEXT CAPABILITY: 0x2000 */
226
227 /**
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700228 * URI scheme for telephone number URIs.
229 */
230 public static final String SCHEME_TEL = "tel";
231
232 /**
233 * URI scheme for voicemail URIs.
234 */
235 public static final String SCHEME_VOICEMAIL = "voicemail";
236
237 /**
238 * URI scheme for SIP URIs.
239 */
240 public static final String SCHEME_SIP = "sip";
241
Nancy Chen3ace54b2014-10-22 17:45:26 -0700242 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800243 * Indicating no icon tint is set.
Santos Cordoncad84a22015-05-13 11:17:25 -0700244 * @hide
Nancy Chen3ace54b2014-10-22 17:45:26 -0700245 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800246 public static final int NO_ICON_TINT = 0;
247
248 /**
249 * Indicating no hightlight color is set.
250 */
251 public static final int NO_HIGHLIGHT_COLOR = 0;
Nancy Chen3ace54b2014-10-22 17:45:26 -0700252
Ihab Awad476cc832014-11-03 09:47:51 -0800253 /**
254 * Indicating no resource ID is set.
255 */
256 public static final int NO_RESOURCE_ID = -1;
257
Evan Charlton8c8a0622014-07-20 12:31:00 -0700258 private final PhoneAccountHandle mAccountHandle;
Andrew Lee3085a6c2014-09-04 10:59:13 -0700259 private final Uri mAddress;
260 private final Uri mSubscriptionAddress;
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700261 private final int mCapabilities;
Ihab Awad476cc832014-11-03 09:47:51 -0800262 private final int mHighlightColor;
Santos Cordon146a3e32014-07-21 00:00:44 -0700263 private final CharSequence mLabel;
264 private final CharSequence mShortDescription;
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700265 private final List<String> mSupportedUriSchemes;
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800266 private final int mSupportedAudioRoutes;
Santos Cordoncad84a22015-05-13 11:17:25 -0700267 private final Icon mIcon;
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700268 private final Bundle mExtras;
Santos Cordon91371dc2015-05-08 13:52:09 -0700269 private boolean mIsEnabled;
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700270 private String mGroupId;
Ihab Awad807fe0a2014-07-09 12:30:52 -0700271
Santos Cordon32c65a52014-10-27 14:57:49 -0700272 /**
273 * Helper class for creating a {@link PhoneAccount}.
274 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700275 public static class Builder {
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800276
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700277 private PhoneAccountHandle mAccountHandle;
Andrew Lee3085a6c2014-09-04 10:59:13 -0700278 private Uri mAddress;
279 private Uri mSubscriptionAddress;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700280 private int mCapabilities;
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800281 private int mSupportedAudioRoutes = CallAudioState.ROUTE_ALL;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800282 private int mHighlightColor = NO_HIGHLIGHT_COLOR;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700283 private CharSequence mLabel;
284 private CharSequence mShortDescription;
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700285 private List<String> mSupportedUriSchemes = new ArrayList<String>();
Santos Cordoncad84a22015-05-13 11:17:25 -0700286 private Icon mIcon;
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700287 private Bundle mExtras;
Santos Cordon91371dc2015-05-08 13:52:09 -0700288 private boolean mIsEnabled = false;
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700289 private String mGroupId = "";
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700290
Santos Cordon32c65a52014-10-27 14:57:49 -0700291 /**
292 * Creates a builder with the specified {@link PhoneAccountHandle} and label.
293 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700294 public Builder(PhoneAccountHandle accountHandle, CharSequence label) {
295 this.mAccountHandle = accountHandle;
296 this.mLabel = label;
297 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700298
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700299 /**
300 * Creates an instance of the {@link PhoneAccount.Builder} from an existing
301 * {@link PhoneAccount}.
302 *
303 * @param phoneAccount The {@link PhoneAccount} used to initialize the builder.
304 */
305 public Builder(PhoneAccount phoneAccount) {
306 mAccountHandle = phoneAccount.getAccountHandle();
307 mAddress = phoneAccount.getAddress();
308 mSubscriptionAddress = phoneAccount.getSubscriptionAddress();
309 mCapabilities = phoneAccount.getCapabilities();
Ihab Awad476cc832014-11-03 09:47:51 -0800310 mHighlightColor = phoneAccount.getHighlightColor();
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700311 mLabel = phoneAccount.getLabel();
312 mShortDescription = phoneAccount.getShortDescription();
313 mSupportedUriSchemes.addAll(phoneAccount.getSupportedUriSchemes());
Santos Cordoncad84a22015-05-13 11:17:25 -0700314 mIcon = phoneAccount.getIcon();
Santos Cordon91371dc2015-05-08 13:52:09 -0700315 mIsEnabled = phoneAccount.isEnabled();
Tyler Gunnd426b202015-10-13 13:33:53 -0700316 mExtras = phoneAccount.getExtras();
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700317 mGroupId = phoneAccount.getGroupId();
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800318 mSupportedAudioRoutes = phoneAccount.getSupportedAudioRoutes();
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700319 }
320
Santos Cordon32c65a52014-10-27 14:57:49 -0700321 /**
Tyler Gunn37653562017-03-13 18:15:15 -0700322 * Sets the label. See {@link PhoneAccount#getLabel()}.
323 *
324 * @param label The label of the phone account.
325 * @return The builder.
326 * @hide
327 */
328 public Builder setLabel(CharSequence label) {
329 this.mLabel = label;
330 return this;
331 }
332
333 /**
Santos Cordon32c65a52014-10-27 14:57:49 -0700334 * Sets the address. See {@link PhoneAccount#getAddress}.
335 *
336 * @param value The address of the phone account.
337 * @return The builder.
338 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700339 public Builder setAddress(Uri value) {
340 this.mAddress = value;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700341 return this;
342 }
343
Santos Cordon32c65a52014-10-27 14:57:49 -0700344 /**
345 * Sets the subscription address. See {@link PhoneAccount#getSubscriptionAddress}.
346 *
347 * @param value The subscription address.
348 * @return The builder.
349 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700350 public Builder setSubscriptionAddress(Uri value) {
351 this.mSubscriptionAddress = value;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700352 return this;
353 }
354
Santos Cordon32c65a52014-10-27 14:57:49 -0700355 /**
356 * Sets the capabilities. See {@link PhoneAccount#getCapabilities}.
357 *
358 * @param value The capabilities to set.
359 * @return The builder.
360 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700361 public Builder setCapabilities(int value) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700362 this.mCapabilities = value;
363 return this;
364 }
365
Santos Cordon32c65a52014-10-27 14:57:49 -0700366 /**
Santos Cordoncad84a22015-05-13 11:17:25 -0700367 * Sets the icon. See {@link PhoneAccount#getIcon}.
Santos Cordon32c65a52014-10-27 14:57:49 -0700368 *
Santos Cordoncad84a22015-05-13 11:17:25 -0700369 * @param icon The icon to set.
Santos Cordon32c65a52014-10-27 14:57:49 -0700370 */
Santos Cordoncad84a22015-05-13 11:17:25 -0700371 public Builder setIcon(Icon icon) {
372 mIcon = icon;
Ihab Awad074bf102014-10-24 11:42:32 -0700373 return this;
374 }
375
376 /**
Ihab Awad476cc832014-11-03 09:47:51 -0800377 * Sets the highlight color. See {@link PhoneAccount#getHighlightColor}.
Ihab Awad074bf102014-10-24 11:42:32 -0700378 *
Ihab Awad476cc832014-11-03 09:47:51 -0800379 * @param value The highlight color.
Ihab Awad074bf102014-10-24 11:42:32 -0700380 * @return The builder.
381 */
Ihab Awad476cc832014-11-03 09:47:51 -0800382 public Builder setHighlightColor(int value) {
383 this.mHighlightColor = value;
Nancy Chen3ace54b2014-10-22 17:45:26 -0700384 return this;
385 }
386
Santos Cordon32c65a52014-10-27 14:57:49 -0700387 /**
388 * Sets the short description. See {@link PhoneAccount#getShortDescription}.
389 *
390 * @param value The short description.
391 * @return The builder.
392 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700393 public Builder setShortDescription(CharSequence value) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700394 this.mShortDescription = value;
395 return this;
396 }
397
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700398 /**
399 * Specifies an additional URI scheme supported by the {@link PhoneAccount}.
400 *
401 * @param uriScheme The URI scheme.
Santos Cordon32c65a52014-10-27 14:57:49 -0700402 * @return The builder.
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700403 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700404 public Builder addSupportedUriScheme(String uriScheme) {
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700405 if (!TextUtils.isEmpty(uriScheme) && !mSupportedUriSchemes.contains(uriScheme)) {
406 this.mSupportedUriSchemes.add(uriScheme);
407 }
408 return this;
409 }
410
411 /**
Andrew Lee3085a6c2014-09-04 10:59:13 -0700412 * Specifies the URI schemes supported by the {@link PhoneAccount}.
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700413 *
414 * @param uriSchemes The URI schemes.
Santos Cordon32c65a52014-10-27 14:57:49 -0700415 * @return The builder.
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700416 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700417 public Builder setSupportedUriSchemes(List<String> uriSchemes) {
418 mSupportedUriSchemes.clear();
419
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700420 if (uriSchemes != null && !uriSchemes.isEmpty()) {
421 for (String uriScheme : uriSchemes) {
Andrew Lee3085a6c2014-09-04 10:59:13 -0700422 addSupportedUriScheme(uriScheme);
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700423 }
424 }
425 return this;
426 }
427
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700428 /**
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700429 * Specifies the extras associated with the {@link PhoneAccount}.
430 * <p>
431 * {@code PhoneAccount}s only support extra values of type: {@link String}, {@link Integer},
432 * and {@link Boolean}. Extras which are not of these types are ignored.
433 *
434 * @param extras
435 * @return
436 */
437 public Builder setExtras(Bundle extras) {
438 mExtras = extras;
439 return this;
440 }
441
442 /**
Santos Cordon91371dc2015-05-08 13:52:09 -0700443 * Sets the enabled state of the phone account.
444 *
445 * @param isEnabled The enabled state.
446 * @return The builder.
447 * @hide
448 */
449 public Builder setIsEnabled(boolean isEnabled) {
450 mIsEnabled = isEnabled;
451 return this;
452 }
453
454 /**
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700455 * Sets the group Id of the {@link PhoneAccount}. When a new {@link PhoneAccount} is
456 * registered to Telecom, it will replace another {@link PhoneAccount} that is already
457 * registered in Telecom and take on the current user defaults and enabled status. There can
458 * only be one {@link PhoneAccount} with a non-empty group number registered to Telecom at a
459 * time. By default, there is no group Id for a {@link PhoneAccount} (an empty String). Only
460 * grouped {@link PhoneAccount}s with the same {@link ConnectionService} can be replaced.
461 * @param groupId The group Id of the {@link PhoneAccount} that will replace any other
462 * registered {@link PhoneAccount} in Telecom with the same Group Id.
463 * @return The builder
464 * @hide
465 */
466 public Builder setGroupId(String groupId) {
467 if (groupId != null) {
468 mGroupId = groupId;
469 } else {
470 mGroupId = "";
471 }
472 return this;
473 }
474
475 /**
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800476 * Sets the audio routes supported by this {@link PhoneAccount}.
477 *
478 * @param routes bit mask of available routes.
479 * @return The builder.
480 * @hide
481 */
482 public Builder setSupportedAudioRoutes(int routes) {
483 mSupportedAudioRoutes = routes;
484 return this;
485 }
486
487 /**
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700488 * Creates an instance of a {@link PhoneAccount} based on the current builder settings.
489 *
490 * @return The {@link PhoneAccount}.
491 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700492 public PhoneAccount build() {
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700493 // If no supported URI schemes were defined, assume "tel" is supported.
494 if (mSupportedUriSchemes.isEmpty()) {
Andrew Lee3085a6c2014-09-04 10:59:13 -0700495 addSupportedUriScheme(SCHEME_TEL);
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700496 }
497
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700498 return new PhoneAccount(
499 mAccountHandle,
Andrew Lee3085a6c2014-09-04 10:59:13 -0700500 mAddress,
501 mSubscriptionAddress,
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700502 mCapabilities,
Santos Cordoncad84a22015-05-13 11:17:25 -0700503 mIcon,
Ihab Awad476cc832014-11-03 09:47:51 -0800504 mHighlightColor,
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700505 mLabel,
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700506 mShortDescription,
Santos Cordon91371dc2015-05-08 13:52:09 -0700507 mSupportedUriSchemes,
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700508 mExtras,
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800509 mSupportedAudioRoutes,
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700510 mIsEnabled,
511 mGroupId);
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700512 }
513 }
514
515 private PhoneAccount(
Evan Charlton6eb262c2014-07-19 18:18:19 -0700516 PhoneAccountHandle account,
Andrew Lee3085a6c2014-09-04 10:59:13 -0700517 Uri address,
518 Uri subscriptionAddress,
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700519 int capabilities,
Santos Cordoncad84a22015-05-13 11:17:25 -0700520 Icon icon,
Ihab Awad476cc832014-11-03 09:47:51 -0800521 int highlightColor,
Santos Cordon146a3e32014-07-21 00:00:44 -0700522 CharSequence label,
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700523 CharSequence shortDescription,
Santos Cordon91371dc2015-05-08 13:52:09 -0700524 List<String> supportedUriSchemes,
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700525 Bundle extras,
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800526 int supportedAudioRoutes,
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700527 boolean isEnabled,
528 String groupId) {
Evan Charlton8c8a0622014-07-20 12:31:00 -0700529 mAccountHandle = account;
Andrew Lee3085a6c2014-09-04 10:59:13 -0700530 mAddress = address;
531 mSubscriptionAddress = subscriptionAddress;
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700532 mCapabilities = capabilities;
Santos Cordoncad84a22015-05-13 11:17:25 -0700533 mIcon = icon;
Ihab Awad476cc832014-11-03 09:47:51 -0800534 mHighlightColor = highlightColor;
Ihab Awad807fe0a2014-07-09 12:30:52 -0700535 mLabel = label;
536 mShortDescription = shortDescription;
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700537 mSupportedUriSchemes = Collections.unmodifiableList(supportedUriSchemes);
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700538 mExtras = extras;
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800539 mSupportedAudioRoutes = supportedAudioRoutes;
Santos Cordon91371dc2015-05-08 13:52:09 -0700540 mIsEnabled = isEnabled;
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700541 mGroupId = groupId;
Ihab Awad807fe0a2014-07-09 12:30:52 -0700542 }
543
Andrew Lee3085a6c2014-09-04 10:59:13 -0700544 public static Builder builder(
545 PhoneAccountHandle accountHandle,
546 CharSequence label) {
547 return new Builder(accountHandle, label);
548 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700549
Ihab Awad807fe0a2014-07-09 12:30:52 -0700550 /**
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700551 * Returns a builder initialized with the current {@link PhoneAccount} instance.
552 *
553 * @return The builder.
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700554 */
555 public Builder toBuilder() { return new Builder(this); }
556
557 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700558 * The unique identifier of this {@code PhoneAccount}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700559 *
Evan Charlton6eb262c2014-07-19 18:18:19 -0700560 * @return A {@code PhoneAccountHandle}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700561 */
Evan Charlton8c8a0622014-07-20 12:31:00 -0700562 public PhoneAccountHandle getAccountHandle() {
563 return mAccountHandle;
Ihab Awad807fe0a2014-07-09 12:30:52 -0700564 }
565
566 /**
Andrew Lee3085a6c2014-09-04 10:59:13 -0700567 * The address (e.g., a phone number) associated with this {@code PhoneAccount}. This
Evan Charlton8c8a0622014-07-20 12:31:00 -0700568 * represents the destination from which outgoing calls using this {@code PhoneAccount}
Evan Charlton6eb262c2014-07-19 18:18:19 -0700569 * will appear to come, if applicable, and the destination to which incoming calls using this
Evan Charlton8c8a0622014-07-20 12:31:00 -0700570 * {@code PhoneAccount} may be addressed.
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700571 *
Andrew Lee3085a6c2014-09-04 10:59:13 -0700572 * @return A address expressed as a {@code Uri}, for example, a phone number.
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700573 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700574 public Uri getAddress() {
575 return mAddress;
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700576 }
577
578 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700579 * The raw callback number used for this {@code PhoneAccount}, as distinct from
Andrew Lee3085a6c2014-09-04 10:59:13 -0700580 * {@link #getAddress()}. For the majority of {@code PhoneAccount}s this should be registered
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700581 * as {@code null}. It is used by the system for SIM-based {@code PhoneAccount} registration
Junda Liuf52ac902014-09-25 17:36:48 +0000582 * where {@link android.telephony.TelephonyManager#setLine1NumberForDisplay(String, String)}
583 * has been used to alter the callback number.
584 * <p>
Evan Charlton222db5252014-07-17 16:59:18 -0700585 *
586 * @return The subscription number, suitable for display to the user.
587 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700588 public Uri getSubscriptionAddress() {
589 return mSubscriptionAddress;
Evan Charlton222db5252014-07-17 16:59:18 -0700590 }
591
592 /**
Evan Charlton8c8a0622014-07-20 12:31:00 -0700593 * The capabilities of this {@code PhoneAccount}.
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700594 *
Evan Charlton8c8a0622014-07-20 12:31:00 -0700595 * @return A bit field of flags describing this {@code PhoneAccount}'s capabilities.
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700596 */
597 public int getCapabilities() {
598 return mCapabilities;
599 }
600
601 /**
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700602 * Determines if this {@code PhoneAccount} has a capabilities specified by the passed in
603 * bit mask.
604 *
605 * @param capability The capabilities to check.
Santos Cordon895d4b82015-06-25 16:41:48 -0700606 * @return {@code true} if the phone account has the capability.
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700607 */
608 public boolean hasCapabilities(int capability) {
609 return (mCapabilities & capability) == capability;
610 }
611
612 /**
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800613 * Determines if this {@code PhoneAccount} has routes specified by the passed in bit mask.
614 *
615 * @param route The routes to check.
616 * @return {@code true} if the phone account has the routes.
617 * @hide
618 */
619 public boolean hasAudioRoutes(int routes) {
620 return (mSupportedAudioRoutes & routes) == routes;
621 }
622
623 /**
Santos Cordon146a3e32014-07-21 00:00:44 -0700624 * A short label describing a {@code PhoneAccount}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700625 *
Evan Charlton8c8a0622014-07-20 12:31:00 -0700626 * @return A label for this {@code PhoneAccount}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700627 */
Santos Cordon146a3e32014-07-21 00:00:44 -0700628 public CharSequence getLabel() {
Ihab Awad807fe0a2014-07-09 12:30:52 -0700629 return mLabel;
630 }
631
632 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700633 * A short paragraph describing this {@code PhoneAccount}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700634 *
Evan Charlton8c8a0622014-07-20 12:31:00 -0700635 * @return A description for this {@code PhoneAccount}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700636 */
Santos Cordon146a3e32014-07-21 00:00:44 -0700637 public CharSequence getShortDescription() {
Ihab Awad807fe0a2014-07-09 12:30:52 -0700638 return mShortDescription;
639 }
640
641 /**
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700642 * The URI schemes supported by this {@code PhoneAccount}.
643 *
644 * @return The URI schemes.
645 */
646 public List<String> getSupportedUriSchemes() {
647 return mSupportedUriSchemes;
648 }
649
650 /**
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700651 * The extras associated with this {@code PhoneAccount}.
652 * <p>
653 * A {@link ConnectionService} may provide implementation specific information about the
654 * {@link PhoneAccount} via the extras.
655 *
656 * @return The extras.
657 */
658 public Bundle getExtras() {
659 return mExtras;
660 }
661
662 /**
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800663 * The audio routes supported by this {@code PhoneAccount}.
664 *
665 * @hide
666 */
667 public int getSupportedAudioRoutes() {
668 return mSupportedAudioRoutes;
669 }
670
671 /**
Santos Cordoncad84a22015-05-13 11:17:25 -0700672 * The icon to represent this {@code PhoneAccount}.
673 *
674 * @return The icon.
675 */
676 public Icon getIcon() {
677 return mIcon;
678 }
679
680 /**
Santos Cordon895d4b82015-06-25 16:41:48 -0700681 * Indicates whether the user has enabled this {@code PhoneAccount} or not. This value is only
682 * populated for {@code PhoneAccount}s returned by {@link TelecomManager#getPhoneAccount}.
Santos Cordon91371dc2015-05-08 13:52:09 -0700683 *
Santos Cordon895d4b82015-06-25 16:41:48 -0700684 * @return {@code true} if the account is enabled by the user, {@code false} otherwise.
Santos Cordon91371dc2015-05-08 13:52:09 -0700685 */
686 public boolean isEnabled() {
687 return mIsEnabled;
688 }
689
690 /**
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700691 * A non-empty {@link String} representing the group that A {@link PhoneAccount} is in or an
692 * empty {@link String} if the {@link PhoneAccount} is not in a group. If this
693 * {@link PhoneAccount} is in a group, this new {@link PhoneAccount} will replace a registered
694 * {@link PhoneAccount} that is in the same group. When the {@link PhoneAccount} is replaced,
695 * its user defined defaults and enabled status will also pass to this new {@link PhoneAccount}.
696 * Only {@link PhoneAccount}s that share the same {@link ConnectionService} can be replaced.
697 *
698 * @return A non-empty String Id if this {@link PhoneAccount} belongs to a group.
699 * @hide
700 */
701 public String getGroupId() {
702 return mGroupId;
703 }
704
705 /**
Andrew Lee3085a6c2014-09-04 10:59:13 -0700706 * Determines if the {@link PhoneAccount} supports calls to/from addresses with a specified URI
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700707 * scheme.
708 *
709 * @param uriScheme The URI scheme to check.
Santos Cordon895d4b82015-06-25 16:41:48 -0700710 * @return {@code true} if the {@code PhoneAccount} supports calls to/from addresses with the
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700711 * specified URI scheme.
712 */
713 public boolean supportsUriScheme(String uriScheme) {
714 if (mSupportedUriSchemes == null || uriScheme == null) {
715 return false;
716 }
717
718 for (String scheme : mSupportedUriSchemes) {
719 if (scheme != null && scheme.equals(uriScheme)) {
720 return true;
721 }
722 }
723 return false;
724 }
725
726 /**
Ihab Awad476cc832014-11-03 09:47:51 -0800727 * A highlight color to use in displaying information about this {@code PhoneAccount}.
728 *
729 * @return A hexadecimal color value.
730 */
731 public int getHighlightColor() {
732 return mHighlightColor;
733 }
734
Santos Cordon91371dc2015-05-08 13:52:09 -0700735 /**
736 * Sets the enabled state of the phone account.
737 * @hide
738 */
739 public void setIsEnabled(boolean isEnabled) {
740 mIsEnabled = isEnabled;
741 }
742
Tyler Gunnf5035432017-01-09 09:43:12 -0800743 /**
744 * @return {@code true} if the {@link PhoneAccount} is self-managed, {@code false} otherwise.
745 * @hide
746 */
747 public boolean isSelfManaged() {
748 return (mCapabilities & CAPABILITY_SELF_MANAGED) == CAPABILITY_SELF_MANAGED;
749 }
750
Ihab Awad807fe0a2014-07-09 12:30:52 -0700751 //
752 // Parcelable implementation
753 //
754
755 @Override
756 public int describeContents() {
757 return 0;
758 }
759
760 @Override
761 public void writeToParcel(Parcel out, int flags) {
Ihab Awad476cc832014-11-03 09:47:51 -0800762 if (mAccountHandle == null) {
763 out.writeInt(0);
764 } else {
765 out.writeInt(1);
766 mAccountHandle.writeToParcel(out, flags);
767 }
768 if (mAddress == null) {
769 out.writeInt(0);
770 } else {
771 out.writeInt(1);
772 mAddress.writeToParcel(out, flags);
773 }
774 if (mSubscriptionAddress == null) {
775 out.writeInt(0);
776 } else {
777 out.writeInt(1);
778 mSubscriptionAddress.writeToParcel(out, flags);
779 }
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700780 out.writeInt(mCapabilities);
Ihab Awad476cc832014-11-03 09:47:51 -0800781 out.writeInt(mHighlightColor);
Santos Cordon146a3e32014-07-21 00:00:44 -0700782 out.writeCharSequence(mLabel);
783 out.writeCharSequence(mShortDescription);
Ihab Awad476cc832014-11-03 09:47:51 -0800784 out.writeStringList(mSupportedUriSchemes);
Santos Cordon91371dc2015-05-08 13:52:09 -0700785
Santos Cordoncad84a22015-05-13 11:17:25 -0700786 if (mIcon == null) {
787 out.writeInt(0);
788 } else {
789 out.writeInt(1);
790 mIcon.writeToParcel(out, flags);
791 }
Santos Cordon91371dc2015-05-08 13:52:09 -0700792 out.writeByte((byte) (mIsEnabled ? 1 : 0));
Tyler Gunnef829ec2015-10-08 09:46:23 -0700793 out.writeBundle(mExtras);
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700794 out.writeString(mGroupId);
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800795 out.writeInt(mSupportedAudioRoutes);
Ihab Awad807fe0a2014-07-09 12:30:52 -0700796 }
797
Evan Charlton8c8a0622014-07-20 12:31:00 -0700798 public static final Creator<PhoneAccount> CREATOR
799 = new Creator<PhoneAccount>() {
Ihab Awad807fe0a2014-07-09 12:30:52 -0700800 @Override
Evan Charlton8c8a0622014-07-20 12:31:00 -0700801 public PhoneAccount createFromParcel(Parcel in) {
802 return new PhoneAccount(in);
Ihab Awad807fe0a2014-07-09 12:30:52 -0700803 }
804
805 @Override
Evan Charlton8c8a0622014-07-20 12:31:00 -0700806 public PhoneAccount[] newArray(int size) {
807 return new PhoneAccount[size];
Ihab Awad807fe0a2014-07-09 12:30:52 -0700808 }
809 };
810
Evan Charlton8c8a0622014-07-20 12:31:00 -0700811 private PhoneAccount(Parcel in) {
Ihab Awad476cc832014-11-03 09:47:51 -0800812 if (in.readInt() > 0) {
813 mAccountHandle = PhoneAccountHandle.CREATOR.createFromParcel(in);
814 } else {
815 mAccountHandle = null;
816 }
817 if (in.readInt() > 0) {
818 mAddress = Uri.CREATOR.createFromParcel(in);
819 } else {
820 mAddress = null;
821 }
822 if (in.readInt() > 0) {
823 mSubscriptionAddress = Uri.CREATOR.createFromParcel(in);
824 } else {
825 mSubscriptionAddress = null;
826 }
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700827 mCapabilities = in.readInt();
Ihab Awad476cc832014-11-03 09:47:51 -0800828 mHighlightColor = in.readInt();
Santos Cordon146a3e32014-07-21 00:00:44 -0700829 mLabel = in.readCharSequence();
830 mShortDescription = in.readCharSequence();
Ihab Awad476cc832014-11-03 09:47:51 -0800831 mSupportedUriSchemes = Collections.unmodifiableList(in.createStringArrayList());
Santos Cordoncad84a22015-05-13 11:17:25 -0700832 if (in.readInt() > 0) {
833 mIcon = Icon.CREATOR.createFromParcel(in);
834 } else {
835 mIcon = null;
836 }
Santos Cordon91371dc2015-05-08 13:52:09 -0700837 mIsEnabled = in.readByte() == 1;
Tyler Gunnef829ec2015-10-08 09:46:23 -0700838 mExtras = in.readBundle();
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700839 mGroupId = in.readString();
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800840 mSupportedAudioRoutes = in.readInt();
Ihab Awad807fe0a2014-07-09 12:30:52 -0700841 }
Tyler Gunn76c01a52014-09-30 14:47:51 -0700842
843 @Override
844 public String toString() {
Santos Cordon91371dc2015-05-08 13:52:09 -0700845 StringBuilder sb = new StringBuilder().append("[[")
846 .append(mIsEnabled ? 'X' : ' ')
847 .append("] PhoneAccount: ")
Tyler Gunn76c01a52014-09-30 14:47:51 -0700848 .append(mAccountHandle)
849 .append(" Capabilities: ")
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800850 .append(capabilitiesToString())
851 .append(" Audio Routes: ")
852 .append(audioRoutesToString())
Tyler Gunn76c01a52014-09-30 14:47:51 -0700853 .append(" Schemes: ");
854 for (String scheme : mSupportedUriSchemes) {
855 sb.append(scheme)
856 .append(" ");
857 }
Tyler Gunnef829ec2015-10-08 09:46:23 -0700858 sb.append(" Extras: ");
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700859 sb.append(mExtras);
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700860 sb.append(" GroupId: ");
861 sb.append(Log.pii(mGroupId));
Tyler Gunn76c01a52014-09-30 14:47:51 -0700862 sb.append("]");
863 return sb.toString();
864 }
Tyler Gunn3e122f72016-01-11 19:25:00 -0800865
866 /**
867 * Generates a string representation of a capabilities bitmask.
868 *
869 * @param capabilities The capabilities bitmask.
870 * @return String representation of the capabilities bitmask.
871 */
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800872 private String capabilitiesToString() {
Tyler Gunn3e122f72016-01-11 19:25:00 -0800873 StringBuilder sb = new StringBuilder();
Tyler Gunnf5035432017-01-09 09:43:12 -0800874 if (hasCapabilities(CAPABILITY_SELF_MANAGED)) {
875 sb.append("SelfManaged ");
876 }
Tyler Gunn58cbd7a2016-11-11 11:31:28 -0800877 if (hasCapabilities(CAPABILITY_SUPPORTS_VIDEO_CALLING)) {
878 sb.append("SuppVideo ");
879 }
Tyler Gunn3e122f72016-01-11 19:25:00 -0800880 if (hasCapabilities(CAPABILITY_VIDEO_CALLING)) {
881 sb.append("Video ");
882 }
883 if (hasCapabilities(CAPABILITY_VIDEO_CALLING_RELIES_ON_PRESENCE)) {
884 sb.append("Presence ");
885 }
886 if (hasCapabilities(CAPABILITY_CALL_PROVIDER)) {
887 sb.append("CallProvider ");
888 }
889 if (hasCapabilities(CAPABILITY_CALL_SUBJECT)) {
890 sb.append("CallSubject ");
891 }
892 if (hasCapabilities(CAPABILITY_CONNECTION_MANAGER)) {
893 sb.append("ConnectionMgr ");
894 }
895 if (hasCapabilities(CAPABILITY_EMERGENCY_CALLS_ONLY)) {
896 sb.append("EmergOnly ");
897 }
898 if (hasCapabilities(CAPABILITY_MULTI_USER)) {
899 sb.append("MultiUser ");
900 }
901 if (hasCapabilities(CAPABILITY_PLACE_EMERGENCY_CALLS)) {
902 sb.append("PlaceEmerg ");
903 }
Tyler Gunncee9ea62016-03-24 11:45:43 -0700904 if (hasCapabilities(CAPABILITY_EMERGENCY_VIDEO_CALLING)) {
905 sb.append("EmergVideo ");
906 }
Tyler Gunn3e122f72016-01-11 19:25:00 -0800907 if (hasCapabilities(CAPABILITY_SIM_SUBSCRIPTION)) {
908 sb.append("SimSub ");
909 }
910 return sb.toString();
911 }
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800912
913 private String audioRoutesToString() {
914 StringBuilder sb = new StringBuilder();
915
916 if (hasAudioRoutes(CallAudioState.ROUTE_BLUETOOTH)) {
917 sb.append("B");
918 }
919 if (hasAudioRoutes(CallAudioState.ROUTE_EARPIECE)) {
920 sb.append("E");
921 }
922 if (hasAudioRoutes(CallAudioState.ROUTE_SPEAKER)) {
923 sb.append("S");
924 }
925 if (hasAudioRoutes(CallAudioState.ROUTE_WIRED_HEADSET)) {
926 sb.append("W");
927 }
928
929 return sb.toString();
930 }
Ihab Awad807fe0a2014-07-09 12:30:52 -0700931}