blob: 1d6d8bcc11472c7c1a79b903daeb20ccb144589c [file] [log] [blame]
Ihab Awad807fe0a2014-07-09 12:30:52 -07001/*
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 Gunnef9f6f92014-09-12 22:16:17 -070017package android.telecom;
Ihab Awad807fe0a2014-07-09 12:30:52 -070018
Tyler Gunn711d876fd2014-09-19 11:17:02 -070019import android.annotation.SystemApi;
Ihab Awad807fe0a2014-07-09 12:30:52 -070020import android.content.Context;
21import android.content.pm.PackageManager;
Santos Cordone8dc4be2014-07-21 01:28:28 -070022import android.content.res.Resources.NotFoundException;
Ihab Awad807fe0a2014-07-09 12:30:52 -070023import android.graphics.drawable.Drawable;
Ihab Awad94cf4bf2014-07-17 11:21:19 -070024import android.net.Uri;
Ihab Awad807fe0a2014-07-09 12:30:52 -070025import android.os.Parcel;
26import android.os.Parcelable;
Tyler Gunnf5b29dc2014-09-03 09:09:12 -070027import android.text.TextUtils;
Ihab Awad807fe0a2014-07-09 12:30:52 -070028
Tyler Gunnf5b29dc2014-09-03 09:09:12 -070029import java.lang.String;
30import java.util.ArrayList;
31import java.util.Collections;
32import java.util.List;
Ihab Awad807fe0a2014-07-09 12:30:52 -070033import java.util.MissingResourceException;
34
35/**
Ihab Awadb19a0bc2014-08-07 19:46:01 -070036 * Describes a distinct account, line of service or call placement method that the system
37 * can use to place phone calls.
Tyler Gunn711d876fd2014-09-19 11:17:02 -070038 * @hide
Ihab Awad807fe0a2014-07-09 12:30:52 -070039 */
Tyler Gunn711d876fd2014-09-19 11:17:02 -070040@SystemApi
Evan Charlton8c8a0622014-07-20 12:31:00 -070041public class PhoneAccount implements Parcelable {
Ihab Awad94cf4bf2014-07-17 11:21:19 -070042
43 /**
Ihab Awadf8b69882014-07-25 15:14:01 -070044 * Flag indicating that this {@code PhoneAccount} can act as a connection manager for
45 * other connections. The {@link ConnectionService} associated with this {@code PhoneAccount}
46 * will be allowed to manage phone calls including using its own proprietary phone-call
47 * implementation (like VoIP calling) to make calls instead of the telephony stack.
48 * <p>
Ihab Awadb19a0bc2014-08-07 19:46:01 -070049 * When a user opts to place a call using the SIM-based telephony stack, the
50 * {@link ConnectionService} associated with this {@code PhoneAccount} will be attempted first
51 * if the user has explicitly selected it to be used as the default connection manager.
Ihab Awad94cf4bf2014-07-17 11:21:19 -070052 * <p>
53 * See {@link #getCapabilities}
54 */
Ihab Awadf8b69882014-07-25 15:14:01 -070055 public static final int CAPABILITY_CONNECTION_MANAGER = 0x1;
Ihab Awad94cf4bf2014-07-17 11:21:19 -070056
57 /**
Evan Charlton8c8a0622014-07-20 12:31:00 -070058 * Flag indicating that this {@code PhoneAccount} can make phone calls in place of
Evan Charlton6eb262c2014-07-19 18:18:19 -070059 * traditional SIM-based telephony calls. This account will be treated as a distinct method
60 * for placing calls alongside the traditional SIM-based telephony stack. This flag is
Ihab Awadf8b69882014-07-25 15:14:01 -070061 * distinct from {@link #CAPABILITY_CONNECTION_MANAGER} in that it is not allowed to manage
Evan Charlton6eb262c2014-07-19 18:18:19 -070062 * calls from or use the built-in telephony stack to place its calls.
Ihab Awad94cf4bf2014-07-17 11:21:19 -070063 * <p>
64 * See {@link #getCapabilities}
Ihab Awadb19a0bc2014-08-07 19:46:01 -070065 * <p>
Evan Charlton7800fb72014-07-20 18:09:38 -070066 * {@hide}
Ihab Awad94cf4bf2014-07-17 11:21:19 -070067 */
68 public static final int CAPABILITY_CALL_PROVIDER = 0x2;
69
Ihab Awad7522bbd2014-07-18 15:53:17 -070070 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -070071 * Flag indicating that this {@code PhoneAccount} represents a built-in PSTN SIM
Evan Charlton6eb262c2014-07-19 18:18:19 -070072 * subscription.
Ihab Awad7522bbd2014-07-18 15:53:17 -070073 * <p>
Ihab Awadb19a0bc2014-08-07 19:46:01 -070074 * Only the Android framework can register a {@code PhoneAccount} having this capability.
75 * <p>
76 * See {@link #getCapabilities}
Ihab Awad7522bbd2014-07-18 15:53:17 -070077 */
78 public static final int CAPABILITY_SIM_SUBSCRIPTION = 0x4;
79
Ihab Awadf8b69882014-07-25 15:14:01 -070080 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -070081 * Flag indicating that this {@code PhoneAccount} is capable of placing video calls.
82 * <p>
83 * See {@link #getCapabilities}
Tyler Gunnbe74de02014-08-29 14:51:48 -070084 * @hide
Ihab Awadf8b69882014-07-25 15:14:01 -070085 */
86 public static final int CAPABILITY_VIDEO_CALLING = 0x8;
87
Tyler Gunnf5b29dc2014-09-03 09:09:12 -070088 /**
Tyler Gunna1ed7d12014-09-08 09:52:22 -070089 * Flag indicating that this {@code PhoneAccount} is capable of placing emergency calls.
90 * By default all PSTN {@code PhoneAccount}s are capable of placing emergency calls.
91 * <p>
92 * See {@link #getCapabilities}
93 */
94 public static final int CAPABILITY_PLACE_EMERGENCY_CALLS = 0x10;
95
96 /**
Tyler Gunnf5b29dc2014-09-03 09:09:12 -070097 * URI scheme for telephone number URIs.
98 */
99 public static final String SCHEME_TEL = "tel";
100
101 /**
102 * URI scheme for voicemail URIs.
103 */
104 public static final String SCHEME_VOICEMAIL = "voicemail";
105
106 /**
107 * URI scheme for SIP URIs.
108 */
109 public static final String SCHEME_SIP = "sip";
110
Evan Charlton8c8a0622014-07-20 12:31:00 -0700111 private final PhoneAccountHandle mAccountHandle;
Andrew Lee3085a6c2014-09-04 10:59:13 -0700112 private final Uri mAddress;
113 private final Uri mSubscriptionAddress;
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700114 private final int mCapabilities;
115 private final int mIconResId;
Santos Cordon146a3e32014-07-21 00:00:44 -0700116 private final CharSequence mLabel;
117 private final CharSequence mShortDescription;
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700118 private final List<String> mSupportedUriSchemes;
Ihab Awad807fe0a2014-07-09 12:30:52 -0700119
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700120 public static class Builder {
121 private PhoneAccountHandle mAccountHandle;
Andrew Lee3085a6c2014-09-04 10:59:13 -0700122 private Uri mAddress;
123 private Uri mSubscriptionAddress;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700124 private int mCapabilities;
125 private int mIconResId;
126 private CharSequence mLabel;
127 private CharSequence mShortDescription;
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700128 private List<String> mSupportedUriSchemes = new ArrayList<String>();
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700129
Andrew Lee3085a6c2014-09-04 10:59:13 -0700130 public Builder(PhoneAccountHandle accountHandle, CharSequence label) {
131 this.mAccountHandle = accountHandle;
132 this.mLabel = label;
133 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700134
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700135 /**
136 * Creates an instance of the {@link PhoneAccount.Builder} from an existing
137 * {@link PhoneAccount}.
138 *
139 * @param phoneAccount The {@link PhoneAccount} used to initialize the builder.
140 */
141 public Builder(PhoneAccount phoneAccount) {
142 mAccountHandle = phoneAccount.getAccountHandle();
143 mAddress = phoneAccount.getAddress();
144 mSubscriptionAddress = phoneAccount.getSubscriptionAddress();
145 mCapabilities = phoneAccount.getCapabilities();
146 mIconResId = phoneAccount.getIconResId();
147 mLabel = phoneAccount.getLabel();
148 mShortDescription = phoneAccount.getShortDescription();
149 mSupportedUriSchemes.addAll(phoneAccount.getSupportedUriSchemes());
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700150 }
151
Andrew Lee3085a6c2014-09-04 10:59:13 -0700152 public Builder setAddress(Uri value) {
153 this.mAddress = value;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700154 return this;
155 }
156
Andrew Lee3085a6c2014-09-04 10:59:13 -0700157 public Builder setSubscriptionAddress(Uri value) {
158 this.mSubscriptionAddress = value;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700159 return this;
160 }
161
Andrew Lee3085a6c2014-09-04 10:59:13 -0700162 public Builder setCapabilities(int value) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700163 this.mCapabilities = value;
164 return this;
165 }
166
Andrew Lee3085a6c2014-09-04 10:59:13 -0700167 public Builder setIconResId(int value) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700168 this.mIconResId = value;
169 return this;
170 }
171
Andrew Lee3085a6c2014-09-04 10:59:13 -0700172 public Builder setShortDescription(CharSequence value) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700173 this.mShortDescription = value;
174 return this;
175 }
176
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700177 /**
178 * Specifies an additional URI scheme supported by the {@link PhoneAccount}.
179 *
180 * @param uriScheme The URI scheme.
181 * @return The Builder.
Andrew Lee3085a6c2014-09-04 10:59:13 -0700182 * @hide
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700183 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700184 public Builder addSupportedUriScheme(String uriScheme) {
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700185 if (!TextUtils.isEmpty(uriScheme) && !mSupportedUriSchemes.contains(uriScheme)) {
186 this.mSupportedUriSchemes.add(uriScheme);
187 }
188 return this;
189 }
190
191 /**
Andrew Lee3085a6c2014-09-04 10:59:13 -0700192 * Specifies the URI schemes supported by the {@link PhoneAccount}.
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700193 *
194 * @param uriSchemes The URI schemes.
195 * @return The Builder.
196 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700197 public Builder setSupportedUriSchemes(List<String> uriSchemes) {
198 mSupportedUriSchemes.clear();
199
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700200 if (uriSchemes != null && !uriSchemes.isEmpty()) {
201 for (String uriScheme : uriSchemes) {
Andrew Lee3085a6c2014-09-04 10:59:13 -0700202 addSupportedUriScheme(uriScheme);
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700203 }
204 }
205 return this;
206 }
207
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700208 /**
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700209 * Creates an instance of a {@link PhoneAccount} based on the current builder settings.
210 *
211 * @return The {@link PhoneAccount}.
212 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700213 public PhoneAccount build() {
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700214 // If no supported URI schemes were defined, assume "tel" is supported.
215 if (mSupportedUriSchemes.isEmpty()) {
Andrew Lee3085a6c2014-09-04 10:59:13 -0700216 addSupportedUriScheme(SCHEME_TEL);
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700217 }
218
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700219 return new PhoneAccount(
220 mAccountHandle,
Andrew Lee3085a6c2014-09-04 10:59:13 -0700221 mAddress,
222 mSubscriptionAddress,
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700223 mCapabilities,
224 mIconResId,
225 mLabel,
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700226 mShortDescription,
Nancy Chen210ef032014-09-15 17:58:42 -0700227 mSupportedUriSchemes);
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700228 }
229 }
230
231 private PhoneAccount(
Evan Charlton6eb262c2014-07-19 18:18:19 -0700232 PhoneAccountHandle account,
Andrew Lee3085a6c2014-09-04 10:59:13 -0700233 Uri address,
234 Uri subscriptionAddress,
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700235 int capabilities,
Ihab Awad807fe0a2014-07-09 12:30:52 -0700236 int iconResId,
Santos Cordon146a3e32014-07-21 00:00:44 -0700237 CharSequence label,
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700238 CharSequence shortDescription,
Nancy Chen210ef032014-09-15 17:58:42 -0700239 List<String> supportedUriSchemes) {
Evan Charlton8c8a0622014-07-20 12:31:00 -0700240 mAccountHandle = account;
Andrew Lee3085a6c2014-09-04 10:59:13 -0700241 mAddress = address;
242 mSubscriptionAddress = subscriptionAddress;
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700243 mCapabilities = capabilities;
Ihab Awad807fe0a2014-07-09 12:30:52 -0700244 mIconResId = iconResId;
245 mLabel = label;
246 mShortDescription = shortDescription;
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700247 mSupportedUriSchemes = Collections.unmodifiableList(supportedUriSchemes);
Ihab Awad807fe0a2014-07-09 12:30:52 -0700248 }
249
Andrew Lee3085a6c2014-09-04 10:59:13 -0700250 public static Builder builder(
251 PhoneAccountHandle accountHandle,
252 CharSequence label) {
253 return new Builder(accountHandle, label);
254 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700255
Ihab Awad807fe0a2014-07-09 12:30:52 -0700256 /**
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700257 * Returns a builder initialized with the current {@link PhoneAccount} instance.
258 *
259 * @return The builder.
260 * @hide
261 */
262 public Builder toBuilder() { return new Builder(this); }
263
264 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700265 * The unique identifier of this {@code PhoneAccount}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700266 *
Evan Charlton6eb262c2014-07-19 18:18:19 -0700267 * @return A {@code PhoneAccountHandle}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700268 */
Evan Charlton8c8a0622014-07-20 12:31:00 -0700269 public PhoneAccountHandle getAccountHandle() {
270 return mAccountHandle;
Ihab Awad807fe0a2014-07-09 12:30:52 -0700271 }
272
273 /**
Andrew Lee3085a6c2014-09-04 10:59:13 -0700274 * The address (e.g., a phone number) associated with this {@code PhoneAccount}. This
Evan Charlton8c8a0622014-07-20 12:31:00 -0700275 * represents the destination from which outgoing calls using this {@code PhoneAccount}
Evan Charlton6eb262c2014-07-19 18:18:19 -0700276 * will appear to come, if applicable, and the destination to which incoming calls using this
Evan Charlton8c8a0622014-07-20 12:31:00 -0700277 * {@code PhoneAccount} may be addressed.
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700278 *
Andrew Lee3085a6c2014-09-04 10:59:13 -0700279 * @return A address expressed as a {@code Uri}, for example, a phone number.
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700280 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700281 public Uri getAddress() {
282 return mAddress;
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700283 }
284
285 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700286 * The raw callback number used for this {@code PhoneAccount}, as distinct from
Andrew Lee3085a6c2014-09-04 10:59:13 -0700287 * {@link #getAddress()}. For the majority of {@code PhoneAccount}s this should be registered
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700288 * as {@code null}. It is used by the system for SIM-based {@code PhoneAccount} registration
Evan Charlton222db522014-07-17 16:59:18 -0700289 *
290 * @return The subscription number, suitable for display to the user.
291 */
Andrew Lee3085a6c2014-09-04 10:59:13 -0700292 public Uri getSubscriptionAddress() {
293 return mSubscriptionAddress;
Evan Charlton222db522014-07-17 16:59:18 -0700294 }
295
296 /**
Evan Charlton8c8a0622014-07-20 12:31:00 -0700297 * The capabilities of this {@code PhoneAccount}.
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700298 *
Evan Charlton8c8a0622014-07-20 12:31:00 -0700299 * @return A bit field of flags describing this {@code PhoneAccount}'s capabilities.
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700300 */
301 public int getCapabilities() {
302 return mCapabilities;
303 }
304
305 /**
Tyler Gunna1ed7d12014-09-08 09:52:22 -0700306 * Determines if this {@code PhoneAccount} has a capabilities specified by the passed in
307 * bit mask.
308 *
309 * @param capability The capabilities to check.
310 * @return {@code True} if the phone account has the capability.
311 */
312 public boolean hasCapabilities(int capability) {
313 return (mCapabilities & capability) == capability;
314 }
315
316 /**
Santos Cordon146a3e32014-07-21 00:00:44 -0700317 * A short label describing a {@code PhoneAccount}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700318 *
Evan Charlton8c8a0622014-07-20 12:31:00 -0700319 * @return A label for this {@code PhoneAccount}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700320 */
Santos Cordon146a3e32014-07-21 00:00:44 -0700321 public CharSequence getLabel() {
Ihab Awad807fe0a2014-07-09 12:30:52 -0700322 return mLabel;
323 }
324
325 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700326 * A short paragraph describing this {@code PhoneAccount}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700327 *
Evan Charlton8c8a0622014-07-20 12:31:00 -0700328 * @return A description for this {@code PhoneAccount}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700329 */
Santos Cordon146a3e32014-07-21 00:00:44 -0700330 public CharSequence getShortDescription() {
Ihab Awad807fe0a2014-07-09 12:30:52 -0700331 return mShortDescription;
332 }
333
334 /**
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700335 * The URI schemes supported by this {@code PhoneAccount}.
336 *
337 * @return The URI schemes.
338 */
339 public List<String> getSupportedUriSchemes() {
340 return mSupportedUriSchemes;
341 }
342
343 /**
Andrew Lee3085a6c2014-09-04 10:59:13 -0700344 * Determines if the {@link PhoneAccount} supports calls to/from addresses with a specified URI
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700345 * scheme.
346 *
347 * @param uriScheme The URI scheme to check.
Andrew Lee3085a6c2014-09-04 10:59:13 -0700348 * @return {@code True} if the {@code PhoneAccount} supports calls to/from addresses with the
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700349 * specified URI scheme.
350 */
351 public boolean supportsUriScheme(String uriScheme) {
352 if (mSupportedUriSchemes == null || uriScheme == null) {
353 return false;
354 }
355
356 for (String scheme : mSupportedUriSchemes) {
357 if (scheme != null && scheme.equals(uriScheme)) {
358 return true;
359 }
360 }
361 return false;
362 }
363
364 /**
Evan Charlton8c8a0622014-07-20 12:31:00 -0700365 * The icon resource ID for the icon of this {@code PhoneAccount}.
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700366 *
367 * @return A resource ID.
368 */
369 public int getIconResId() {
370 return mIconResId;
371 }
372
373 /**
Evan Charlton8c8a0622014-07-20 12:31:00 -0700374 * An icon to represent this {@code PhoneAccount} in a user interface.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700375 *
Evan Charlton8c8a0622014-07-20 12:31:00 -0700376 * @return An icon for this {@code PhoneAccount}.
Ihab Awad807fe0a2014-07-09 12:30:52 -0700377 */
378 public Drawable getIcon(Context context) {
379 return getIcon(context, mIconResId);
380 }
381
382 private Drawable getIcon(Context context, int resId) {
383 Context packageContext;
384 try {
385 packageContext = context.createPackageContext(
Evan Charlton8c8a0622014-07-20 12:31:00 -0700386 mAccountHandle.getComponentName().getPackageName(), 0);
Ihab Awad807fe0a2014-07-09 12:30:52 -0700387 } catch (PackageManager.NameNotFoundException e) {
Evan Charlton8c8a0622014-07-20 12:31:00 -0700388 Log.w(this, "Cannot find package %s", mAccountHandle.getComponentName().getPackageName());
Ihab Awad807fe0a2014-07-09 12:30:52 -0700389 return null;
390 }
391 try {
Alan Viverette03d30a52014-08-14 12:59:10 -0700392 return packageContext.getDrawable(resId);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700393 } catch (NotFoundException|MissingResourceException e) {
Ihab Awad807fe0a2014-07-09 12:30:52 -0700394 Log.e(this, e, "Cannot find icon %d in package %s",
Evan Charlton8c8a0622014-07-20 12:31:00 -0700395 resId, mAccountHandle.getComponentName().getPackageName());
Ihab Awad807fe0a2014-07-09 12:30:52 -0700396 return null;
397 }
398 }
399
400 //
401 // Parcelable implementation
402 //
403
404 @Override
405 public int describeContents() {
406 return 0;
407 }
408
409 @Override
410 public void writeToParcel(Parcel out, int flags) {
Evan Charlton8c8a0622014-07-20 12:31:00 -0700411 out.writeParcelable(mAccountHandle, 0);
Andrew Lee3085a6c2014-09-04 10:59:13 -0700412 out.writeParcelable(mAddress, 0);
413 out.writeParcelable(mSubscriptionAddress, 0);
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700414 out.writeInt(mCapabilities);
Ihab Awad807fe0a2014-07-09 12:30:52 -0700415 out.writeInt(mIconResId);
Santos Cordon146a3e32014-07-21 00:00:44 -0700416 out.writeCharSequence(mLabel);
417 out.writeCharSequence(mShortDescription);
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700418 out.writeList(mSupportedUriSchemes);
Ihab Awad807fe0a2014-07-09 12:30:52 -0700419 }
420
Evan Charlton8c8a0622014-07-20 12:31:00 -0700421 public static final Creator<PhoneAccount> CREATOR
422 = new Creator<PhoneAccount>() {
Ihab Awad807fe0a2014-07-09 12:30:52 -0700423 @Override
Evan Charlton8c8a0622014-07-20 12:31:00 -0700424 public PhoneAccount createFromParcel(Parcel in) {
425 return new PhoneAccount(in);
Ihab Awad807fe0a2014-07-09 12:30:52 -0700426 }
427
428 @Override
Evan Charlton8c8a0622014-07-20 12:31:00 -0700429 public PhoneAccount[] newArray(int size) {
430 return new PhoneAccount[size];
Ihab Awad807fe0a2014-07-09 12:30:52 -0700431 }
432 };
433
Evan Charlton8c8a0622014-07-20 12:31:00 -0700434 private PhoneAccount(Parcel in) {
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700435 ClassLoader classLoader = PhoneAccount.class.getClassLoader();
436
Evan Charlton8c8a0622014-07-20 12:31:00 -0700437 mAccountHandle = in.readParcelable(getClass().getClassLoader());
Andrew Lee3085a6c2014-09-04 10:59:13 -0700438 mAddress = in.readParcelable(getClass().getClassLoader());
439 mSubscriptionAddress = in.readParcelable(getClass().getClassLoader());
Ihab Awad94cf4bf2014-07-17 11:21:19 -0700440 mCapabilities = in.readInt();
Ihab Awad807fe0a2014-07-09 12:30:52 -0700441 mIconResId = in.readInt();
Santos Cordon146a3e32014-07-21 00:00:44 -0700442 mLabel = in.readCharSequence();
443 mShortDescription = in.readCharSequence();
Tyler Gunnf5b29dc2014-09-03 09:09:12 -0700444
445 List<String> supportedUriSchemes = new ArrayList<>();
446 in.readList(supportedUriSchemes, classLoader);
447 mSupportedUriSchemes = Collections.unmodifiableList(supportedUriSchemes);
Ihab Awad807fe0a2014-07-09 12:30:52 -0700448 }
449}