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