summaryrefslogtreecommitdiffstats
path: root/telephony/java/android/telephony/SubscriptionManager.java
diff options
context:
space:
mode:
authorWink Saville <wink@google.com>2014-11-20 20:29:51 +0000
committerWink Saville <wink@google.com>2014-11-20 20:29:51 +0000
commit2d1ee982276f5dbd0e035778b731b48e4ef34515 (patch)
tree54b91fd0d47c400df93c0c2ed7fae7eff2f05f0e /telephony/java/android/telephony/SubscriptionManager.java
parentbaf21da1e17ef358632c078128d381b3be218a08 (diff)
downloadframeworks_base-2d1ee982276f5dbd0e035778b731b48e4ef34515.zip
frameworks_base-2d1ee982276f5dbd0e035778b731b48e4ef34515.tar.gz
frameworks_base-2d1ee982276f5dbd0e035778b731b48e4ef34515.tar.bz2
Revert "Additional changes to SubscriptionManager API as per API council."
This reverts commit baf21da1e17ef358632c078128d381b3be218a08. Change-Id: I73cbdfadf07ca3cf20b042781b62aafcc72b17d6
Diffstat (limited to 'telephony/java/android/telephony/SubscriptionManager.java')
-rw-r--r--telephony/java/android/telephony/SubscriptionManager.java377
1 files changed, 137 insertions, 240 deletions
diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java
index 43ce51f..78ab6870 100644
--- a/telephony/java/android/telephony/SubscriptionManager.java
+++ b/telephony/java/android/telephony/SubscriptionManager.java
@@ -21,14 +21,12 @@ import android.annotation.SdkConstant.SdkConstantType;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
+import android.provider.BaseColumns;
import android.telephony.Rlog;
-import android.os.Handler;
-import android.os.Message;
import android.os.ServiceManager;
import android.os.RemoteException;
import com.android.internal.telephony.ISub;
-import com.android.internal.telephony.IOnSubscriptionsChangedListener;
import com.android.internal.telephony.ITelephonyRegistry;
import com.android.internal.telephony.PhoneConstants;
@@ -38,79 +36,62 @@ import java.util.List;
/**
* SubscriptionManager is the application interface to SubscriptionController
* and provides information about the current Telephony Subscriptions.
- * * <p>
- * You do not instantiate this class directly; instead, you retrieve
- * a reference to an instance through {@link #from}.
- * <p>
- * All SDK public methods require android.Manifest.permission.READ_PHONE_STATE.
+ *
+ * The android.Manifest.permission.READ_PHONE_STATE to retrieve the information, except
+ * getActiveSubIdList and getActiveSubIdCount for which no permission is needed.
*/
-public class SubscriptionManager {
- private static final String LOG_TAG = "SubscriptionManager";
+public class SubscriptionManager implements BaseColumns {
+ private static final String LOG_TAG = "SUB";
private static final boolean DBG = true;
private static final boolean VDBG = false;
/** An invalid subscription identifier */
- public static final int INVALID_SUBSCRIPTION_ID = -1;
-
- /** Base value for Dummy SUBSCRIPTION_ID's. */
- /** FIXME: Remove DummySubId's, but for now have them map just below INVALID_SUBSCRIPTION_ID
- /** @hide */
- public static final int DUMMY_SUBSCRIPTION_ID_BASE = INVALID_SUBSCRIPTION_ID - 1;
+ public static final int INVALID_SUB_ID = -1000;
/** An invalid phone identifier */
/** @hide */
- public static final int INVALID_PHONE_INDEX = -1;
+ public static final int INVALID_PHONE_ID = -1;
/** An invalid slot identifier */
/** @hide */
- public static final int INVALID_SIM_SLOT_INDEX = -1;
+ public static final int INVALID_SLOT_ID = -1;
/** Indicates the caller wants the default sub id. */
/** @hide */
- public static final int DEFAULT_SUBSCRIPTION_ID = Integer.MAX_VALUE;
+ public static final int DEFAULT_SUB_ID = Integer.MAX_VALUE;
- /**
- * Indicates the caller wants the default phone id.
- * Used in SubscriptionController and PhoneBase but do we really need it???
- * @hide
- */
- public static final int DEFAULT_PHONE_INDEX = Integer.MAX_VALUE;
+ /** Indicates the caller wants the default phone id. */
+ /** @hide */
+ public static final int DEFAULT_PHONE_ID = Integer.MAX_VALUE;
- /** Indicates the caller wants the default slot id. NOT used remove? */
+ /** Indicates the caller wants the default slot id. */
/** @hide */
- public static final int DEFAULT_SIM_SLOT_INDEX = Integer.MAX_VALUE;
+ public static final int DEFAULT_SLOT_ID = Integer.MAX_VALUE;
/** Minimum possible subid that represents a subscription */
/** @hide */
- public static final int MIN_SUBSCRIPTION_ID_VALUE = 0;
+ public static final int MIN_SUB_ID_VALUE = 0;
/** Maximum possible subid that represents a subscription */
/** @hide */
- public static final int MAX_SUBSCRIPTION_ID_VALUE = DEFAULT_SUBSCRIPTION_ID - 1;
+ public static final int MAX_SUB_ID_VALUE = DEFAULT_SUB_ID - 1;
- /** @hide */
- public static final Uri CONTENT_URI = Uri.parse("content://telephony/siminfo");
- /**
- * TelephonyProvider unique key column name is the subscription id.
- * <P>Type: TEXT (String)</P>
- */
/** @hide */
- public static final String UNIQUE_KEY_SUBSCRIPTION_ID = "_id";
+ public static final Uri CONTENT_URI = Uri.parse("content://telephony/siminfo");
/**
- * TelephonyProvider column name for SIM ICC Identifier
+ * The ICC ID of a SIM.
* <P>Type: TEXT (String)</P>
*/
/** @hide */
public static final String ICC_ID = "icc_id";
/**
- * TelephonyProvider column name for user SIM_SlOT_INDEX
* <P>Type: INTEGER (int)</P>
*/
/** @hide */
- public static final String SIM_SLOT_INDEX = "sim_id";
+ public static final String SIM_ID = "sim_id";
/** SIM is not inserted */
/** @hide */
@@ -249,107 +230,39 @@ public class SubscriptionManager {
/**
* Broadcast Action: The user has changed one of the default subs related to
* data, phone calls, or sms</p>
- *
- * TODO: Change to a listener
* @hide
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String SUB_DEFAULT_CHANGED_ACTION =
"android.intent.action.SUB_DEFAULT_CHANGED";
- private final Context mContext;
-
- /**
- * A listener class for monitoring changes to {@link SubscriptionInfo} records.
- * <p>
- * Override the onSubscriptionsChanged method in the object that extends this
- * class and pass it to {@link #registerOnSubscriptionsChangedListener(OnSubscriptionsChangedListener)}
- * to register your listener and to unregister invoke
- * {@link #unregisterOnSubscriptionsChangedListener(OnSubscriptionsChangedListener)}
- * <p>
- * Permissions android.Manifest.permission.READ_PHONE_STATE is required
- * for #onSubscriptionsChanged to be invoked.
- */
- public static class OnSubscriptionsChangedListener {
- /** @hide */
- public static final String PERMISSION_ON_SUBSCRIPTIONS_CHANGED =
- android.Manifest.permission.READ_PHONE_STATE;
-
- private final Handler mHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- if (DBG) {
- log("handleMessage: invoke the overriden onSubscriptionsChanged()");
- }
- OnSubscriptionsChangedListener.this.onSubscriptionsChanged();
- }
- };
-
- /**
- * Callback invoked when there is any change to any SubscriptionInfo. Typically
- * this method would invoke {@link #getActiveSubscriptionInfoList}
- */
- public void onSubscriptionsChanged() {
- if (DBG) log("onSubscriptionsChanged: NOT OVERRIDDEN");
- }
-
- /**
- * The callback methods need to be called on the handler thread where
- * this object was created. If the binder did that for us it'd be nice.
- */
- IOnSubscriptionsChangedListener callback = new IOnSubscriptionsChangedListener.Stub() {
- @Override
- public void onSubscriptionsChanged() {
- if (DBG) log("callbad: received, sendEmptyMessage(0) to handler");
- mHandler.sendEmptyMessage(0);
- }
- };
-
- private void log(String s) {
- Rlog.d(LOG_TAG, s);
- }
- }
-
/** @hide */
- public SubscriptionManager(Context context) {
+ public SubscriptionManager() {
if (DBG) logd("SubscriptionManager created");
- mContext = context;
}
/**
- * Get an instance of the SubscriptionManager from the Context.
- * This invokes {@link android.content.Context#getSystemService
- * Context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE)}.
+ * Register for changes to events defined by SubscriptionListener.LISTEN_Xxx. Some of
+ * the events will fire as registration completes, this could be before or after
+ * this method returns.
*
- * @param context to use.
- * @return SubscriptionManager instance
+ * @param listener an instance of SubscriptionListner with overridden methods the
+ * overridden method should match the bits defined in events.
+ * @param events is one or more of the SubscriptionListener.LISTEN_Xxx bits
*/
- public static SubscriptionManager from(Context context) {
- return (SubscriptionManager) context.getSystemService(
- Context.TELEPHONY_SUBSCRIPTION_SERVICE);
- }
-
- /**
- * 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.
- */
- public void registerOnSubscriptionsChangedListener(OnSubscriptionsChangedListener listener) {
- String pkgForDebug = mContext != null ? mContext.getPackageName() : "<unknown>";
+ public static void register(Context context, SubscriptionListener listener, int events) {
+ String pkgForDebug = context != null ? context.getPackageName() : "<unknown>";
if (DBG) {
- logd("register OnSubscriptionsChangedListener pkgForDebug=" + pkgForDebug
- + " listener=" + listener);
+ logd("SubscriptionManager listen pkgForDebug=" + pkgForDebug
+ + " events=0x" + Integer.toHexString(events) + " 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
+ // 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.registerOnSubscriptionsChangedListener(pkgForDebug, listener.callback);
+ tr.registerSubscriptionListener(pkgForDebug, listener.callback, events);
}
} catch (RemoteException ex) {
// Should not happen
@@ -357,16 +270,15 @@ public class SubscriptionManager {
}
/**
- * Unregister the {@link OnSubscriptionsChangedListener}. This is not strictly necessary
- * as the listener will automatically be unregistered if an attempt to invoke the listener
- * fails.
+ * Unregister the listener.
*
- * @param listener that is to be unregistered.
+ * @param context
+ * @param listener
*/
- public void unregisterOnSubscriptionsChangedListener(OnSubscriptionsChangedListener listener) {
- String pkgForDebug = mContext != null ? mContext.getPackageName() : "<unknown>";
+ public static void unregister(Context context, SubscriptionListener listener) {
+ String pkgForDebug = context != null ? context.getPackageName() : "<unknown>";
if (DBG) {
- logd("unregister OnSubscriptionsChangedListener pkgForDebug=" + pkgForDebug
+ logd("SubscriptionManager unregister pkgForDebug=" + pkgForDebug
+ " listener=" + listener);
}
try {
@@ -375,7 +287,7 @@ public class SubscriptionManager {
ITelephonyRegistry tr = ITelephonyRegistry.Stub.asInterface(ServiceManager.getService(
"telephony.registry"));
if (tr != null) {
- tr.unregisterOnSubscriptionsChangedListener(pkgForDebug, listener.callback);
+ tr.unregisterSubscriptionListener(pkgForDebug, listener.callback);
}
} catch (RemoteException ex) {
// Should not happen
@@ -383,14 +295,13 @@ public class SubscriptionManager {
}
/**
- * Get the active SubscriptionInfo with the subId key
- * @param subId The unique SubscriptionInfo key in database
- * @return SubscriptionInfo, maybe null if its not active.
+ * Get the SubscriptionInfo associated with the subId
+ * @param subId The unique SubscriptionInfo index in database
+ * @return SubscriptionInfo, maybe null
*/
- public SubscriptionInfo getActiveSubscriptionInfo(int subId) {
- if (VDBG) logd("[getActiveSubscriptionInfo]+ subId=" + subId);
+ public static SubscriptionInfo getSubscriptionInfoForSubscriber(int subId) {
if (!isValidSubId(subId)) {
- logd("[getActiveSubscriptionInfo]- invalid subId");
+ logd("[getSubscriptionInfoForSubscriber]- invalid subId");
return null;
}
@@ -399,7 +310,7 @@ public class SubscriptionManager {
try {
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
if (iSub != null) {
- subInfo = iSub.getActiveSubscriptionInfo(subId);
+ subInfo = iSub.getSubInfoForSubscriber(subId);
}
} catch (RemoteException ex) {
// ignore it
@@ -410,64 +321,73 @@ public class SubscriptionManager {
}
/**
- * Get the active SubscriptionInfo associated with the iccId
+ * Get the SubscriptionInfo according to an IccId
* @param iccId the IccId of SIM card
- * @return SubscriptionInfo, maybe null if its not active
+ * @return SubscriptionInfo List, maybe empty but not null
* @hide
*/
- public SubscriptionInfo getActiveSubscriptionInfoForIccIndex(String iccId) {
- if (VDBG) logd("[getActiveSubscriptionInfoForIccIndex]+ iccId=" + iccId);
+ public static List<SubscriptionInfo> getSubscriptionInfoUsingIccId(String iccId) {
+ if (VDBG) logd("[getSubscriptionInfoUsingIccId]+ iccId=" + iccId);
if (iccId == null) {
- logd("[getActiveSubscriptionInfoForIccIndex]- null iccid");
+ logd("[getSubscriptionInfoUsingIccId]- null iccid");
return null;
}
- SubscriptionInfo result = null;
+ List<SubscriptionInfo> result = null;
try {
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
if (iSub != null) {
- result = iSub.getActiveSubscriptionInfoForIccId(iccId);
+ result = iSub.getSubInfoUsingIccId(iccId);
}
} catch (RemoteException ex) {
// ignore it
}
+
+ if (result == null) {
+ result = new ArrayList<SubscriptionInfo>();
+ }
return result;
}
/**
- * 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
+ * Get the SubscriptionInfo according to slotId
+ * @param slotId the slot which the SIM is inserted
+ * @return SubscriptionInfo list, maybe empty but not null
*/
- public SubscriptionInfo getActiveSubscriptionInfoForSimSlotIndex(int slotIdx) {
- if (VDBG) logd("[getActiveSubscriptionInfoForSimSlotIndex]+ slotIdx=" + slotIdx);
- if (!isValidSlotId(slotIdx)) {
- logd("[getActiveSubscriptionInfoForSimSlotIndex]- invalid slotIdx");
+ public static List<SubscriptionInfo> getSubscriptionInfoUsingSlotId(int slotId) {
+ // FIXME: Consider never returning null
+ if (!isValidSlotId(slotId)) {
+ logd("[getSubscriptionInfoUsingSlotId]- invalid slotId");
return null;
}
- SubscriptionInfo result = null;
+ List<SubscriptionInfo> result = null;
try {
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
if (iSub != null) {
- result = iSub.getActiveSubscriptionInfoForSimSlotIndex(slotIdx);
+ result = iSub.getSubInfoUsingSlotId(slotId);
}
} catch (RemoteException ex) {
// ignore it
}
+
+ if (result == null) {
+ result = new ArrayList<SubscriptionInfo>();
+ }
return result;
}
/**
- * @return List of all SubscriptionInfo records in database,
- * include those that were inserted before, maybe empty but not null.
+ * Get all the SubscriptionInfo(s) in subInfo database
+ * @return List of all SubscriptionInfos in database, include those that were inserted before
+ * maybe empty but not null.
* @hide
*/
- public List<SubscriptionInfo> getAllSubscriptionInfoList() {
+ public static List<SubscriptionInfo> getAllSubscriptionInfoList() {
if (VDBG) logd("[getAllSubscriptionInfoList]+");
List<SubscriptionInfo> result = null;
@@ -488,45 +408,33 @@ public class SubscriptionManager {
}
/**
- * 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.
- * <ul>
- * <li>
- * 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.
- * </li>
- * <li>
- * If the list is empty then there are no {@link SubscriptionInfo} records currently available.
- * </li>
- * <li>
- * if the list is non-empty the list is sorted by {@link SubscriptionInfo#getSimSlotIndex}
- * then by {@link SubscriptionInfo#getSubscriptionId}.
- * </li>
- * </ul>
+ * Get the SubscriptionInfo(s) of the currently inserted SIM(s)
+ * @return Array list of currently inserted SubscriptionInfo(s) maybe empty but not null
*/
- public List<SubscriptionInfo> getActiveSubscriptionInfoList() {
+ public static List<SubscriptionInfo> getActiveSubscriptionInfoList() {
List<SubscriptionInfo> result = null;
try {
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
if (iSub != null) {
- result = iSub.getActiveSubscriptionInfoList();
+ result = iSub.getActiveSubInfoList();
}
} catch (RemoteException ex) {
// ignore it
}
+
+ if (result == null) {
+ result = new ArrayList<SubscriptionInfo>();
+ }
return result;
}
/**
- * @return the count of all subscriptions in the database, this includes
- * all subscriptions that have been seen.
+ * Get the SUB count of all SUB(s) in subinfo database
+ * @return all SIM count in database, include what was inserted before
* @hide
*/
- public int getAllSubscriptionInfoCount() {
+ public static int getAllSubscriptionInfoCount() {
if (VDBG) logd("[getAllSubscriptionInfoCount]+");
int result = 0;
@@ -544,10 +452,11 @@ public class SubscriptionManager {
}
/**
- * @return the number of active subscriptions
+ * Get the count of active SUB(s)
+ * @return active SIM count
* @hide
*/
- public int getActiveSubscriptionInfoCount() {
+ public static int getActiveSubscriptionInfoCount() {
int result = 0;
try {
@@ -563,32 +472,13 @@ public class SubscriptionManager {
}
/**
- * @return the maximum number of subscriptions this device will support at any one time.
- * @hide
- */
- 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;
- }
-
- /**
* Add a new SubscriptionInfo to subinfo 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
*/
- public Uri addSubscriptionInfoRecord(String iccId, int slotId) {
+ public static Uri addSubscriptionInfoRecord(String iccId, int slotId) {
if (VDBG) logd("[addSubscriptionInfoRecord]+ iccId:" + iccId + " slotId:" + slotId);
if (iccId == null) {
logd("[addSubscriptionInfoRecord]- null iccId");
@@ -619,7 +509,7 @@ public class SubscriptionManager {
* @return the number of records updated
* @hide
*/
- public int setIconTint(int tint, int subId) {
+ public static int setIconTint(int tint, int subId) {
if (VDBG) logd("[setIconTint]+ tint:" + tint + " subId:" + subId);
if (!isValidSubId(subId)) {
logd("[setIconTint]- fail");
@@ -648,7 +538,7 @@ public class SubscriptionManager {
* @return the number of records updated
* @hide
*/
- public int setDisplayName(String displayName, int subId) {
+ public static int setDisplayName(String displayName, int subId) {
return setDisplayName(displayName, subId, NAME_SOURCE_UNDEFINDED);
}
@@ -661,7 +551,7 @@ public class SubscriptionManager {
* @return the number of records updated or -1 if invalid subId
* @hide
*/
- public int setDisplayName(String displayName, int subId, long nameSource) {
+ public static int setDisplayName(String displayName, int subId, long nameSource) {
if (VDBG) {
logd("[setDisplayName]+ displayName:" + displayName + " subId:" + subId
+ " nameSource:" + nameSource);
@@ -693,7 +583,7 @@ public class SubscriptionManager {
* @return the number of records updated
* @hide
*/
- public int setDisplayNumber(String number, int subId) {
+ public static int setDisplayNumber(String number, int subId) {
if (number == null || !isValidSubId(subId)) {
logd("[setDisplayNumber]- fail");
return -1;
@@ -721,7 +611,7 @@ public class SubscriptionManager {
* @return the number of records updated
* @hide
*/
- public int setDataRoaming(int roaming, int subId) {
+ public static int setDataRoaming(int roaming, int subId) {
if (VDBG) logd("[setDataRoaming]+ roaming:" + roaming + " subId:" + subId);
if (roaming < 0 || !isValidSubId(subId)) {
logd("[setDataRoaming]- fail");
@@ -753,7 +643,7 @@ public class SubscriptionManager {
logd("[getSlotId]- fail");
}
- int result = INVALID_SIM_SLOT_INDEX;
+ int result = INVALID_SLOT_ID;
try {
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
@@ -793,10 +683,10 @@ public class SubscriptionManager {
public static int getPhoneId(int subId) {
if (!isValidSubId(subId)) {
logd("[getPhoneId]- fail");
- return INVALID_PHONE_INDEX;
+ return INVALID_PHONE_ID;
}
- int result = INVALID_PHONE_INDEX;
+ int result = INVALID_PHONE_ID;
try {
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
@@ -813,7 +703,7 @@ public class SubscriptionManager {
}
private static void logd(String msg) {
- Rlog.d(LOG_TAG, msg);
+ Rlog.d(LOG_TAG, "[SubManager] " + msg);
}
/**
@@ -823,7 +713,7 @@ public class SubscriptionManager {
* @hide
*/
public static int getDefaultSubId() {
- int subId = INVALID_SUBSCRIPTION_ID;
+ int subId = INVALID_SUB_ID;
try {
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
@@ -840,7 +730,7 @@ public class SubscriptionManager {
/** @hide */
public static int getDefaultVoiceSubId() {
- int subId = INVALID_SUBSCRIPTION_ID;
+ int subId = INVALID_SUB_ID;
try {
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
@@ -856,7 +746,7 @@ public class SubscriptionManager {
}
/** @hide */
- public void setDefaultVoiceSubId(int subId) {
+ public static void setDefaultVoiceSubId(int subId) {
if (VDBG) logd("setDefaultVoiceSubId sub id = " + subId);
try {
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
@@ -869,8 +759,8 @@ public class SubscriptionManager {
}
/** @hide */
- public SubscriptionInfo getDefaultVoiceSubscriptionInfo() {
- return getActiveSubscriptionInfo(getDefaultVoiceSubId());
+ public static SubscriptionInfo getDefaultVoiceSubscriptionInfo() {
+ return getSubscriptionInfoForSubscriber(getDefaultVoiceSubId());
}
/** @hide */
@@ -879,13 +769,11 @@ public class SubscriptionManager {
}
/**
- * @return subId of the DefaultSms subscription or
- * the value INVALID_SUBSCRIPTION_ID if an error.
- *
+ * @return subId of the DefaultSms subscription or the value INVALID_SUB_ID if an error.
* @hide
*/
public static int getDefaultSmsSubId() {
- int subId = INVALID_SUBSCRIPTION_ID;
+ int subId = INVALID_SUB_ID;
try {
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
@@ -901,7 +789,7 @@ public class SubscriptionManager {
}
/** @hide */
- public void setDefaultSmsSubId(int subId) {
+ public static void setDefaultSmsSubId(int subId) {
if (VDBG) logd("setDefaultSmsSubId sub id = " + subId);
try {
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
@@ -914,18 +802,18 @@ public class SubscriptionManager {
}
/** @hide */
- public SubscriptionInfo getDefaultSmsSubscriptionInfo() {
- return getActiveSubscriptionInfo(getDefaultSmsSubId());
+ public static SubscriptionInfo getDefaultSmsSubscriptionInfo() {
+ return getSubscriptionInfoForSubscriber(getDefaultSmsSubId());
}
/** @hide */
- public int getDefaultSmsPhoneId() {
+ public static int getDefaultSmsPhoneId() {
return getPhoneId(getDefaultSmsSubId());
}
/** @hide */
public static int getDefaultDataSubId() {
- int subId = INVALID_SUBSCRIPTION_ID;
+ int subId = INVALID_SUB_ID;
try {
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
@@ -941,7 +829,7 @@ public class SubscriptionManager {
}
/** @hide */
- public void setDefaultDataSubId(int subId) {
+ public static void setDefaultDataSubId(int subId) {
if (VDBG) logd("setDataSubscription sub id = " + subId);
try {
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
@@ -954,17 +842,17 @@ public class SubscriptionManager {
}
/** @hide */
- public SubscriptionInfo getDefaultDataSubscriptionInfo() {
- return getActiveSubscriptionInfo(getDefaultDataSubId());
+ public static SubscriptionInfo getDefaultDataSubscriptionInfo() {
+ return getSubscriptionInfoForSubscriber(getDefaultDataSubId());
}
/** @hide */
- public int getDefaultDataPhoneId() {
+ public static int getDefaultDataPhoneId() {
return getPhoneId(getDefaultDataSubId());
}
/** @hide */
- public void clearSubscriptionInfo() {
+ public static void clearSubscriptionInfo() {
try {
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
if (iSub != null) {
@@ -979,14 +867,14 @@ public class SubscriptionManager {
//FIXME this is vulnerable to race conditions
/** @hide */
- public boolean allDefaultsSelected() {
- if (getDefaultDataSubId() == INVALID_SUBSCRIPTION_ID) {
+ public static boolean allDefaultsSelected() {
+ if (getDefaultDataSubId() == INVALID_SUB_ID) {
return false;
}
- if (getDefaultSmsSubId() == INVALID_SUBSCRIPTION_ID) {
+ if (getDefaultSmsSubId() == INVALID_SUB_ID) {
return false;
}
- if (getDefaultVoiceSubId() == INVALID_SUBSCRIPTION_ID) {
+ if (getDefaultVoiceSubId() == INVALID_SUB_ID) {
return false;
}
return true;
@@ -994,10 +882,10 @@ public class SubscriptionManager {
/**
* If a default is set to subscription which is not active, this will reset that default back to
- * INVALID_SUBSCRIPTION_ID.
+ * INVALID_SUB_ID.
* @hide
*/
- public void clearDefaultsForInactiveSubIds() {
+ public static void clearDefaultsForInactiveSubIds() {
if (VDBG) logd("clearDefaultsForInactiveSubIds");
try {
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
@@ -1014,26 +902,34 @@ public class SubscriptionManager {
* @hide
*/
public static boolean isValidSubId(int subId) {
- return subId > INVALID_SUBSCRIPTION_ID ;
+ return subId > INVALID_SUB_ID ;
}
/**
* @return true if subId is an usable subId value else false. A
- * usable subId means its neither a INVALID_SUBSCRIPTION_ID nor a DEFAUL_SUB_ID.
+ * usable subId means its neither a INVALID_SUB_ID nor a DEFAUL_SUB_ID.
* @hide
*/
public static boolean isUsableSubIdValue(int subId) {
- return subId >= MIN_SUBSCRIPTION_ID_VALUE && subId <= MAX_SUBSCRIPTION_ID_VALUE;
+ return subId >= MIN_SUB_ID_VALUE && subId <= MAX_SUB_ID_VALUE;
}
/** @hide */
public static boolean isValidSlotId(int slotId) {
- return slotId >= 0 && slotId < TelephonyManager.getDefault().getSimCount();
+ // We are testing INVALID_SLOT_ID and slotId >= 0 independently because we should
+ // not assume that INVALID_SLOT_ID will always be a negative value. Any negative
+ // value is invalid.
+ return slotId != INVALID_SLOT_ID && slotId >= 0 &&
+ slotId < TelephonyManager.getDefault().getSimCount();
}
/** @hide */
public static boolean isValidPhoneId(int phoneId) {
- return phoneId >= 0 && phoneId < TelephonyManager.getDefault().getPhoneCount();
+ // We are testing INVALID_PHONE_ID and phoneId >= 0 independently because we should
+ // not assume that INVALID_PHONE_ID will always be a negative value. Any negative
+ // value is invalid.
+ return phoneId != INVALID_PHONE_ID && phoneId >= 0 &&
+ phoneId < TelephonyManager.getDefault().getPhoneCount();
}
/** @hide */
@@ -1061,7 +957,7 @@ public class SubscriptionManager {
* is never null but the length maybe 0.
* @hide
*/
- public int[] getActiveSubscriptionIdList() {
+ public static int[] getActiveSubIdList() {
int[] subId = null;
try {
@@ -1078,6 +974,7 @@ public class SubscriptionManager {
}
return subId;
+
}
}