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