blob: ca5448658b457decaf062d57120996afa5379ca7 [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 Gunnf5b29dc2014-09-03 09:09:12 -0700192 * URI scheme for telephone number URIs.
193 */
194 public static final String SCHEME_TEL = "tel";
195
196 /**
197 * URI scheme for voicemail URIs.
198 */
199 public static final String SCHEME_VOICEMAIL = "voicemail";
200
201 /**
202 * URI scheme for SIP URIs.
203 */
204 public static final String SCHEME_SIP = "sip";
205
Nancy Chen3ace54b2014-10-22 17:45:26 -0700206 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800207 * Indicating no icon tint is set.
Santos Cordoncad84a22015-05-13 11:17:25 -0700208 * @hide
Nancy Chen3ace54b2014-10-22 17:45:26 -0700209 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800210 public static final int NO_ICON_TINT = 0;
211
212 /**
213 * Indicating no hightlight color is set.
214 */
215 public static final int NO_HIGHLIGHT_COLOR = 0;
Nancy Chen3ace54b2014-10-22 17:45:26 -0700216
Ihab Awad476cc832014-11-03 09:47:51 -0800217 /**
218 * Indicating no resource ID is set.
219 */
220 public static final int NO_RESOURCE_ID = -1;
221
Evan Charlton8c8a0622014-07-20 12:31:00 -0700222 private final PhoneAccountHandle mAccountHandle;
Andrew Lee3085a6c2014-09-04 10:59:13 -0700223 private final Uri mAddress;
224 private final Uri mSubscriptionAddress;
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700225 private final int mCapabilities;
Ihab Awad476cc832014-11-03 09:47:51 -0800226 private final int mHighlightColor;
Santos Cordon146a3e32014-07-21 00:00:44 -0700227 private final CharSequence mLabel;
228 private final CharSequence mShortDescription;
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700229 private final List<String> mSupportedUriSchemes;
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800230 private final int mSupportedAudioRoutes;
Santos Cordoncad84a22015-05-13 11:17:25 -0700231 private final Icon mIcon;
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700232 private final Bundle mExtras;
Santos Cordon91371dc2015-05-08 13:52:09 -0700233 private boolean mIsEnabled;
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700234 private String mGroupId;
Ihab Awad807fe0a2014-07-09 12:30:52 -0700235
Santos Cordon32c65a52014-10-27 14:57:49 -0700236 /**
237 * Helper class for creating a {@link PhoneAccount}.
238 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700239 public static class Builder {
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800240
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700241 private PhoneAccountHandle mAccountHandle;
Andrew Lee3085a6c2014-09-04 10:59:13 -0700242 private Uri mAddress;
243 private Uri mSubscriptionAddress;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700244 private int mCapabilities;
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800245 private int mSupportedAudioRoutes = CallAudioState.ROUTE_ALL;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800246 private int mHighlightColor = NO_HIGHLIGHT_COLOR;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700247 private CharSequence mLabel;
248 private CharSequence mShortDescription;
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700249 private List<String> mSupportedUriSchemes = new ArrayList<String>();
Santos Cordoncad84a22015-05-13 11:17:25 -0700250 private Icon mIcon;
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700251 private Bundle mExtras;
Santos Cordon91371dc2015-05-08 13:52:09 -0700252 private boolean mIsEnabled = false;
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700253 private String mGroupId = "";
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700254
Santos Cordon32c65a52014-10-27 14:57:49 -0700255 /**
256 * Creates a builder with the specified {@link PhoneAccountHandle} and label.
257 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700258 public Builder(PhoneAccountHandle accountHandle, CharSequence label) {
259 this.mAccountHandle = accountHandle;
260 this.mLabel = label;
261 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700262
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700263 /**
264 * Creates an instance of the {@link PhoneAccount.Builder} from an existing
265 * {@link PhoneAccount}.
266 *
267 * @param phoneAccount The {@link PhoneAccount} used to initialize the builder.
268 */
269 public Builder(PhoneAccount phoneAccount) {
270 mAccountHandle = phoneAccount.getAccountHandle();
271 mAddress = phoneAccount.getAddress();
272 mSubscriptionAddress = phoneAccount.getSubscriptionAddress();
273 mCapabilities = phoneAccount.getCapabilities();
Ihab Awad476cc832014-11-03 09:47:51 -0800274 mHighlightColor = phoneAccount.getHighlightColor();
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700275 mLabel = phoneAccount.getLabel();
276 mShortDescription = phoneAccount.getShortDescription();
277 mSupportedUriSchemes.addAll(phoneAccount.getSupportedUriSchemes());
Santos Cordoncad84a22015-05-13 11:17:25 -0700278 mIcon = phoneAccount.getIcon();
Santos Cordon91371dc2015-05-08 13:52:09 -0700279 mIsEnabled = phoneAccount.isEnabled();
Tyler Gunnd426b202015-10-13 13:33:53 -0700280 mExtras = phoneAccount.getExtras();
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700281 mGroupId = phoneAccount.getGroupId();
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800282 mSupportedAudioRoutes = phoneAccount.getSupportedAudioRoutes();
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700283 }
284
Santos Cordon32c65a52014-10-27 14:57:49 -0700285 /**
286 * Sets the address. See {@link PhoneAccount#getAddress}.
287 *
288 * @param value The address of the phone account.
289 * @return The builder.
290 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700291 public Builder setAddress(Uri value) {
292 this.mAddress = value;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700293 return this;
294 }
295
Santos Cordon32c65a52014-10-27 14:57:49 -0700296 /**
297 * Sets the subscription address. See {@link PhoneAccount#getSubscriptionAddress}.
298 *
299 * @param value The subscription address.
300 * @return The builder.
301 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700302 public Builder setSubscriptionAddress(Uri value) {
303 this.mSubscriptionAddress = value;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700304 return this;
305 }
306
Santos Cordon32c65a52014-10-27 14:57:49 -0700307 /**
308 * Sets the capabilities. See {@link PhoneAccount#getCapabilities}.
309 *
310 * @param value The capabilities to set.
311 * @return The builder.
312 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700313 public Builder setCapabilities(int value) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700314 this.mCapabilities = value;
315 return this;
316 }
317
Santos Cordon32c65a52014-10-27 14:57:49 -0700318 /**
Santos Cordoncad84a22015-05-13 11:17:25 -0700319 * Sets the icon. See {@link PhoneAccount#getIcon}.
Santos Cordon32c65a52014-10-27 14:57:49 -0700320 *
Santos Cordoncad84a22015-05-13 11:17:25 -0700321 * @param icon The icon to set.
Santos Cordon32c65a52014-10-27 14:57:49 -0700322 */
Santos Cordoncad84a22015-05-13 11:17:25 -0700323 public Builder setIcon(Icon icon) {
324 mIcon = icon;
Ihab Awad074bf102014-10-24 11:42:32 -0700325 return this;
326 }
327
328 /**
Ihab Awad476cc832014-11-03 09:47:51 -0800329 * Sets the highlight color. See {@link PhoneAccount#getHighlightColor}.
Ihab Awad074bf102014-10-24 11:42:32 -0700330 *
Ihab Awad476cc832014-11-03 09:47:51 -0800331 * @param value The highlight color.
Ihab Awad074bf102014-10-24 11:42:32 -0700332 * @return The builder.
333 */
Ihab Awad476cc832014-11-03 09:47:51 -0800334 public Builder setHighlightColor(int value) {
335 this.mHighlightColor = value;
Nancy Chen3ace54b2014-10-22 17:45:26 -0700336 return this;
337 }
338
Santos Cordon32c65a52014-10-27 14:57:49 -0700339 /**
340 * Sets the short description. See {@link PhoneAccount#getShortDescription}.
341 *
342 * @param value The short description.
343 * @return The builder.
344 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700345 public Builder setShortDescription(CharSequence value) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700346 this.mShortDescription = value;
347 return this;
348 }
349
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700350 /**
351 * Specifies an additional URI scheme supported by the {@link PhoneAccount}.
352 *
353 * @param uriScheme The URI scheme.
Santos Cordon32c65a52014-10-27 14:57:49 -0700354 * @return The builder.
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700355 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700356 public Builder addSupportedUriScheme(String uriScheme) {
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700357 if (!TextUtils.isEmpty(uriScheme) && !mSupportedUriSchemes.contains(uriScheme)) {
358 this.mSupportedUriSchemes.add(uriScheme);
359 }
360 return this;
361 }
362
363 /**
Andrew Lee3085a6c2014-09-04 10:59:13 -0700364 * Specifies the URI schemes supported by the {@link PhoneAccount}.
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700365 *
366 * @param uriSchemes The URI schemes.
Santos Cordon32c65a52014-10-27 14:57:49 -0700367 * @return The builder.
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700368 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700369 public Builder setSupportedUriSchemes(List<String> uriSchemes) {
370 mSupportedUriSchemes.clear();
371
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700372 if (uriSchemes != null && !uriSchemes.isEmpty()) {
373 for (String uriScheme : uriSchemes) {
Andrew Lee3085a6c2014-09-04 10:59:13 -0700374 addSupportedUriScheme(uriScheme);
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700375 }
376 }
377 return this;
378 }
379
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700380 /**
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700381 * Specifies the extras associated with the {@link PhoneAccount}.
382 * <p>
383 * {@code PhoneAccount}s only support extra values of type: {@link String}, {@link Integer},
384 * and {@link Boolean}. Extras which are not of these types are ignored.
385 *
386 * @param extras
387 * @return
388 */
389 public Builder setExtras(Bundle extras) {
390 mExtras = extras;
391 return this;
392 }
393
394 /**
Santos Cordon91371dc2015-05-08 13:52:09 -0700395 * Sets the enabled state of the phone account.
396 *
397 * @param isEnabled The enabled state.
398 * @return The builder.
399 * @hide
400 */
401 public Builder setIsEnabled(boolean isEnabled) {
402 mIsEnabled = isEnabled;
403 return this;
404 }
405
406 /**
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700407 * Sets the group Id of the {@link PhoneAccount}. When a new {@link PhoneAccount} is
408 * registered to Telecom, it will replace another {@link PhoneAccount} that is already
409 * registered in Telecom and take on the current user defaults and enabled status. There can
410 * only be one {@link PhoneAccount} with a non-empty group number registered to Telecom at a
411 * time. By default, there is no group Id for a {@link PhoneAccount} (an empty String). Only
412 * grouped {@link PhoneAccount}s with the same {@link ConnectionService} can be replaced.
413 * @param groupId The group Id of the {@link PhoneAccount} that will replace any other
414 * registered {@link PhoneAccount} in Telecom with the same Group Id.
415 * @return The builder
416 * @hide
417 */
418 public Builder setGroupId(String groupId) {
419 if (groupId != null) {
420 mGroupId = groupId;
421 } else {
422 mGroupId = "";
423 }
424 return this;
425 }
426
427 /**
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800428 * Sets the audio routes supported by this {@link PhoneAccount}.
429 *
430 * @param routes bit mask of available routes.
431 * @return The builder.
432 * @hide
433 */
434 public Builder setSupportedAudioRoutes(int routes) {
435 mSupportedAudioRoutes = routes;
436 return this;
437 }
438
439 /**
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700440 * Creates an instance of a {@link PhoneAccount} based on the current builder settings.
441 *
442 * @return The {@link PhoneAccount}.
443 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700444 public PhoneAccount build() {
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700445 // If no supported URI schemes were defined, assume "tel" is supported.
446 if (mSupportedUriSchemes.isEmpty()) {
Andrew Lee3085a6c2014-09-04 10:59:13 -0700447 addSupportedUriScheme(SCHEME_TEL);
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700448 }
449
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700450 return new PhoneAccount(
451 mAccountHandle,
Andrew Lee3085a6c2014-09-04 10:59:13 -0700452 mAddress,
453 mSubscriptionAddress,
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700454 mCapabilities,
Santos Cordoncad84a22015-05-13 11:17:25 -0700455 mIcon,
Ihab Awad476cc832014-11-03 09:47:51 -0800456 mHighlightColor,
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700457 mLabel,
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700458 mShortDescription,
Santos Cordon91371dc2015-05-08 13:52:09 -0700459 mSupportedUriSchemes,
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700460 mExtras,
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800461 mSupportedAudioRoutes,
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700462 mIsEnabled,
463 mGroupId);
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700464 }
465 }
466
467 private PhoneAccount(
Evan Charlton6eb262c2014-07-19 18:18:19 -0700468 PhoneAccountHandle account,
Andrew Lee3085a6c2014-09-04 10:59:13 -0700469 Uri address,
470 Uri subscriptionAddress,
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700471 int capabilities,
Santos Cordoncad84a22015-05-13 11:17:25 -0700472 Icon icon,
Ihab Awad476cc832014-11-03 09:47:51 -0800473 int highlightColor,
Santos Cordon146a3e32014-07-21 00:00:44 -0700474 CharSequence label,
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700475 CharSequence shortDescription,
Santos Cordon91371dc2015-05-08 13:52:09 -0700476 List<String> supportedUriSchemes,
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700477 Bundle extras,
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800478 int supportedAudioRoutes,
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700479 boolean isEnabled,
480 String groupId) {
Evan Charlton8c8a0622014-07-20 12:31:00 -0700481 mAccountHandle = account;
Andrew Lee3085a6c2014-09-04 10:59:13 -0700482 mAddress = address;
483 mSubscriptionAddress = subscriptionAddress;
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700484 mCapabilities = capabilities;
Santos Cordoncad84a22015-05-13 11:17:25 -0700485 mIcon = icon;
Ihab Awad476cc832014-11-03 09:47:51 -0800486 mHighlightColor = highlightColor;
Ihab Awad807fe0a2014-07-09 12:30:52 -0700487 mLabel = label;
488 mShortDescription = shortDescription;
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700489 mSupportedUriSchemes = Collections.unmodifiableList(supportedUriSchemes);
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700490 mExtras = extras;
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800491 mSupportedAudioRoutes = supportedAudioRoutes;
Santos Cordon91371dc2015-05-08 13:52:09 -0700492 mIsEnabled = isEnabled;
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700493 mGroupId = groupId;
Ihab Awad807fe0a2014-07-09 12:30:52 -0700494 }
495
Andrew Lee3085a6c2014-09-04 10:59:13 -0700496 public static Builder builder(
497 PhoneAccountHandle accountHandle,
498 CharSequence label) {
499 return new Builder(accountHandle, label);
500 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700501
Ihab Awad807fe0a2014-07-09 12:30:52 -0700502 /**
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700503 * Returns a builder initialized with the current {@link PhoneAccount} instance.
504 *
505 * @return The builder.
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700506 */
507 public Builder toBuilder() { return new Builder(this); }
508
509 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700510 * The unique identifier of this {@code PhoneAccount}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700511 *
Evan Charlton6eb262c2014-07-19 18:18:19 -0700512 * @return A {@code PhoneAccountHandle}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700513 */
Evan Charlton8c8a0622014-07-20 12:31:00 -0700514 public PhoneAccountHandle getAccountHandle() {
515 return mAccountHandle;
Ihab Awad807fe0a2014-07-09 12:30:52 -0700516 }
517
518 /**
Andrew Lee3085a6c2014-09-04 10:59:13 -0700519 * The address (e.g., a phone number) associated with this {@code PhoneAccount}. This
Evan Charlton8c8a0622014-07-20 12:31:00 -0700520 * represents the destination from which outgoing calls using this {@code PhoneAccount}
Evan Charlton6eb262c2014-07-19 18:18:19 -0700521 * will appear to come, if applicable, and the destination to which incoming calls using this
Evan Charlton8c8a0622014-07-20 12:31:00 -0700522 * {@code PhoneAccount} may be addressed.
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700523 *
Andrew Lee3085a6c2014-09-04 10:59:13 -0700524 * @return A address expressed as a {@code Uri}, for example, a phone number.
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700525 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700526 public Uri getAddress() {
527 return mAddress;
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700528 }
529
530 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700531 * The raw callback number used for this {@code PhoneAccount}, as distinct from
Andrew Lee3085a6c2014-09-04 10:59:13 -0700532 * {@link #getAddress()}. For the majority of {@code PhoneAccount}s this should be registered
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700533 * as {@code null}. It is used by the system for SIM-based {@code PhoneAccount} registration
Junda Liuf52ac902014-09-25 17:36:48 +0000534 * where {@link android.telephony.TelephonyManager#setLine1NumberForDisplay(String, String)}
535 * has been used to alter the callback number.
536 * <p>
Evan Charlton222db5252014-07-17 16:59:18 -0700537 *
538 * @return The subscription number, suitable for display to the user.
539 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700540 public Uri getSubscriptionAddress() {
541 return mSubscriptionAddress;
Evan Charlton222db5252014-07-17 16:59:18 -0700542 }
543
544 /**
Evan Charlton8c8a0622014-07-20 12:31:00 -0700545 * The capabilities of this {@code PhoneAccount}.
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700546 *
Evan Charlton8c8a0622014-07-20 12:31:00 -0700547 * @return A bit field of flags describing this {@code PhoneAccount}'s capabilities.
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700548 */
549 public int getCapabilities() {
550 return mCapabilities;
551 }
552
553 /**
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700554 * Determines if this {@code PhoneAccount} has a capabilities specified by the passed in
555 * bit mask.
556 *
557 * @param capability The capabilities to check.
Santos Cordon895d4b82015-06-25 16:41:48 -0700558 * @return {@code true} if the phone account has the capability.
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700559 */
560 public boolean hasCapabilities(int capability) {
561 return (mCapabilities & capability) == capability;
562 }
563
564 /**
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800565 * Determines if this {@code PhoneAccount} has routes specified by the passed in bit mask.
566 *
567 * @param route The routes to check.
568 * @return {@code true} if the phone account has the routes.
569 * @hide
570 */
571 public boolean hasAudioRoutes(int routes) {
572 return (mSupportedAudioRoutes & routes) == routes;
573 }
574
575 /**
Santos Cordon146a3e32014-07-21 00:00:44 -0700576 * A short label describing a {@code PhoneAccount}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700577 *
Evan Charlton8c8a0622014-07-20 12:31:00 -0700578 * @return A label for this {@code PhoneAccount}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700579 */
Santos Cordon146a3e32014-07-21 00:00:44 -0700580 public CharSequence getLabel() {
Ihab Awad807fe0a2014-07-09 12:30:52 -0700581 return mLabel;
582 }
583
584 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700585 * A short paragraph describing this {@code PhoneAccount}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700586 *
Evan Charlton8c8a0622014-07-20 12:31:00 -0700587 * @return A description for this {@code PhoneAccount}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700588 */
Santos Cordon146a3e32014-07-21 00:00:44 -0700589 public CharSequence getShortDescription() {
Ihab Awad807fe0a2014-07-09 12:30:52 -0700590 return mShortDescription;
591 }
592
593 /**
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700594 * The URI schemes supported by this {@code PhoneAccount}.
595 *
596 * @return The URI schemes.
597 */
598 public List<String> getSupportedUriSchemes() {
599 return mSupportedUriSchemes;
600 }
601
602 /**
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700603 * The extras associated with this {@code PhoneAccount}.
604 * <p>
605 * A {@link ConnectionService} may provide implementation specific information about the
606 * {@link PhoneAccount} via the extras.
607 *
608 * @return The extras.
609 */
610 public Bundle getExtras() {
611 return mExtras;
612 }
613
614 /**
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800615 * The audio routes supported by this {@code PhoneAccount}.
616 *
617 * @hide
618 */
619 public int getSupportedAudioRoutes() {
620 return mSupportedAudioRoutes;
621 }
622
623 /**
Santos Cordoncad84a22015-05-13 11:17:25 -0700624 * The icon to represent this {@code PhoneAccount}.
625 *
626 * @return The icon.
627 */
628 public Icon getIcon() {
629 return mIcon;
630 }
631
632 /**
Santos Cordon895d4b82015-06-25 16:41:48 -0700633 * Indicates whether the user has enabled this {@code PhoneAccount} or not. This value is only
634 * populated for {@code PhoneAccount}s returned by {@link TelecomManager#getPhoneAccount}.
Santos Cordon91371dc2015-05-08 13:52:09 -0700635 *
Santos Cordon895d4b82015-06-25 16:41:48 -0700636 * @return {@code true} if the account is enabled by the user, {@code false} otherwise.
Santos Cordon91371dc2015-05-08 13:52:09 -0700637 */
638 public boolean isEnabled() {
639 return mIsEnabled;
640 }
641
642 /**
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700643 * A non-empty {@link String} representing the group that A {@link PhoneAccount} is in or an
644 * empty {@link String} if the {@link PhoneAccount} is not in a group. If this
645 * {@link PhoneAccount} is in a group, this new {@link PhoneAccount} will replace a registered
646 * {@link PhoneAccount} that is in the same group. When the {@link PhoneAccount} is replaced,
647 * its user defined defaults and enabled status will also pass to this new {@link PhoneAccount}.
648 * Only {@link PhoneAccount}s that share the same {@link ConnectionService} can be replaced.
649 *
650 * @return A non-empty String Id if this {@link PhoneAccount} belongs to a group.
651 * @hide
652 */
653 public String getGroupId() {
654 return mGroupId;
655 }
656
657 /**
Andrew Lee3085a6c2014-09-04 10:59:13 -0700658 * Determines if the {@link PhoneAccount} supports calls to/from addresses with a specified URI
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700659 * scheme.
660 *
661 * @param uriScheme The URI scheme to check.
Santos Cordon895d4b82015-06-25 16:41:48 -0700662 * @return {@code true} if the {@code PhoneAccount} supports calls to/from addresses with the
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700663 * specified URI scheme.
664 */
665 public boolean supportsUriScheme(String uriScheme) {
666 if (mSupportedUriSchemes == null || uriScheme == null) {
667 return false;
668 }
669
670 for (String scheme : mSupportedUriSchemes) {
671 if (scheme != null && scheme.equals(uriScheme)) {
672 return true;
673 }
674 }
675 return false;
676 }
677
678 /**
Ihab Awad476cc832014-11-03 09:47:51 -0800679 * A highlight color to use in displaying information about this {@code PhoneAccount}.
680 *
681 * @return A hexadecimal color value.
682 */
683 public int getHighlightColor() {
684 return mHighlightColor;
685 }
686
Santos Cordon91371dc2015-05-08 13:52:09 -0700687 /**
688 * Sets the enabled state of the phone account.
689 * @hide
690 */
691 public void setIsEnabled(boolean isEnabled) {
692 mIsEnabled = isEnabled;
693 }
694
Ihab Awad807fe0a2014-07-09 12:30:52 -0700695 //
696 // Parcelable implementation
697 //
698
699 @Override
700 public int describeContents() {
701 return 0;
702 }
703
704 @Override
705 public void writeToParcel(Parcel out, int flags) {
Ihab Awad476cc832014-11-03 09:47:51 -0800706 if (mAccountHandle == null) {
707 out.writeInt(0);
708 } else {
709 out.writeInt(1);
710 mAccountHandle.writeToParcel(out, flags);
711 }
712 if (mAddress == null) {
713 out.writeInt(0);
714 } else {
715 out.writeInt(1);
716 mAddress.writeToParcel(out, flags);
717 }
718 if (mSubscriptionAddress == null) {
719 out.writeInt(0);
720 } else {
721 out.writeInt(1);
722 mSubscriptionAddress.writeToParcel(out, flags);
723 }
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700724 out.writeInt(mCapabilities);
Ihab Awad476cc832014-11-03 09:47:51 -0800725 out.writeInt(mHighlightColor);
Santos Cordon146a3e32014-07-21 00:00:44 -0700726 out.writeCharSequence(mLabel);
727 out.writeCharSequence(mShortDescription);
Ihab Awad476cc832014-11-03 09:47:51 -0800728 out.writeStringList(mSupportedUriSchemes);
Santos Cordon91371dc2015-05-08 13:52:09 -0700729
Santos Cordoncad84a22015-05-13 11:17:25 -0700730 if (mIcon == null) {
731 out.writeInt(0);
732 } else {
733 out.writeInt(1);
734 mIcon.writeToParcel(out, flags);
735 }
Santos Cordon91371dc2015-05-08 13:52:09 -0700736 out.writeByte((byte) (mIsEnabled ? 1 : 0));
Tyler Gunnef829ec2015-10-08 09:46:23 -0700737 out.writeBundle(mExtras);
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700738 out.writeString(mGroupId);
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800739 out.writeInt(mSupportedAudioRoutes);
Ihab Awad807fe0a2014-07-09 12:30:52 -0700740 }
741
Evan Charlton8c8a0622014-07-20 12:31:00 -0700742 public static final Creator<PhoneAccount> CREATOR
743 = new Creator<PhoneAccount>() {
Ihab Awad807fe0a2014-07-09 12:30:52 -0700744 @Override
Evan Charlton8c8a0622014-07-20 12:31:00 -0700745 public PhoneAccount createFromParcel(Parcel in) {
746 return new PhoneAccount(in);
Ihab Awad807fe0a2014-07-09 12:30:52 -0700747 }
748
749 @Override
Evan Charlton8c8a0622014-07-20 12:31:00 -0700750 public PhoneAccount[] newArray(int size) {
751 return new PhoneAccount[size];
Ihab Awad807fe0a2014-07-09 12:30:52 -0700752 }
753 };
754
Evan Charlton8c8a0622014-07-20 12:31:00 -0700755 private PhoneAccount(Parcel in) {
Ihab Awad476cc832014-11-03 09:47:51 -0800756 if (in.readInt() > 0) {
757 mAccountHandle = PhoneAccountHandle.CREATOR.createFromParcel(in);
758 } else {
759 mAccountHandle = null;
760 }
761 if (in.readInt() > 0) {
762 mAddress = Uri.CREATOR.createFromParcel(in);
763 } else {
764 mAddress = null;
765 }
766 if (in.readInt() > 0) {
767 mSubscriptionAddress = Uri.CREATOR.createFromParcel(in);
768 } else {
769 mSubscriptionAddress = null;
770 }
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700771 mCapabilities = in.readInt();
Ihab Awad476cc832014-11-03 09:47:51 -0800772 mHighlightColor = in.readInt();
Santos Cordon146a3e32014-07-21 00:00:44 -0700773 mLabel = in.readCharSequence();
774 mShortDescription = in.readCharSequence();
Ihab Awad476cc832014-11-03 09:47:51 -0800775 mSupportedUriSchemes = Collections.unmodifiableList(in.createStringArrayList());
Santos Cordoncad84a22015-05-13 11:17:25 -0700776 if (in.readInt() > 0) {
777 mIcon = Icon.CREATOR.createFromParcel(in);
778 } else {
779 mIcon = null;
780 }
Santos Cordon91371dc2015-05-08 13:52:09 -0700781 mIsEnabled = in.readByte() == 1;
Tyler Gunnef829ec2015-10-08 09:46:23 -0700782 mExtras = in.readBundle();
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700783 mGroupId = in.readString();
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800784 mSupportedAudioRoutes = in.readInt();
Ihab Awad807fe0a2014-07-09 12:30:52 -0700785 }
Tyler Gunn76c01a52014-09-30 14:47:51 -0700786
787 @Override
788 public String toString() {
Santos Cordon91371dc2015-05-08 13:52:09 -0700789 StringBuilder sb = new StringBuilder().append("[[")
790 .append(mIsEnabled ? 'X' : ' ')
791 .append("] PhoneAccount: ")
Tyler Gunn76c01a52014-09-30 14:47:51 -0700792 .append(mAccountHandle)
793 .append(" Capabilities: ")
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800794 .append(capabilitiesToString())
795 .append(" Audio Routes: ")
796 .append(audioRoutesToString())
Tyler Gunn76c01a52014-09-30 14:47:51 -0700797 .append(" Schemes: ");
798 for (String scheme : mSupportedUriSchemes) {
799 sb.append(scheme)
800 .append(" ");
801 }
Tyler Gunnef829ec2015-10-08 09:46:23 -0700802 sb.append(" Extras: ");
Tyler Gunn25ed2d72015-10-05 14:14:38 -0700803 sb.append(mExtras);
Brad Ebinger7298f3b2016-06-10 17:19:42 -0700804 sb.append(" GroupId: ");
805 sb.append(Log.pii(mGroupId));
Tyler Gunn76c01a52014-09-30 14:47:51 -0700806 sb.append("]");
807 return sb.toString();
808 }
Tyler Gunn3e122f72016-01-11 19:25:00 -0800809
810 /**
811 * Generates a string representation of a capabilities bitmask.
812 *
813 * @param capabilities The capabilities bitmask.
814 * @return String representation of the capabilities bitmask.
815 */
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800816 private String capabilitiesToString() {
Tyler Gunn3e122f72016-01-11 19:25:00 -0800817 StringBuilder sb = new StringBuilder();
Tyler Gunn58cbd7a2016-11-11 11:31:28 -0800818 if (hasCapabilities(CAPABILITY_SUPPORTS_VIDEO_CALLING)) {
819 sb.append("SuppVideo ");
820 }
Tyler Gunn3e122f72016-01-11 19:25:00 -0800821 if (hasCapabilities(CAPABILITY_VIDEO_CALLING)) {
822 sb.append("Video ");
823 }
824 if (hasCapabilities(CAPABILITY_VIDEO_CALLING_RELIES_ON_PRESENCE)) {
825 sb.append("Presence ");
826 }
827 if (hasCapabilities(CAPABILITY_CALL_PROVIDER)) {
828 sb.append("CallProvider ");
829 }
830 if (hasCapabilities(CAPABILITY_CALL_SUBJECT)) {
831 sb.append("CallSubject ");
832 }
833 if (hasCapabilities(CAPABILITY_CONNECTION_MANAGER)) {
834 sb.append("ConnectionMgr ");
835 }
836 if (hasCapabilities(CAPABILITY_EMERGENCY_CALLS_ONLY)) {
837 sb.append("EmergOnly ");
838 }
839 if (hasCapabilities(CAPABILITY_MULTI_USER)) {
840 sb.append("MultiUser ");
841 }
842 if (hasCapabilities(CAPABILITY_PLACE_EMERGENCY_CALLS)) {
843 sb.append("PlaceEmerg ");
844 }
Tyler Gunncee9ea62016-03-24 11:45:43 -0700845 if (hasCapabilities(CAPABILITY_EMERGENCY_VIDEO_CALLING)) {
846 sb.append("EmergVideo ");
847 }
Tyler Gunn3e122f72016-01-11 19:25:00 -0800848 if (hasCapabilities(CAPABILITY_SIM_SUBSCRIPTION)) {
849 sb.append("SimSub ");
850 }
851 return sb.toString();
852 }
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800853
854 private String audioRoutesToString() {
855 StringBuilder sb = new StringBuilder();
856
857 if (hasAudioRoutes(CallAudioState.ROUTE_BLUETOOTH)) {
858 sb.append("B");
859 }
860 if (hasAudioRoutes(CallAudioState.ROUTE_EARPIECE)) {
861 sb.append("E");
862 }
863 if (hasAudioRoutes(CallAudioState.ROUTE_SPEAKER)) {
864 sb.append("S");
865 }
866 if (hasAudioRoutes(CallAudioState.ROUTE_WIRED_HEADSET)) {
867 sb.append("W");
868 }
869
870 return sb.toString();
871 }
Ihab Awad807fe0a2014-07-09 12:30:52 -0700872}