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
|
|
|
|
2014-11-08 15:49:16 -08:00
|
|
|
import android.annotation.SystemApi;
|
2014-10-24 11:42:32 -07:00
|
|
|
import android.content.ComponentName;
|
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-10-24 11:42:32 -07:00
|
|
|
import android.graphics.Bitmap;
|
|
|
|
import android.graphics.Color;
|
|
|
|
import android.graphics.drawable.BitmapDrawable;
|
|
|
|
import android.graphics.drawable.ColorDrawable;
|
2014-07-09 12:30:52 -07:00
|
|
|
import android.graphics.drawable.Drawable;
|
2015-05-13 11:17:25 -07:00
|
|
|
import android.graphics.drawable.Icon;
|
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-10-27 14:57:49 -07:00
|
|
|
* 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
|
2014-12-19 11:37:16 -08:00
|
|
|
* this class and register it with the system using {@link TelecomManager}.
|
2014-10-27 14:57:49 -07:00
|
|
|
* <p>
|
|
|
|
* {@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
|
2014-12-19 11:37:16 -08:00
|
|
|
* should supply a valid {@link PhoneAccountHandle} that references the connection service
|
2014-10-27 14:57:49 -07:00
|
|
|
* implementation Telecom will use to interact with the app.
|
2014-07-09 12:30:52 -07:00
|
|
|
*/
|
2015-05-12 13:31:25 -07:00
|
|
|
public final 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-10-27 14:57:49 -07:00
|
|
|
* or place calls from the built-in telephony stack.
|
2014-07-17 11:21:19 -07:00
|
|
|
* <p>
|
|
|
|
* See {@link #getCapabilities}
|
2014-08-07 19:46:01 -07:00
|
|
|
* <p>
|
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-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-11-25 14:12:57 -08:00
|
|
|
/**
|
|
|
|
* 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).
|
|
|
|
* <p>
|
|
|
|
* See {@link #getCapabilities}
|
|
|
|
* @hide
|
|
|
|
*/
|
2014-12-19 11:37:16 -08:00
|
|
|
@SystemApi
|
2014-11-25 14:12:57 -08:00
|
|
|
public static final int CAPABILITY_MULTI_USER = 0x20;
|
|
|
|
|
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-10-22 17:45:26 -07:00
|
|
|
/**
|
2014-11-12 13:41:16 -08:00
|
|
|
* Indicating no icon tint is set.
|
2015-05-13 11:17:25 -07:00
|
|
|
* @hide
|
2014-10-22 17:45:26 -07:00
|
|
|
*/
|
2014-11-12 13:41:16 -08:00
|
|
|
public static final int NO_ICON_TINT = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicating no hightlight color is set.
|
|
|
|
*/
|
|
|
|
public static final int NO_HIGHLIGHT_COLOR = 0;
|
2014-10-22 17:45:26 -07:00
|
|
|
|
2014-11-03 09:47:51 -08:00
|
|
|
/**
|
|
|
|
* Indicating no resource ID is set.
|
|
|
|
*/
|
|
|
|
public static final int NO_RESOURCE_ID = -1;
|
|
|
|
|
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;
|
2014-11-03 09:47:51 -08:00
|
|
|
private final int mHighlightColor;
|
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;
|
2015-05-13 11:17:25 -07:00
|
|
|
private final Icon mIcon;
|
2015-05-08 13:52:09 -07:00
|
|
|
private boolean mIsEnabled;
|
2014-07-09 12:30:52 -07:00
|
|
|
|
2014-10-27 14:57:49 -07:00
|
|
|
/**
|
|
|
|
* Helper class for creating a {@link PhoneAccount}.
|
|
|
|
*/
|
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;
|
2014-11-12 13:41:16 -08:00
|
|
|
private int mHighlightColor = NO_HIGHLIGHT_COLOR;
|
2014-08-07 19:46:01 -07:00
|
|
|
private CharSequence mLabel;
|
|
|
|
private CharSequence mShortDescription;
|
2014-09-03 09:09:12 -07:00
|
|
|
private List<String> mSupportedUriSchemes = new ArrayList<String>();
|
2015-05-13 11:17:25 -07:00
|
|
|
private Icon mIcon;
|
2015-05-08 13:52:09 -07:00
|
|
|
private boolean mIsEnabled = false;
|
2014-08-07 19:46:01 -07:00
|
|
|
|
2014-10-27 14:57:49 -07:00
|
|
|
/**
|
|
|
|
* Creates a builder with the specified {@link PhoneAccountHandle} and label.
|
|
|
|
*/
|
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();
|
2014-11-03 09:47:51 -08:00
|
|
|
mHighlightColor = phoneAccount.getHighlightColor();
|
2014-09-08 09:52:22 -07:00
|
|
|
mLabel = phoneAccount.getLabel();
|
|
|
|
mShortDescription = phoneAccount.getShortDescription();
|
|
|
|
mSupportedUriSchemes.addAll(phoneAccount.getSupportedUriSchemes());
|
2015-05-13 11:17:25 -07:00
|
|
|
mIcon = phoneAccount.getIcon();
|
2015-05-08 13:52:09 -07:00
|
|
|
mIsEnabled = phoneAccount.isEnabled();
|
2014-09-08 09:52:22 -07:00
|
|
|
}
|
|
|
|
|
2014-10-27 14:57:49 -07:00
|
|
|
/**
|
|
|
|
* Sets the address. See {@link PhoneAccount#getAddress}.
|
|
|
|
*
|
|
|
|
* @param value The address of the phone account.
|
|
|
|
* @return The builder.
|
|
|
|
*/
|
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-10-27 14:57:49 -07:00
|
|
|
/**
|
|
|
|
* Sets the subscription address. See {@link PhoneAccount#getSubscriptionAddress}.
|
|
|
|
*
|
|
|
|
* @param value The subscription address.
|
|
|
|
* @return The builder.
|
|
|
|
*/
|
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-10-27 14:57:49 -07:00
|
|
|
/**
|
|
|
|
* Sets the capabilities. See {@link PhoneAccount#getCapabilities}.
|
|
|
|
*
|
|
|
|
* @param value The capabilities to set.
|
|
|
|
* @return The builder.
|
|
|
|
*/
|
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-10-27 14:57:49 -07:00
|
|
|
/**
|
2015-05-13 11:17:25 -07:00
|
|
|
* Sets the icon. See {@link PhoneAccount#getIcon}.
|
2014-10-24 11:42:32 -07:00
|
|
|
*
|
2015-05-13 11:17:25 -07:00
|
|
|
* @param icon The icon to set.
|
2014-10-24 11:42:32 -07:00
|
|
|
*/
|
2015-05-13 11:17:25 -07:00
|
|
|
public Builder setIcon(Icon icon) {
|
|
|
|
mIcon = icon;
|
2014-10-24 11:42:32 -07:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-11-03 09:47:51 -08:00
|
|
|
* Sets the highlight color. See {@link PhoneAccount#getHighlightColor}.
|
2014-10-24 11:42:32 -07:00
|
|
|
*
|
2014-11-03 09:47:51 -08:00
|
|
|
* @param value The highlight color.
|
2014-10-24 11:42:32 -07:00
|
|
|
* @return The builder.
|
|
|
|
*/
|
2014-11-03 09:47:51 -08:00
|
|
|
public Builder setHighlightColor(int value) {
|
|
|
|
this.mHighlightColor = value;
|
2014-10-22 17:45:26 -07:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2014-10-27 14:57:49 -07:00
|
|
|
/**
|
|
|
|
* Sets the short description. See {@link PhoneAccount#getShortDescription}.
|
|
|
|
*
|
|
|
|
* @param value The short description.
|
|
|
|
* @return The builder.
|
|
|
|
*/
|
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.
|
2014-10-27 14:57:49 -07:00
|
|
|
* @return The builder.
|
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.
|
2014-10-27 14:57:49 -07:00
|
|
|
* @return The builder.
|
2014-09-03 09:09:12 -07:00
|
|
|
*/
|
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;
|
|
|
|
}
|
|
|
|
|
2015-05-08 13:52:09 -07:00
|
|
|
/**
|
|
|
|
* Sets the enabled state of the phone account.
|
|
|
|
*
|
|
|
|
* @param isEnabled The enabled state.
|
|
|
|
* @return The builder.
|
|
|
|
* @hide
|
|
|
|
*/
|
|
|
|
public Builder setIsEnabled(boolean isEnabled) {
|
|
|
|
mIsEnabled = isEnabled;
|
|
|
|
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,
|
2015-05-13 11:17:25 -07:00
|
|
|
mIcon,
|
2014-11-03 09:47:51 -08:00
|
|
|
mHighlightColor,
|
2014-08-07 19:46:01 -07:00
|
|
|
mLabel,
|
2014-09-03 09:09:12 -07:00
|
|
|
mShortDescription,
|
2015-05-08 13:52:09 -07:00
|
|
|
mSupportedUriSchemes,
|
|
|
|
mIsEnabled);
|
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,
|
2015-05-13 11:17:25 -07:00
|
|
|
Icon icon,
|
2014-11-03 09:47:51 -08:00
|
|
|
int highlightColor,
|
2014-07-21 00:00:44 -07:00
|
|
|
CharSequence label,
|
2014-09-03 09:09:12 -07:00
|
|
|
CharSequence shortDescription,
|
2015-05-08 13:52:09 -07:00
|
|
|
List<String> supportedUriSchemes,
|
|
|
|
boolean isEnabled) {
|
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;
|
2015-05-13 11:17:25 -07:00
|
|
|
mIcon = icon;
|
2014-11-03 09:47:51 -08:00
|
|
|
mHighlightColor = highlightColor;
|
2014-07-09 12:30:52 -07:00
|
|
|
mLabel = label;
|
|
|
|
mShortDescription = shortDescription;
|
2014-09-03 09:09:12 -07:00
|
|
|
mSupportedUriSchemes = Collections.unmodifiableList(supportedUriSchemes);
|
2015-05-08 13:52:09 -07:00
|
|
|
mIsEnabled = isEnabled;
|
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.
|
|
|
|
*/
|
|
|
|
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-09-25 17:36:48 +00:00
|
|
|
* where {@link android.telephony.TelephonyManager#setLine1NumberForDisplay(String, String)}
|
|
|
|
* has been used to alter the callback number.
|
|
|
|
* <p>
|
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;
|
|
|
|
}
|
|
|
|
|
2015-05-13 11:17:25 -07:00
|
|
|
/**
|
|
|
|
* The icon to represent this {@code PhoneAccount}.
|
|
|
|
*
|
|
|
|
* @return The icon.
|
|
|
|
*/
|
|
|
|
public Icon getIcon() {
|
|
|
|
return mIcon;
|
|
|
|
}
|
|
|
|
|
2015-05-08 13:52:09 -07:00
|
|
|
/**
|
|
|
|
* Indicates whether the user has enabled this phone account or not {@code PhoneAccounts}.
|
|
|
|
*
|
|
|
|
* @return The {@code true} if the account is enabled by the user, {@code false} otherwise.
|
|
|
|
*/
|
|
|
|
public boolean isEnabled() {
|
|
|
|
return mIsEnabled;
|
|
|
|
}
|
|
|
|
|
2014-09-03 09:09:12 -07:00
|
|
|
/**
|
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-11-03 09:47:51 -08:00
|
|
|
/**
|
|
|
|
* A highlight color to use in displaying information about this {@code PhoneAccount}.
|
|
|
|
*
|
|
|
|
* @return A hexadecimal color value.
|
|
|
|
*/
|
|
|
|
public int getHighlightColor() {
|
|
|
|
return mHighlightColor;
|
|
|
|
}
|
|
|
|
|
2015-05-08 13:52:09 -07:00
|
|
|
/**
|
|
|
|
* Sets the enabled state of the phone account.
|
|
|
|
* @hide
|
|
|
|
*/
|
|
|
|
public void setIsEnabled(boolean isEnabled) {
|
|
|
|
mIsEnabled = isEnabled;
|
|
|
|
}
|
|
|
|
|
2014-07-09 12:30:52 -07:00
|
|
|
//
|
|
|
|
// Parcelable implementation
|
|
|
|
//
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int describeContents() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void writeToParcel(Parcel out, int flags) {
|
2014-11-03 09:47:51 -08:00
|
|
|
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);
|
|
|
|
}
|
2014-07-17 11:21:19 -07:00
|
|
|
out.writeInt(mCapabilities);
|
2014-11-03 09:47:51 -08:00
|
|
|
out.writeInt(mHighlightColor);
|
2014-07-21 00:00:44 -07:00
|
|
|
out.writeCharSequence(mLabel);
|
|
|
|
out.writeCharSequence(mShortDescription);
|
2014-11-03 09:47:51 -08:00
|
|
|
out.writeStringList(mSupportedUriSchemes);
|
2015-05-08 13:52:09 -07:00
|
|
|
|
2015-05-13 11:17:25 -07:00
|
|
|
if (mIcon == null) {
|
|
|
|
out.writeInt(0);
|
|
|
|
} else {
|
|
|
|
out.writeInt(1);
|
|
|
|
mIcon.writeToParcel(out, flags);
|
|
|
|
}
|
2015-05-08 13:52:09 -07:00
|
|
|
out.writeByte((byte) (mIsEnabled ? 1 : 0));
|
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-11-03 09:47:51 -08:00
|
|
|
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;
|
|
|
|
}
|
2014-07-17 11:21:19 -07:00
|
|
|
mCapabilities = in.readInt();
|
2014-11-03 09:47:51 -08:00
|
|
|
mHighlightColor = in.readInt();
|
2014-07-21 00:00:44 -07:00
|
|
|
mLabel = in.readCharSequence();
|
|
|
|
mShortDescription = in.readCharSequence();
|
2014-11-03 09:47:51 -08:00
|
|
|
mSupportedUriSchemes = Collections.unmodifiableList(in.createStringArrayList());
|
2015-05-13 11:17:25 -07:00
|
|
|
if (in.readInt() > 0) {
|
|
|
|
mIcon = Icon.CREATOR.createFromParcel(in);
|
|
|
|
} else {
|
|
|
|
mIcon = null;
|
|
|
|
}
|
2015-05-08 13:52:09 -07:00
|
|
|
mIsEnabled = in.readByte() == 1;
|
2014-07-09 12:30:52 -07:00
|
|
|
}
|
2014-09-30 14:47:51 -07:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
2015-05-08 13:52:09 -07:00
|
|
|
StringBuilder sb = new StringBuilder().append("[[")
|
|
|
|
.append(mIsEnabled ? 'X' : ' ')
|
|
|
|
.append("] PhoneAccount: ")
|
2014-09-30 14:47:51 -07:00
|
|
|
.append(mAccountHandle)
|
|
|
|
.append(" Capabilities: ")
|
|
|
|
.append(mCapabilities)
|
|
|
|
.append(" Schemes: ");
|
|
|
|
for (String scheme : mSupportedUriSchemes) {
|
|
|
|
sb.append(scheme)
|
|
|
|
.append(" ");
|
|
|
|
}
|
|
|
|
sb.append("]");
|
|
|
|
return sb.toString();
|
|
|
|
}
|
2014-07-09 12:30:52 -07:00
|
|
|
}
|