FileDocCategorySizeDatePackage
PhoneAccount.javaAPI DocAndroid 5.1 API25120Thu Mar 12 22:22:42 GMT 2015android.telecom

PhoneAccount

public class PhoneAccount extends Object implements android.os.Parcelable
Represents a distinct method to place or receive a phone call. Apps which can place calls and want those calls to be integrated into the dialer and in-call UI should build an instance of this class and register it with the system using {@link TelecomManager#registerPhoneAccount}.

{@link TelecomManager} uses registered {@link PhoneAccount}s to present the user with alternative options when placing a phone call. When building a {@link PhoneAccount}, the app should supply a valid {@link PhoneAccountHandle} that references the {@link ConnectionService} implementation Telecom will use to interact with the app.

hide

Fields Summary
public static final int
CAPABILITY_CONNECTION_MANAGER
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.

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.

See {@link #getCapabilities}

public static final int
CAPABILITY_CALL_PROVIDER
Flag indicating that this {@code PhoneAccount} can make phone calls in place of 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 distinct from {@link #CAPABILITY_CONNECTION_MANAGER} in that it is not allowed to manage or place calls from the built-in telephony stack.

See {@link #getCapabilities}

{@hide}

public static final int
CAPABILITY_SIM_SUBSCRIPTION
Flag indicating that this {@code PhoneAccount} represents a built-in PSTN SIM subscription.

Only the Android framework can register a {@code PhoneAccount} having this capability.

See {@link #getCapabilities}

public static final int
CAPABILITY_VIDEO_CALLING
Flag indicating that this {@code PhoneAccount} is capable of placing video calls.

See {@link #getCapabilities}

public static final int
CAPABILITY_PLACE_EMERGENCY_CALLS
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.

See {@link #getCapabilities}

public static final int
CAPABILITY_MULTI_USER
Flag indicating that this {@code PhoneAccount} is capable of being used by all users. This should only be used by system apps (and will be ignored for all other apps trying to use it).

See {@link #getCapabilities}

public static final String
SCHEME_TEL
URI scheme for telephone number URIs.
public static final String
SCHEME_VOICEMAIL
URI scheme for voicemail URIs.
public static final String
SCHEME_SIP
URI scheme for SIP URIs.
public static final int
NO_ICON_TINT
Indicating no icon tint is set.
public static final int
NO_HIGHLIGHT_COLOR
Indicating no hightlight color is set.
public static final int
NO_RESOURCE_ID
Indicating no resource ID is set.
private final PhoneAccountHandle
mAccountHandle
private final android.net.Uri
mAddress
private final android.net.Uri
mSubscriptionAddress
private final int
mCapabilities
private final int
mIconResId
private final String
mIconPackageName
private final android.graphics.Bitmap
mIconBitmap
private final int
mIconTint
private final int
mHighlightColor
private final CharSequence
mLabel
private final CharSequence
mShortDescription
private final List
mSupportedUriSchemes
public static final Creator
CREATOR
Constructors Summary
private PhoneAccount(PhoneAccountHandle account, android.net.Uri address, android.net.Uri subscriptionAddress, int capabilities, int iconResId, String iconPackageName, android.graphics.Bitmap iconBitmap, int iconTint, int highlightColor, CharSequence label, CharSequence shortDescription, List supportedUriSchemes)

        mAccountHandle = account;
        mAddress = address;
        mSubscriptionAddress = subscriptionAddress;
        mCapabilities = capabilities;
        mIconResId = iconResId;
        mIconPackageName = iconPackageName;
        mIconBitmap = iconBitmap;
        mIconTint = iconTint;
        mHighlightColor = highlightColor;
        mLabel = label;
        mShortDescription = shortDescription;
        mSupportedUriSchemes = Collections.unmodifiableList(supportedUriSchemes);
    
private PhoneAccount(android.os.Parcel in)


       
        if (in.readInt() > 0) {
            mAccountHandle = PhoneAccountHandle.CREATOR.createFromParcel(in);
        } else {
            mAccountHandle = null;
        }
        if (in.readInt() > 0) {
            mAddress = Uri.CREATOR.createFromParcel(in);
        } else {
            mAddress = null;
        }
        if (in.readInt() > 0) {
            mSubscriptionAddress = Uri.CREATOR.createFromParcel(in);
        } else {
            mSubscriptionAddress = null;
        }
        mCapabilities = in.readInt();
        mIconResId = in.readInt();
        mIconPackageName = in.readString();
        if (in.readInt() > 0) {
            mIconBitmap = Bitmap.CREATOR.createFromParcel(in);
        } else {
            mIconBitmap = null;
        }
        mIconTint = in.readInt();
        mHighlightColor = in.readInt();
        mLabel = in.readCharSequence();
        mShortDescription = in.readCharSequence();
        mSupportedUriSchemes = Collections.unmodifiableList(in.createStringArrayList());
    
Methods Summary
public static android.telecom.PhoneAccount$Builderbuilder(PhoneAccountHandle accountHandle, java.lang.CharSequence label)

        return new Builder(accountHandle, label);
    
public android.graphics.drawable.DrawablecreateIconDrawable(android.content.Context context)
Builds and returns an icon {@code Drawable} to represent this {@code PhoneAccount} in a user interface. Uses the properties {@link #getIconResId()}, {@link #getIconPackageName()}, and {@link #getIconBitmap()} as necessary.

param
context A {@code Context} to use for loading {@code Drawable}s.
return
An icon for this {@code PhoneAccount}.

        if (mIconBitmap != null) {
            return new BitmapDrawable(context.getResources(), mIconBitmap);
        }

        if (mIconResId != 0) {
            try {
                Context packageContext = context.createPackageContext(mIconPackageName, 0);
                try {
                    Drawable iconDrawable = packageContext.getDrawable(mIconResId);
                    if (mIconTint != NO_ICON_TINT) {
                        iconDrawable.setTint(mIconTint);
                    }
                    return iconDrawable;
                } catch (NotFoundException | MissingResourceException e) {
                    Log.e(this, e, "Cannot find icon %d in package %s",
                            mIconResId, mIconPackageName);
                }
            } catch (PackageManager.NameNotFoundException e) {
                Log.w(this, "Cannot find package %s", mIconPackageName);
            }
        }

        return new ColorDrawable(Color.TRANSPARENT);
    
public intdescribeContents()

        return 0;
    
public PhoneAccountHandlegetAccountHandle()
The unique identifier of this {@code PhoneAccount}.

return
A {@code PhoneAccountHandle}.

        return mAccountHandle;
    
public android.net.UrigetAddress()
The address (e.g., a phone number) associated with this {@code PhoneAccount}. This represents the destination from which outgoing calls using this {@code PhoneAccount} will appear to come, if applicable, and the destination to which incoming calls using this {@code PhoneAccount} may be addressed.

return
A address expressed as a {@code Uri}, for example, a phone number.

        return mAddress;
    
public intgetCapabilities()
The capabilities of this {@code PhoneAccount}.

return
A bit field of flags describing this {@code PhoneAccount}'s capabilities.

        return mCapabilities;
    
public intgetHighlightColor()
A highlight color to use in displaying information about this {@code PhoneAccount}.

return
A hexadecimal color value.

        return mHighlightColor;
    
public android.graphics.BitmapgetIconBitmap()
A literal icon bitmap to represent this {@code PhoneAccount} in a user interface.

If this property is specified, it is to be considered the preferred icon. Otherwise, the resource specified by {@link #getIconResId()} should be used.

Clients wishing to display a {@code PhoneAccount} should use {@link #createIconDrawable(Context)}.

return
A bitmap.

        return mIconBitmap;
    
public java.lang.StringgetIconPackageName()
The package name from which to load the icon of this {@code PhoneAccount}.

If this property is {@code null}, the resource {@link #getIconResId()} will be loaded from the package in the {@link ComponentName} of the {@link #getAccountHandle()}.

Clients wishing to display a {@code PhoneAccount} should use {@link #createIconDrawable(Context)}.

return
A package name.

        return mIconPackageName;
    
public intgetIconResId()
The icon resource ID for the icon of this {@code PhoneAccount}.

Creators of a {@code PhoneAccount} who possess the icon in static resources should prefer this method of indicating the icon rather than using {@link #getIconBitmap()}, since it leads to less resource usage.

Clients wishing to display a {@code PhoneAccount} should use {@link #createIconDrawable(Context)}.

return
A resource ID.

        return mIconResId;
    
public intgetIconTint()
A tint to apply to the icon of this {@code PhoneAccount}.

return
A hexadecimal color value.

        return mIconTint;
    
public java.lang.CharSequencegetLabel()
A short label describing a {@code PhoneAccount}.

return
A label for this {@code PhoneAccount}.

        return mLabel;
    
public java.lang.CharSequencegetShortDescription()
A short paragraph describing this {@code PhoneAccount}.

return
A description for this {@code PhoneAccount}.

        return mShortDescription;
    
public android.net.UrigetSubscriptionAddress()
The raw callback number used for this {@code PhoneAccount}, as distinct from {@link #getAddress()}. For the majority of {@code PhoneAccount}s this should be registered as {@code null}. It is used by the system for SIM-based {@code PhoneAccount} registration where {@link android.telephony.TelephonyManager#setLine1NumberForDisplay(String, String)} has been used to alter the callback number.

return
The subscription number, suitable for display to the user.

        return mSubscriptionAddress;
    
public java.util.ListgetSupportedUriSchemes()
The URI schemes supported by this {@code PhoneAccount}.

return
The URI schemes.

        return mSupportedUriSchemes;
    
public booleanhasCapabilities(int capability)
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.

        return (mCapabilities & capability) == capability;
    
public booleansupportsUriScheme(java.lang.String uriScheme)
Determines if the {@link PhoneAccount} supports calls to/from addresses with a specified URI scheme.

param
uriScheme The URI scheme to check.
return
{@code True} if the {@code PhoneAccount} supports calls to/from addresses with the specified URI scheme.

        if (mSupportedUriSchemes == null || uriScheme == null) {
            return false;
        }

        for (String scheme : mSupportedUriSchemes) {
            if (scheme != null && scheme.equals(uriScheme)) {
                return true;
            }
        }
        return false;
    
public android.telecom.PhoneAccount$BuildertoBuilder()
Returns a builder initialized with the current {@link PhoneAccount} instance.

return
The builder.
hide

 return new Builder(this); 
public java.lang.StringtoString()

        StringBuilder sb = new StringBuilder().append("[PhoneAccount: ")
                .append(mAccountHandle)
                .append(" Capabilities: ")
                .append(mCapabilities)
                .append(" Schemes: ");
        for (String scheme : mSupportedUriSchemes) {
            sb.append(scheme)
                    .append(" ");
        }
        sb.append("]");
        return sb.toString();
    
public voidwriteToParcel(android.os.Parcel out, int flags)

        if (mAccountHandle == null) {
            out.writeInt(0);
        } else {
            out.writeInt(1);
            mAccountHandle.writeToParcel(out, flags);
        }
        if (mAddress == null) {
            out.writeInt(0);
        } else {
            out.writeInt(1);
            mAddress.writeToParcel(out, flags);
        }
        if (mSubscriptionAddress == null) {
            out.writeInt(0);
        } else {
            out.writeInt(1);
            mSubscriptionAddress.writeToParcel(out, flags);
        }
        out.writeInt(mCapabilities);
        out.writeInt(mIconResId);
        out.writeString(mIconPackageName);
        if (mIconBitmap == null) {
            out.writeInt(0);
        } else {
            out.writeInt(1);
            mIconBitmap.writeToParcel(out, flags);
        }
        out.writeInt(mIconTint);
        out.writeInt(mHighlightColor);
        out.writeCharSequence(mLabel);
        out.writeCharSequence(mShortDescription);
        out.writeStringList(mSupportedUriSchemes);