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