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