| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 1 | /* |
| 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 Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 17 | package android.telecom; |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 18 | |
| Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 19 | import android.annotation.SystemApi; |
| Santos Cordon | cad84a2 | 2015-05-13 11:17:25 -0700 | [diff] [blame] | 20 | import android.graphics.drawable.Icon; |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 21 | import android.net.Uri; |
| Tyler Gunn | 25ed2d7 | 2015-10-05 14:14:38 -0700 | [diff] [blame] | 22 | import android.os.Bundle; |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 23 | import android.os.Parcel; |
| 24 | import android.os.Parcelable; |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 25 | import android.text.TextUtils; |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 26 | |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 27 | import java.lang.String; |
| 28 | import java.util.ArrayList; |
| 29 | import java.util.Collections; |
| 30 | import java.util.List; |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 31 | |
| 32 | /** |
| Santos Cordon | 32c65a5 | 2014-10-27 14:57:49 -0700 | [diff] [blame] | 33 | * 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 Attwell | ad147f4 | 2014-12-19 11:37:16 -0800 | [diff] [blame] | 35 | * this class and register it with the system using {@link TelecomManager}. |
| Santos Cordon | 32c65a5 | 2014-10-27 14:57:49 -0700 | [diff] [blame] | 36 | * <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 Attwell | ad147f4 | 2014-12-19 11:37:16 -0800 | [diff] [blame] | 39 | * should supply a valid {@link PhoneAccountHandle} that references the connection service |
| Santos Cordon | 32c65a5 | 2014-10-27 14:57:49 -0700 | [diff] [blame] | 40 | * implementation Telecom will use to interact with the app. |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 41 | */ |
| Yorke Lee | 400470f | 2015-05-12 13:31:25 -0700 | [diff] [blame] | 42 | public final class PhoneAccount implements Parcelable { |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 43 | |
| 44 | /** |
| Tyler Gunn | d426b20 | 2015-10-13 13:33:53 -0700 | [diff] [blame] | 45 | * {@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 | /** |
| Tyler Gunn | 8bf7657 | 2017-04-06 15:30:08 -0700 | [diff] [blame^] | 71 | * Boolean {@link PhoneAccount} extras key (see {@link PhoneAccount#getExtras()}) which |
| 72 | * indicates whether this {@link PhoneAccount} is capable of supporting a request to handover a |
| 73 | * connection (see {@link android.telecom.Call#EVENT_REQUEST_HANDOVER}) to this |
| 74 | * {@link PhoneAccount} from a {@link PhoneAccount} specifying |
| 75 | * {@link #EXTRA_SUPPORTS_HANDOVER_FROM}. |
| 76 | * <p> |
| 77 | * A handover request is initiated by the user from the default dialer app to indicate a desire |
| 78 | * to handover a call from one {@link PhoneAccount}/{@link ConnectionService} to another. |
| 79 | * @hide |
| 80 | */ |
| 81 | public static final String EXTRA_SUPPORTS_HANDOVER_TO = |
| 82 | "android.telecom.extra.SUPPORTS_HANDOVER_TO"; |
| 83 | |
| 84 | /** |
| 85 | * Boolean {@link PhoneAccount} extras key (see {@link PhoneAccount#getExtras()}) which |
| 86 | * indicates whether this {@link PhoneAccount} is capable of supporting a request to handover a |
| 87 | * connection from this {@link PhoneAccount} to another {@link PhoneAccount}. |
| 88 | * (see {@link android.telecom.Call#EVENT_REQUEST_HANDOVER}) which specifies |
| 89 | * {@link #EXTRA_SUPPORTS_HANDOVER_TO}. |
| 90 | * <p> |
| 91 | * A handover request is initiated by the user from the default dialer app to indicate a desire |
| 92 | * to handover a call from one {@link PhoneAccount}/{@link ConnectionService} to another. |
| 93 | * @hide |
| 94 | */ |
| 95 | public static final String EXTRA_SUPPORTS_HANDOVER_FROM = |
| 96 | "android.telecom.extra.SUPPORTS_HANDOVER_FROM"; |
| 97 | |
| 98 | /** |
| Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 99 | * Flag indicating that this {@code PhoneAccount} can act as a connection manager for |
| 100 | * other connections. The {@link ConnectionService} associated with this {@code PhoneAccount} |
| 101 | * will be allowed to manage phone calls including using its own proprietary phone-call |
| 102 | * implementation (like VoIP calling) to make calls instead of the telephony stack. |
| 103 | * <p> |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 104 | * When a user opts to place a call using the SIM-based telephony stack, the |
| 105 | * {@link ConnectionService} associated with this {@code PhoneAccount} will be attempted first |
| 106 | * if the user has explicitly selected it to be used as the default connection manager. |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 107 | * <p> |
| 108 | * See {@link #getCapabilities} |
| 109 | */ |
| Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 110 | public static final int CAPABILITY_CONNECTION_MANAGER = 0x1; |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 111 | |
| 112 | /** |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 113 | * Flag indicating that this {@code PhoneAccount} can make phone calls in place of |
| Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 114 | * traditional SIM-based telephony calls. This account will be treated as a distinct method |
| 115 | * for placing calls alongside the traditional SIM-based telephony stack. This flag is |
| Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 116 | * distinct from {@link #CAPABILITY_CONNECTION_MANAGER} in that it is not allowed to manage |
| Santos Cordon | 32c65a5 | 2014-10-27 14:57:49 -0700 | [diff] [blame] | 117 | * or place calls from the built-in telephony stack. |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 118 | * <p> |
| 119 | * See {@link #getCapabilities} |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 120 | * <p> |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 121 | */ |
| 122 | public static final int CAPABILITY_CALL_PROVIDER = 0x2; |
| 123 | |
| Ihab Awad | 7522bbd6 | 2014-07-18 15:53:17 -0700 | [diff] [blame] | 124 | /** |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 125 | * Flag indicating that this {@code PhoneAccount} represents a built-in PSTN SIM |
| Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 126 | * subscription. |
| Ihab Awad | 7522bbd6 | 2014-07-18 15:53:17 -0700 | [diff] [blame] | 127 | * <p> |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 128 | * Only the Android framework can register a {@code PhoneAccount} having this capability. |
| 129 | * <p> |
| 130 | * See {@link #getCapabilities} |
| Ihab Awad | 7522bbd6 | 2014-07-18 15:53:17 -0700 | [diff] [blame] | 131 | */ |
| 132 | public static final int CAPABILITY_SIM_SUBSCRIPTION = 0x4; |
| 133 | |
| Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 134 | /** |
| Tyler Gunn | 58cbd7a | 2016-11-11 11:31:28 -0800 | [diff] [blame] | 135 | * Flag indicating that this {@code PhoneAccount} is currently able to place video calls. |
| 136 | * <p> |
| 137 | * See also {@link #CAPABILITY_SUPPORTS_VIDEO_CALLING} which indicates whether the |
| 138 | * {@code PhoneAccount} supports placing video calls. |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 139 | * <p> |
| 140 | * See {@link #getCapabilities} |
| Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 141 | */ |
| 142 | public static final int CAPABILITY_VIDEO_CALLING = 0x8; |
| 143 | |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 144 | /** |
| Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 145 | * Flag indicating that this {@code PhoneAccount} is capable of placing emergency calls. |
| 146 | * By default all PSTN {@code PhoneAccount}s are capable of placing emergency calls. |
| 147 | * <p> |
| 148 | * See {@link #getCapabilities} |
| 149 | */ |
| 150 | public static final int CAPABILITY_PLACE_EMERGENCY_CALLS = 0x10; |
| 151 | |
| 152 | /** |
| Evan Charlton | 134dd68 | 2014-11-25 14:12:57 -0800 | [diff] [blame] | 153 | * Flag indicating that this {@code PhoneAccount} is capable of being used by all users. This |
| 154 | * should only be used by system apps (and will be ignored for all other apps trying to use it). |
| 155 | * <p> |
| 156 | * See {@link #getCapabilities} |
| 157 | * @hide |
| 158 | */ |
| Brian Attwell | ad147f4 | 2014-12-19 11:37:16 -0800 | [diff] [blame] | 159 | @SystemApi |
| Evan Charlton | 134dd68 | 2014-11-25 14:12:57 -0800 | [diff] [blame] | 160 | public static final int CAPABILITY_MULTI_USER = 0x20; |
| 161 | |
| 162 | /** |
| Tyler Gunn | 65a3d34 | 2015-07-27 16:06:16 -0700 | [diff] [blame] | 163 | * Flag indicating that this {@code PhoneAccount} supports a subject for Calls. This means a |
| 164 | * caller is able to specify a short subject line for an outgoing call. A capable receiving |
| 165 | * device displays the call subject on the incoming call screen. |
| 166 | * <p> |
| 167 | * See {@link #getCapabilities} |
| 168 | */ |
| 169 | public static final int CAPABILITY_CALL_SUBJECT = 0x40; |
| 170 | |
| 171 | /** |
| Bryce Lee | b96d89c | 2015-10-14 16:48:40 -0700 | [diff] [blame] | 172 | * Flag indicating that this {@code PhoneAccount} should only be used for emergency calls. |
| 173 | * <p> |
| 174 | * See {@link #getCapabilities} |
| 175 | * @hide |
| 176 | */ |
| 177 | public static final int CAPABILITY_EMERGENCY_CALLS_ONLY = 0x80; |
| 178 | |
| 179 | /** |
| Tyler Gunn | 9a36575 | 2015-12-09 15:00:18 -0800 | [diff] [blame] | 180 | * Flag indicating that for this {@code PhoneAccount}, the ability to make a video call to a |
| 181 | * number relies on presence. Should only be set if the {@code PhoneAccount} also has |
| 182 | * {@link #CAPABILITY_VIDEO_CALLING}. |
| 183 | * <p> |
| 184 | * When set, the {@link ConnectionService} is responsible for toggling the |
| 185 | * {@link android.provider.ContactsContract.Data#CARRIER_PRESENCE_VT_CAPABLE} bit on the |
| 186 | * {@link android.provider.ContactsContract.Data#CARRIER_PRESENCE} column to indicate whether |
| 187 | * a contact's phone number supports video calling. |
| 188 | * <p> |
| 189 | * See {@link #getCapabilities} |
| 190 | */ |
| 191 | public static final int CAPABILITY_VIDEO_CALLING_RELIES_ON_PRESENCE = 0x100; |
| 192 | |
| 193 | /** |
| Tyler Gunn | cee9ea6 | 2016-03-24 11:45:43 -0700 | [diff] [blame] | 194 | * Flag indicating that for this {@link PhoneAccount}, emergency video calling is allowed. |
| 195 | * <p> |
| 196 | * When set, Telecom will allow emergency video calls to be placed. When not set, Telecom will |
| 197 | * convert all outgoing video calls to emergency numbers to audio-only. |
| 198 | * @hide |
| 199 | */ |
| 200 | public static final int CAPABILITY_EMERGENCY_VIDEO_CALLING = 0x200; |
| 201 | |
| 202 | /** |
| Tyler Gunn | 58cbd7a | 2016-11-11 11:31:28 -0800 | [diff] [blame] | 203 | * Flag indicating that this {@link PhoneAccount} supports video calling. |
| 204 | * This is not an indication that the {@link PhoneAccount} is currently able to make a video |
| 205 | * call, but rather that it has the ability to make video calls (but not necessarily at this |
| 206 | * time). |
| 207 | * <p> |
| 208 | * Whether a {@link PhoneAccount} can make a video call is ultimately controlled by |
| 209 | * {@link #CAPABILITY_VIDEO_CALLING}, which indicates whether the {@link PhoneAccount} is |
| 210 | * currently capable of making a video call. Consider a case where, for example, a |
| 211 | * {@link PhoneAccount} supports making video calls (e.g. |
| 212 | * {@link #CAPABILITY_SUPPORTS_VIDEO_CALLING}), but a current lack of network connectivity |
| 213 | * prevents video calls from being made (e.g. {@link #CAPABILITY_VIDEO_CALLING}). |
| 214 | * <p> |
| 215 | * See {@link #getCapabilities} |
| 216 | */ |
| 217 | public static final int CAPABILITY_SUPPORTS_VIDEO_CALLING = 0x400; |
| 218 | |
| 219 | /** |
| Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 220 | * Flag indicating that this {@link PhoneAccount} is responsible for managing its own |
| 221 | * {@link Connection}s. This type of {@link PhoneAccount} is ideal for use with standalone |
| 222 | * calling apps which do not wish to use the default phone app for {@link Connection} UX, |
| 223 | * but which want to leverage the call and audio routing capabilities of the Telecom framework. |
| 224 | * <p> |
| 225 | * When set, {@link Connection}s created by the self-managed {@link ConnectionService} will not |
| 226 | * be surfaced to implementations of the {@link InCallService} API. Thus it is the |
| 227 | * responsibility of a self-managed {@link ConnectionService} to provide a user interface for |
| 228 | * its {@link Connection}s. |
| 229 | * <p> |
| 230 | * Self-managed {@link Connection}s will, however, be displayed on connected Bluetooth devices. |
| 231 | */ |
| 232 | public static final int CAPABILITY_SELF_MANAGED = 0x800; |
| 233 | |
| 234 | /** |
| Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 235 | * Flag indicating that this {@link PhoneAccount} is capable of making a call with an |
| 236 | * RTT (Real-time text) session. |
| 237 | * When set, Telecom will attempt to open an RTT session on outgoing calls that specify |
| 238 | * that they should be placed with an RTT session , and the in-call app will be displayed |
| 239 | * with text entry fields for RTT. Likewise, the in-call app can request that an RTT |
| 240 | * session be opened during a call if this bit is set. |
| 241 | */ |
| 242 | public static final int CAPABILITY_RTT = 0x1000; |
| 243 | |
| 244 | /* NEXT CAPABILITY: 0x2000 */ |
| 245 | |
| 246 | /** |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 247 | * URI scheme for telephone number URIs. |
| 248 | */ |
| 249 | public static final String SCHEME_TEL = "tel"; |
| 250 | |
| 251 | /** |
| 252 | * URI scheme for voicemail URIs. |
| 253 | */ |
| 254 | public static final String SCHEME_VOICEMAIL = "voicemail"; |
| 255 | |
| 256 | /** |
| 257 | * URI scheme for SIP URIs. |
| 258 | */ |
| 259 | public static final String SCHEME_SIP = "sip"; |
| 260 | |
| Nancy Chen | 3ace54b | 2014-10-22 17:45:26 -0700 | [diff] [blame] | 261 | /** |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 262 | * Indicating no icon tint is set. |
| Santos Cordon | cad84a2 | 2015-05-13 11:17:25 -0700 | [diff] [blame] | 263 | * @hide |
| Nancy Chen | 3ace54b | 2014-10-22 17:45:26 -0700 | [diff] [blame] | 264 | */ |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 265 | public static final int NO_ICON_TINT = 0; |
| 266 | |
| 267 | /** |
| 268 | * Indicating no hightlight color is set. |
| 269 | */ |
| 270 | public static final int NO_HIGHLIGHT_COLOR = 0; |
| Nancy Chen | 3ace54b | 2014-10-22 17:45:26 -0700 | [diff] [blame] | 271 | |
| Ihab Awad | 476cc83 | 2014-11-03 09:47:51 -0800 | [diff] [blame] | 272 | /** |
| 273 | * Indicating no resource ID is set. |
| 274 | */ |
| 275 | public static final int NO_RESOURCE_ID = -1; |
| 276 | |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 277 | private final PhoneAccountHandle mAccountHandle; |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 278 | private final Uri mAddress; |
| 279 | private final Uri mSubscriptionAddress; |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 280 | private final int mCapabilities; |
| Ihab Awad | 476cc83 | 2014-11-03 09:47:51 -0800 | [diff] [blame] | 281 | private final int mHighlightColor; |
| Santos Cordon | 146a3e3 | 2014-07-21 00:00:44 -0700 | [diff] [blame] | 282 | private final CharSequence mLabel; |
| 283 | private final CharSequence mShortDescription; |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 284 | private final List<String> mSupportedUriSchemes; |
| Christine Hallstrom | 2830ce9 | 2016-11-30 16:06:42 -0800 | [diff] [blame] | 285 | private final int mSupportedAudioRoutes; |
| Santos Cordon | cad84a2 | 2015-05-13 11:17:25 -0700 | [diff] [blame] | 286 | private final Icon mIcon; |
| Tyler Gunn | 25ed2d7 | 2015-10-05 14:14:38 -0700 | [diff] [blame] | 287 | private final Bundle mExtras; |
| Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 288 | private boolean mIsEnabled; |
| Brad Ebinger | 7298f3b | 2016-06-10 17:19:42 -0700 | [diff] [blame] | 289 | private String mGroupId; |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 290 | |
| Santos Cordon | 32c65a5 | 2014-10-27 14:57:49 -0700 | [diff] [blame] | 291 | /** |
| 292 | * Helper class for creating a {@link PhoneAccount}. |
| 293 | */ |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 294 | public static class Builder { |
| Christine Hallstrom | 2830ce9 | 2016-11-30 16:06:42 -0800 | [diff] [blame] | 295 | |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 296 | private PhoneAccountHandle mAccountHandle; |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 297 | private Uri mAddress; |
| 298 | private Uri mSubscriptionAddress; |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 299 | private int mCapabilities; |
| Christine Hallstrom | 2830ce9 | 2016-11-30 16:06:42 -0800 | [diff] [blame] | 300 | private int mSupportedAudioRoutes = CallAudioState.ROUTE_ALL; |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 301 | private int mHighlightColor = NO_HIGHLIGHT_COLOR; |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 302 | private CharSequence mLabel; |
| 303 | private CharSequence mShortDescription; |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 304 | private List<String> mSupportedUriSchemes = new ArrayList<String>(); |
| Santos Cordon | cad84a2 | 2015-05-13 11:17:25 -0700 | [diff] [blame] | 305 | private Icon mIcon; |
| Tyler Gunn | 25ed2d7 | 2015-10-05 14:14:38 -0700 | [diff] [blame] | 306 | private Bundle mExtras; |
| Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 307 | private boolean mIsEnabled = false; |
| Brad Ebinger | 7298f3b | 2016-06-10 17:19:42 -0700 | [diff] [blame] | 308 | private String mGroupId = ""; |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 309 | |
| Santos Cordon | 32c65a5 | 2014-10-27 14:57:49 -0700 | [diff] [blame] | 310 | /** |
| 311 | * Creates a builder with the specified {@link PhoneAccountHandle} and label. |
| 312 | */ |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 313 | public Builder(PhoneAccountHandle accountHandle, CharSequence label) { |
| 314 | this.mAccountHandle = accountHandle; |
| 315 | this.mLabel = label; |
| 316 | } |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 317 | |
| Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 318 | /** |
| 319 | * Creates an instance of the {@link PhoneAccount.Builder} from an existing |
| 320 | * {@link PhoneAccount}. |
| 321 | * |
| 322 | * @param phoneAccount The {@link PhoneAccount} used to initialize the builder. |
| 323 | */ |
| 324 | public Builder(PhoneAccount phoneAccount) { |
| 325 | mAccountHandle = phoneAccount.getAccountHandle(); |
| 326 | mAddress = phoneAccount.getAddress(); |
| 327 | mSubscriptionAddress = phoneAccount.getSubscriptionAddress(); |
| 328 | mCapabilities = phoneAccount.getCapabilities(); |
| Ihab Awad | 476cc83 | 2014-11-03 09:47:51 -0800 | [diff] [blame] | 329 | mHighlightColor = phoneAccount.getHighlightColor(); |
| Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 330 | mLabel = phoneAccount.getLabel(); |
| 331 | mShortDescription = phoneAccount.getShortDescription(); |
| 332 | mSupportedUriSchemes.addAll(phoneAccount.getSupportedUriSchemes()); |
| Santos Cordon | cad84a2 | 2015-05-13 11:17:25 -0700 | [diff] [blame] | 333 | mIcon = phoneAccount.getIcon(); |
| Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 334 | mIsEnabled = phoneAccount.isEnabled(); |
| Tyler Gunn | d426b20 | 2015-10-13 13:33:53 -0700 | [diff] [blame] | 335 | mExtras = phoneAccount.getExtras(); |
| Brad Ebinger | 7298f3b | 2016-06-10 17:19:42 -0700 | [diff] [blame] | 336 | mGroupId = phoneAccount.getGroupId(); |
| Christine Hallstrom | 2830ce9 | 2016-11-30 16:06:42 -0800 | [diff] [blame] | 337 | mSupportedAudioRoutes = phoneAccount.getSupportedAudioRoutes(); |
| Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 338 | } |
| 339 | |
| Santos Cordon | 32c65a5 | 2014-10-27 14:57:49 -0700 | [diff] [blame] | 340 | /** |
| Tyler Gunn | 3765356 | 2017-03-13 18:15:15 -0700 | [diff] [blame] | 341 | * Sets the label. See {@link PhoneAccount#getLabel()}. |
| 342 | * |
| 343 | * @param label The label of the phone account. |
| 344 | * @return The builder. |
| 345 | * @hide |
| 346 | */ |
| 347 | public Builder setLabel(CharSequence label) { |
| 348 | this.mLabel = label; |
| 349 | return this; |
| 350 | } |
| 351 | |
| 352 | /** |
| Santos Cordon | 32c65a5 | 2014-10-27 14:57:49 -0700 | [diff] [blame] | 353 | * Sets the address. See {@link PhoneAccount#getAddress}. |
| 354 | * |
| 355 | * @param value The address of the phone account. |
| 356 | * @return The builder. |
| 357 | */ |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 358 | public Builder setAddress(Uri value) { |
| 359 | this.mAddress = value; |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 360 | return this; |
| 361 | } |
| 362 | |
| Santos Cordon | 32c65a5 | 2014-10-27 14:57:49 -0700 | [diff] [blame] | 363 | /** |
| 364 | * Sets the subscription address. See {@link PhoneAccount#getSubscriptionAddress}. |
| 365 | * |
| 366 | * @param value The subscription address. |
| 367 | * @return The builder. |
| 368 | */ |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 369 | public Builder setSubscriptionAddress(Uri value) { |
| 370 | this.mSubscriptionAddress = value; |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 371 | return this; |
| 372 | } |
| 373 | |
| Santos Cordon | 32c65a5 | 2014-10-27 14:57:49 -0700 | [diff] [blame] | 374 | /** |
| 375 | * Sets the capabilities. See {@link PhoneAccount#getCapabilities}. |
| 376 | * |
| 377 | * @param value The capabilities to set. |
| 378 | * @return The builder. |
| 379 | */ |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 380 | public Builder setCapabilities(int value) { |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 381 | this.mCapabilities = value; |
| 382 | return this; |
| 383 | } |
| 384 | |
| Santos Cordon | 32c65a5 | 2014-10-27 14:57:49 -0700 | [diff] [blame] | 385 | /** |
| Santos Cordon | cad84a2 | 2015-05-13 11:17:25 -0700 | [diff] [blame] | 386 | * Sets the icon. See {@link PhoneAccount#getIcon}. |
| Santos Cordon | 32c65a5 | 2014-10-27 14:57:49 -0700 | [diff] [blame] | 387 | * |
| Santos Cordon | cad84a2 | 2015-05-13 11:17:25 -0700 | [diff] [blame] | 388 | * @param icon The icon to set. |
| Santos Cordon | 32c65a5 | 2014-10-27 14:57:49 -0700 | [diff] [blame] | 389 | */ |
| Santos Cordon | cad84a2 | 2015-05-13 11:17:25 -0700 | [diff] [blame] | 390 | public Builder setIcon(Icon icon) { |
| 391 | mIcon = icon; |
| Ihab Awad | 074bf10 | 2014-10-24 11:42:32 -0700 | [diff] [blame] | 392 | return this; |
| 393 | } |
| 394 | |
| 395 | /** |
| Ihab Awad | 476cc83 | 2014-11-03 09:47:51 -0800 | [diff] [blame] | 396 | * Sets the highlight color. See {@link PhoneAccount#getHighlightColor}. |
| Ihab Awad | 074bf10 | 2014-10-24 11:42:32 -0700 | [diff] [blame] | 397 | * |
| Ihab Awad | 476cc83 | 2014-11-03 09:47:51 -0800 | [diff] [blame] | 398 | * @param value The highlight color. |
| Ihab Awad | 074bf10 | 2014-10-24 11:42:32 -0700 | [diff] [blame] | 399 | * @return The builder. |
| 400 | */ |
| Ihab Awad | 476cc83 | 2014-11-03 09:47:51 -0800 | [diff] [blame] | 401 | public Builder setHighlightColor(int value) { |
| 402 | this.mHighlightColor = value; |
| Nancy Chen | 3ace54b | 2014-10-22 17:45:26 -0700 | [diff] [blame] | 403 | return this; |
| 404 | } |
| 405 | |
| Santos Cordon | 32c65a5 | 2014-10-27 14:57:49 -0700 | [diff] [blame] | 406 | /** |
| 407 | * Sets the short description. See {@link PhoneAccount#getShortDescription}. |
| 408 | * |
| 409 | * @param value The short description. |
| 410 | * @return The builder. |
| 411 | */ |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 412 | public Builder setShortDescription(CharSequence value) { |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 413 | this.mShortDescription = value; |
| 414 | return this; |
| 415 | } |
| 416 | |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 417 | /** |
| 418 | * Specifies an additional URI scheme supported by the {@link PhoneAccount}. |
| 419 | * |
| 420 | * @param uriScheme The URI scheme. |
| Santos Cordon | 32c65a5 | 2014-10-27 14:57:49 -0700 | [diff] [blame] | 421 | * @return The builder. |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 422 | */ |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 423 | public Builder addSupportedUriScheme(String uriScheme) { |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 424 | if (!TextUtils.isEmpty(uriScheme) && !mSupportedUriSchemes.contains(uriScheme)) { |
| 425 | this.mSupportedUriSchemes.add(uriScheme); |
| 426 | } |
| 427 | return this; |
| 428 | } |
| 429 | |
| 430 | /** |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 431 | * Specifies the URI schemes supported by the {@link PhoneAccount}. |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 432 | * |
| 433 | * @param uriSchemes The URI schemes. |
| Santos Cordon | 32c65a5 | 2014-10-27 14:57:49 -0700 | [diff] [blame] | 434 | * @return The builder. |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 435 | */ |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 436 | public Builder setSupportedUriSchemes(List<String> uriSchemes) { |
| 437 | mSupportedUriSchemes.clear(); |
| 438 | |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 439 | if (uriSchemes != null && !uriSchemes.isEmpty()) { |
| 440 | for (String uriScheme : uriSchemes) { |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 441 | addSupportedUriScheme(uriScheme); |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 442 | } |
| 443 | } |
| 444 | return this; |
| 445 | } |
| 446 | |
| Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 447 | /** |
| Tyler Gunn | 25ed2d7 | 2015-10-05 14:14:38 -0700 | [diff] [blame] | 448 | * Specifies the extras associated with the {@link PhoneAccount}. |
| 449 | * <p> |
| 450 | * {@code PhoneAccount}s only support extra values of type: {@link String}, {@link Integer}, |
| 451 | * and {@link Boolean}. Extras which are not of these types are ignored. |
| 452 | * |
| 453 | * @param extras |
| 454 | * @return |
| 455 | */ |
| 456 | public Builder setExtras(Bundle extras) { |
| 457 | mExtras = extras; |
| 458 | return this; |
| 459 | } |
| 460 | |
| 461 | /** |
| Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 462 | * Sets the enabled state of the phone account. |
| 463 | * |
| 464 | * @param isEnabled The enabled state. |
| 465 | * @return The builder. |
| 466 | * @hide |
| 467 | */ |
| 468 | public Builder setIsEnabled(boolean isEnabled) { |
| 469 | mIsEnabled = isEnabled; |
| 470 | return this; |
| 471 | } |
| 472 | |
| 473 | /** |
| Brad Ebinger | 7298f3b | 2016-06-10 17:19:42 -0700 | [diff] [blame] | 474 | * Sets the group Id of the {@link PhoneAccount}. When a new {@link PhoneAccount} is |
| 475 | * registered to Telecom, it will replace another {@link PhoneAccount} that is already |
| 476 | * registered in Telecom and take on the current user defaults and enabled status. There can |
| 477 | * only be one {@link PhoneAccount} with a non-empty group number registered to Telecom at a |
| 478 | * time. By default, there is no group Id for a {@link PhoneAccount} (an empty String). Only |
| 479 | * grouped {@link PhoneAccount}s with the same {@link ConnectionService} can be replaced. |
| 480 | * @param groupId The group Id of the {@link PhoneAccount} that will replace any other |
| 481 | * registered {@link PhoneAccount} in Telecom with the same Group Id. |
| 482 | * @return The builder |
| 483 | * @hide |
| 484 | */ |
| 485 | public Builder setGroupId(String groupId) { |
| 486 | if (groupId != null) { |
| 487 | mGroupId = groupId; |
| 488 | } else { |
| 489 | mGroupId = ""; |
| 490 | } |
| 491 | return this; |
| 492 | } |
| 493 | |
| 494 | /** |
| Christine Hallstrom | 2830ce9 | 2016-11-30 16:06:42 -0800 | [diff] [blame] | 495 | * Sets the audio routes supported by this {@link PhoneAccount}. |
| 496 | * |
| 497 | * @param routes bit mask of available routes. |
| 498 | * @return The builder. |
| 499 | * @hide |
| 500 | */ |
| 501 | public Builder setSupportedAudioRoutes(int routes) { |
| 502 | mSupportedAudioRoutes = routes; |
| 503 | return this; |
| 504 | } |
| 505 | |
| 506 | /** |
| Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 507 | * Creates an instance of a {@link PhoneAccount} based on the current builder settings. |
| 508 | * |
| 509 | * @return The {@link PhoneAccount}. |
| 510 | */ |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 511 | public PhoneAccount build() { |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 512 | // If no supported URI schemes were defined, assume "tel" is supported. |
| 513 | if (mSupportedUriSchemes.isEmpty()) { |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 514 | addSupportedUriScheme(SCHEME_TEL); |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 515 | } |
| 516 | |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 517 | return new PhoneAccount( |
| 518 | mAccountHandle, |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 519 | mAddress, |
| 520 | mSubscriptionAddress, |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 521 | mCapabilities, |
| Santos Cordon | cad84a2 | 2015-05-13 11:17:25 -0700 | [diff] [blame] | 522 | mIcon, |
| Ihab Awad | 476cc83 | 2014-11-03 09:47:51 -0800 | [diff] [blame] | 523 | mHighlightColor, |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 524 | mLabel, |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 525 | mShortDescription, |
| Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 526 | mSupportedUriSchemes, |
| Tyler Gunn | 25ed2d7 | 2015-10-05 14:14:38 -0700 | [diff] [blame] | 527 | mExtras, |
| Christine Hallstrom | 2830ce9 | 2016-11-30 16:06:42 -0800 | [diff] [blame] | 528 | mSupportedAudioRoutes, |
| Brad Ebinger | 7298f3b | 2016-06-10 17:19:42 -0700 | [diff] [blame] | 529 | mIsEnabled, |
| 530 | mGroupId); |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 531 | } |
| 532 | } |
| 533 | |
| 534 | private PhoneAccount( |
| Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 535 | PhoneAccountHandle account, |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 536 | Uri address, |
| 537 | Uri subscriptionAddress, |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 538 | int capabilities, |
| Santos Cordon | cad84a2 | 2015-05-13 11:17:25 -0700 | [diff] [blame] | 539 | Icon icon, |
| Ihab Awad | 476cc83 | 2014-11-03 09:47:51 -0800 | [diff] [blame] | 540 | int highlightColor, |
| Santos Cordon | 146a3e3 | 2014-07-21 00:00:44 -0700 | [diff] [blame] | 541 | CharSequence label, |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 542 | CharSequence shortDescription, |
| Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 543 | List<String> supportedUriSchemes, |
| Tyler Gunn | 25ed2d7 | 2015-10-05 14:14:38 -0700 | [diff] [blame] | 544 | Bundle extras, |
| Christine Hallstrom | 2830ce9 | 2016-11-30 16:06:42 -0800 | [diff] [blame] | 545 | int supportedAudioRoutes, |
| Brad Ebinger | 7298f3b | 2016-06-10 17:19:42 -0700 | [diff] [blame] | 546 | boolean isEnabled, |
| 547 | String groupId) { |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 548 | mAccountHandle = account; |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 549 | mAddress = address; |
| 550 | mSubscriptionAddress = subscriptionAddress; |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 551 | mCapabilities = capabilities; |
| Santos Cordon | cad84a2 | 2015-05-13 11:17:25 -0700 | [diff] [blame] | 552 | mIcon = icon; |
| Ihab Awad | 476cc83 | 2014-11-03 09:47:51 -0800 | [diff] [blame] | 553 | mHighlightColor = highlightColor; |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 554 | mLabel = label; |
| 555 | mShortDescription = shortDescription; |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 556 | mSupportedUriSchemes = Collections.unmodifiableList(supportedUriSchemes); |
| Tyler Gunn | 25ed2d7 | 2015-10-05 14:14:38 -0700 | [diff] [blame] | 557 | mExtras = extras; |
| Christine Hallstrom | 2830ce9 | 2016-11-30 16:06:42 -0800 | [diff] [blame] | 558 | mSupportedAudioRoutes = supportedAudioRoutes; |
| Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 559 | mIsEnabled = isEnabled; |
| Brad Ebinger | 7298f3b | 2016-06-10 17:19:42 -0700 | [diff] [blame] | 560 | mGroupId = groupId; |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 561 | } |
| 562 | |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 563 | public static Builder builder( |
| 564 | PhoneAccountHandle accountHandle, |
| 565 | CharSequence label) { |
| 566 | return new Builder(accountHandle, label); |
| 567 | } |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 568 | |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 569 | /** |
| Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 570 | * Returns a builder initialized with the current {@link PhoneAccount} instance. |
| 571 | * |
| 572 | * @return The builder. |
| Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 573 | */ |
| 574 | public Builder toBuilder() { return new Builder(this); } |
| 575 | |
| 576 | /** |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 577 | * The unique identifier of this {@code PhoneAccount}. |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 578 | * |
| Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 579 | * @return A {@code PhoneAccountHandle}. |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 580 | */ |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 581 | public PhoneAccountHandle getAccountHandle() { |
| 582 | return mAccountHandle; |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 583 | } |
| 584 | |
| 585 | /** |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 586 | * The address (e.g., a phone number) associated with this {@code PhoneAccount}. This |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 587 | * represents the destination from which outgoing calls using this {@code PhoneAccount} |
| Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 588 | * will appear to come, if applicable, and the destination to which incoming calls using this |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 589 | * {@code PhoneAccount} may be addressed. |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 590 | * |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 591 | * @return A address expressed as a {@code Uri}, for example, a phone number. |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 592 | */ |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 593 | public Uri getAddress() { |
| 594 | return mAddress; |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 595 | } |
| 596 | |
| 597 | /** |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 598 | * The raw callback number used for this {@code PhoneAccount}, as distinct from |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 599 | * {@link #getAddress()}. For the majority of {@code PhoneAccount}s this should be registered |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 600 | * as {@code null}. It is used by the system for SIM-based {@code PhoneAccount} registration |
| Junda Liu | f52ac90 | 2014-09-25 17:36:48 +0000 | [diff] [blame] | 601 | * where {@link android.telephony.TelephonyManager#setLine1NumberForDisplay(String, String)} |
| 602 | * has been used to alter the callback number. |
| 603 | * <p> |
| Evan Charlton | 222db525 | 2014-07-17 16:59:18 -0700 | [diff] [blame] | 604 | * |
| 605 | * @return The subscription number, suitable for display to the user. |
| 606 | */ |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 607 | public Uri getSubscriptionAddress() { |
| 608 | return mSubscriptionAddress; |
| Evan Charlton | 222db525 | 2014-07-17 16:59:18 -0700 | [diff] [blame] | 609 | } |
| 610 | |
| 611 | /** |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 612 | * The capabilities of this {@code PhoneAccount}. |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 613 | * |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 614 | * @return A bit field of flags describing this {@code PhoneAccount}'s capabilities. |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 615 | */ |
| 616 | public int getCapabilities() { |
| 617 | return mCapabilities; |
| 618 | } |
| 619 | |
| 620 | /** |
| Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 621 | * Determines if this {@code PhoneAccount} has a capabilities specified by the passed in |
| 622 | * bit mask. |
| 623 | * |
| 624 | * @param capability The capabilities to check. |
| Santos Cordon | 895d4b8 | 2015-06-25 16:41:48 -0700 | [diff] [blame] | 625 | * @return {@code true} if the phone account has the capability. |
| Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 626 | */ |
| 627 | public boolean hasCapabilities(int capability) { |
| 628 | return (mCapabilities & capability) == capability; |
| 629 | } |
| 630 | |
| 631 | /** |
| Christine Hallstrom | 2830ce9 | 2016-11-30 16:06:42 -0800 | [diff] [blame] | 632 | * Determines if this {@code PhoneAccount} has routes specified by the passed in bit mask. |
| 633 | * |
| 634 | * @param route The routes to check. |
| 635 | * @return {@code true} if the phone account has the routes. |
| 636 | * @hide |
| 637 | */ |
| 638 | public boolean hasAudioRoutes(int routes) { |
| 639 | return (mSupportedAudioRoutes & routes) == routes; |
| 640 | } |
| 641 | |
| 642 | /** |
| Santos Cordon | 146a3e3 | 2014-07-21 00:00:44 -0700 | [diff] [blame] | 643 | * A short label describing a {@code PhoneAccount}. |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 644 | * |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 645 | * @return A label for this {@code PhoneAccount}. |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 646 | */ |
| Santos Cordon | 146a3e3 | 2014-07-21 00:00:44 -0700 | [diff] [blame] | 647 | public CharSequence getLabel() { |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 648 | return mLabel; |
| 649 | } |
| 650 | |
| 651 | /** |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 652 | * A short paragraph describing this {@code PhoneAccount}. |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 653 | * |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 654 | * @return A description for this {@code PhoneAccount}. |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 655 | */ |
| Santos Cordon | 146a3e3 | 2014-07-21 00:00:44 -0700 | [diff] [blame] | 656 | public CharSequence getShortDescription() { |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 657 | return mShortDescription; |
| 658 | } |
| 659 | |
| 660 | /** |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 661 | * The URI schemes supported by this {@code PhoneAccount}. |
| 662 | * |
| 663 | * @return The URI schemes. |
| 664 | */ |
| 665 | public List<String> getSupportedUriSchemes() { |
| 666 | return mSupportedUriSchemes; |
| 667 | } |
| 668 | |
| 669 | /** |
| Tyler Gunn | 25ed2d7 | 2015-10-05 14:14:38 -0700 | [diff] [blame] | 670 | * The extras associated with this {@code PhoneAccount}. |
| 671 | * <p> |
| 672 | * A {@link ConnectionService} may provide implementation specific information about the |
| 673 | * {@link PhoneAccount} via the extras. |
| 674 | * |
| 675 | * @return The extras. |
| 676 | */ |
| 677 | public Bundle getExtras() { |
| 678 | return mExtras; |
| 679 | } |
| 680 | |
| 681 | /** |
| Christine Hallstrom | 2830ce9 | 2016-11-30 16:06:42 -0800 | [diff] [blame] | 682 | * The audio routes supported by this {@code PhoneAccount}. |
| 683 | * |
| 684 | * @hide |
| 685 | */ |
| 686 | public int getSupportedAudioRoutes() { |
| 687 | return mSupportedAudioRoutes; |
| 688 | } |
| 689 | |
| 690 | /** |
| Santos Cordon | cad84a2 | 2015-05-13 11:17:25 -0700 | [diff] [blame] | 691 | * The icon to represent this {@code PhoneAccount}. |
| 692 | * |
| 693 | * @return The icon. |
| 694 | */ |
| 695 | public Icon getIcon() { |
| 696 | return mIcon; |
| 697 | } |
| 698 | |
| 699 | /** |
| Santos Cordon | 895d4b8 | 2015-06-25 16:41:48 -0700 | [diff] [blame] | 700 | * Indicates whether the user has enabled this {@code PhoneAccount} or not. This value is only |
| 701 | * populated for {@code PhoneAccount}s returned by {@link TelecomManager#getPhoneAccount}. |
| Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 702 | * |
| Santos Cordon | 895d4b8 | 2015-06-25 16:41:48 -0700 | [diff] [blame] | 703 | * @return {@code true} if the account is enabled by the user, {@code false} otherwise. |
| Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 704 | */ |
| 705 | public boolean isEnabled() { |
| 706 | return mIsEnabled; |
| 707 | } |
| 708 | |
| 709 | /** |
| Brad Ebinger | 7298f3b | 2016-06-10 17:19:42 -0700 | [diff] [blame] | 710 | * A non-empty {@link String} representing the group that A {@link PhoneAccount} is in or an |
| 711 | * empty {@link String} if the {@link PhoneAccount} is not in a group. If this |
| 712 | * {@link PhoneAccount} is in a group, this new {@link PhoneAccount} will replace a registered |
| 713 | * {@link PhoneAccount} that is in the same group. When the {@link PhoneAccount} is replaced, |
| 714 | * its user defined defaults and enabled status will also pass to this new {@link PhoneAccount}. |
| 715 | * Only {@link PhoneAccount}s that share the same {@link ConnectionService} can be replaced. |
| 716 | * |
| 717 | * @return A non-empty String Id if this {@link PhoneAccount} belongs to a group. |
| 718 | * @hide |
| 719 | */ |
| 720 | public String getGroupId() { |
| 721 | return mGroupId; |
| 722 | } |
| 723 | |
| 724 | /** |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 725 | * Determines if the {@link PhoneAccount} supports calls to/from addresses with a specified URI |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 726 | * scheme. |
| 727 | * |
| 728 | * @param uriScheme The URI scheme to check. |
| Santos Cordon | 895d4b8 | 2015-06-25 16:41:48 -0700 | [diff] [blame] | 729 | * @return {@code true} if the {@code PhoneAccount} supports calls to/from addresses with the |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 730 | * specified URI scheme. |
| 731 | */ |
| 732 | public boolean supportsUriScheme(String uriScheme) { |
| 733 | if (mSupportedUriSchemes == null || uriScheme == null) { |
| 734 | return false; |
| 735 | } |
| 736 | |
| 737 | for (String scheme : mSupportedUriSchemes) { |
| 738 | if (scheme != null && scheme.equals(uriScheme)) { |
| 739 | return true; |
| 740 | } |
| 741 | } |
| 742 | return false; |
| 743 | } |
| 744 | |
| 745 | /** |
| Ihab Awad | 476cc83 | 2014-11-03 09:47:51 -0800 | [diff] [blame] | 746 | * A highlight color to use in displaying information about this {@code PhoneAccount}. |
| 747 | * |
| 748 | * @return A hexadecimal color value. |
| 749 | */ |
| 750 | public int getHighlightColor() { |
| 751 | return mHighlightColor; |
| 752 | } |
| 753 | |
| Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 754 | /** |
| 755 | * Sets the enabled state of the phone account. |
| 756 | * @hide |
| 757 | */ |
| 758 | public void setIsEnabled(boolean isEnabled) { |
| 759 | mIsEnabled = isEnabled; |
| 760 | } |
| 761 | |
| Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 762 | /** |
| 763 | * @return {@code true} if the {@link PhoneAccount} is self-managed, {@code false} otherwise. |
| 764 | * @hide |
| 765 | */ |
| 766 | public boolean isSelfManaged() { |
| 767 | return (mCapabilities & CAPABILITY_SELF_MANAGED) == CAPABILITY_SELF_MANAGED; |
| 768 | } |
| 769 | |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 770 | // |
| 771 | // Parcelable implementation |
| 772 | // |
| 773 | |
| 774 | @Override |
| 775 | public int describeContents() { |
| 776 | return 0; |
| 777 | } |
| 778 | |
| 779 | @Override |
| 780 | public void writeToParcel(Parcel out, int flags) { |
| Ihab Awad | 476cc83 | 2014-11-03 09:47:51 -0800 | [diff] [blame] | 781 | if (mAccountHandle == null) { |
| 782 | out.writeInt(0); |
| 783 | } else { |
| 784 | out.writeInt(1); |
| 785 | mAccountHandle.writeToParcel(out, flags); |
| 786 | } |
| 787 | if (mAddress == null) { |
| 788 | out.writeInt(0); |
| 789 | } else { |
| 790 | out.writeInt(1); |
| 791 | mAddress.writeToParcel(out, flags); |
| 792 | } |
| 793 | if (mSubscriptionAddress == null) { |
| 794 | out.writeInt(0); |
| 795 | } else { |
| 796 | out.writeInt(1); |
| 797 | mSubscriptionAddress.writeToParcel(out, flags); |
| 798 | } |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 799 | out.writeInt(mCapabilities); |
| Ihab Awad | 476cc83 | 2014-11-03 09:47:51 -0800 | [diff] [blame] | 800 | out.writeInt(mHighlightColor); |
| Santos Cordon | 146a3e3 | 2014-07-21 00:00:44 -0700 | [diff] [blame] | 801 | out.writeCharSequence(mLabel); |
| 802 | out.writeCharSequence(mShortDescription); |
| Ihab Awad | 476cc83 | 2014-11-03 09:47:51 -0800 | [diff] [blame] | 803 | out.writeStringList(mSupportedUriSchemes); |
| Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 804 | |
| Santos Cordon | cad84a2 | 2015-05-13 11:17:25 -0700 | [diff] [blame] | 805 | if (mIcon == null) { |
| 806 | out.writeInt(0); |
| 807 | } else { |
| 808 | out.writeInt(1); |
| 809 | mIcon.writeToParcel(out, flags); |
| 810 | } |
| Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 811 | out.writeByte((byte) (mIsEnabled ? 1 : 0)); |
| Tyler Gunn | ef829ec | 2015-10-08 09:46:23 -0700 | [diff] [blame] | 812 | out.writeBundle(mExtras); |
| Brad Ebinger | 7298f3b | 2016-06-10 17:19:42 -0700 | [diff] [blame] | 813 | out.writeString(mGroupId); |
| Christine Hallstrom | 2830ce9 | 2016-11-30 16:06:42 -0800 | [diff] [blame] | 814 | out.writeInt(mSupportedAudioRoutes); |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 815 | } |
| 816 | |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 817 | public static final Creator<PhoneAccount> CREATOR |
| 818 | = new Creator<PhoneAccount>() { |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 819 | @Override |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 820 | public PhoneAccount createFromParcel(Parcel in) { |
| 821 | return new PhoneAccount(in); |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 822 | } |
| 823 | |
| 824 | @Override |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 825 | public PhoneAccount[] newArray(int size) { |
| 826 | return new PhoneAccount[size]; |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 827 | } |
| 828 | }; |
| 829 | |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 830 | private PhoneAccount(Parcel in) { |
| Ihab Awad | 476cc83 | 2014-11-03 09:47:51 -0800 | [diff] [blame] | 831 | if (in.readInt() > 0) { |
| 832 | mAccountHandle = PhoneAccountHandle.CREATOR.createFromParcel(in); |
| 833 | } else { |
| 834 | mAccountHandle = null; |
| 835 | } |
| 836 | if (in.readInt() > 0) { |
| 837 | mAddress = Uri.CREATOR.createFromParcel(in); |
| 838 | } else { |
| 839 | mAddress = null; |
| 840 | } |
| 841 | if (in.readInt() > 0) { |
| 842 | mSubscriptionAddress = Uri.CREATOR.createFromParcel(in); |
| 843 | } else { |
| 844 | mSubscriptionAddress = null; |
| 845 | } |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 846 | mCapabilities = in.readInt(); |
| Ihab Awad | 476cc83 | 2014-11-03 09:47:51 -0800 | [diff] [blame] | 847 | mHighlightColor = in.readInt(); |
| Santos Cordon | 146a3e3 | 2014-07-21 00:00:44 -0700 | [diff] [blame] | 848 | mLabel = in.readCharSequence(); |
| 849 | mShortDescription = in.readCharSequence(); |
| Ihab Awad | 476cc83 | 2014-11-03 09:47:51 -0800 | [diff] [blame] | 850 | mSupportedUriSchemes = Collections.unmodifiableList(in.createStringArrayList()); |
| Santos Cordon | cad84a2 | 2015-05-13 11:17:25 -0700 | [diff] [blame] | 851 | if (in.readInt() > 0) { |
| 852 | mIcon = Icon.CREATOR.createFromParcel(in); |
| 853 | } else { |
| 854 | mIcon = null; |
| 855 | } |
| Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 856 | mIsEnabled = in.readByte() == 1; |
| Tyler Gunn | ef829ec | 2015-10-08 09:46:23 -0700 | [diff] [blame] | 857 | mExtras = in.readBundle(); |
| Brad Ebinger | 7298f3b | 2016-06-10 17:19:42 -0700 | [diff] [blame] | 858 | mGroupId = in.readString(); |
| Christine Hallstrom | 2830ce9 | 2016-11-30 16:06:42 -0800 | [diff] [blame] | 859 | mSupportedAudioRoutes = in.readInt(); |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 860 | } |
| Tyler Gunn | 76c01a5 | 2014-09-30 14:47:51 -0700 | [diff] [blame] | 861 | |
| 862 | @Override |
| 863 | public String toString() { |
| Santos Cordon | 91371dc0 | 2015-05-08 13:52:09 -0700 | [diff] [blame] | 864 | StringBuilder sb = new StringBuilder().append("[[") |
| 865 | .append(mIsEnabled ? 'X' : ' ') |
| 866 | .append("] PhoneAccount: ") |
| Tyler Gunn | 76c01a5 | 2014-09-30 14:47:51 -0700 | [diff] [blame] | 867 | .append(mAccountHandle) |
| 868 | .append(" Capabilities: ") |
| Christine Hallstrom | 2830ce9 | 2016-11-30 16:06:42 -0800 | [diff] [blame] | 869 | .append(capabilitiesToString()) |
| 870 | .append(" Audio Routes: ") |
| 871 | .append(audioRoutesToString()) |
| Tyler Gunn | 76c01a5 | 2014-09-30 14:47:51 -0700 | [diff] [blame] | 872 | .append(" Schemes: "); |
| 873 | for (String scheme : mSupportedUriSchemes) { |
| 874 | sb.append(scheme) |
| 875 | .append(" "); |
| 876 | } |
| Tyler Gunn | ef829ec | 2015-10-08 09:46:23 -0700 | [diff] [blame] | 877 | sb.append(" Extras: "); |
| Tyler Gunn | 25ed2d7 | 2015-10-05 14:14:38 -0700 | [diff] [blame] | 878 | sb.append(mExtras); |
| Brad Ebinger | 7298f3b | 2016-06-10 17:19:42 -0700 | [diff] [blame] | 879 | sb.append(" GroupId: "); |
| 880 | sb.append(Log.pii(mGroupId)); |
| Tyler Gunn | 76c01a5 | 2014-09-30 14:47:51 -0700 | [diff] [blame] | 881 | sb.append("]"); |
| 882 | return sb.toString(); |
| 883 | } |
| Tyler Gunn | 3e122f7 | 2016-01-11 19:25:00 -0800 | [diff] [blame] | 884 | |
| 885 | /** |
| 886 | * Generates a string representation of a capabilities bitmask. |
| 887 | * |
| 888 | * @param capabilities The capabilities bitmask. |
| 889 | * @return String representation of the capabilities bitmask. |
| 890 | */ |
| Christine Hallstrom | 2830ce9 | 2016-11-30 16:06:42 -0800 | [diff] [blame] | 891 | private String capabilitiesToString() { |
| Tyler Gunn | 3e122f7 | 2016-01-11 19:25:00 -0800 | [diff] [blame] | 892 | StringBuilder sb = new StringBuilder(); |
| Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 893 | if (hasCapabilities(CAPABILITY_SELF_MANAGED)) { |
| 894 | sb.append("SelfManaged "); |
| 895 | } |
| Tyler Gunn | 58cbd7a | 2016-11-11 11:31:28 -0800 | [diff] [blame] | 896 | if (hasCapabilities(CAPABILITY_SUPPORTS_VIDEO_CALLING)) { |
| 897 | sb.append("SuppVideo "); |
| 898 | } |
| Tyler Gunn | 3e122f7 | 2016-01-11 19:25:00 -0800 | [diff] [blame] | 899 | if (hasCapabilities(CAPABILITY_VIDEO_CALLING)) { |
| 900 | sb.append("Video "); |
| 901 | } |
| 902 | if (hasCapabilities(CAPABILITY_VIDEO_CALLING_RELIES_ON_PRESENCE)) { |
| 903 | sb.append("Presence "); |
| 904 | } |
| 905 | if (hasCapabilities(CAPABILITY_CALL_PROVIDER)) { |
| 906 | sb.append("CallProvider "); |
| 907 | } |
| 908 | if (hasCapabilities(CAPABILITY_CALL_SUBJECT)) { |
| 909 | sb.append("CallSubject "); |
| 910 | } |
| 911 | if (hasCapabilities(CAPABILITY_CONNECTION_MANAGER)) { |
| 912 | sb.append("ConnectionMgr "); |
| 913 | } |
| 914 | if (hasCapabilities(CAPABILITY_EMERGENCY_CALLS_ONLY)) { |
| 915 | sb.append("EmergOnly "); |
| 916 | } |
| 917 | if (hasCapabilities(CAPABILITY_MULTI_USER)) { |
| 918 | sb.append("MultiUser "); |
| 919 | } |
| 920 | if (hasCapabilities(CAPABILITY_PLACE_EMERGENCY_CALLS)) { |
| 921 | sb.append("PlaceEmerg "); |
| 922 | } |
| Tyler Gunn | cee9ea6 | 2016-03-24 11:45:43 -0700 | [diff] [blame] | 923 | if (hasCapabilities(CAPABILITY_EMERGENCY_VIDEO_CALLING)) { |
| 924 | sb.append("EmergVideo "); |
| 925 | } |
| Tyler Gunn | 3e122f7 | 2016-01-11 19:25:00 -0800 | [diff] [blame] | 926 | if (hasCapabilities(CAPABILITY_SIM_SUBSCRIPTION)) { |
| 927 | sb.append("SimSub "); |
| 928 | } |
| 929 | return sb.toString(); |
| 930 | } |
| Christine Hallstrom | 2830ce9 | 2016-11-30 16:06:42 -0800 | [diff] [blame] | 931 | |
| 932 | private String audioRoutesToString() { |
| 933 | StringBuilder sb = new StringBuilder(); |
| 934 | |
| 935 | if (hasAudioRoutes(CallAudioState.ROUTE_BLUETOOTH)) { |
| 936 | sb.append("B"); |
| 937 | } |
| 938 | if (hasAudioRoutes(CallAudioState.ROUTE_EARPIECE)) { |
| 939 | sb.append("E"); |
| 940 | } |
| 941 | if (hasAudioRoutes(CallAudioState.ROUTE_SPEAKER)) { |
| 942 | sb.append("S"); |
| 943 | } |
| 944 | if (hasAudioRoutes(CallAudioState.ROUTE_WIRED_HEADSET)) { |
| 945 | sb.append("W"); |
| 946 | } |
| 947 | |
| 948 | return sb.toString(); |
| 949 | } |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 950 | } |