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