FileDocCategorySizeDatePackage
SubscriptionInfo.javaAPI DocAndroid 5.1 API10117Thu Mar 12 22:22:42 GMT 2015android.telephony

SubscriptionInfo

public class SubscriptionInfo extends Object implements android.os.Parcelable
A Parcelable class for Subscription Information.

Fields Summary
private static final int
TEXT_SIZE
Size of text to render on the icon.
private int
mId
Subscription Identifier, this is a device unique number and not an index into an array
private String
mIccId
The GID for a SIM that maybe associated with this subscription, empty if unknown
private int
mSimSlotIndex
The index of the slot that currently contains the subscription and not necessarily unique and maybe INVALID_SLOT_ID if unknown
private CharSequence
mDisplayName
The name displayed to the user that identifies this subscription
private CharSequence
mCarrierName
The string displayed to the user that identifies Subscription Provider Name
private int
mNameSource
The source of the name, NAME_SOURCE_UNDEFINED, NAME_SOURCE_DEFAULT_SOURCE, NAME_SOURCE_SIM_SOURCE or NAME_SOURCE_USER_INPUT.
private int
mIconTint
The color to be used for tinting the icon when displaying to the user
private String
mNumber
A number presented to the user identify this subscription
private int
mDataRoaming
Data roaming state, DATA_RAOMING_ENABLE, DATA_RAOMING_DISABLE
private android.graphics.Bitmap
mIconBitmap
SIM Icon bitmap
private int
mMcc
Mobile Country Code
private int
mMnc
Mobile Network Code
private String
mCountryIso
ISO Country code for the subscription's provider
public static final Parcelable.Creator
CREATOR
Constructors Summary
public SubscriptionInfo(int id, String iccId, int simSlotIndex, CharSequence displayName, CharSequence carrierName, int nameSource, int iconTint, String number, int roaming, android.graphics.Bitmap icon, int mcc, int mnc, String countryIso)

hide


          
            
                     
                    
        this.mId = id;
        this.mIccId = iccId;
        this.mSimSlotIndex = simSlotIndex;
        this.mDisplayName = displayName;
        this.mCarrierName = carrierName;
        this.mNameSource = nameSource;
        this.mIconTint = iconTint;
        this.mNumber = number;
        this.mDataRoaming = roaming;
        this.mIconBitmap = icon;
        this.mMcc = mcc;
        this.mMnc = mnc;
        this.mCountryIso = countryIso;
    
Methods Summary
public android.graphics.BitmapcreateIconBitmap(android.content.Context context)
Creates and returns an icon {@code Bitmap} to represent this {@code SubscriptionInfo} in a user interface.

param
context A {@code Context} to get the {@code DisplayMetrics}s from.
return
A bitmap icon for this {@code SubscriptionInfo}.

        int width = mIconBitmap.getWidth();
        int height = mIconBitmap.getHeight();
        DisplayMetrics metrics = context.getResources().getDisplayMetrics();

        // Create a new bitmap of the same size because it will be modified.
        Bitmap workingBitmap = Bitmap.createBitmap(metrics, width, height, mIconBitmap.getConfig());

        Canvas canvas = new Canvas(workingBitmap);
        Paint paint = new Paint();

        // Tint the icon with the color.
        paint.setColorFilter(new PorterDuffColorFilter(mIconTint, PorterDuff.Mode.SRC_ATOP));
        canvas.drawBitmap(mIconBitmap, 0, 0, paint);
        paint.setColorFilter(null);

        // Write the sim slot index.
        paint.setAntiAlias(true);
        paint.setTypeface(Typeface.create("sans-serif", Typeface.NORMAL));
        paint.setColor(Color.WHITE);
        // Set text size scaled by density
        paint.setTextSize(TEXT_SIZE * metrics.density);
        // Convert sim slot index to localized string
        final String index = String.format("%d", mSimSlotIndex + 1);
        final Rect textBound = new Rect();
        paint.getTextBounds(index, 0, 1, textBound);
        final float xOffset = (width / 2.f) - textBound.centerX();
        final float yOffset = (height / 2.f) - textBound.centerY();
        canvas.drawText(index, xOffset, yOffset, paint);

        return workingBitmap;
    
public intdescribeContents()

        return 0;
    
public java.lang.CharSequencegetCarrierName()

return
the name displayed to the user that identifies Subscription provider name

        return this.mCarrierName;
    
public java.lang.StringgetCountryIso()

return
the ISO country code

        return this.mCountryIso;
    
public intgetDataRoaming()

return
the data roaming state for this subscription, either {@link SubscriptionManager#DATA_ROAMING_ENABLE} or {@link SubscriptionManager#DATA_ROAMING_DISABLE}.

        return this.mDataRoaming;
    
public java.lang.CharSequencegetDisplayName()

return
the name displayed to the user that identifies this subscription

        return this.mDisplayName;
    
public java.lang.StringgetIccId()

return
the ICC ID.

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

return
A hexadecimal color value.

        return mIconTint;
    
public intgetMcc()

return
the MCC.

        return this.mMcc;
    
public intgetMnc()

return
the MNC.

        return this.mMnc;
    
public intgetNameSource()

return
the source of the name, eg NAME_SOURCE_UNDEFINED, NAME_SOURCE_DEFAULT_SOURCE, NAME_SOURCE_SIM_SOURCE or NAME_SOURCE_USER_INPUT.
hide

        return this.mNameSource;
    
public java.lang.StringgetNumber()

return
the number of this subscription.

        return mNumber;
    
public intgetSimSlotIndex()

return
the slot index of this Subscription's SIM card.

        return this.mSimSlotIndex;
    
public intgetSubscriptionId()

return
the subscription ID.

        return this.mId;
    
public voidsetCarrierName(java.lang.CharSequence name)
Sets the name displayed to the user that identifies Subscription provider name

hide

        this.mCarrierName = name;
    
public voidsetDisplayName(java.lang.CharSequence name)
Sets the name displayed to the user that identifies this subscription

hide

        this.mDisplayName = name;
    
public voidsetIconTint(int iconTint)
Sets the color displayed to the user that identifies this subscription

hide

        this.mIconTint = iconTint;
    
public java.lang.StringtoString()

        return "{id=" + mId + ", iccId=" + mIccId + " simSlotIndex=" + mSimSlotIndex
                + " displayName=" + mDisplayName + " carrierName=" + mCarrierName
                + " nameSource=" + mNameSource + " iconTint=" + mIconTint
                + " dataRoaming=" + mDataRoaming + " iconBitmap=" + mIconBitmap + " mcc " + mMcc
                + " mnc " + mMnc + "}";
    
public voidwriteToParcel(android.os.Parcel dest, int flags)


    
          
        dest.writeInt(mId);
        dest.writeString(mIccId);
        dest.writeInt(mSimSlotIndex);
        dest.writeCharSequence(mDisplayName);
        dest.writeCharSequence(mCarrierName);
        dest.writeInt(mNameSource);
        dest.writeInt(mIconTint);
        dest.writeString(mNumber);
        dest.writeInt(mDataRoaming);
        dest.writeInt(mMcc);
        dest.writeInt(mMnc);
        dest.writeString(mCountryIso);
        mIconBitmap.writeToParcel(dest, flags);