| 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 | |
| Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame^] | 19 | import android.annotation.SystemApi; |
| Ihab Awad | 074bf10 | 2014-10-24 11:42:32 -0700 | [diff] [blame] | 20 | import android.content.ComponentName; |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 21 | import android.content.Context; |
| 22 | import android.content.pm.PackageManager; |
| Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 23 | import android.content.res.Resources.NotFoundException; |
| Ihab Awad | 074bf10 | 2014-10-24 11:42:32 -0700 | [diff] [blame] | 24 | import android.graphics.Bitmap; |
| 25 | import android.graphics.Color; |
| 26 | import android.graphics.drawable.BitmapDrawable; |
| 27 | import android.graphics.drawable.ColorDrawable; |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 28 | import android.graphics.drawable.Drawable; |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 29 | import android.net.Uri; |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 30 | import android.os.Parcel; |
| 31 | import android.os.Parcelable; |
| 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.lang.String; |
| 35 | import java.util.ArrayList; |
| 36 | import java.util.Collections; |
| 37 | import java.util.List; |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 38 | import java.util.MissingResourceException; |
| 39 | |
| 40 | /** |
| Santos Cordon | 32c65a5 | 2014-10-27 14:57:49 -0700 | [diff] [blame] | 41 | * Represents a distinct method to place or receive a phone call. Apps which can place calls and |
| 42 | * want those calls to be integrated into the dialer and in-call UI should build an instance of |
| 43 | * this class and register it with the system using {@link TelecomManager#registerPhoneAccount}. |
| 44 | * <p> |
| 45 | * {@link TelecomManager} uses registered {@link PhoneAccount}s to present the user with |
| 46 | * alternative options when placing a phone call. When building a {@link PhoneAccount}, the app |
| 47 | * should supply a valid {@link PhoneAccountHandle} that references the {@link ConnectionService} |
| 48 | * implementation Telecom will use to interact with the app. |
| Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame^] | 49 | * @hide |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 50 | */ |
| Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame^] | 51 | @SystemApi |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 52 | public class PhoneAccount implements Parcelable { |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 53 | |
| 54 | /** |
| Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 55 | * Flag indicating that this {@code PhoneAccount} can act as a connection manager for |
| 56 | * other connections. The {@link ConnectionService} associated with this {@code PhoneAccount} |
| 57 | * will be allowed to manage phone calls including using its own proprietary phone-call |
| 58 | * implementation (like VoIP calling) to make calls instead of the telephony stack. |
| 59 | * <p> |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 60 | * When a user opts to place a call using the SIM-based telephony stack, the |
| 61 | * {@link ConnectionService} associated with this {@code PhoneAccount} will be attempted first |
| 62 | * 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] | 63 | * <p> |
| 64 | * See {@link #getCapabilities} |
| 65 | */ |
| Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 66 | public static final int CAPABILITY_CONNECTION_MANAGER = 0x1; |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 67 | |
| 68 | /** |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 69 | * 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] | 70 | * traditional SIM-based telephony calls. This account will be treated as a distinct method |
| 71 | * 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] | 72 | * 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] | 73 | * or place calls from the built-in telephony stack. |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 74 | * <p> |
| 75 | * See {@link #getCapabilities} |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 76 | * <p> |
| Evan Charlton | 7800fb7 | 2014-07-20 18:09:38 -0700 | [diff] [blame] | 77 | * {@hide} |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 78 | */ |
| 79 | public static final int CAPABILITY_CALL_PROVIDER = 0x2; |
| 80 | |
| Ihab Awad | 7522bbd6 | 2014-07-18 15:53:17 -0700 | [diff] [blame] | 81 | /** |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 82 | * Flag indicating that this {@code PhoneAccount} represents a built-in PSTN SIM |
| Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 83 | * subscription. |
| Ihab Awad | 7522bbd6 | 2014-07-18 15:53:17 -0700 | [diff] [blame] | 84 | * <p> |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 85 | * Only the Android framework can register a {@code PhoneAccount} having this capability. |
| 86 | * <p> |
| 87 | * See {@link #getCapabilities} |
| Ihab Awad | 7522bbd6 | 2014-07-18 15:53:17 -0700 | [diff] [blame] | 88 | */ |
| 89 | public static final int CAPABILITY_SIM_SUBSCRIPTION = 0x4; |
| 90 | |
| Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 91 | /** |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 92 | * Flag indicating that this {@code PhoneAccount} is capable of placing video calls. |
| 93 | * <p> |
| 94 | * See {@link #getCapabilities} |
| Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 95 | * @hide |
| Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 96 | */ |
| 97 | public static final int CAPABILITY_VIDEO_CALLING = 0x8; |
| 98 | |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 99 | /** |
| Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 100 | * Flag indicating that this {@code PhoneAccount} is capable of placing emergency calls. |
| 101 | * By default all PSTN {@code PhoneAccount}s are capable of placing emergency calls. |
| 102 | * <p> |
| 103 | * See {@link #getCapabilities} |
| 104 | */ |
| 105 | public static final int CAPABILITY_PLACE_EMERGENCY_CALLS = 0x10; |
| 106 | |
| 107 | /** |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 108 | * URI scheme for telephone number URIs. |
| 109 | */ |
| 110 | public static final String SCHEME_TEL = "tel"; |
| 111 | |
| 112 | /** |
| 113 | * URI scheme for voicemail URIs. |
| 114 | */ |
| 115 | public static final String SCHEME_VOICEMAIL = "voicemail"; |
| 116 | |
| 117 | /** |
| 118 | * URI scheme for SIP URIs. |
| 119 | */ |
| 120 | public static final String SCHEME_SIP = "sip"; |
| 121 | |
| Nancy Chen | 3ace54b | 2014-10-22 17:45:26 -0700 | [diff] [blame] | 122 | /** |
| 123 | * Indicating no color is set. |
| 124 | */ |
| 125 | public static final int NO_COLOR = -1; |
| 126 | |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 127 | private final PhoneAccountHandle mAccountHandle; |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 128 | private final Uri mAddress; |
| 129 | private final Uri mSubscriptionAddress; |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 130 | private final int mCapabilities; |
| 131 | private final int mIconResId; |
| Ihab Awad | 074bf10 | 2014-10-24 11:42:32 -0700 | [diff] [blame] | 132 | private final String mIconPackageName; |
| 133 | private final Bitmap mIconBitmap; |
| Nancy Chen | 3ace54b | 2014-10-22 17:45:26 -0700 | [diff] [blame] | 134 | private final int mColor; |
| Santos Cordon | 146a3e3 | 2014-07-21 00:00:44 -0700 | [diff] [blame] | 135 | private final CharSequence mLabel; |
| 136 | private final CharSequence mShortDescription; |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 137 | private final List<String> mSupportedUriSchemes; |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 138 | |
| Santos Cordon | 32c65a5 | 2014-10-27 14:57:49 -0700 | [diff] [blame] | 139 | /** |
| 140 | * Helper class for creating a {@link PhoneAccount}. |
| 141 | */ |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 142 | public static class Builder { |
| 143 | private PhoneAccountHandle mAccountHandle; |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 144 | private Uri mAddress; |
| 145 | private Uri mSubscriptionAddress; |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 146 | private int mCapabilities; |
| 147 | private int mIconResId; |
| Ihab Awad | 074bf10 | 2014-10-24 11:42:32 -0700 | [diff] [blame] | 148 | private String mIconPackageName; |
| 149 | private Bitmap mIconBitmap; |
| Nancy Chen | 3ace54b | 2014-10-22 17:45:26 -0700 | [diff] [blame] | 150 | private int mColor = NO_COLOR; |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 151 | private CharSequence mLabel; |
| 152 | private CharSequence mShortDescription; |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 153 | private List<String> mSupportedUriSchemes = new ArrayList<String>(); |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 154 | |
| Santos Cordon | 32c65a5 | 2014-10-27 14:57:49 -0700 | [diff] [blame] | 155 | /** |
| 156 | * Creates a builder with the specified {@link PhoneAccountHandle} and label. |
| 157 | */ |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 158 | public Builder(PhoneAccountHandle accountHandle, CharSequence label) { |
| 159 | this.mAccountHandle = accountHandle; |
| 160 | this.mLabel = label; |
| 161 | } |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 162 | |
| Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 163 | /** |
| 164 | * Creates an instance of the {@link PhoneAccount.Builder} from an existing |
| 165 | * {@link PhoneAccount}. |
| 166 | * |
| 167 | * @param phoneAccount The {@link PhoneAccount} used to initialize the builder. |
| 168 | */ |
| 169 | public Builder(PhoneAccount phoneAccount) { |
| 170 | mAccountHandle = phoneAccount.getAccountHandle(); |
| 171 | mAddress = phoneAccount.getAddress(); |
| 172 | mSubscriptionAddress = phoneAccount.getSubscriptionAddress(); |
| 173 | mCapabilities = phoneAccount.getCapabilities(); |
| 174 | mIconResId = phoneAccount.getIconResId(); |
| Ihab Awad | 074bf10 | 2014-10-24 11:42:32 -0700 | [diff] [blame] | 175 | mIconPackageName = phoneAccount.getIconPackageName(); |
| 176 | mIconBitmap = phoneAccount.getIconBitmap(); |
| Nancy Chen | 3ace54b | 2014-10-22 17:45:26 -0700 | [diff] [blame] | 177 | mColor = phoneAccount.getColor(); |
| Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 178 | mLabel = phoneAccount.getLabel(); |
| 179 | mShortDescription = phoneAccount.getShortDescription(); |
| 180 | mSupportedUriSchemes.addAll(phoneAccount.getSupportedUriSchemes()); |
| Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 181 | } |
| 182 | |
| Santos Cordon | 32c65a5 | 2014-10-27 14:57:49 -0700 | [diff] [blame] | 183 | /** |
| 184 | * Sets the address. See {@link PhoneAccount#getAddress}. |
| 185 | * |
| 186 | * @param value The address of the phone account. |
| 187 | * @return The builder. |
| 188 | */ |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 189 | public Builder setAddress(Uri value) { |
| 190 | this.mAddress = value; |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 191 | return this; |
| 192 | } |
| 193 | |
| Santos Cordon | 32c65a5 | 2014-10-27 14:57:49 -0700 | [diff] [blame] | 194 | /** |
| 195 | * Sets the subscription address. See {@link PhoneAccount#getSubscriptionAddress}. |
| 196 | * |
| 197 | * @param value The subscription address. |
| 198 | * @return The builder. |
| 199 | */ |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 200 | public Builder setSubscriptionAddress(Uri value) { |
| 201 | this.mSubscriptionAddress = value; |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 202 | return this; |
| 203 | } |
| 204 | |
| Santos Cordon | 32c65a5 | 2014-10-27 14:57:49 -0700 | [diff] [blame] | 205 | /** |
| 206 | * Sets the capabilities. See {@link PhoneAccount#getCapabilities}. |
| 207 | * |
| 208 | * @param value The capabilities to set. |
| 209 | * @return The builder. |
| 210 | */ |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 211 | public Builder setCapabilities(int value) { |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 212 | this.mCapabilities = value; |
| 213 | return this; |
| 214 | } |
| 215 | |
| Santos Cordon | 32c65a5 | 2014-10-27 14:57:49 -0700 | [diff] [blame] | 216 | /** |
| 217 | * Sets the icon resource ID. See {@link PhoneAccount#getIconResId}. |
| 218 | * |
| 219 | * @param value The resource ID of the icon. |
| 220 | * @return The builder. |
| 221 | */ |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 222 | public Builder setIconResId(int value) { |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 223 | this.mIconResId = value; |
| 224 | return this; |
| 225 | } |
| 226 | |
| Ihab Awad | 074bf10 | 2014-10-24 11:42:32 -0700 | [diff] [blame] | 227 | /** |
| 228 | * Sets the icon package name. See {@link PhoneAccount#getIconPackageName}. |
| 229 | * |
| 230 | * @param value The name of the package from which to load the icon. |
| 231 | * @return The builder. |
| 232 | */ |
| 233 | public Builder setIconPackageName(String value) { |
| 234 | this.mIconPackageName = value; |
| 235 | return this; |
| 236 | } |
| 237 | |
| 238 | /** |
| 239 | * Sets the icon bitmap. See {@link PhoneAccount#getIconBitmap}. |
| 240 | * |
| 241 | * @param value The icon bitmap. |
| 242 | * @return The builder. |
| 243 | */ |
| 244 | public Builder setIconBitmap(Bitmap value) { |
| 245 | this.mIconBitmap = value; |
| 246 | return this; |
| 247 | } |
| 248 | |
| 249 | /** |
| 250 | * Sets the color. See {@link PhoneAccount#getColor}. |
| 251 | * |
| 252 | * @param value The resource ID of the icon. |
| 253 | * @return The builder. |
| 254 | */ |
| Nancy Chen | 3ace54b | 2014-10-22 17:45:26 -0700 | [diff] [blame] | 255 | public Builder setColor(int value) { |
| 256 | this.mColor = value; |
| 257 | return this; |
| 258 | } |
| 259 | |
| Santos Cordon | 32c65a5 | 2014-10-27 14:57:49 -0700 | [diff] [blame] | 260 | /** |
| 261 | * Sets the short description. See {@link PhoneAccount#getShortDescription}. |
| 262 | * |
| 263 | * @param value The short description. |
| 264 | * @return The builder. |
| 265 | */ |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 266 | public Builder setShortDescription(CharSequence value) { |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 267 | this.mShortDescription = value; |
| 268 | return this; |
| 269 | } |
| 270 | |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 271 | /** |
| 272 | * Specifies an additional URI scheme supported by the {@link PhoneAccount}. |
| 273 | * |
| 274 | * @param uriScheme The URI scheme. |
| Santos Cordon | 32c65a5 | 2014-10-27 14:57:49 -0700 | [diff] [blame] | 275 | * @return The builder. |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 276 | * @hide |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 277 | */ |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 278 | public Builder addSupportedUriScheme(String uriScheme) { |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 279 | if (!TextUtils.isEmpty(uriScheme) && !mSupportedUriSchemes.contains(uriScheme)) { |
| 280 | this.mSupportedUriSchemes.add(uriScheme); |
| 281 | } |
| 282 | return this; |
| 283 | } |
| 284 | |
| 285 | /** |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 286 | * Specifies the URI schemes supported by the {@link PhoneAccount}. |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 287 | * |
| 288 | * @param uriSchemes The URI schemes. |
| Santos Cordon | 32c65a5 | 2014-10-27 14:57:49 -0700 | [diff] [blame] | 289 | * @return The builder. |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 290 | */ |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 291 | public Builder setSupportedUriSchemes(List<String> uriSchemes) { |
| 292 | mSupportedUriSchemes.clear(); |
| 293 | |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 294 | if (uriSchemes != null && !uriSchemes.isEmpty()) { |
| 295 | for (String uriScheme : uriSchemes) { |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 296 | addSupportedUriScheme(uriScheme); |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 297 | } |
| 298 | } |
| 299 | return this; |
| 300 | } |
| 301 | |
| Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 302 | /** |
| Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 303 | * Creates an instance of a {@link PhoneAccount} based on the current builder settings. |
| 304 | * |
| 305 | * @return The {@link PhoneAccount}. |
| 306 | */ |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 307 | public PhoneAccount build() { |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 308 | // If no supported URI schemes were defined, assume "tel" is supported. |
| 309 | if (mSupportedUriSchemes.isEmpty()) { |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 310 | addSupportedUriScheme(SCHEME_TEL); |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 311 | } |
| 312 | |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 313 | return new PhoneAccount( |
| 314 | mAccountHandle, |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 315 | mAddress, |
| 316 | mSubscriptionAddress, |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 317 | mCapabilities, |
| 318 | mIconResId, |
| Ihab Awad | 074bf10 | 2014-10-24 11:42:32 -0700 | [diff] [blame] | 319 | mIconPackageName, |
| 320 | mIconBitmap, |
| Nancy Chen | 3ace54b | 2014-10-22 17:45:26 -0700 | [diff] [blame] | 321 | mColor, |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 322 | mLabel, |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 323 | mShortDescription, |
| Nancy Chen | 210ef03 | 2014-09-15 17:58:42 -0700 | [diff] [blame] | 324 | mSupportedUriSchemes); |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 325 | } |
| 326 | } |
| 327 | |
| 328 | private PhoneAccount( |
| Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 329 | PhoneAccountHandle account, |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 330 | Uri address, |
| 331 | Uri subscriptionAddress, |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 332 | int capabilities, |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 333 | int iconResId, |
| Ihab Awad | 074bf10 | 2014-10-24 11:42:32 -0700 | [diff] [blame] | 334 | String iconPackageName, |
| 335 | Bitmap iconBitmap, |
| Nancy Chen | 3ace54b | 2014-10-22 17:45:26 -0700 | [diff] [blame] | 336 | int color, |
| Santos Cordon | 146a3e3 | 2014-07-21 00:00:44 -0700 | [diff] [blame] | 337 | CharSequence label, |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 338 | CharSequence shortDescription, |
| Nancy Chen | 210ef03 | 2014-09-15 17:58:42 -0700 | [diff] [blame] | 339 | List<String> supportedUriSchemes) { |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 340 | mAccountHandle = account; |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 341 | mAddress = address; |
| 342 | mSubscriptionAddress = subscriptionAddress; |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 343 | mCapabilities = capabilities; |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 344 | mIconResId = iconResId; |
| Ihab Awad | 074bf10 | 2014-10-24 11:42:32 -0700 | [diff] [blame] | 345 | mIconPackageName = iconPackageName; |
| 346 | mIconBitmap = iconBitmap; |
| Nancy Chen | 3ace54b | 2014-10-22 17:45:26 -0700 | [diff] [blame] | 347 | mColor = color; |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 348 | mLabel = label; |
| 349 | mShortDescription = shortDescription; |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 350 | mSupportedUriSchemes = Collections.unmodifiableList(supportedUriSchemes); |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 351 | } |
| 352 | |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 353 | public static Builder builder( |
| 354 | PhoneAccountHandle accountHandle, |
| 355 | CharSequence label) { |
| 356 | return new Builder(accountHandle, label); |
| 357 | } |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 358 | |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 359 | /** |
| Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 360 | * Returns a builder initialized with the current {@link PhoneAccount} instance. |
| 361 | * |
| 362 | * @return The builder. |
| 363 | * @hide |
| 364 | */ |
| 365 | public Builder toBuilder() { return new Builder(this); } |
| 366 | |
| 367 | /** |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 368 | * The unique identifier of this {@code PhoneAccount}. |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 369 | * |
| Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 370 | * @return A {@code PhoneAccountHandle}. |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 371 | */ |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 372 | public PhoneAccountHandle getAccountHandle() { |
| 373 | return mAccountHandle; |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 374 | } |
| 375 | |
| 376 | /** |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 377 | * 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] | 378 | * represents the destination from which outgoing calls using this {@code PhoneAccount} |
| Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 379 | * 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] | 380 | * {@code PhoneAccount} may be addressed. |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 381 | * |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 382 | * @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] | 383 | */ |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 384 | public Uri getAddress() { |
| 385 | return mAddress; |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 386 | } |
| 387 | |
| 388 | /** |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 389 | * The raw callback number used for this {@code PhoneAccount}, as distinct from |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 390 | * {@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] | 391 | * 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] | 392 | * where {@link android.telephony.TelephonyManager#setLine1NumberForDisplay(String, String)} |
| 393 | * has been used to alter the callback number. |
| 394 | * <p> |
| Evan Charlton | 222db525 | 2014-07-17 16:59:18 -0700 | [diff] [blame] | 395 | * |
| 396 | * @return The subscription number, suitable for display to the user. |
| 397 | */ |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 398 | public Uri getSubscriptionAddress() { |
| 399 | return mSubscriptionAddress; |
| Evan Charlton | 222db525 | 2014-07-17 16:59:18 -0700 | [diff] [blame] | 400 | } |
| 401 | |
| 402 | /** |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 403 | * The capabilities of this {@code PhoneAccount}. |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 404 | * |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 405 | * @return A bit field of flags describing this {@code PhoneAccount}'s capabilities. |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 406 | */ |
| 407 | public int getCapabilities() { |
| 408 | return mCapabilities; |
| 409 | } |
| 410 | |
| 411 | /** |
| Tyler Gunn | a1ed7d1 | 2014-09-08 09:52:22 -0700 | [diff] [blame] | 412 | * Determines if this {@code PhoneAccount} has a capabilities specified by the passed in |
| 413 | * bit mask. |
| 414 | * |
| 415 | * @param capability The capabilities to check. |
| 416 | * @return {@code True} if the phone account has the capability. |
| 417 | */ |
| 418 | public boolean hasCapabilities(int capability) { |
| 419 | return (mCapabilities & capability) == capability; |
| 420 | } |
| 421 | |
| 422 | /** |
| Santos Cordon | 146a3e3 | 2014-07-21 00:00:44 -0700 | [diff] [blame] | 423 | * A short label describing a {@code PhoneAccount}. |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 424 | * |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 425 | * @return A label for this {@code PhoneAccount}. |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 426 | */ |
| Santos Cordon | 146a3e3 | 2014-07-21 00:00:44 -0700 | [diff] [blame] | 427 | public CharSequence getLabel() { |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 428 | return mLabel; |
| 429 | } |
| 430 | |
| 431 | /** |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 432 | * A short paragraph describing this {@code PhoneAccount}. |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 433 | * |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 434 | * @return A description for this {@code PhoneAccount}. |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 435 | */ |
| Santos Cordon | 146a3e3 | 2014-07-21 00:00:44 -0700 | [diff] [blame] | 436 | public CharSequence getShortDescription() { |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 437 | return mShortDescription; |
| 438 | } |
| 439 | |
| 440 | /** |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 441 | * The URI schemes supported by this {@code PhoneAccount}. |
| 442 | * |
| 443 | * @return The URI schemes. |
| 444 | */ |
| 445 | public List<String> getSupportedUriSchemes() { |
| 446 | return mSupportedUriSchemes; |
| 447 | } |
| 448 | |
| 449 | /** |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 450 | * 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] | 451 | * scheme. |
| 452 | * |
| 453 | * @param uriScheme The URI scheme to check. |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 454 | * @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] | 455 | * specified URI scheme. |
| 456 | */ |
| 457 | public boolean supportsUriScheme(String uriScheme) { |
| 458 | if (mSupportedUriSchemes == null || uriScheme == null) { |
| 459 | return false; |
| 460 | } |
| 461 | |
| 462 | for (String scheme : mSupportedUriSchemes) { |
| 463 | if (scheme != null && scheme.equals(uriScheme)) { |
| 464 | return true; |
| 465 | } |
| 466 | } |
| 467 | return false; |
| 468 | } |
| 469 | |
| 470 | /** |
| Ihab Awad | 074bf10 | 2014-10-24 11:42:32 -0700 | [diff] [blame] | 471 | * The icon resource ID for the icon of this {@code PhoneAccount}. |
| 472 | * <p> |
| 473 | * Creators of a {@code PhoneAccount} who possess the icon in static resources should prefer |
| 474 | * this method of indicating the icon rather than using {@link #getIconBitmap()}, since it |
| 475 | * leads to less resource usage. |
| 476 | * <p> |
| 477 | * Clients wishing to display a {@code PhoneAccount} should use {@link #getIcon(Context)}. |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 478 | * |
| 479 | * @return A resource ID. |
| 480 | */ |
| 481 | public int getIconResId() { |
| 482 | return mIconResId; |
| 483 | } |
| 484 | |
| 485 | /** |
| Ihab Awad | 074bf10 | 2014-10-24 11:42:32 -0700 | [diff] [blame] | 486 | * The package name from which to load the icon of this {@code PhoneAccount}. |
| 487 | * <p> |
| 488 | * If this property is {@code null}, the resource {@link #getIconResId()} will be loaded from |
| 489 | * the package in the {@link ComponentName} of the {@link #getAccountHandle()}. |
| 490 | * <p> |
| 491 | * Clients wishing to display a {@code PhoneAccount} should use {@link #getIcon(Context)}. |
| 492 | * |
| 493 | * @return A package name. |
| 494 | */ |
| 495 | public String getIconPackageName() { |
| 496 | return mIconPackageName; |
| 497 | } |
| 498 | |
| 499 | /** |
| Nancy Chen | 3ace54b | 2014-10-22 17:45:26 -0700 | [diff] [blame] | 500 | * A highlight color to use in displaying information about this {@code PhoneAccount}. |
| 501 | * |
| 502 | * @return A hexadecimal color value. |
| 503 | */ |
| 504 | public int getColor() { |
| 505 | return mColor; |
| 506 | } |
| 507 | |
| 508 | /** |
| Ihab Awad | 074bf10 | 2014-10-24 11:42:32 -0700 | [diff] [blame] | 509 | * A literal icon bitmap to represent this {@code PhoneAccount} in a user interface. |
| 510 | * <p> |
| 511 | * If this property is specified, it is to be considered the preferred icon. Otherwise, the |
| 512 | * resource specified by {@link #getIconResId()} should be used. |
| 513 | * <p> |
| 514 | * Clients wishing to display a {@code PhoneAccount} should use {@link #getIcon(Context)}. |
| 515 | * |
| 516 | * @return A bitmap. |
| 517 | */ |
| 518 | public Bitmap getIconBitmap() { |
| 519 | return mIconBitmap; |
| 520 | } |
| 521 | |
| 522 | /** |
| 523 | * Builds and returns an icon {@code Drawable} to represent this {@code PhoneAccount} in a user |
| 524 | * interface. Uses the properties {@link #getIconResId()}, {@link #getIconPackageName()}, and |
| 525 | * {@link #getIconBitmap()} as necessary. |
| 526 | * |
| 527 | * @param context A {@code Context} to use for loading {@code Drawable}s. |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 528 | * |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 529 | * @return An icon for this {@code PhoneAccount}. |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 530 | */ |
| 531 | public Drawable getIcon(Context context) { |
| Ihab Awad | 074bf10 | 2014-10-24 11:42:32 -0700 | [diff] [blame] | 532 | if (mIconBitmap != null) { |
| 533 | return new BitmapDrawable(context.getResources(), mIconBitmap); |
| Sailesh Nepal | 77780a4 | 2014-09-26 18:12:00 -0700 | [diff] [blame] | 534 | } |
| 535 | |
| Ihab Awad | 074bf10 | 2014-10-24 11:42:32 -0700 | [diff] [blame] | 536 | if (mIconResId != 0) { |
| 537 | String packageName = mIconPackageName == null |
| 538 | ? mAccountHandle.getComponentName().getPackageName() |
| 539 | : mIconPackageName; |
| 540 | |
| 541 | try { |
| 542 | Context packageContext = context.createPackageContext(packageName, 0); |
| 543 | try { |
| 544 | return packageContext.getDrawable(mIconResId); |
| 545 | } catch (NotFoundException | MissingResourceException e) { |
| 546 | Log.e(this, e, "Cannot find icon %d in package %s", mIconResId, packageName); |
| 547 | } |
| 548 | } catch (PackageManager.NameNotFoundException e) { |
| 549 | Log.w(this, "Cannot find package %s", packageName); |
| 550 | } |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 551 | } |
| Ihab Awad | 074bf10 | 2014-10-24 11:42:32 -0700 | [diff] [blame] | 552 | |
| 553 | return new ColorDrawable(Color.TRANSPARENT); |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 554 | } |
| 555 | |
| 556 | // |
| 557 | // Parcelable implementation |
| 558 | // |
| 559 | |
| 560 | @Override |
| 561 | public int describeContents() { |
| 562 | return 0; |
| 563 | } |
| 564 | |
| 565 | @Override |
| 566 | public void writeToParcel(Parcel out, int flags) { |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 567 | out.writeParcelable(mAccountHandle, 0); |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 568 | out.writeParcelable(mAddress, 0); |
| 569 | out.writeParcelable(mSubscriptionAddress, 0); |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 570 | out.writeInt(mCapabilities); |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 571 | out.writeInt(mIconResId); |
| Ihab Awad | 074bf10 | 2014-10-24 11:42:32 -0700 | [diff] [blame] | 572 | out.writeString(mIconPackageName); |
| 573 | out.writeParcelable(mIconBitmap, 0); |
| Nancy Chen | 3ace54b | 2014-10-22 17:45:26 -0700 | [diff] [blame] | 574 | out.writeInt(mColor); |
| Santos Cordon | 146a3e3 | 2014-07-21 00:00:44 -0700 | [diff] [blame] | 575 | out.writeCharSequence(mLabel); |
| 576 | out.writeCharSequence(mShortDescription); |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 577 | out.writeList(mSupportedUriSchemes); |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 578 | } |
| 579 | |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 580 | public static final Creator<PhoneAccount> CREATOR |
| 581 | = new Creator<PhoneAccount>() { |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 582 | @Override |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 583 | public PhoneAccount createFromParcel(Parcel in) { |
| 584 | return new PhoneAccount(in); |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 585 | } |
| 586 | |
| 587 | @Override |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 588 | public PhoneAccount[] newArray(int size) { |
| 589 | return new PhoneAccount[size]; |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 590 | } |
| 591 | }; |
| 592 | |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 593 | private PhoneAccount(Parcel in) { |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 594 | ClassLoader classLoader = PhoneAccount.class.getClassLoader(); |
| 595 | |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 596 | mAccountHandle = in.readParcelable(getClass().getClassLoader()); |
| Andrew Lee | 3085a6c | 2014-09-04 10:59:13 -0700 | [diff] [blame] | 597 | mAddress = in.readParcelable(getClass().getClassLoader()); |
| 598 | mSubscriptionAddress = in.readParcelable(getClass().getClassLoader()); |
| Ihab Awad | 94cf4bf | 2014-07-17 11:21:19 -0700 | [diff] [blame] | 599 | mCapabilities = in.readInt(); |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 600 | mIconResId = in.readInt(); |
| Ihab Awad | 074bf10 | 2014-10-24 11:42:32 -0700 | [diff] [blame] | 601 | mIconPackageName = in.readString(); |
| 602 | mIconBitmap = in.readParcelable(getClass().getClassLoader()); |
| Nancy Chen | 3ace54b | 2014-10-22 17:45:26 -0700 | [diff] [blame] | 603 | mColor = in.readInt(); |
| Santos Cordon | 146a3e3 | 2014-07-21 00:00:44 -0700 | [diff] [blame] | 604 | mLabel = in.readCharSequence(); |
| 605 | mShortDescription = in.readCharSequence(); |
| Tyler Gunn | f5b29dc | 2014-09-03 09:09:12 -0700 | [diff] [blame] | 606 | |
| 607 | List<String> supportedUriSchemes = new ArrayList<>(); |
| 608 | in.readList(supportedUriSchemes, classLoader); |
| 609 | mSupportedUriSchemes = Collections.unmodifiableList(supportedUriSchemes); |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 610 | } |
| Tyler Gunn | 76c01a5 | 2014-09-30 14:47:51 -0700 | [diff] [blame] | 611 | |
| 612 | @Override |
| 613 | public String toString() { |
| 614 | StringBuilder sb = new StringBuilder().append("[PhoneAccount: ") |
| 615 | .append(mAccountHandle) |
| 616 | .append(" Capabilities: ") |
| 617 | .append(mCapabilities) |
| 618 | .append(" Schemes: "); |
| 619 | for (String scheme : mSupportedUriSchemes) { |
| 620 | sb.append(scheme) |
| 621 | .append(" "); |
| 622 | } |
| 623 | sb.append("]"); |
| 624 | return sb.toString(); |
| 625 | } |
| Ihab Awad | 807fe0a | 2014-07-09 12:30:52 -0700 | [diff] [blame] | 626 | } |