diff options
Diffstat (limited to 'telecomm/java/android/telecom/PhoneAccount.java')
| -rw-r--r-- | telecomm/java/android/telecom/PhoneAccount.java | 55 |
1 files changed, 51 insertions, 4 deletions
diff --git a/telecomm/java/android/telecom/PhoneAccount.java b/telecomm/java/android/telecom/PhoneAccount.java index 1d6d8bc..402df30 100644 --- a/telecomm/java/android/telecom/PhoneAccount.java +++ b/telecomm/java/android/telecom/PhoneAccount.java @@ -16,7 +16,6 @@ package android.telecom; -import android.annotation.SystemApi; import android.content.Context; import android.content.pm.PackageManager; import android.content.res.Resources.NotFoundException; @@ -35,9 +34,7 @@ import java.util.MissingResourceException; /** * Describes a distinct account, line of service or call placement method that the system * can use to place phone calls. - * @hide */ -@SystemApi public class PhoneAccount implements Parcelable { /** @@ -108,11 +105,17 @@ public class PhoneAccount implements Parcelable { */ public static final String SCHEME_SIP = "sip"; + /** + * Indicating no color is set. + */ + public static final int NO_COLOR = -1; + private final PhoneAccountHandle mAccountHandle; private final Uri mAddress; private final Uri mSubscriptionAddress; private final int mCapabilities; private final int mIconResId; + private final int mColor; private final CharSequence mLabel; private final CharSequence mShortDescription; private final List<String> mSupportedUriSchemes; @@ -123,6 +126,7 @@ public class PhoneAccount implements Parcelable { private Uri mSubscriptionAddress; private int mCapabilities; private int mIconResId; + private int mColor = NO_COLOR; private CharSequence mLabel; private CharSequence mShortDescription; private List<String> mSupportedUriSchemes = new ArrayList<String>(); @@ -144,6 +148,7 @@ public class PhoneAccount implements Parcelable { mSubscriptionAddress = phoneAccount.getSubscriptionAddress(); mCapabilities = phoneAccount.getCapabilities(); mIconResId = phoneAccount.getIconResId(); + mColor = phoneAccount.getColor(); mLabel = phoneAccount.getLabel(); mShortDescription = phoneAccount.getShortDescription(); mSupportedUriSchemes.addAll(phoneAccount.getSupportedUriSchemes()); @@ -169,6 +174,11 @@ public class PhoneAccount implements Parcelable { return this; } + public Builder setColor(int value) { + this.mColor = value; + return this; + } + public Builder setShortDescription(CharSequence value) { this.mShortDescription = value; return this; @@ -222,6 +232,7 @@ public class PhoneAccount implements Parcelable { mSubscriptionAddress, mCapabilities, mIconResId, + mColor, mLabel, mShortDescription, mSupportedUriSchemes); @@ -234,6 +245,7 @@ public class PhoneAccount implements Parcelable { Uri subscriptionAddress, int capabilities, int iconResId, + int color, CharSequence label, CharSequence shortDescription, List<String> supportedUriSchemes) { @@ -242,6 +254,7 @@ public class PhoneAccount implements Parcelable { mSubscriptionAddress = subscriptionAddress; mCapabilities = capabilities; mIconResId = iconResId; + mColor = color; mLabel = label; mShortDescription = shortDescription; mSupportedUriSchemes = Collections.unmodifiableList(supportedUriSchemes); @@ -286,6 +299,9 @@ public class PhoneAccount implements Parcelable { * 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. + * <p> * * @return The subscription number, suitable for display to the user. */ @@ -371,6 +387,15 @@ public class PhoneAccount implements Parcelable { } /** + * A highlight color to use in displaying information about this {@code PhoneAccount}. + * + * @return A hexadecimal color value. + */ + public int getColor() { + return mColor; + } + + /** * An icon to represent this {@code PhoneAccount} in a user interface. * * @return An icon for this {@code PhoneAccount}. @@ -380,12 +405,17 @@ public class PhoneAccount implements Parcelable { } private Drawable getIcon(Context context, int resId) { + if (resId == 0) { + return null; + } + Context packageContext; try { packageContext = context.createPackageContext( mAccountHandle.getComponentName().getPackageName(), 0); } catch (PackageManager.NameNotFoundException e) { - Log.w(this, "Cannot find package %s", mAccountHandle.getComponentName().getPackageName()); + Log.w(this, "Cannot find package %s", + mAccountHandle.getComponentName().getPackageName()); return null; } try { @@ -413,6 +443,7 @@ public class PhoneAccount implements Parcelable { out.writeParcelable(mSubscriptionAddress, 0); out.writeInt(mCapabilities); out.writeInt(mIconResId); + out.writeInt(mColor); out.writeCharSequence(mLabel); out.writeCharSequence(mShortDescription); out.writeList(mSupportedUriSchemes); @@ -439,6 +470,7 @@ public class PhoneAccount implements Parcelable { mSubscriptionAddress = in.readParcelable(getClass().getClassLoader()); mCapabilities = in.readInt(); mIconResId = in.readInt(); + mColor = in.readInt(); mLabel = in.readCharSequence(); mShortDescription = in.readCharSequence(); @@ -446,4 +478,19 @@ public class PhoneAccount implements Parcelable { in.readList(supportedUriSchemes, classLoader); mSupportedUriSchemes = Collections.unmodifiableList(supportedUriSchemes); } + + @Override + public String toString() { + 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(); + } } |
