FileDocCategorySizeDatePackage
SubscriptionManager.javaAPI DocAndroid 5.1 API36170Thu Mar 12 22:22:42 GMT 2015android.telephony

SubscriptionManager

public class SubscriptionManager extends Object
SubscriptionManager is the application interface to SubscriptionController and provides information about the current Telephony Subscriptions. *

You do not instantiate this class directly; instead, you retrieve a reference to an instance through {@link #from}.

All SDK public methods require android.Manifest.permission.READ_PHONE_STATE.

Fields Summary
private static final String
LOG_TAG
private static final boolean
DBG
private static final boolean
VDBG
public static final int
INVALID_SUBSCRIPTION_ID
public static final int
DUMMY_SUBSCRIPTION_ID_BASE
FIXME: Remove DummySubId's, but for now have them map just below INVALID_SUBSCRIPTION_ID /**
public static final int
INVALID_PHONE_INDEX
public static final int
INVALID_SIM_SLOT_INDEX
public static final int
DEFAULT_SUBSCRIPTION_ID
public static final int
DEFAULT_PHONE_INDEX
Indicates the caller wants the default phone id. Used in SubscriptionController and PhoneBase but do we really need it???
public static final int
DEFAULT_SIM_SLOT_INDEX
public static final int
MIN_SUBSCRIPTION_ID_VALUE
public static final int
MAX_SUBSCRIPTION_ID_VALUE
public static final android.net.Uri
CONTENT_URI
public static final String
UNIQUE_KEY_SUBSCRIPTION_ID
public static final String
ICC_ID
public static final String
SIM_SLOT_INDEX
public static final int
SIM_NOT_INSERTED
public static final String
DISPLAY_NAME
public static final String
CARRIER_NAME
public static final int
DEFAULT_NAME_RES
Default name resource
public static final String
NAME_SOURCE
TelephonyProvider column name for source of the user displayed name.

Type: INT (int)

with one of the NAME_SOURCE_XXXX values below
public static final int
NAME_SOURCE_UNDEFINDED
The name_source is undefined
public static final int
NAME_SOURCE_DEFAULT_SOURCE
The name_source is the default
public static final int
NAME_SOURCE_SIM_SOURCE
The name_source is from the SIM
public static final int
NAME_SOURCE_USER_INPUT
The name_source is from the user
public static final String
COLOR
public static final int
COLOR_1
public static final int
COLOR_2
public static final int
COLOR_3
public static final int
COLOR_4
public static final int
COLOR_DEFAULT
public static final String
NUMBER
public static final String
DISPLAY_NUMBER_FORMAT
public static final int
DISPLAY_NUMBER_NONE
public static final int
DISPLAY_NUMBER_FIRST
public static final int
DISPLAY_NUMBER_LAST
public static final int
DISPLAY_NUMBER_DEFAULT
public static final String
DATA_ROAMING
public static final int
DATA_ROAMING_ENABLE
Indicates that data roaming is enabled for a subscription
public static final int
DATA_ROAMING_DISABLE
Indicates that data roaming is disabled for a subscription
public static final int
DATA_ROAMING_DEFAULT
public static final String
MCC
TelephonyProvider column name for the MCC associated with a SIM.

Type: INTEGER (int)

public static final String
MNC
TelephonyProvider column name for the MNC associated with a SIM.

Type: INTEGER (int)

public static final String
SUB_DEFAULT_CHANGED_ACTION
Broadcast Action: The user has changed one of the default subs related to data, phone calls, or sms

TODO: Change to a listener
private final android.content.Context
mContext
Constructors Summary
public SubscriptionManager(android.content.Context context)

hide

        if (DBG) logd("SubscriptionManager created");
        mContext = context;
    
Methods Summary
public voidaddOnSubscriptionsChangedListener(android.telephony.SubscriptionManager$OnSubscriptionsChangedListener listener)
Register for changes to the list of active {@link SubscriptionInfo} records or to the individual records themselves. When a change occurs the onSubscriptionsChanged method of the listener will be invoked immediately if there has been a notification.

param
listener an instance of {@link OnSubscriptionsChangedListener} with onSubscriptionsChanged overridden.

        String pkgForDebug = mContext != null ? mContext.getPackageName() : "<unknown>";
        if (DBG) {
            logd("register OnSubscriptionsChangedListener pkgForDebug=" + pkgForDebug
                    + " listener=" + listener);
        }
        try {
            // We use the TelephonyRegistry as it runs in the system and thus is always
            // available. Where as SubscriptionController could crash and not be available
            ITelephonyRegistry tr = ITelephonyRegistry.Stub.asInterface(ServiceManager.getService(
                    "telephony.registry"));
            if (tr != null) {
                tr.addOnSubscriptionsChangedListener(pkgForDebug, listener.callback);
            }
        } catch (RemoteException ex) {
            // Should not happen
        }
    
public android.net.UriaddSubscriptionInfoRecord(java.lang.String iccId, int slotId)
Add a new SubscriptionInfo to SubscriptionInfo database if needed

param
iccId the IccId of the SIM card
param
slotId the slot which the SIM is inserted
return
the URL of the newly created row or the updated row
hide

        if (VDBG) logd("[addSubscriptionInfoRecord]+ iccId:" + iccId + " slotId:" + slotId);
        if (iccId == null) {
            logd("[addSubscriptionInfoRecord]- null iccId");
        }
        if (!isValidSlotId(slotId)) {
            logd("[addSubscriptionInfoRecord]- invalid slotId");
        }

        try {
            ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
            if (iSub != null) {
                // FIXME: This returns 1 on success, 0 on error should should we return it?
                iSub.addSubInfoRecord(iccId, slotId);
            }
        } catch (RemoteException ex) {
            // ignore it
        }

        // FIXME: Always returns null?
        return null;

    
public booleanallDefaultsSelected()

hide

        if (!isValidSubscriptionId(getDefaultDataSubId())) {
            return false;
        }
        if (!isValidSubscriptionId(getDefaultSmsSubId())) {
            return false;
        }
        if (!isValidSubscriptionId(getDefaultVoiceSubId())) {
            return false;
        }
        return true;
    
public voidclearDefaultsForInactiveSubIds()
If a default is set to subscription which is not active, this will reset that default back to an invalid subscription id, i.e. < 0.

hide

        if (VDBG) logd("clearDefaultsForInactiveSubIds");
        try {
            ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
            if (iSub != null) {
                iSub.clearDefaultsForInactiveSubIds();
            }
        } catch (RemoteException ex) {
            // ignore it
        }
    
public voidclearSubscriptionInfo()

hide

        try {
            ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
            if (iSub != null) {
                iSub.clearSubInfo();
            }
        } catch (RemoteException ex) {
            // ignore it
        }

        return;
    
public static android.telephony.SubscriptionManagerfrom(android.content.Context context)
Get an instance of the SubscriptionManager from the Context. This invokes {@link android.content.Context#getSystemService Context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE)}.

param
context to use.
return
SubscriptionManager instance

        return (SubscriptionManager) context.getSystemService(
                Context.TELEPHONY_SUBSCRIPTION_SERVICE);
    
public int[]getActiveSubscriptionIdList()

return
the list of subId's that are active, is never null but the length maybe 0.
hide

        int[] subId = null;

        try {
            ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
            if (iSub != null) {
                subId = iSub.getActiveSubIdList();
            }
        } catch (RemoteException ex) {
            // ignore it
        }

        if (subId == null) {
            subId = new int[0];
        }

        return subId;

    
public SubscriptionInfogetActiveSubscriptionInfo(int subId)
Get the active SubscriptionInfo with the subId key

param
subId The unique SubscriptionInfo key in database
return
SubscriptionInfo, maybe null if its not active.

        if (VDBG) logd("[getActiveSubscriptionInfo]+ subId=" + subId);
        if (!isValidSubscriptionId(subId)) {
            logd("[getActiveSubscriptionInfo]- invalid subId");
            return null;
        }

        SubscriptionInfo subInfo = null;

        try {
            ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
            if (iSub != null) {
                subInfo = iSub.getActiveSubscriptionInfo(subId);
            }
        } catch (RemoteException ex) {
            // ignore it
        }

        return subInfo;

    
public intgetActiveSubscriptionInfoCount()

return
the current number of active subscriptions. There is no guarantee the value returned by this method will be the same as the length of the list returned by {@link #getActiveSubscriptionInfoList}.

        int result = 0;

        try {
            ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
            if (iSub != null) {
                result = iSub.getActiveSubInfoCount();
            }
        } catch (RemoteException ex) {
            // ignore it
        }

        return result;
    
public intgetActiveSubscriptionInfoCountMax()

return
the maximum number of active subscriptions that will be returned by {@link #getActiveSubscriptionInfoList} and the value returned by {@link #getActiveSubscriptionInfoCount}.

        int result = 0;

        try {
            ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
            if (iSub != null) {
                result = iSub.getActiveSubInfoCountMax();
            }
        } catch (RemoteException ex) {
            // ignore it
        }

        return result;
    
public SubscriptionInfogetActiveSubscriptionInfoForIccIndex(java.lang.String iccId)
Get the active SubscriptionInfo associated with the iccId

param
iccId the IccId of SIM card
return
SubscriptionInfo, maybe null if its not active
hide

        if (VDBG) logd("[getActiveSubscriptionInfoForIccIndex]+ iccId=" + iccId);
        if (iccId == null) {
            logd("[getActiveSubscriptionInfoForIccIndex]- null iccid");
            return null;
        }

        SubscriptionInfo result = null;

        try {
            ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
            if (iSub != null) {
                result = iSub.getActiveSubscriptionInfoForIccId(iccId);
            }
        } catch (RemoteException ex) {
            // ignore it
        }

        return result;
    
public SubscriptionInfogetActiveSubscriptionInfoForSimSlotIndex(int slotIdx)
Get the active SubscriptionInfo associated with the slotIdx

param
slotIdx the slot which the subscription is inserted
return
SubscriptionInfo, maybe null if its not active

        if (VDBG) logd("[getActiveSubscriptionInfoForSimSlotIndex]+ slotIdx=" + slotIdx);
        if (!isValidSlotId(slotIdx)) {
            logd("[getActiveSubscriptionInfoForSimSlotIndex]- invalid slotIdx");
            return null;
        }

        SubscriptionInfo result = null;

        try {
            ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
            if (iSub != null) {
                result = iSub.getActiveSubscriptionInfoForSimSlotIndex(slotIdx);
            }
        } catch (RemoteException ex) {
            // ignore it
        }

        return result;
    
public java.util.ListgetActiveSubscriptionInfoList()
Get the SubscriptionInfo(s) of the currently inserted SIM(s). The records will be sorted by {@link SubscriptionInfo#getSimSlotIndex} then by {@link SubscriptionInfo#getSubscriptionId}.

return
Sorted list of the currently {@link SubscriptionInfo} records available on the device.
  • If null is returned the current state is unknown but if a {@link OnSubscriptionsChangedListener} has been registered {@link OnSubscriptionsChangedListener#onSubscriptionsChanged} will be invoked in the future.
  • If the list is empty then there are no {@link SubscriptionInfo} records currently available.
  • if the list is non-empty the list is sorted by {@link SubscriptionInfo#getSimSlotIndex} then by {@link SubscriptionInfo#getSubscriptionId}.

        List<SubscriptionInfo> result = null;

        try {
            ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
            if (iSub != null) {
                result = iSub.getActiveSubscriptionInfoList();
            }
        } catch (RemoteException ex) {
            // ignore it
        }
        return result;
    
public intgetAllSubscriptionInfoCount()

return
the count of all subscriptions in the database, this includes all subscriptions that have been seen.
hide

        if (VDBG) logd("[getAllSubscriptionInfoCount]+");

        int result = 0;

        try {
            ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
            if (iSub != null) {
                result = iSub.getAllSubInfoCount();
            }
        } catch (RemoteException ex) {
            // ignore it
        }

        return result;
    
public java.util.ListgetAllSubscriptionInfoList()

return
List of all SubscriptionInfo records in database, include those that were inserted before, maybe empty but not null.
hide

        if (VDBG) logd("[getAllSubscriptionInfoList]+");

        List<SubscriptionInfo> result = null;

        try {
            ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
            if (iSub != null) {
                result = iSub.getAllSubInfoList();
            }
        } catch (RemoteException ex) {
            // ignore it
        }

        if (result == null) {
            result = new ArrayList<SubscriptionInfo>();
        }
        return result;
    
public intgetDefaultDataPhoneId()

hide

        return getPhoneId(getDefaultDataSubId());
    
public static intgetDefaultDataSubId()

hide

        int subId = INVALID_SUBSCRIPTION_ID;

        try {
            ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
            if (iSub != null) {
                subId = iSub.getDefaultDataSubId();
            }
        } catch (RemoteException ex) {
            // ignore it
        }

        if (VDBG) logd("getDefaultDataSubId, sub id = " + subId);
        return subId;
    
public SubscriptionInfogetDefaultDataSubscriptionInfo()

hide

        return getActiveSubscriptionInfo(getDefaultDataSubId());
    
public intgetDefaultSmsPhoneId()

hide

        return getPhoneId(getDefaultSmsSubId());
    
public static intgetDefaultSmsSubId()

return
subId of the DefaultSms subscription or a value < 0 if an error.
hide

        int subId = INVALID_SUBSCRIPTION_ID;

        try {
            ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
            if (iSub != null) {
                subId = iSub.getDefaultSmsSubId();
            }
        } catch (RemoteException ex) {
            // ignore it
        }

        if (VDBG) logd("getDefaultSmsSubId, sub id = " + subId);
        return subId;
    
public SubscriptionInfogetDefaultSmsSubscriptionInfo()

hide

        return getActiveSubscriptionInfo(getDefaultSmsSubId());
    
public static intgetDefaultSubId()

return
the "system" defaultSubId on a voice capable device this will be getDefaultVoiceSubId() and on a data only device it will be getDefaultDataSubId().
hide

        int subId = INVALID_SUBSCRIPTION_ID;

        try {
            ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
            if (iSub != null) {
                subId = iSub.getDefaultSubId();
            }
        } catch (RemoteException ex) {
            // ignore it
        }

        if (VDBG) logd("getDefaultSubId=" + subId);
        return subId;
    
public static intgetDefaultVoicePhoneId()

hide

        return getPhoneId(getDefaultVoiceSubId());
    
public static intgetDefaultVoiceSubId()

hide

        int subId = INVALID_SUBSCRIPTION_ID;

        try {
            ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
            if (iSub != null) {
                subId = iSub.getDefaultVoiceSubId();
            }
        } catch (RemoteException ex) {
            // ignore it
        }

        if (VDBG) logd("getDefaultVoiceSubId, sub id = " + subId);
        return subId;
    
public SubscriptionInfogetDefaultVoiceSubscriptionInfo()

hide

        return getActiveSubscriptionInfo(getDefaultVoiceSubId());
    
public static intgetPhoneId(int subId)

hide

        if (!isValidSubscriptionId(subId)) {
            logd("[getPhoneId]- fail");
            return INVALID_PHONE_INDEX;
        }

        int result = INVALID_PHONE_INDEX;

        try {
            ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
            if (iSub != null) {
                result = iSub.getPhoneId(subId);
            }
        } catch (RemoteException ex) {
            // ignore it
        }

        if (VDBG) logd("[getPhoneId]- phoneId=" + result);
        return result;

    
public static intgetSimStateForSubscriber(int subId)
Returns a constant indicating the state of sim for the subscription.

param
subId {@See TelephonyManager#SIM_STATE_UNKNOWN} {@See TelephonyManager#SIM_STATE_ABSENT} {@See TelephonyManager#SIM_STATE_PIN_REQUIRED} {@See TelephonyManager#SIM_STATE_PUK_REQUIRED} {@See TelephonyManager#SIM_STATE_NETWORK_LOCKED} {@See TelephonyManager#SIM_STATE_READY} {@See TelephonyManager#SIM_STATE_NOT_READY} {@See TelephonyManager#SIM_STATE_PERM_DISABLED} {@See TelephonyManager#SIM_STATE_CARD_IO_ERROR} {@hide}

        int simState;

        try {
            ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
            simState = iSub.getSimStateForSubscriber(subId);
        } catch (RemoteException ex) {
            simState = TelephonyManager.SIM_STATE_UNKNOWN;
        }
        logd("getSimStateForSubscriber: simState=" + simState + " subId=" + subId);
        return simState;
    
public static intgetSlotId(int subId)
Get slotId associated with the subscription.

return
slotId as a positive integer or a negative value if an error either SIM_NOT_INSERTED or < 0 if an invalid slot index
hide

        if (!isValidSubscriptionId(subId)) {
            logd("[getSlotId]- fail");
        }

        int result = INVALID_SIM_SLOT_INDEX;

        try {
            ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
            if (iSub != null) {
                result = iSub.getSlotId(subId);
            }
        } catch (RemoteException ex) {
            // ignore it
        }

        return result;

    
public static int[]getSubId(int slotId)

hide

        if (!isValidSlotId(slotId)) {
            logd("[getSubId]- fail");
            return null;
        }

        int[] subId = null;

        try {
            ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
            if (iSub != null) {
                subId = iSub.getSubId(slotId);
            }
        } catch (RemoteException ex) {
            // ignore it
        }

        return subId;
    
public booleanisNetworkRoaming(int subId)
Returns true if the device is considered roaming on the current network for a subscription.

Availability: Only when user registered to a network.

param
subId The subscription ID
return
true if the network for the subscription is roaming, false otherwise

        final int phoneId = getPhoneId(subId);
        if (phoneId < 0) {
            // What else can we do?
            return false;
        }
        return TelephonyManager.getDefault().isNetworkRoaming(subId);
    
public static booleanisUsableSubIdValue(int subId)

return
true if subId is an usable subId value else false. A usable subId means its neither a INVALID_SUBSCRIPTION_ID nor a DEFAULT_SUB_ID.
hide

        return subId >= MIN_SUBSCRIPTION_ID_VALUE && subId <= MAX_SUBSCRIPTION_ID_VALUE;
    
public static booleanisValidPhoneId(int phoneId)

hide

        return phoneId >= 0 && phoneId < TelephonyManager.getDefault().getPhoneCount();
    
public static booleanisValidSlotId(int slotId)

hide

        return slotId >= 0 && slotId < TelephonyManager.getDefault().getSimCount();
    
public static booleanisValidSubscriptionId(int subId)

return
true if a valid subId else false
hide

        return subId > INVALID_SUBSCRIPTION_ID ;
    
private static voidlogd(java.lang.String msg)

        Rlog.d(LOG_TAG, msg);
    
public static voidputPhoneIdAndSubIdExtra(android.content.Intent intent, int phoneId)

hide

        int[] subIds = SubscriptionManager.getSubId(phoneId);
        if (subIds != null && subIds.length > 0) {
            putPhoneIdAndSubIdExtra(intent, phoneId, subIds[0]);
        } else {
            logd("putPhoneIdAndSubIdExtra: no valid subs");
        }
    
public static voidputPhoneIdAndSubIdExtra(android.content.Intent intent, int phoneId, int subId)

hide

        if (VDBG) logd("putPhoneIdAndSubIdExtra: phoneId=" + phoneId + " subId=" + subId);
        intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
        intent.putExtra(PhoneConstants.PHONE_KEY, phoneId);
        //FIXME this is using phoneId and slotId interchangeably
        //Eventually, this should be removed as it is not the slot id
        intent.putExtra(PhoneConstants.SLOT_KEY, phoneId);
    
public voidremoveOnSubscriptionsChangedListener(android.telephony.SubscriptionManager$OnSubscriptionsChangedListener listener)
Unregister the {@link OnSubscriptionsChangedListener}. This is not strictly necessary as the listener will automatically be unregistered if an attempt to invoke the listener fails.

param
listener that is to be unregistered.

        String pkgForDebug = mContext != null ? mContext.getPackageName() : "<unknown>";
        if (DBG) {
            logd("unregister OnSubscriptionsChangedListener pkgForDebug=" + pkgForDebug
                    + " listener=" + listener);
        }
        try {
            // We use the TelephonyRegistry as its runs in the system and thus is always
            // available where as SubscriptionController could crash and not be available
            ITelephonyRegistry tr = ITelephonyRegistry.Stub.asInterface(ServiceManager.getService(
                    "telephony.registry"));
            if (tr != null) {
                tr.removeOnSubscriptionsChangedListener(pkgForDebug, listener.callback);
            }
        } catch (RemoteException ex) {
            // Should not happen
        }
    
public intsetDataRoaming(int roaming, int subId)
Set data roaming by simInfo index

param
roaming 0:Don't allow data when roaming, 1:Allow data when roaming
param
subId the unique SubscriptionInfo index in database
return
the number of records updated
hide

        if (VDBG) logd("[setDataRoaming]+ roaming:" + roaming + " subId:" + subId);
        if (roaming < 0 || !isValidSubscriptionId(subId)) {
            logd("[setDataRoaming]- fail");
            return -1;
        }

        int result = 0;

        try {
            ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
            if (iSub != null) {
                result = iSub.setDataRoaming(roaming, subId);
            }
        } catch (RemoteException ex) {
            // ignore it
        }

        return result;
    
public voidsetDefaultDataSubId(int subId)

hide

        if (VDBG) logd("setDataSubscription sub id = " + subId);
        try {
            ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
            if (iSub != null) {
                iSub.setDefaultDataSubId(subId);
            }
        } catch (RemoteException ex) {
            // ignore it
        }
    
public voidsetDefaultSmsSubId(int subId)

hide

        if (VDBG) logd("setDefaultSmsSubId sub id = " + subId);
        try {
            ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
            if (iSub != null) {
                iSub.setDefaultSmsSubId(subId);
            }
        } catch (RemoteException ex) {
            // ignore it
        }
    
public voidsetDefaultVoiceSubId(int subId)

hide

        if (VDBG) logd("setDefaultVoiceSubId sub id = " + subId);
        try {
            ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
            if (iSub != null) {
                iSub.setDefaultVoiceSubId(subId);
            }
        } catch (RemoteException ex) {
            // ignore it
        }
    
public intsetDisplayName(java.lang.String displayName, int subId)
Set display name by simInfo index

param
displayName the display name of SIM card
param
subId the unique SubscriptionInfo index in database
return
the number of records updated
hide

        return setDisplayName(displayName, subId, NAME_SOURCE_UNDEFINDED);
    
public intsetDisplayName(java.lang.String displayName, int subId, long nameSource)
Set display name by simInfo index with name source

param
displayName the display name of SIM card
param
subId the unique SubscriptionInfo index in database
param
nameSource 0: NAME_SOURCE_DEFAULT_SOURCE, 1: NAME_SOURCE_SIM_SOURCE, 2: NAME_SOURCE_USER_INPUT, -1 NAME_SOURCE_UNDEFINED
return
the number of records updated or < 0 if invalid subId
hide

        if (VDBG) {
            logd("[setDisplayName]+  displayName:" + displayName + " subId:" + subId
                    + " nameSource:" + nameSource);
        }
        if (!isValidSubscriptionId(subId)) {
            logd("[setDisplayName]- fail");
            return -1;
        }

        int result = 0;

        try {
            ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
            if (iSub != null) {
                result = iSub.setDisplayNameUsingSrc(displayName, subId, nameSource);
            }
        } catch (RemoteException ex) {
            // ignore it
        }

        return result;

    
public intsetDisplayNumber(java.lang.String number, int subId)
Set phone number by subId

param
number the phone number of the SIM
param
subId the unique SubscriptionInfo index in database
return
the number of records updated
hide

        if (number == null || !isValidSubscriptionId(subId)) {
            logd("[setDisplayNumber]- fail");
            return -1;
        }

        int result = 0;

        try {
            ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
            if (iSub != null) {
                result = iSub.setDisplayNumber(number, subId);
            }
        } catch (RemoteException ex) {
            // ignore it
        }

        return result;

    
public intsetIconTint(int tint, int subId)
Set SIM icon tint color by simInfo index

param
tint the RGB value of icon tint color of the SIM
param
subId the unique SubInfoRecord index in database
return
the number of records updated
hide

        if (VDBG) logd("[setIconTint]+ tint:" + tint + " subId:" + subId);
        if (!isValidSubscriptionId(subId)) {
            logd("[setIconTint]- fail");
            return -1;
        }

        int result = 0;

        try {
            ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
            if (iSub != null) {
                result = iSub.setIconTint(tint, subId);
            }
        } catch (RemoteException ex) {
            // ignore it
        }

        return result;