2014-07-09 12:30:52 -07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2014-09-12 22:16:17 -07:00
|
|
|
package android.telecom;
|
2014-07-09 12:30:52 -07:00
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.pm.PackageManager;
|
2014-07-21 01:28:28 -07:00
|
|
|
import android.content.res.Resources.NotFoundException;
|
2014-07-09 12:30:52 -07:00
|
|
|
import android.graphics.drawable.Drawable;
|
2014-07-17 11:21:19 -07:00
|
|
|
import android.net.Uri;
|
2014-07-09 12:30:52 -07:00
|
|
|
import android.os.Parcel;
|
|
|
|
import android.os.Parcelable;
|
2014-09-03 09:09:12 -07:00
|
|
|
import android.text.TextUtils;
|
2014-07-09 12:30:52 -07:00
|
|
|
|
2014-09-03 09:09:12 -07:00
|
|
|
import java.lang.String;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
2014-07-09 12:30:52 -07:00
|
|
|
import java.util.MissingResourceException;
|
|
|
|
|
|
|
|
/**
|
2014-08-07 19:46:01 -07:00
|
|
|
* Describes a distinct account, line of service or call placement method that the system
|
|
|
|
* can use to place phone calls.
|
2014-07-09 12:30:52 -07:00
|
|
|
*/
|
2014-07-20 12:31:00 -07:00
|
|
|
public class PhoneAccount implements Parcelable {
|
2014-07-17 11:21:19 -07:00
|
|
|
|
|
|
|
/**
|
2014-07-25 15:14:01 -07:00
|
|
|
* Flag indicating that this {@code PhoneAccount} can act as a connection manager for
|
|
|
|
* other connections. The {@link ConnectionService} associated with this {@code PhoneAccount}
|
|
|
|
* will be allowed to manage phone calls including using its own proprietary phone-call
|
|
|
|
* implementation (like VoIP calling) to make calls instead of the telephony stack.
|
|
|
|
* <p>
|
2014-08-07 19:46:01 -07:00
|
|
|
* When a user opts to place a call using the SIM-based telephony stack, the
|
|
|
|
* {@link ConnectionService} associated with this {@code PhoneAccount} will be attempted first
|
|
|
|
* if the user has explicitly selected it to be used as the default connection manager.
|
2014-07-17 11:21:19 -07:00
|
|
|
* <p>
|
|
|
|
* See {@link #getCapabilities}
|
|
|
|
*/
|
2014-07-25 15:14:01 -07:00
|
|
|
public static final int CAPABILITY_CONNECTION_MANAGER = 0x1;
|
2014-07-17 11:21:19 -07:00
|
|
|
|
|
|
|
/**
|
2014-07-20 12:31:00 -07:00
|
|
|
* Flag indicating that this {@code PhoneAccount} can make phone calls in place of
|
2014-07-19 18:18:19 -07:00
|
|
|
* traditional SIM-based telephony calls. This account will be treated as a distinct method
|
|
|
|
* for placing calls alongside the traditional SIM-based telephony stack. This flag is
|
2014-07-25 15:14:01 -07:00
|
|
|
* distinct from {@link #CAPABILITY_CONNECTION_MANAGER} in that it is not allowed to manage
|
2014-07-19 18:18:19 -07:00
|
|
|
* calls from or use the built-in telephony stack to place its calls.
|
2014-07-17 11:21:19 -07:00
|
|
|
* <p>
|
|
|
|
* See {@link #getCapabilities}
|
2014-08-07 19:46:01 -07:00
|
|
|
* <p>
|
2014-07-20 18:09:38 -07:00
|
|
|
* {@hide}
|
2014-07-17 11:21:19 -07:00
|
|
|
*/
|
|
|
|
public static final int CAPABILITY_CALL_PROVIDER = 0x2;
|
|
|
|
|
2014-07-18 15:53:17 -07:00
|
|
|
/**
|
2014-08-07 19:46:01 -07:00
|
|
|
* Flag indicating that this {@code PhoneAccount} represents a built-in PSTN SIM
|
2014-07-19 18:18:19 -07:00
|
|
|
* subscription.
|
2014-07-18 15:53:17 -07:00
|
|
|
* <p>
|
2014-08-07 19:46:01 -07:00
|
|
|
* Only the Android framework can register a {@code PhoneAccount} having this capability.
|
|
|
|
* <p>
|
|
|
|
* See {@link #getCapabilities}
|
2014-07-18 15:53:17 -07:00
|
|
|
*/
|
|
|
|
public static final int CAPABILITY_SIM_SUBSCRIPTION = 0x4;
|
|
|
|
|
2014-07-25 15:14:01 -07:00
|
|
|
/**
|
2014-08-07 19:46:01 -07:00
|
|
|
* Flag indicating that this {@code PhoneAccount} is capable of placing video calls.
|
|
|
|
* <p>
|
|
|
|
* See {@link #getCapabilities}
|
2014-08-29 14:51:48 -07:00
|
|
|
* @hide
|
2014-07-25 15:14:01 -07:00
|
|
|
*/
|
|
|
|
public static final int CAPABILITY_VIDEO_CALLING = 0x8;
|
|
|
|
|
2014-09-08 09:52:22 -07:00
|
|
|
/**
|
|
|
|
* Flag indicating that this {@code PhoneAccount} is capable of placing emergency calls.
|
|
|
|
* By default all PSTN {@code PhoneAccount}s are capable of placing emergency calls.
|
|
|
|
* <p>
|
|
|
|
* See {@link #getCapabilities}
|
|
|
|
*/
|
|
|
|
public static final int CAPABILITY_PLACE_EMERGENCY_CALLS = 0x10;
|
|
|
|
|
2014-09-03 09:09:12 -07:00
|
|
|
/**
|
|
|
|
* URI scheme for telephone number URIs.
|
|
|
|
*/
|
|
|
|
public static final String SCHEME_TEL = "tel";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* URI scheme for voicemail URIs.
|
|
|
|
*/
|
|
|
|
public static final String SCHEME_VOICEMAIL = "voicemail";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* URI scheme for SIP URIs.
|
|
|
|
*/
|
|
|
|
public static final String SCHEME_SIP = "sip";
|
|
|
|
|
2014-07-20 12:31:00 -07:00
|
|
|
private final PhoneAccountHandle mAccountHandle;
|
2014-09-04 10:59:13 -07:00
|
|
|
private final Uri mAddress;
|
|
|
|
private final Uri mSubscriptionAddress;
|
2014-07-17 11:21:19 -07:00
|
|
|
private final int mCapabilities;
|
|
|
|
private final int mIconResId;
|
2014-07-21 00:00:44 -07:00
|
|
|
private final CharSequence mLabel;
|
|
|
|
private final CharSequence mShortDescription;
|
2014-09-03 09:09:12 -07:00
|
|
|
private final List<String> mSupportedUriSchemes;
|
2014-07-09 12:30:52 -07:00
|
|
|
|
2014-08-07 19:46:01 -07:00
|
|
|
public static class Builder {
|
|
|
|
private PhoneAccountHandle mAccountHandle;
|
2014-09-04 10:59:13 -07:00
|
|
|
private Uri mAddress;
|
|
|
|
private Uri mSubscriptionAddress;
|
2014-08-07 19:46:01 -07:00
|
|
|
private int mCapabilities;
|
|
|
|
private int mIconResId;
|
|
|
|
private CharSequence mLabel;
|
|
|
|
private CharSequence mShortDescription;
|
2014-09-03 09:09:12 -07:00
|
|
|
private List<String> mSupportedUriSchemes = new ArrayList<String>();
|
2014-08-07 19:46:01 -07:00
|
|
|
|
2014-09-04 10:59:13 -07:00
|
|
|
public Builder(PhoneAccountHandle accountHandle, CharSequence label) {
|
|
|
|
this.mAccountHandle = accountHandle;
|
|
|
|
this.mLabel = label;
|
2014-08-07 19:46:01 -07:00
|
|
|
}
|
|
|
|
|
2014-09-08 09:52:22 -07:00
|
|
|
/**
|
|
|
|
* Creates an instance of the {@link PhoneAccount.Builder} from an existing
|
|
|
|
* {@link PhoneAccount}.
|
|
|
|
*
|
|
|
|
* @param phoneAccount The {@link PhoneAccount} used to initialize the builder.
|
|
|
|
*/
|
|
|
|
public Builder(PhoneAccount phoneAccount) {
|
|
|
|
mAccountHandle = phoneAccount.getAccountHandle();
|
|
|
|
mAddress = phoneAccount.getAddress();
|
|
|
|
mSubscriptionAddress = phoneAccount.getSubscriptionAddress();
|
|
|
|
mCapabilities = phoneAccount.getCapabilities();
|
|
|
|
mIconResId = phoneAccount.getIconResId();
|
|
|
|
mLabel = phoneAccount.getLabel();
|
|
|
|
mShortDescription = phoneAccount.getShortDescription();
|
|
|
|
mSupportedUriSchemes.addAll(phoneAccount.getSupportedUriSchemes());
|
|
|
|
}
|
|
|
|
|
2014-09-04 10:59:13 -07:00
|
|
|
public Builder setAddress(Uri value) {
|
|
|
|
this.mAddress = value;
|
2014-08-07 19:46:01 -07:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2014-09-04 10:59:13 -07:00
|
|
|
public Builder setSubscriptionAddress(Uri value) {
|
|
|
|
this.mSubscriptionAddress = value;
|
2014-08-07 19:46:01 -07:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2014-09-04 10:59:13 -07:00
|
|
|
public Builder setCapabilities(int value) {
|
2014-08-07 19:46:01 -07:00
|
|
|
this.mCapabilities = value;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2014-09-04 10:59:13 -07:00
|
|
|
public Builder setIconResId(int value) {
|
2014-08-07 19:46:01 -07:00
|
|
|
this.mIconResId = value;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2014-09-04 10:59:13 -07:00
|
|
|
public Builder setShortDescription(CharSequence value) {
|
2014-08-07 19:46:01 -07:00
|
|
|
this.mShortDescription = value;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2014-09-03 09:09:12 -07:00
|
|
|
/**
|
|
|
|
* Specifies an additional URI scheme supported by the {@link PhoneAccount}.
|
|
|
|
*
|
|
|
|
* @param uriScheme The URI scheme.
|
|
|
|
* @return The Builder.
|
2014-09-04 10:59:13 -07:00
|
|
|
* @hide
|
2014-09-03 09:09:12 -07:00
|
|
|
*/
|
2014-09-04 10:59:13 -07:00
|
|
|
public Builder addSupportedUriScheme(String uriScheme) {
|
2014-09-03 09:09:12 -07:00
|
|
|
if (!TextUtils.isEmpty(uriScheme) && !mSupportedUriSchemes.contains(uriScheme)) {
|
|
|
|
this.mSupportedUriSchemes.add(uriScheme);
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-09-04 10:59:13 -07:00
|
|
|
* Specifies the URI schemes supported by the {@link PhoneAccount}.
|
2014-09-03 09:09:12 -07:00
|
|
|
*
|
|
|
|
* @param uriSchemes The URI schemes.
|
|
|
|
* @return The Builder.
|
|
|
|
*/
|
2014-09-04 10:59:13 -07:00
|
|
|
public Builder setSupportedUriSchemes(List<String> uriSchemes) {
|
|
|
|
mSupportedUriSchemes.clear();
|
|
|
|
|
2014-09-03 09:09:12 -07:00
|
|
|
if (uriSchemes != null && !uriSchemes.isEmpty()) {
|
|
|
|
for (String uriScheme : uriSchemes) {
|
2014-09-04 10:59:13 -07:00
|
|
|
addSupportedUriScheme(uriScheme);
|
2014-09-03 09:09:12 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2014-09-08 09:52:22 -07:00
|
|
|
/**
|
|
|
|
* Creates an instance of a {@link PhoneAccount} based on the current builder settings.
|
|
|
|
*
|
|
|
|
* @return The {@link PhoneAccount}.
|
|
|
|
*/
|
2014-08-07 19:46:01 -07:00
|
|
|
public PhoneAccount build() {
|
2014-09-03 09:09:12 -07:00
|
|
|
// If no supported URI schemes were defined, assume "tel" is supported.
|
|
|
|
if (mSupportedUriSchemes.isEmpty()) {
|
2014-09-04 10:59:13 -07:00
|
|
|
addSupportedUriScheme(SCHEME_TEL);
|
2014-09-03 09:09:12 -07:00
|
|
|
}
|
|
|
|
|
2014-08-07 19:46:01 -07:00
|
|
|
return new PhoneAccount(
|
|
|
|
mAccountHandle,
|
2014-09-04 10:59:13 -07:00
|
|
|
mAddress,
|
|
|
|
mSubscriptionAddress,
|
2014-08-07 19:46:01 -07:00
|
|
|
mCapabilities,
|
|
|
|
mIconResId,
|
|
|
|
mLabel,
|
2014-09-03 09:09:12 -07:00
|
|
|
mShortDescription,
|
2014-09-15 17:58:42 -07:00
|
|
|
mSupportedUriSchemes);
|
2014-08-07 19:46:01 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private PhoneAccount(
|
2014-07-19 18:18:19 -07:00
|
|
|
PhoneAccountHandle account,
|
2014-09-04 10:59:13 -07:00
|
|
|
Uri address,
|
|
|
|
Uri subscriptionAddress,
|
2014-07-17 11:21:19 -07:00
|
|
|
int capabilities,
|
2014-07-09 12:30:52 -07:00
|
|
|
int iconResId,
|
2014-07-21 00:00:44 -07:00
|
|
|
CharSequence label,
|
2014-09-03 09:09:12 -07:00
|
|
|
CharSequence shortDescription,
|
2014-09-15 17:58:42 -07:00
|
|
|
List<String> supportedUriSchemes) {
|
2014-07-20 12:31:00 -07:00
|
|
|
mAccountHandle = account;
|
2014-09-04 10:59:13 -07:00
|
|
|
mAddress = address;
|
|
|
|
mSubscriptionAddress = subscriptionAddress;
|
2014-07-17 11:21:19 -07:00
|
|
|
mCapabilities = capabilities;
|
2014-07-09 12:30:52 -07:00
|
|
|
mIconResId = iconResId;
|
|
|
|
mLabel = label;
|
|
|
|
mShortDescription = shortDescription;
|
2014-09-03 09:09:12 -07:00
|
|
|
mSupportedUriSchemes = Collections.unmodifiableList(supportedUriSchemes);
|
2014-07-09 12:30:52 -07:00
|
|
|
}
|
|
|
|
|
2014-09-04 10:59:13 -07:00
|
|
|
public static Builder builder(
|
|
|
|
PhoneAccountHandle accountHandle,
|
|
|
|
CharSequence label) {
|
|
|
|
return new Builder(accountHandle, label);
|
|
|
|
}
|
2014-08-07 19:46:01 -07:00
|
|
|
|
2014-09-08 09:52:22 -07:00
|
|
|
/**
|
|
|
|
* Returns a builder initialized with the current {@link PhoneAccount} instance.
|
|
|
|
*
|
|
|
|
* @return The builder.
|
|
|
|
* @hide
|
|
|
|
*/
|
|
|
|
public Builder toBuilder() { return new Builder(this); }
|
|
|
|
|
2014-07-09 12:30:52 -07:00
|
|
|
/**
|
2014-08-07 19:46:01 -07:00
|
|
|
* The unique identifier of this {@code PhoneAccount}.
|
2014-07-09 12:30:52 -07:00
|
|
|
*
|
2014-07-19 18:18:19 -07:00
|
|
|
* @return A {@code PhoneAccountHandle}.
|
2014-07-09 12:30:52 -07:00
|
|
|
*/
|
2014-07-20 12:31:00 -07:00
|
|
|
public PhoneAccountHandle getAccountHandle() {
|
|
|
|
return mAccountHandle;
|
2014-07-09 12:30:52 -07:00
|
|
|
}
|
|
|
|
|
2014-07-17 11:21:19 -07:00
|
|
|
/**
|
2014-09-04 10:59:13 -07:00
|
|
|
* The address (e.g., a phone number) associated with this {@code PhoneAccount}. This
|
2014-07-20 12:31:00 -07:00
|
|
|
* represents the destination from which outgoing calls using this {@code PhoneAccount}
|
2014-07-19 18:18:19 -07:00
|
|
|
* will appear to come, if applicable, and the destination to which incoming calls using this
|
2014-07-20 12:31:00 -07:00
|
|
|
* {@code PhoneAccount} may be addressed.
|
2014-07-17 11:21:19 -07:00
|
|
|
*
|
2014-09-04 10:59:13 -07:00
|
|
|
* @return A address expressed as a {@code Uri}, for example, a phone number.
|
2014-07-17 11:21:19 -07:00
|
|
|
*/
|
2014-09-04 10:59:13 -07:00
|
|
|
public Uri getAddress() {
|
|
|
|
return mAddress;
|
2014-07-17 11:21:19 -07:00
|
|
|
}
|
|
|
|
|
2014-07-17 16:59:18 -07:00
|
|
|
/**
|
2014-08-07 19:46:01 -07:00
|
|
|
* The raw callback number used for this {@code PhoneAccount}, as distinct from
|
2014-09-04 10:59:13 -07:00
|
|
|
* {@link #getAddress()}. For the majority of {@code PhoneAccount}s this should be registered
|
2014-08-07 19:46:01 -07:00
|
|
|
* as {@code null}. It is used by the system for SIM-based {@code PhoneAccount} registration
|
2014-07-17 16:59:18 -07:00
|
|
|
*
|
|
|
|
* @return The subscription number, suitable for display to the user.
|
|
|
|
*/
|
2014-09-04 10:59:13 -07:00
|
|
|
public Uri getSubscriptionAddress() {
|
|
|
|
return mSubscriptionAddress;
|
2014-07-17 16:59:18 -07:00
|
|
|
}
|
|
|
|
|
2014-07-17 11:21:19 -07:00
|
|
|
/**
|
2014-07-20 12:31:00 -07:00
|
|
|
* The capabilities of this {@code PhoneAccount}.
|
2014-07-17 11:21:19 -07:00
|
|
|
*
|
2014-07-20 12:31:00 -07:00
|
|
|
* @return A bit field of flags describing this {@code PhoneAccount}'s capabilities.
|
2014-07-17 11:21:19 -07:00
|
|
|
*/
|
|
|
|
public int getCapabilities() {
|
|
|
|
return mCapabilities;
|
|
|
|
}
|
|
|
|
|
2014-09-08 09:52:22 -07:00
|
|
|
/**
|
|
|
|
* Determines if this {@code PhoneAccount} has a capabilities specified by the passed in
|
|
|
|
* bit mask.
|
|
|
|
*
|
|
|
|
* @param capability The capabilities to check.
|
|
|
|
* @return {@code True} if the phone account has the capability.
|
|
|
|
*/
|
|
|
|
public boolean hasCapabilities(int capability) {
|
|
|
|
return (mCapabilities & capability) == capability;
|
|
|
|
}
|
|
|
|
|
2014-07-09 12:30:52 -07:00
|
|
|
/**
|
2014-07-21 00:00:44 -07:00
|
|
|
* A short label describing a {@code PhoneAccount}.
|
2014-07-09 12:30:52 -07:00
|
|
|
*
|
2014-07-20 12:31:00 -07:00
|
|
|
* @return A label for this {@code PhoneAccount}.
|
2014-07-09 12:30:52 -07:00
|
|
|
*/
|
2014-07-21 00:00:44 -07:00
|
|
|
public CharSequence getLabel() {
|
2014-07-09 12:30:52 -07:00
|
|
|
return mLabel;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-08-07 19:46:01 -07:00
|
|
|
* A short paragraph describing this {@code PhoneAccount}.
|
2014-07-09 12:30:52 -07:00
|
|
|
*
|
2014-07-20 12:31:00 -07:00
|
|
|
* @return A description for this {@code PhoneAccount}.
|
2014-07-09 12:30:52 -07:00
|
|
|
*/
|
2014-07-21 00:00:44 -07:00
|
|
|
public CharSequence getShortDescription() {
|
2014-07-09 12:30:52 -07:00
|
|
|
return mShortDescription;
|
|
|
|
}
|
|
|
|
|
2014-09-03 09:09:12 -07:00
|
|
|
/**
|
|
|
|
* The URI schemes supported by this {@code PhoneAccount}.
|
|
|
|
*
|
|
|
|
* @return The URI schemes.
|
|
|
|
*/
|
|
|
|
public List<String> getSupportedUriSchemes() {
|
|
|
|
return mSupportedUriSchemes;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-09-04 10:59:13 -07:00
|
|
|
* Determines if the {@link PhoneAccount} supports calls to/from addresses with a specified URI
|
2014-09-03 09:09:12 -07:00
|
|
|
* scheme.
|
|
|
|
*
|
|
|
|
* @param uriScheme The URI scheme to check.
|
2014-09-04 10:59:13 -07:00
|
|
|
* @return {@code True} if the {@code PhoneAccount} supports calls to/from addresses with the
|
2014-09-03 09:09:12 -07:00
|
|
|
* specified URI scheme.
|
|
|
|
*/
|
|
|
|
public boolean supportsUriScheme(String uriScheme) {
|
|
|
|
if (mSupportedUriSchemes == null || uriScheme == null) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (String scheme : mSupportedUriSchemes) {
|
|
|
|
if (scheme != null && scheme.equals(uriScheme)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-07-17 11:21:19 -07:00
|
|
|
/**
|
2014-07-20 12:31:00 -07:00
|
|
|
* The icon resource ID for the icon of this {@code PhoneAccount}.
|
2014-07-17 11:21:19 -07:00
|
|
|
*
|
|
|
|
* @return A resource ID.
|
|
|
|
*/
|
|
|
|
public int getIconResId() {
|
|
|
|
return mIconResId;
|
|
|
|
}
|
|
|
|
|
2014-07-09 12:30:52 -07:00
|
|
|
/**
|
2014-07-20 12:31:00 -07:00
|
|
|
* An icon to represent this {@code PhoneAccount} in a user interface.
|
2014-07-09 12:30:52 -07:00
|
|
|
*
|
2014-07-20 12:31:00 -07:00
|
|
|
* @return An icon for this {@code PhoneAccount}.
|
2014-07-09 12:30:52 -07:00
|
|
|
*/
|
|
|
|
public Drawable getIcon(Context context) {
|
|
|
|
return getIcon(context, mIconResId);
|
|
|
|
}
|
|
|
|
|
|
|
|
private Drawable getIcon(Context context, int resId) {
|
|
|
|
Context packageContext;
|
|
|
|
try {
|
|
|
|
packageContext = context.createPackageContext(
|
2014-07-20 12:31:00 -07:00
|
|
|
mAccountHandle.getComponentName().getPackageName(), 0);
|
2014-07-09 12:30:52 -07:00
|
|
|
} catch (PackageManager.NameNotFoundException e) {
|
2014-07-20 12:31:00 -07:00
|
|
|
Log.w(this, "Cannot find package %s", mAccountHandle.getComponentName().getPackageName());
|
2014-07-09 12:30:52 -07:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
try {
|
2014-08-14 12:59:10 -07:00
|
|
|
return packageContext.getDrawable(resId);
|
2014-07-21 01:28:28 -07:00
|
|
|
} catch (NotFoundException|MissingResourceException e) {
|
2014-07-09 12:30:52 -07:00
|
|
|
Log.e(this, e, "Cannot find icon %d in package %s",
|
2014-07-20 12:31:00 -07:00
|
|
|
resId, mAccountHandle.getComponentName().getPackageName());
|
2014-07-09 12:30:52 -07:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Parcelable implementation
|
|
|
|
//
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int describeContents() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void writeToParcel(Parcel out, int flags) {
|
2014-07-20 12:31:00 -07:00
|
|
|
out.writeParcelable(mAccountHandle, 0);
|
2014-09-04 10:59:13 -07:00
|
|
|
out.writeParcelable(mAddress, 0);
|
|
|
|
out.writeParcelable(mSubscriptionAddress, 0);
|
2014-07-17 11:21:19 -07:00
|
|
|
out.writeInt(mCapabilities);
|
2014-07-09 12:30:52 -07:00
|
|
|
out.writeInt(mIconResId);
|
2014-07-21 00:00:44 -07:00
|
|
|
out.writeCharSequence(mLabel);
|
|
|
|
out.writeCharSequence(mShortDescription);
|
2014-09-03 09:09:12 -07:00
|
|
|
out.writeList(mSupportedUriSchemes);
|
2014-07-09 12:30:52 -07:00
|
|
|
}
|
|
|
|
|
2014-07-20 12:31:00 -07:00
|
|
|
public static final Creator<PhoneAccount> CREATOR
|
|
|
|
= new Creator<PhoneAccount>() {
|
2014-07-09 12:30:52 -07:00
|
|
|
@Override
|
2014-07-20 12:31:00 -07:00
|
|
|
public PhoneAccount createFromParcel(Parcel in) {
|
|
|
|
return new PhoneAccount(in);
|
2014-07-09 12:30:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-07-20 12:31:00 -07:00
|
|
|
public PhoneAccount[] newArray(int size) {
|
|
|
|
return new PhoneAccount[size];
|
2014-07-09 12:30:52 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-07-20 12:31:00 -07:00
|
|
|
private PhoneAccount(Parcel in) {
|
2014-09-03 09:09:12 -07:00
|
|
|
ClassLoader classLoader = PhoneAccount.class.getClassLoader();
|
|
|
|
|
2014-07-20 12:31:00 -07:00
|
|
|
mAccountHandle = in.readParcelable(getClass().getClassLoader());
|
2014-09-04 10:59:13 -07:00
|
|
|
mAddress = in.readParcelable(getClass().getClassLoader());
|
|
|
|
mSubscriptionAddress = in.readParcelable(getClass().getClassLoader());
|
2014-07-17 11:21:19 -07:00
|
|
|
mCapabilities = in.readInt();
|
2014-07-09 12:30:52 -07:00
|
|
|
mIconResId = in.readInt();
|
2014-07-21 00:00:44 -07:00
|
|
|
mLabel = in.readCharSequence();
|
|
|
|
mShortDescription = in.readCharSequence();
|
2014-09-03 09:09:12 -07:00
|
|
|
|
|
|
|
List<String> supportedUriSchemes = new ArrayList<>();
|
|
|
|
in.readList(supportedUriSchemes, classLoader);
|
|
|
|
mSupportedUriSchemes = Collections.unmodifiableList(supportedUriSchemes);
|
2014-07-09 12:30:52 -07:00
|
|
|
}
|
|
|
|
}
|