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