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