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_BASEFIXME: 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_INDEXIndicates 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_RESDefault name resource |
public static final String | NAME_SOURCETelephonyProvider 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_UNDEFINDEDThe name_source is undefined |
public static final int | NAME_SOURCE_DEFAULT_SOURCEThe name_source is the default |
public static final int | NAME_SOURCE_SIM_SOURCEThe name_source is from the SIM |
public static final int | NAME_SOURCE_USER_INPUTThe 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_ENABLEIndicates that data roaming is enabled for a subscription |
public static final int | DATA_ROAMING_DISABLEIndicates that data roaming is disabled for a subscription |
public static final int | DATA_ROAMING_DEFAULT |
public static final String | MCCTelephonyProvider column name for the MCC associated with a SIM.
Type: INTEGER (int) |
public static final String | MNCTelephonyProvider column name for the MNC associated with a SIM.
Type: INTEGER (int) |
public static final String | SUB_DEFAULT_CHANGED_ACTIONBroadcast 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 |
Methods Summary |
---|
public void | addOnSubscriptionsChangedListener(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.
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.Uri | addSubscriptionInfoRecord(java.lang.String iccId, int slotId)Add a new SubscriptionInfo to SubscriptionInfo database if needed
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 boolean | allDefaultsSelected()
if (!isValidSubscriptionId(getDefaultDataSubId())) {
return false;
}
if (!isValidSubscriptionId(getDefaultSmsSubId())) {
return false;
}
if (!isValidSubscriptionId(getDefaultVoiceSubId())) {
return false;
}
return true;
|
public void | clearDefaultsForInactiveSubIds()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.
if (VDBG) logd("clearDefaultsForInactiveSubIds");
try {
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
if (iSub != null) {
iSub.clearDefaultsForInactiveSubIds();
}
} catch (RemoteException ex) {
// ignore it
}
|
public void | clearSubscriptionInfo()
try {
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
if (iSub != null) {
iSub.clearSubInfo();
}
} catch (RemoteException ex) {
// ignore it
}
return;
|
public static android.telephony.SubscriptionManager | from(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)}.
return (SubscriptionManager) context.getSystemService(
Context.TELEPHONY_SUBSCRIPTION_SERVICE);
|
public int[] | getActiveSubscriptionIdList()
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 SubscriptionInfo | getActiveSubscriptionInfo(int subId)Get the active SubscriptionInfo with the subId key
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 int | getActiveSubscriptionInfoCount()
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 int | getActiveSubscriptionInfoCountMax()
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 SubscriptionInfo | getActiveSubscriptionInfoForIccIndex(java.lang.String iccId)Get the active SubscriptionInfo associated with the iccId
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 SubscriptionInfo | getActiveSubscriptionInfoForSimSlotIndex(int slotIdx)Get the active SubscriptionInfo associated with the slotIdx
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.List | getActiveSubscriptionInfoList()Get the SubscriptionInfo(s) of the currently inserted SIM(s). The records will be 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 int | getAllSubscriptionInfoCount()
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.List | getAllSubscriptionInfoList()
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 int | getDefaultDataPhoneId()
return getPhoneId(getDefaultDataSubId());
|
public static int | getDefaultDataSubId()
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 SubscriptionInfo | getDefaultDataSubscriptionInfo()
return getActiveSubscriptionInfo(getDefaultDataSubId());
|
public int | getDefaultSmsPhoneId()
return getPhoneId(getDefaultSmsSubId());
|
public static int | getDefaultSmsSubId()
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 SubscriptionInfo | getDefaultSmsSubscriptionInfo()
return getActiveSubscriptionInfo(getDefaultSmsSubId());
|
public static int | getDefaultSubId()
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 int | getDefaultVoicePhoneId()
return getPhoneId(getDefaultVoiceSubId());
|
public static int | getDefaultVoiceSubId()
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 SubscriptionInfo | getDefaultVoiceSubscriptionInfo()
return getActiveSubscriptionInfo(getDefaultVoiceSubId());
|
public static int | getPhoneId(int subId)
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 int | getSimStateForSubscriber(int subId)Returns a constant indicating the state of sim for the subscription.
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 int | getSlotId(int subId)Get slotId associated with the subscription.
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)
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 boolean | isNetworkRoaming(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.
final int phoneId = getPhoneId(subId);
if (phoneId < 0) {
// What else can we do?
return false;
}
return TelephonyManager.getDefault().isNetworkRoaming(subId);
|
public static boolean | isUsableSubIdValue(int subId)
return subId >= MIN_SUBSCRIPTION_ID_VALUE && subId <= MAX_SUBSCRIPTION_ID_VALUE;
|
public static boolean | isValidPhoneId(int phoneId)
return phoneId >= 0 && phoneId < TelephonyManager.getDefault().getPhoneCount();
|
public static boolean | isValidSlotId(int slotId)
return slotId >= 0 && slotId < TelephonyManager.getDefault().getSimCount();
|
public static boolean | isValidSubscriptionId(int subId)
return subId > INVALID_SUBSCRIPTION_ID ;
|
private static void | logd(java.lang.String msg)
Rlog.d(LOG_TAG, msg);
|
public static void | putPhoneIdAndSubIdExtra(android.content.Intent intent, int phoneId)
int[] subIds = SubscriptionManager.getSubId(phoneId);
if (subIds != null && subIds.length > 0) {
putPhoneIdAndSubIdExtra(intent, phoneId, subIds[0]);
} else {
logd("putPhoneIdAndSubIdExtra: no valid subs");
}
|
public static void | putPhoneIdAndSubIdExtra(android.content.Intent intent, int phoneId, int subId)
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 void | removeOnSubscriptionsChangedListener(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.
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 int | setDataRoaming(int roaming, int subId)Set data roaming by simInfo index
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 void | setDefaultDataSubId(int subId)
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 void | setDefaultSmsSubId(int subId)
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 void | setDefaultVoiceSubId(int subId)
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 int | setDisplayName(java.lang.String displayName, int subId)Set display name by simInfo index
return setDisplayName(displayName, subId, NAME_SOURCE_UNDEFINDED);
|
public int | setDisplayName(java.lang.String displayName, int subId, long nameSource)Set display name by simInfo index with name source
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 int | setDisplayNumber(java.lang.String number, int subId)Set phone number by subId
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 int | setIconTint(int tint, int subId)Set SIM icon tint color by simInfo index
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;
|