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