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