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