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