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